Skip to content
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

Wrong ES256 signature length #187

Closed
ivailokolev opened this issue Jul 1, 2017 · 9 comments
Closed

Wrong ES256 signature length #187

ivailokolev opened this issue Jul 1, 2017 · 9 comments
Milestone

Comments

@ivailokolev
Copy link

Hi,

Seems like the ES256 signature length produced by Java-JWT doesn't match the definition in RFC7518 https://tools.ietf.org/html/rfc7518#page-10. It is expected that the signature is 64 bytes, but its 71 or 72, probably related to DER encoding.

When validating a signature ECDSAAlgorithm makes JOSEToDER. Shouldn't it make DERToJOSE when creating signatures?

Cheers, Ivo Kolev

@ivailokolev
Copy link
Author

Seems like the JOSEToDER is incorrect. Below is a JWT signature produced by other library. The method adds redundant zero byte to make the signature S component positive, while its already positive.

30 46 02 21 00b08c3280fc20fd95351aa081526e6a846781ef68b2cee8a71866d500c0286f72 02 21 0017457be7263fa2f3e34294d2f323f3168b6788d3d403f784d1a83b722ad25add

0x30; TotalLen=70(0x46); 0x02; ECRLen=33(0x21) - properly padded; 0x02; ECSLen=33(0x21); The padding is wrong as 0x17 is positive;

@coelho
Copy link

coelho commented Oct 10, 2017

Just got bit by this too. Completely broken. Needs DERToJOSE.
Any updates on this? This library's ECDSA is pretty broken until this is fixed.

@lbalmaceda
Copy link
Contributor

I'll look into it this week. Thanks for reporting this.

@lbalmaceda
Copy link
Contributor

@coelho @ivailokolev I've submitted #212 with the fix. Please, give it a try and leave any feedback here or in the PR discussion.

@coelho
Copy link

coelho commented Nov 3, 2017

@lbalmaceda looks good thanks!

@ivailokolev
Copy link
Author

@lbalmaceda Thank you. Crossed checked with another JWT library, both sign and verify were OK. If I may suggest a little change in the dependencies - bump up the Jakson's Databind to 2.9.2.

@ivailokolev
Copy link
Author

Hi @lbalmaceda
Is there any rough plan about the releasing of the EC fix?
Cheers, Ivo Kolev

@lbalmaceda
Copy link
Contributor

I'll try to make a release today. 👍
Cheers

@lbalmaceda lbalmaceda added this to the v3-Next milestone Nov 6, 2017
@lbalmaceda lbalmaceda changed the title ES256 signature length Wrong ES256 signature length Nov 6, 2017
@lbalmaceda lbalmaceda modified the milestones: v3-Next, 3.3.0 Nov 6, 2017
@lbalmaceda
Copy link
Contributor

version 3.3.0 is on already up on bintray. Should be available in maven central in a few hours. Cheers

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants