-
Notifications
You must be signed in to change notification settings - Fork 1k
hmac code not compatible with hashlib/uhashlib implementations #369
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
Comments
@peter-conalgo: perhaps are you interested in this issue ? |
Somewhat. I used this code as an example, and made my own when I needed HMAC recently. Pared down features I didn't need so that in the end, I didn't need to copy state. My version: https://github.com/Coldcard/firmware/blob/119d7f79d82d98d35e53a941bbc065fa81182e50/shared/hmac.py |
Thanks @peter-conalgo. I'll try your code ! |
hello the code error digest_size. |
See #515 for a fix for this (sorry this has taken so long) |
Fixed by f95260d |
I noticed that micropython's
hmac
implementation relies on the existence of.copy()
on instances of shaXX, which works fine with the implementation provided inhashlib._sha224
/256
/384
/512
, but does not work with the implementations thathashlib
auto-loads fromuhashlib
whenuhashlib
is present (since this change).I tested recent versions micropython-lib master and micropython 1.12).
Forcing the use of the implementation under
hashlib._sha256
works though:(this workaround unfortunately does not work for SHA1 since SHA1 has no implementation in
hashlib
)I presume that whether
hmac
should be implemented without using relying oncopy()
, or at least should not autoloadhashlib
(this last solution would leave HMAC SHA1 unimplemented).The text was updated successfully, but these errors were encountered: