Merged
Conversation
2ad3e3f to
5b147c8
Compare
Contributor
Author
|
Had some issues with the CI, force pushed to keep things tidy. |
- it works often for P256 & P384, fails often for P521
Member
|
@atombrella or @adferrand, do either of you have the time and interest to take a look at this since you reviewed #51? |
Collaborator
|
For sure I will review it in the next days. I already looked at it quickly this week and it seemed good. |
Member
|
Thanks Adrien! I'm assigning you for now but if you end up not being able to get to it for whatever reason, just let me know. |
adferrand
approved these changes
Mar 14, 2021
Collaborator
adferrand
left a comment
There was a problem hiding this comment.
Thanks a lot @commonism, this LGTM. I appreciate in particular the updated test cases that will catch this error if future developments would break again when leading zeros are involved, since this is something quite hard to catch without unit tests.
This was referenced Mar 16, 2021
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The r||s encoding is wrong for ec keys and signatures with leading zeros.
This results in bad signatures, I've come across:
"Parse error reading JWS: EC public key has incorrect padding"
"failed to unmarshal JWK: square/go-jose: invalid EC public key, wrong length"
Leading zero happens very frequently for ES512, rare with ES256.
This was already wrong in my proposal for r||s and just got ported to using cryptography api.
int.to_bytes requires python >= 3.2
bytes.fromhex python >= 3.0
so they are safe to use here.