Skip to content

Commit 66afa8d

Browse files
committed
feat: add DER encoding methods and update key type alias in key_utils
Signed-off-by: MonaaEid <monaa_eid@hotmail.com>
1 parent 480b663 commit 66afa8d

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

tests/unit/keys_public_test.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -327,6 +327,7 @@ def test_from_bytes_invalid():
327327
with pytest.warns(UserWarning), pytest.raises(ValueError, match="Failed to load public key"):
328328
PublicKey.from_bytes(data)
329329

330+
330331
# ------------------------------------------------------------------------------
331332
# Test: DER helper encoders and compressed DER export
332333
# ------------------------------------------------------------------------------
@@ -337,6 +338,7 @@ def test_encode_der_length_short_and_long_forms():
337338
assert PublicKey._encode_der_length(0x0100) == b"\x82\x01\x00"
338339
assert PublicKey._encode_der_length(0x1000000) == b"\x84\x01\x00\x00\x00"
339340

341+
340342
def test_encode_der_length_negative_raises():
341343
with pytest.raises(ValueError, match="non-negative"):
342344
PublicKey._encode_der_length(-1)
@@ -403,12 +405,14 @@ def test_to_bytes_der_ecdsa_compressed_rejects_ed25519(ed25519_keypair):
403405
with pytest.raises(ValueError, match="only supported for ECDSA"):
404406
public_key.to_bytes_der_ecdsa_compressed()
405407

408+
406409
def test_encode_vlq_values():
407410
assert PublicKey._encode_vlq(0) == b"\x00"
408411
assert PublicKey._encode_vlq(127) == b"\x7f"
409412
assert PublicKey._encode_vlq(128) == b"\x81\x00"
410413
assert PublicKey._encode_vlq(0x4000) == b"\x81\x80\x00"
411414

415+
412416
# ------------------------------------------------------------------------------
413417
# Test: from_string_xxx
414418
# ------------------------------------------------------------------------------

0 commit comments

Comments
 (0)