Skip to content

gh-136547: refactor hashlib_helper for blocking and requesting digests #136762

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

Merged
merged 13 commits into from
Jul 20, 2025
Prev Previous commit
Next Next commit
fix names
  • Loading branch information
picnixz committed Jul 20, 2025
commit 2b8d5f0ddb8f5748857db6b135fe94f44a780fb6
5 changes: 3 additions & 2 deletions Lib/test/support/hashlib_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -560,7 +560,8 @@ def _block_openssl_hash_new(blocked_name):
def _hashlib_new(name, data=b'', *, usedforsecurity=True, string=None):
if name == blocked_name:
raise _hashlib.UnsupportedDigestmodError(blocked_name)
return wrapped(*args, **kwargs)
return wrapped(name, data,
usedforsecurity=usedforsecurity, string=string)

_ensure_wrapper_signature(_hashlib_new, wrapped)
return unittest.mock.patch('_hashlib.new', _hashlib_new)
Expand Down Expand Up @@ -596,7 +597,7 @@ def _block_openssl_hmac_digest(blocked_name):
def _hashlib_hmac_digest(key, msg, digest):
if digest == blocked_name:
raise _hashlib.UnsupportedDigestmodError(blocked_name)
return wrapped(key, msg, digestmod)
return wrapped(key, msg, digest)

_ensure_wrapper_signature(_hashlib_hmac_digest, wrapped)
return unittest.mock.patch('_hashlib.hmac_digest', _hashlib_hmac_digest)
Expand Down
Loading
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy