-
-
Notifications
You must be signed in to change notification settings - Fork 32.1k
Port HMAC implementation to new OpenSSL APIs #134531
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
I can take care of this. Note that EVP_MAC-HMAC is only available since OpenSSL 3.x and the requirements for CPython are OpenSSL 1.1.1 and later. We still need to maintain the old API (though, we're already doing it through PY_EVP_MD macros) since our build requirements OpenSSL 3.0.9 is the recommended minimum version for the ssl and hashlib extension modules. |
Ok, so I had a quick look at how I would plan this. I'll need multiple PRs because Note: I eventually decided against the backports, even if they could ease the life of my future self (see #134626 (comment) and #134703 (comment)). |
Rename components related to `_hashlib.{HASH,HASHXOF}` objects. - The `EVPobject` structure is renamed `HASHobject`. - Non-clinic `HASH` methods are now prefixed by `_hashlib_HASH_*`. A similar change is made for non-clinic `HASHXOF` methods. - Functions extracting information from `EVP_MD` objects and functions constructing `EVP_MD` objects now include `openssl_evp_md` in their name. This change allows us to avoid future ambiguities between the `EVP_MD` and the `EVP_MAC` APIs (currently, we only use `EVP_MD` for hash functions and rely on the legacy interface for HMAC instead of using `EVP_MAC`).
…nGH-134626) Rename components related to `_hashlib.{HASH,HASHXOF}` objects. - The `EVPobject` structure is renamed `HASHobject`. - Non-clinic `HASH` methods are now prefixed by `_hashlib_HASH_*`. A similar change is made for non-clinic `HASHXOF` methods. - Functions extracting information from `EVP_MD` objects and functions constructing `EVP_MD` objects now include `openssl_evp_md` in their name. This change allows us to avoid future ambiguities between the `EVP_MD` and the `EVP_MAC` APIs (currently, we only use `EVP_MD` for hash functions and rely on the legacy interface for HMAC instead of using `EVP_MAC`). (cherry picked from commit cb8045e) Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
Ok, so here's the plan. I've finished writing the implementation, but the PR is huge:
So I'll break down the commits, because I also found multiple issues elsewhere. Well, not real issues, but annoying interfaces that should be refactored first.
The deprecated HMAC API is deprecated because it's actually wrapping an I have a branch with everything ready so I'll just make different PRs. At the same time, I'll also refactor |
Uh oh!
There was an error while loading. Please reload this page.
Feature or enhancement
Our current OpenSSL implementation of HMAC is based on the deprecated HMAC API.
We should migrate to the new EVP_MAC-HMAC API instead.
Linked PRs
_hashopenssl.c
to supportEVP_MAC
#134626_hashopenssl.c
to supportEVP_MAC
(GH-134626) #134703EVP_MAC
API for_hashlib.HMAC
#135235_hashlib
clinic directive post GH-134626 #135249_hashlib
logic for mapping NIDs to EVP_MD objects #135254The text was updated successfully, but these errors were encountered: