-
Notifications
You must be signed in to change notification settings - Fork 44
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
Add code to prevent locking the token by mistake #457
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
@Jakuje I have not added tests for this feature, do you think it is obvious enough, or do you think I should try to create a test? I might be able to do it with kryoptic at least. |
I think having a test coverage for this would be helpful to be sure it works as expected. Just something simple trying to login several times using pkcs11 provider and bad pin (different processes so this is not caught by the mechanism preventing relogin with bad pin), then checking it is not locked (for example using pkcs11-tool), then using the right pin in pkcs11 tool and then verifying the functionality again with pkcs11 provider. |
For tokens that properly report the status of the PIN authentication counter via token flags, check them out and refuse to attempt login if the token is on its last try. A token should never be on its last try and finding this flags set is an indication that someone may have hardocded an in correct pin in the configuration or an URI. Proceeding would have a high chance of ending up blocking the token. Fixes: latchset#455 Signed-off-by: Simo Sorce <[email protected]>
6c393f3
to
4cb0d53
Compare
Added a test! |
So I will push a change soon as -T was not working with tokens with multiple slots as pkcs11-tool was trying to login to each token that way, -I works better to test the login. However softhsm gets to pin count low and then never locks it (I tried manually some 30/40 login attempts. While softokn seem to never set even any low count or lock flags at all. So neither can be tested. |
Only kryoptic seem to correctly enforce pin lockout and return the correct flags. Softhsm seem to expose CKF_PIN_COUNT_LOW at some point but never lock the token. Softoken seem not support pin counting or locking at all. Signed-off-by: Simo Sorce <[email protected]>
Description
For tokens that properly report the status of the PIN authentication counter via token flags, check them out and refuse to attempt login if the token is on its last try.
A token should never be on its last try and finding this flags set is an indication that someone may have hardocded an in correct pin in the configuration or an URI. Proceeding would have a high chance of ending up blocking the token.
Fixes: #455
Checklist
Reviewer's checklist: