Skip to content

Commit

Permalink
Add specific error status for FIDO key mismatch.
Browse files Browse the repository at this point in the history
  • Loading branch information
elibon99 committed Dec 20, 2023
1 parent a08fb71 commit 9fcf468
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
9 changes: 8 additions & 1 deletion helper/helper/fido.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,13 @@ def __init__(self):
)


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)

Expand Down Expand Up @@ -171,7 +178,7 @@ def reset(self, params, event, signal):
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:
Expand Down
2 changes: 1 addition & 1 deletion lib/fido/views/reset_dialog.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 9fcf468

Please sign in to comment.