Skip to content

Commit

Permalink
fido2 list-credentials: Skip enumerating RPs when empty
Browse files Browse the repository at this point in the history
If we know that the credentials count is zero, we don’t have to
enumerate RPs.  This works around an issue with the Nitrokey FIDO2 not
including the totalRPs field in the enumeration response if it is zero.

Fixes: #336
  • Loading branch information
robin-nitrokey committed Mar 28, 2023
1 parent a66418b commit 4679869
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions pynitrokey/cli/fido2.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,8 +218,6 @@ def list_credentials(serial, pin):
CredentialManagement.RESULT.MAX_REMAINING_COUNT
)

reliable_party_list = cred_manager.enumerate_rps()

if cred_count == 0:
local_print("There are no registered credentials")
local_print(
Expand All @@ -230,6 +228,8 @@ def list_credentials(serial, pin):
# Get amount of registered creds from first key in list (Same trick is used in the CredentialManager)
local_print(f"There are {cred_count} registered credentials")

reliable_party_list = cred_manager.enumerate_rps()

for reliable_party_result in reliable_party_list:
reliable_party = reliable_party_result.get(CredentialManagement.RESULT.RP)
reliable_party_hash = reliable_party_result.get(
Expand Down

0 comments on commit 4679869

Please sign in to comment.