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

Incorrect sha512 values vs node 'crypto' and golang sha512 #518

Closed
tobowers opened this issue Jun 30, 2017 · 4 comments
Closed

Incorrect sha512 values vs node 'crypto' and golang sha512 #518

tobowers opened this issue Jun 30, 2017 · 4 comments

Comments

@tobowers
Copy link

Hi,

I'm having trouble getting a correct sha512 out of forge. I keep thinking it must be encoding issues, but I have some pretty straightforward code generating different results.

Data used (hex) 0a102f696e736161736974792f616c6963651203616c6c1a05616c6963652209696e73616173697479320c08bfe2d7ca0510e197be9301

Forge generated sha512 (hex): 6a09c3a667c3b3c2bcc38908c2bb67c2aec285c284c38ac2a73b3c6ec3b372c3bec294c3b82bc2a54fc3b53a5f1d36c3b1510e527fc2adc3a6c282c391c29b0568c28c2b3e6c1f1fc283c399c2abc3bb41c2bd6b5bc3a0c38d19137e2179

Expected sha512 (hex): a9a49744122da1eca02334b2e37a7230864cafebd02479eb230d57e3caa1220a67d52316f1bfef68bcabb12b960dddc4ad104480428a9349b0e279dc02207030

nodejs crypto library producing expected: https://runkit.com/tobowers/5955f7b1fef5ec00129c7dd2
golang cyrpto library producing expected: https://play.golang.org/p/g3P9h9Wjo_

forge producing unexpected result: https://runkit.com/tobowers/5955f80ef9fe430012c7986c

PS: Amazing library and I'm super excited to use it. All of the more advanced features are working perfectly for me (rsa keypairs, certs, PSS, etc).

@tobowers
Copy link
Author

@tobowers
Copy link
Author

ok... I think I got it: https://runkit.com/tobowers/5955faae1cba570012814f47

Which I kind of gleamed from here: #128

That interface is a bit confusing though... if the function can take a buffer it should probably do that conversion for you? Or raise an error when it's not a string?

@dlongley
Copy link
Member

dlongley commented Jun 30, 2017

That interface is a bit confusing though... if the function can take a buffer it should probably do that conversion for you? Or raise an error when it's not a string?

Yes, you're right. Dealing with encoding issues and improving the API (throwing better errors, requiring buffers, forcing string encodings to be specified and so forth) is on the roadmap, with some preliminary work done on another branch here:

https://github.com/digitalbazaar/forge/tree/0.8.x

That branch is needs to be rebased on top of the recent build fixes that were performed to go from forge 0.6.x to 0.7.x before further work can occur.

@dlongley
Copy link
Member

Closing, resolving this issue is on the roadmap.

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

2 participants