Add specific error status for FIDO key mismatch.

This commit is contained in:
Elias Bonnici 2023-12-20 14:18:59 +01:00
parent a08fb71ec6
commit 9fcf468fe5
No known key found for this signature in database
GPG Key ID: 5EAC28EA3F980CCF
2 changed files with 9 additions and 2 deletions

View File

@ -55,6 +55,13 @@ class InactivityException(RpcException):
)
class KeyMismatchException(RpcException):
def __init__(self):
super().__init__(
"key-mismatch", "Re-inserted YubiKey does not match initial device"
)
def _ctap_id(ctap):
return (ctap.info.aaguid, ctap.info.firmware_version)
@ -171,7 +178,7 @@ class Ctap2Node(RpcNode):
logger.debug("Performing reset...")
self.ctap = Ctap2(connection)
if target != _ctap_id(self.ctap):
raise ValueError("Re-inserted YubiKey does not match initial device")
raise KeyMismatchException()
try:
self.ctap.reset(event=event)
except CtapError as e:

View File

@ -99,7 +99,7 @@ class _ResetDialogState extends ConsumerState<ResetDialog> {
if (e is RpcError) {
if (e.status == 'connection-error') {
errorMessage = l10n.l_failed_connecting_to_fido;
} else if (e.status == 'invalid-command') {
} else if (e.status == 'key-mismatch') {
errorMessage = l10n.l_wrong_inserted_yk_error;
} else if (e.status == 'user-action-timeout') {
errorMessage = l10n.l_user_action_timeout_error;