Skip to content

Commit

Permalink
Fix bio metadata handling on older devices.
Browse files Browse the repository at this point in the history
  • Loading branch information
dainnilsson committed Jan 26, 2024
1 parent 1f320e9 commit 3778238
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions tests/device/test_hsmauth.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,15 +134,15 @@ def test_import_credential_symmetric_works(self, session):
@condition.min_version(5, 6)
def test_import_credential_asymmetric_unsupported_key(self, session):
private_key = ec.generate_private_key(
ec.SECP224R1, backend=default_backend()
ec.SECP224R1(), backend=default_backend()
) # curve secp224r1 is not supported

with pytest.raises(ValueError):
import_key_asymmetric(session, DEFAULT_MANAGEMENT_KEY, private_key)

@condition.min_version(5, 6)
def test_import_credential_asymmetric_works(self, session):
private_key = ec.generate_private_key(ec.SECP256R1, backend=default_backend())
private_key = ec.generate_private_key(ec.SECP256R1(), backend=default_backend())
credential = import_key_asymmetric(session, DEFAULT_MANAGEMENT_KEY, private_key)

public_key = private_key.public_key()
Expand Down
2 changes: 1 addition & 1 deletion ykman/piv.py
Original file line number Diff line number Diff line change
Expand Up @@ -546,9 +546,9 @@ def get_piv_info(session: PivSession):
] = f"Configured, {bio.attempts_remaining} attempts remaining"
else:
info["Biometrics"] = "Not configured"

except NotSupportedError:
pass

try:
metadata = session.get_management_key_metadata()
if metadata.default_value:
Expand Down
2 changes: 1 addition & 1 deletion yubikit/piv.py
Original file line number Diff line number Diff line change
Expand Up @@ -786,7 +786,7 @@ def get_bio_metadata(self) -> BioMetadata:
self.protocol.send_apdu(0, INS_GET_METADATA, 0, SLOT_OCC_AUTH)
)
except ApduError as e:
if e.sw == SW.REFERENCE_DATA_NOT_FOUND:
if e.sw in (SW.REFERENCE_DATA_NOT_FOUND, SW.INVALID_INSTRUCTION):
raise NotSupportedError(
"Biometric verification not supported by this YuibKey"
)
Expand Down

0 comments on commit 3778238

Please sign in to comment.