-
Notifications
You must be signed in to change notification settings - Fork 45
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
Perform key sanity check when verifying signatures #46
Comments
Add the 'checkJWK' function for sanity checking a JWK to make sure it is not totally unusable. This work is motivated by the problem where loading a small key means that signature verification fails with 'InvalidSignature', obscuring the fact that the verification key is too small to be used. The fact that the validation function may attempt to validate a single signature against several keys makes it difficult to convey the error for a single signature to the caller. Instead, library users are encouraged to explicitly apply checkJWK to all JWKs that may be used for verification, and fail, warn, or omit offending keys. Fixes: #46
@begriffs have a look at: 59ca5e6 Note that this step is not automatically performed during verification for a couple of reasons:
Instead of presenting the above problems to library users, I've decided to just implement the Let me know what you think of the approach and its usability. Cheers! |
Thanks for the helper function. I will try it out and see how it goes! |
@begriffs did you have any feedback re |
Thanks, I haven't gotten around to using this function, but I filed an issue in my project so that I or someone else will use it to improve error messages for users. |
@begriffs righto, I'll merge it soon. |
Why can't Much better UX for library users IMHO. |
@ecthiender it's because there can be multiple keys that could be used to verify some signature, and there is not yet a way to propagate complete information about the verification results for particular keys. I'll think about how the API could be enhanced to provide that. If you have ideas, please share. |
Add the 'checkJWK' function for sanity checking a JWK to make sure it is not totally unusable. This work is motivated by the problem where loading a small key means that signature verification fails with 'InvalidSignature', obscuring the fact that the verification key is too small to be used. The fact that the validation function may attempt to validate a single signature against several keys makes it difficult to convey the error for a single signature to the caller. Instead, library users are encouraged to explicitly apply checkJWK to all JWKs that may be used for verification, and fail, warn, or omit offending keys. Fixes: #46
Currently if a key is too small, the verification fails with
InvalidSignature
insteadof
KeySizeTooSmall
. Add a key sanity check step before attempting to validatethe signature so that the appropriate error gets returned to the caller.
Thanks to @begriffs for reporting.
The text was updated successfully, but these errors were encountered: