Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork33.3k
bpo-40645: use C implementation of HMAC#24920
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
Signed-off-by: Christian Heimes <christian@python.org>
Uh oh!
There was an error while loading.Please reload this page.
Lib/hmac.py Outdated
| _hashopensslisnotNoneand | ||
| (digestname:=_hashlib._digestmod_to_name(digestmod)) | ||
| ): | ||
| self._init_hmac(key,msg,digestname) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
This makes the assumption that if we have_hashopenssl, all possible digests anyone could use will be available as part of openssl for use via its hmac implementation. I don't think that is necessarily true. A digestmod that supplies a string name can be supplied but not be something available in openssl.
presumably the easiest way around this while retaining the optimal openssl computation when possible is to catch an exception from_init_hmac (due to_hashopenssl.hmac_new raising) and fall back to_init_old instead.
a test should be added to cover this case. (via a custom digestmod-like-object with a name and blocksize perhaps)
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Lib/hmac.py Outdated
| _hashopensslisnotNoneand | ||
| (digestname:=_hashlib._digestmod_to_name(digest)) | ||
| ): | ||
| return_hashopenssl.hmac_digest(key,msg,digestname) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
fallback logic needed here as when digestname isn't supported by openssl.
bedevere-bot commentedMar 18, 2021
When you're done making the requested changes, leave the comment: |
Thanks for the feedback,@gpshead! I'm not happy with the first draft. It's not elegant. It's easier to track builtin constructors in C and map them directly in |
Recognize _hashlib.openssl_sha256 function object as "sha256".
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
pablogsal commentedMar 29, 2021 • edited by bedevere-bot
Loading Uh oh!
There was an error while loading.Please reload this page.
edited by bedevere-bot
Uh oh!
There was an error while loading.Please reload this page.
Seems that commit933dfd7 introduced some reference leaks: commit933dfd7 𓋹 ./python.exe -m test test_hashlib -R 3:3 == Tests result: FAILURE == 1 test failed: Total duration: 8.7 sec Lib/hashlib.py | 1 + |
Opened#25063 to address it |
- [x] fix tests- [ ] add test scenarios for old/new code.Signed-off-by: Christian Heimes <christian@python.org>
…,pythonGH-26079)This backports the feature and 2 subsequent bugfixesfrom:https://bugs.python.org/issue40645Signed-off-by: Christian Heimes <christian@python.org>Co-authored-by: Erlend Egeberg Aasland <erlend.aasland@innova.no>Co-Authored-By: Pablo Galindo <Pablogsal@gmail.com>
…,pythonGH-26079)This backports the feature and 2 subsequent bugfixesfrom:https://bugs.python.org/issue40645Signed-off-by: Christian Heimes <christian@python.org>Co-authored-by: Erlend Egeberg Aasland <erlend.aasland@innova.no>Co-Authored-By: Pablo Galindo <Pablogsal@gmail.com>
…,pythonGH-26079)This backports the feature and 2 subsequent bugfixesfrom:https://bugs.python.org/issue40645Signed-off-by: Christian Heimes <christian@python.org>Co-authored-by: Erlend Egeberg Aasland <erlend.aasland@innova.no>Co-Authored-By: Pablo Galindo <Pablogsal@gmail.com>
Uh oh!
There was an error while loading.Please reload this page.
Signed-off-by: Christian Heimeschristian@python.org
https://bugs.python.org/issue40645
Automerge-Triggered-By: GH:tiran