Nitrokey / pynitrokey

Python client for Nitrokey devices
Apache License 2.0
98 stars 27 forks source link

fido2 list-credentials: Skip enumerating RPs when empty #360

Closed robin-nitrokey closed 1 year ago

robin-nitrokey commented 1 year ago

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

@szszszsz Can you please test this change with a FIDO2 without credentials? I don’t have a development FIDO2 device.

Checklist

szszszsz commented 1 year ago

Works. Tested with empty NK FIDO2 on the current master and this PR:

master $ ./venv/bin/nitropy fido2 list-credentials
Command line tool to interact with Nitrokey devices 0.4.36
Please provide pin:
Critical error:
An unhandled exception occurred
        Exception encountered: KeyError(<RESULT.TOTAL_RPS: 5>)

--------------------------------------------------------------------------------
Critical error occurred, exiting now
Unexpected? Is this a bug? Would you like to get support/help?
- You can report issues at: https://support.nitrokey.com/
- Writing an e-mail to support@nitrokey.com is also possible
- Please attach the log: '/tmp/nitropy.log.oxpe2_yj' with any support/help request!
- Please check if you have udev rules installed: https://docs.nitrokey.com/nitrokey3/linux/firmware-updat
.html#troubleshooting

~/w/pynitrokey (master|✔) [1]$ gh pr checkout 360
Switched to branch 'list-credentials-total'
Your branch is up to date with 'origin/list-credentials-total'.
Already up to date.
~/w/pynitrokey (list-credentials-total|✔) $ ./venv/bin/nitropy fido2 list-credentials
Command line tool to interact with Nitrokey devices 0.4.35
Please provide pin:
There are no registered credentials
There is an estimated amount of 50 credential slots left
~/w/pynitrokey (list-credentials-total|✔) $