Skip to content

Commit 2de56c4

Browse files
fido2: Verify attestation signature after makeCredential
The fido2 make-credential and verify commands perform a makeCredential operation on the device. This patch extends the commands to verify the attestation signature for the generated credential.
1 parent 7484c15 commit 2de56c4

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

pynitrokey/cli/fido2.py

+10
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
from typing import Any, Optional
1616

1717
import click
18+
from fido2.attestation.base import InvalidSignature
19+
from fido2.attestation.packed import PackedAttestation
1820
from fido2.client import ClientError as Fido2ClientError
1921
from fido2.client import Fido2Client, UserInteraction
2022
from fido2.cose import ES256, EdDSA
@@ -188,6 +190,14 @@ def _make_credential(
188190

189191
response = client.make_credential(options)
190192

193+
att_obj = response.attestation_object
194+
assert att_obj.fmt == "packed"
195+
verifier = PackedAttestation()
196+
try:
197+
verifier.verify(att_obj.att_stmt, att_obj.auth_data, response.client_data.hash)
198+
except InvalidSignature:
199+
raise CliException("Invalid attestation signature in makeCredential")
200+
191201
if hmac_secret:
192202
assert response.extension_results is not None
193203
assert "hmacCreateSecret" in response.extension_results

0 commit comments

Comments
 (0)