Skip to content

Commit 5411233

Browse files
committed
Fix P-256 verification in demo client
1 parent 2b126dd commit 5411233

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

demo_client/webauthn.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -405,12 +405,14 @@ def _cose_verify(cose_key: bytes, signature: bytes, data: bytes):
405405

406406
cose_crv = cred_pub_key[COSE_EC2_CRV]
407407
if cose_crv == COSE_CRV_P256:
408-
crv = ec.SECP2561R1
408+
crv = ec.SECP256R1()
409409
alg = ec.ECDSA(hashes.SHA256())
410410
else:
411411
raise Exception(f"Unsupported COSE ECDSA curve specified: {crv}")
412412

413-
signing_key = ec.EllipticCurvePublicNumbers(crv, x, y).public_key()
413+
# WebAuthn uses uncompressed points only.
414+
pub_key_bytes = bytes(b'\x04' + x + y)
415+
signing_key = ec.EllipticCurvePublicKey.from_encoded_point(crv, pub_key_bytes)
414416
signing_key.verify(signature, data, alg)
415417
elif cose_alg == COSE_ALG_EDDSA:
416418
if kty != COSE_KTY_OKP:

0 commit comments

Comments
 (0)