Skip to content

Commit b80da41

Browse files
RinZ27ronf
authored andcommitted
Fix NameError in PQDH when handling invalid algorithms
1 parent 94a996c commit b80da41

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

asyncssh/crypto/pq.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ def __init__(self, alg_name: bytes):
5959
self.ciphertext_bytes, self.secret_bytes, \
6060
oqs_name = _pq_algs[alg_name]
6161
except KeyError: # pragma: no cover, other algs not registered
62-
raise ValueError(f'Unknown PQ algorithm {oqs_name}') from None
62+
raise ValueError(f'Unknown PQ algorithm {alg_name.decode()}') from None
6363

6464
if not hasattr(_oqs, 'OQS_' + oqs_name + '_keypair'): # pragma: no cover
6565
oqs_name += '_ipd'

tests/test_kex.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -650,3 +650,9 @@ async def test_rsa_errors(self):
650650

651651
client_conn.close()
652652
server_conn.close()
653+
654+
def test_invalid_pq_alg(self):
655+
"""Test providing an invalid PQ algorithm"""
656+
657+
with self.assertRaisesRegex(ValueError, 'Unknown PQ algorithm invalid'):
658+
PQDH(b'invalid')

0 commit comments

Comments
 (0)