-
Notifications
You must be signed in to change notification settings - Fork 34
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Increase user password buffer in IsAESSupported command #158
base: master
Are you sure you want to change the base?
Increase user password buffer in IsAESSupported command #158
Conversation
The IsAESSupported command struct has a 20 byte buffer size for storing the user password. That is in contrast to, say, the EnablePasswordSafe struct which uses a 30 byte buffer. Such a smaller buffer can cause string length errors to be emitted for a legitimate user PIN as has been found as part of the investigation for d-e-s-o/nitrocli#85. That is, the nitrokey allows for setting a user PIN of 21 characters. Retrieving an OTP using such a PIN works fine, whereas inquiring the PWS status does not, as it first tries to cram the supplied password into 20 characters, which fails. This change increases the buffer size in the IsAESSupported command struct to 30 bytes.
Hi! As for the size choice, the 25 bytes PIN size used in commands was selected to allow packing both old and new PIN inside one USB 1.1 HID command 64 bytes buffer, for case of its update through HID (to keep things simple, and avoid more complicated transport protocol). Some of the commands indeed allow 30 bytes PIN length, and this is inconsistent (though might be usable in case, when the longer PIN is set via the CCID interface). Our use-case rule for the maximum PIN size is 20 bytes (link to FAQ), and usual size is expected to be about 10 characters (or less), since smart card does not allow more than 3 guess attempts anyway, and thus brute-forcing here could not apply. Edit: added link to FAQ |
Thanks for the explanation! Sounds good. If there is nothing you need from my side then feel free to close this pull request.
Okay, but can we somehow at least make the command for changing the PIN accept the lowest of the sizes of the other command's buffers? Otherwise we can change the PIN successfully and then have other commands fail with errors when really they must not. |
I plan to merge it with a modification in a separate commit, to keep your work included.
You are right with that case of course. I will decrease it to Thank you for the idea! |
Fix type annotation for re.Pattern
The IsAESSupported command struct has a 20 byte buffer size for storing
the user password. That is in contrast to, say, the EnablePasswordSafe
struct which uses a 30 byte buffer. Such a smaller buffer can cause
string length errors to be emitted for a legitimate user PIN as has been
found as part of the investigation for d-e-s-o/nitrocli#85. That is, the
nitrokey allows for setting a user PIN of 21 characters. Retrieving an
OTP using such a PIN works fine, whereas inquiring the PWS status does
not, as it first tries to cram the supplied password into 20 characters,
which fails.
This change increases the buffer size in the IsAESSupported command
struct to 30 bytes.