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

Bug report: HMAC operation produces incorrect output with hex keys with bytes >= 0x80 #437

Closed
imhotepisinvisible opened this issue Dec 4, 2018 · 3 comments

Comments

@imhotepisinvisible
Copy link
Contributor

Summary

The HMAC operation seems to produce incorrect output when using with hex keys with bytes >= 0x80

Example

Openssl:

$ echo -n 'test' | openssl dgst -sha256 -mac HMAC -macopt hexkey:00000000000000000000000000000000
(stdin)= 43b0cef99265f9e34c10ea9d3501926d27b39f57c6d674561d8ba236e7a819fb

CyberChef:

https://gchq.github.io/CyberChef/#recipe=HMAC(%7B'option':'Hex','string':'00000000000000000000000000000000'%7D,'SHA256')&input=dGVzdA
Output (correct): 43b0cef99265f9e34c10ea9d3501926d27b39f57c6d674561d8ba236e7a819fb

Openssl:

$ echo -n 'test' | openssl dgst -sha256 -mac HMAC -macopt hexkey:00000000000000000000000000000080
(stdin)= 82eb64f8f0732e166df7ffa088393fcea946233c8df3f76d7dc1dde0a055ae4e

CyberChef:

https://gchq.github.io/CyberChef/#recipe=HMAC(%7B'option':'Hex','string':'00000000000000000000000000000080'%7D,'SHA256')&input=dGVzdA
Output (incorrect): 40793ae8db3df4bcb12aa92cd3a1ca619a55cc3070e0eb06dedb47afdd4c6e06

@bwhitn
Copy link
Contributor

bwhitn commented Dec 14, 2018

Haven't looked into it much yet but this appears to be the same issue as other Crypto based functions have had in the past with string vs buffer input.

imhotepisinvisible added a commit to imhotepisinvisible/CyberChef that referenced this issue Dec 14, 2018
@imhotepisinvisible
Copy link
Contributor Author

I've submitted a PR that should fix the issue. Looks like it came in in PR #391

@n1474335
Copy link
Member

Thanks for the fix @imhotepisinvisible

BRAVO68WEB pushed a commit to BRAVO68WEB/CyberChef that referenced this issue May 29, 2022
BRAVO68WEB pushed a commit to BRAVO68WEB/CyberChef that referenced this issue May 29, 2022
BRAVO68WEB pushed a commit to BRAVO68WEB/CyberChef that referenced this issue May 29, 2022
BRAVO68WEB pushed a commit to BRAVO68WEB/CyberChef that referenced this issue May 29, 2022
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