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

Signature is different at each run #190

Closed
collimarco opened this issue Feb 8, 2017 · 3 comments
Closed

Signature is different at each run #190

collimarco opened this issue Feb 8, 2017 · 3 comments

Comments

@collimarco
Copy link

If I run the same program multiple times, with the exact same header and payload, I get different signatures at each run. Is that an expected behavior?

Take for example this code:

http://blog.pushpad.xyz/2017/02/push-api-from-scratch-how-to-generate-the-vapid-headers-with-ruby/#more-101

and use the same key pair, replace Time.now with a fixed time and also fix an endpoint.

If you run it multiple times the header.payload part is always the same, but not the signature.

@excpt
Copy link
Member

excpt commented Feb 8, 2017

When using keys to sign tokens the outcome on each run is and has to be different.

When looking at the ruby-jwt test suite you'll see we test the results against certificates because there is no way that we will get the exact same result twice when signing with elliptic curve keys.

It's the correct behaviour.

Why this is that way you have to dive deeper into encryption and elliptic curve algos.

The actual signing magic happens inside OpenSSL.

@collimarco
Copy link
Author

Thank you! I've have noticed that while I was trying to write tests... now, at least I know that it's not a bug. Sorry for my lacking knowledge about elliptic curve algorithms.

@excpt
Copy link
Member

excpt commented Feb 9, 2017

No problem at all. That's what a community is for. Sharing knowledge. :)

@excpt excpt closed this as completed Feb 9, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants