Skip to content

gh-134531: use EVP_MAC API for _hashlib.HMAC #135235

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

Open
wants to merge 44 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
c444180
allow to use EVP_MAC API
picnixz Jun 7, 2025
eb3cb2e
add helpers for setting exceptions
picnixz Jun 8, 2025
e242865
refactor `get_openssl_evp_md_by_utf8name` error branches
picnixz Jun 8, 2025
ac6dea4
refactor `HASH.{digest,hexdigest}` computations
picnixz Jun 8, 2025
4bc2808
refactor `_hashlib_HASH_copy_locked` and `locked_HMAC_CTX_copy`
picnixz Jun 8, 2025
14b87df
set remaining exceptions after an OpenSSL failure
picnixz Jun 8, 2025
e5b2ef3
blurb
picnixz Jun 8, 2025
5b41242
wrap OpenSSL context allocators
picnixz Jun 8, 2025
2a8cf55
fix compilation, remove unused functions and update messages
picnixz Jun 8, 2025
ea2ce0e
update wrappers
picnixz Jun 8, 2025
43739c5
align exception messages
picnixz Jun 8, 2025
e226431
context allocators can only set an ERR_R_MALLOC_FAILURE error
picnixz Jun 8, 2025
7201e0a
update exception message for `get_openssl_evp_md_by_utf8name`
picnixz Jun 8, 2025
f8c2aed
refactor logic for mapping NIDs to EVP_MD objects
picnixz Jun 8, 2025
64539c8
fix(typo)
picnixz Jun 8, 2025
0b75636
Merge remote-tracking branch 'upstream/main' into feat/hashlib/evp-ma…
picnixz Jun 8, 2025
a9e440c
Merge branch 'refactor/hashlib/evp-nid-interface-134531' into feat/ha…
picnixz Jun 8, 2025
f96d44e
Merge branch 'feat/hashlib/smart-exceptions-135234' into feat/hashlib…
picnixz Jun 8, 2025
94858be
post-merge
picnixz Jun 8, 2025
ecfb74a
remove useless macros
picnixz Jun 8, 2025
fc6b0b1
remove useless directives
picnixz Jun 8, 2025
661472c
post-merge
picnixz Jun 8, 2025
a837e21
post-merge
picnixz Jun 8, 2025
380f5a0
Update Modules/_hashopenssl.c
picnixz Jun 8, 2025
7036df8
remove TODO
picnixz Jun 8, 2025
b7f0947
Merge branch 'refactor/hashlib/evp-nid-interface-134531' into feat/ha…
picnixz Jun 8, 2025
a1066fe
pull main
picnixz Jun 8, 2025
76c7dd2
Merge branch 'main' into feat/hashlib/smart-exceptions-135234
picnixz Jun 8, 2025
0cf0f8b
Merge branch 'feat/hashlib/smart-exceptions-135234' into feat/hashlib…
picnixz Jun 8, 2025
5d4c829
Merge branch 'main' into feat/hashlib/evp-mac-134531
picnixz Jun 9, 2025
1a311e7
post merge
picnixz Jun 9, 2025
e64e664
post-merge
picnixz Jun 9, 2025
9d44b31
remove un-necessary macros
picnixz Jun 9, 2025
8b64ad6
simplify some function calls
picnixz Jun 9, 2025
2307154
simplify call
picnixz Jun 9, 2025
90c4e94
fix leak
picnixz Jun 9, 2025
3640c09
fix lint
picnixz Jun 9, 2025
f1127a1
raise an ImportError when failing to fetch OpenSSL HMAC
picnixz Jun 14, 2025
6179261
raise an ImportError when failing to fetch OpenSSL HMAC
picnixz Jun 14, 2025
c04eacb
Merge remote-tracking branch 'upstream/main' into feat/hashlib/evp-ma…
picnixz Jun 22, 2025
e8fb310
reduce diff
picnixz Jun 22, 2025
e92f7cc
Merge branch 'main' into feat/hashlib/evp-mac-134531
picnixz Jun 22, 2025
6e10d74
Merge branch 'main' into feat/hashlib/evp-mac-134531
picnixz Jun 22, 2025
4b3ff7d
blurb
picnixz Jun 23, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
simplify call
  • Loading branch information
picnixz committed Jun 9, 2025
commit 2307154e61a250c2e275882c4f062801a5860e3d
5 changes: 2 additions & 3 deletions Modules/_hashopenssl.c
Original file line number Diff line number Diff line change
Expand Up @@ -2166,7 +2166,7 @@ hashlib_openssl_HMAC_digest_compute(HMACobject *self, unsigned char *buf)
#else
int r = HMAC_Final(ctx, buf, NULL);
#endif
hashlib_openssl_HMAC_CTX_free(ctx);
PY_HMAC_CTX_free(ctx);
if (r == 0) {
#ifdef Py_HAS_OPENSSL3_SUPPORT
notify_ssl_error_occurred_in(Py_STRINGIFY(EVP_MAC_final));
Expand Down Expand Up @@ -2325,8 +2325,7 @@ _openssl_hash_name_mapper(const EVP_MD *md, const char *from,
py_name = name == NULL ? NULL : PyUnicode_FromString(name);
if (py_name == NULL) {
state->error = 1;
}
else {
} else {
if (PySet_Add(state->set, py_name) != 0) {
state->error = 1;
}
Expand Down
Loading