FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

gh-134531: cleanup `_hashopenssl.c` to support `EVP_MAC` by picnixz · Pull Request #134626 · python/cpython · GitHub

Repository navigation

gh-134531: cleanup _hashopenssl.c to support EVP_MAC - #134626

Merged
picnixz merged 17 commits into
python:mainfrom
picnixz:feat/hmac/prepare-for-openssl-3x-134531
May 26, 2025
Merged

picnixz merged 17 commits into
python:mainfrom
picnixz:feat/hmac/prepare-for-openssl-3x-134531

Conversation

picnixz commented May 24, 2025 •
edited by bedevere-app Bot
Loading

Copy link
Copy Markdown
Member

Previously, we used EVP to denote anything related to hash functions. We didn't need to distinguish between EVP_MD and EVP_MAC. However, we will need to distinguish them and honestly, I always wanted to refactor this module.

So, I decided to rewrite many function names. The logic is as follows:

  • use _hashlib_HASH_* for HASH methods (previously EVPobject)
  • use _hashlib_HASHXOF_* for SHAKE methods (previously EVPXOF)
  • only use EVP in function names when we're actually dealing with OpenSSL itself. It's confusing otherwise. On CPython's side, we're only wrapping an EVP_MD object, but we're not an EVP_MD object IMO. We are a HASH or a HASHXOF object since we export them as such.

Note that we can backport this to 3.14, and, ideally, to 3.13 as well because if I were to fix a bug in 3.15, then we'll likely have conflicts if I were to backport the fix to 3.13.

picnixz requested a review from gpshead as a code owner May 24, 2025 10:41
picnixz added the 🔨 test-with-buildbots Test PR w/ buildbots; report in status section label May 24, 2025

Copy link
Copy Markdown

🤖 New build scheduled with the buildbot fleet by @picnixz for commit 63bc38c 🤖

Results will be shown at:

https://buildbot.python.org/all/#/grid?branch=refs%2Fpull%2F134626%2Fmerge

If you want to schedule another build, you need to add the 🔨 test-with-buildbots label again.

bedevere-bot removed the 🔨 test-with-buildbots Test PR w/ buildbots; report in status section label May 24, 2025
gpshead added needs backport to 3.13 only security fixes needs backport to 3.14 bugs and security fixes labels May 25, 2025

gpshead commented May 25, 2025

Copy link
Copy Markdown
Member

I suggest adding a small news entry regardless, as this will land in a release branch it is nice to indicate to people reading the changelog where a name cleanup refactoring was done to the internals.

picnixz commented May 25, 2025

Copy link
Copy Markdown
Member Author

I suggest adding a small news entry regardless, as this will land in a release branch it is nice to indicate to people reading the changelog where a name cleanup refactoring was done to the internals.

Sure, I'll write a NEWS entry tomorrow and will merge this.

picnixz commented May 26, 2025 •
edited
Loading

Copy link
Copy Markdown
Member Author

Note: failures are related to GH. And if the backport fails to 3.13 due to conflicts, I'll ignore it as well (this liokely means I would anyway need to work harder :'))

picnixz enabled auto-merge (squash) May 26, 2025 10:12
picnixz merged commit cb8045e into python:main May 26, 2025

Copy link
Copy Markdown

Thanks @picnixz for the PR 🌮🎉.. I'm working now to backport this PR to: 3.13, 3.14.
🐍🍒⛏🤖

picnixz deleted the feat/hmac/prepare-for-openssl-3x-134531 branch May 26, 2025 10:12
miss-islington pushed a commit to miss-islington/cpython that referenced this pull request May 26, 2025
…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>

Copy link
Copy Markdown

Sorry, @picnixz, I could not cleanly backport this to 3.13 due to a conflict.
Please backport using cherry_picker on command line.

cherry_picker cb8045e86c4fadfd847d614193f2b38ec03933b8 3.13

bedevere-app Bot commented May 26, 2025

Copy link
Copy Markdown

GH-134703 is a backport of this pull request to the 3.14 branch.

bedevere-app Bot removed the needs backport to 3.14 bugs and security fixes label May 26, 2025

picnixz commented May 26, 2025

Copy link
Copy Markdown
Member Author

Ok let's have a look at the conflicts.

picnixz commented May 26, 2025

Copy link
Copy Markdown
Member Author

Ok, forget it, the conflicts are too hard to fix because of UBSan failures that were fixed and clinic that was fixed differently.

picnixz removed the needs backport to 3.13 only security fixes label May 26, 2025
lkollar pushed a commit to lkollar/cpython that referenced this pull request Jun 19, 2025
Pranjal095 pushed a commit to Pranjal095/cpython that referenced this pull request Jul 12, 2025
…n#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`).
Pranjal095 pushed a commit to Pranjal095/cpython that referenced this pull request Jul 12, 2025
taegyunkim pushed a commit to taegyunkim/cpython that referenced this pull request Aug 4, 2025
…n#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`).
taegyunkim pushed a commit to taegyunkim/cpython that referenced this pull request Aug 4, 2025
Agent-Hellboy pushed a commit to Agent-Hellboy/cpython that referenced this pull request Aug 19, 2025
gostak-dd pushed a commit to gostak-dd/cpython that referenced this pull request Jun 2, 2026
…n#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`).
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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants


Back | FazBrowse Home | New Git URL