bpo-40645: Implement HMAC in C (GH-20129)#20129
Merged
tiran merged 1 commit intopython:masterfrom May 17, 2020
Merged
Conversation
6bbb177 to
3e2345b
Compare
The internal module ``_hashlib`` wraps and exposes OpenSSL's HMAC API. The new code will be used in Python 3.10 after the internal implementation details of the pure Python HMAC module are no longer part of the public API. The code is based on a patch by Petr Viktorin for RHEL and Python 3.6. news.gmane.io Co-Authored-By: Petr Viktorin <encukou@gmail.com> Signed-off-by: Christian Heimes <christian@python.org>
Member
Author
|
@gpshead I'm merging the PR without your ACK to get it into Python 3.9 before beta freeze. In case you don't like it I can remove it from 3.9 and postpone the new feature to 3.10. |
arturoescaip
pushed a commit
to arturoescaip/cpython
that referenced
this pull request
May 24, 2020
The internal module ``_hashlib`` wraps and exposes OpenSSL's HMAC API. The new code will be used in Python 3.10 after the internal implementation details of the pure Python HMAC module are no longer part of the public API. The code is based on a patch by Petr Viktorin for RHEL and Python 3.6. Co-Authored-By: Petr Viktorin <encukou@gmail.com>
| if (self->lock != NULL) { | ||
| ENTER_HASHLIB(self); | ||
| r = HMAC_Update(self->ctx, (const unsigned char*)view.buf, view.len); | ||
| LEAVE_HASHLIB(self); |
Contributor
There was a problem hiding this comment.
Looking at the definition of ENTER_HASHLIB, I believe that the GIL is released only while acquiring the HMACobject lock, and not during the actual HMAC_Update.
It seems the intention was to release it for HMAC_Update as well, which is what EVP_update does. If that's the case, then I think this should use the same approach as EVP_update. Something like
Py_BEGIN_ALLOW_THREADS
PyThread_acquire_lock(self->lock, 1);
r = HMAC_Update(self->ctx, (const unsigned char*)view.buf, view.len);
PyThread_release_lock(self->lock);
Py_END_ALLOW_THREADS
Member
There was a problem hiding this comment.
Good catch. True. https://bugs.python.org/issue44145 filed to track and fix.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The internal module
_hashlibwraps and exposes OpenSSL's HMAC API. Thenew code will be used in Python 3.10 after the internal implementation
details of the pure Python HMAC module are no longer part of the public API.
The code is based on a patch by Petr Viktorin for RHEL and Python 3.6.
https://bugs.python.org/issue40645