-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Support EVP_MAC for HMAC #120769
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
Support EVP_MAC for HMAC #120769
Conversation
Co-authored-by: Copilot <[email protected]>
Tagging subscribers to this area: @dotnet/area-system-security, @bartonjs, @vcsjones |
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.
Pull Request Overview
This PR migrates HMAC implementation to use OpenSSL 3.0's EVP_MAC APIs instead of the deprecated HMAC APIs when running on OpenSSL 3+, while maintaining backward compatibility with older OpenSSL versions.
Key Changes
- Introduced
DN_MAC_CTX
wrapper structure to support both legacy HMAC_CTX and new EVP_MAC_CTX implementations - Added runtime detection and initialization of EVP_MAC support
- Implemented workaround for OpenSSL 3.0.0-3.0.2 bug where EVP_MAC_init cannot reset with existing key
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
Show a summary per file
File | Description |
---|---|
pal_hmac.h |
Updated function signatures to use DN_MAC_CTX instead of HMAC_CTX and added the new context structure definition |
pal_hmac.c |
Implemented dual-path logic for EVP_MAC (OpenSSL 3.0+) and legacy HMAC APIs with version-specific workarounds |
osslcompat_30.h |
Added OSSL_MAC_PARAM_DIGEST constant and EVP_MD_get0_name function declaration for OpenSSL 3.0 compatibility |
opensslshim.h |
Registered new OpenSSL functions (CRYPTO_clear_free , CRYPTO_zalloc , EVP_MD_get0_name ) and added version constant for OpenSSL 3.0.2 |
IncrementalHashTests.cs |
Added test case to verify HMAC cloning with empty keys works correctly |
src/libraries/System.Security.Cryptography/tests/IncrementalHashTests.cs
Outdated
Show resolved
Hide resolved
Co-authored-by: Copilot <[email protected]>
If we are on OpenSSL 3, we should use the EVP_MAC APIs instead of the now deprecated HMAC APIs.
Replaces #118856
Closes #118807
Contributes to #46526