From 467986946a09df5edb4649b438b15f9a762fc26d Mon Sep 17 00:00:00 2001 From: Robin Krahl Date: Tue, 28 Mar 2023 17:43:13 +0200 Subject: [PATCH] fido2 list-credentials: Skip enumerating RPs when empty MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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: https://github.com/Nitrokey/pynitrokey/issues/336 --- pynitrokey/cli/fido2.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pynitrokey/cli/fido2.py b/pynitrokey/cli/fido2.py index 3176da61..e96bd55f 100644 --- a/pynitrokey/cli/fido2.py +++ b/pynitrokey/cli/fido2.py @@ -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( @@ -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(