Content-Length: 294146 | pFad | http://github.com/python/cpython/pull/136570/commits/879cc7345c90902cebcfdc6327ce6e442f5efaee

D2 gh-136547: allow to temporarily disable hash algorithms in tests by picnixz · Pull Request #136570 · python/cpython · GitHub
Skip to content

gh-136547: allow to temporarily disable hash algorithms in tests #136570

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 4 commits into from
Jul 13, 2025
Merged
Changes from 1 commit
Commits
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
typo
  • Loading branch information
picnixz committed Jul 12, 2025
commit 879cc7345c90902cebcfdc6327ce6e442f5efaee
12 changes: 7 additions & 5 deletions Lib/test/support/hashlib_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,10 @@
))

NON_HMAC_DIGEST_NAMES = frozenset({
'shake_128', 'shake_256', 'blake2s', 'blake2b'
'shake_128', 'shake_256',
'blake2s', 'blake2b',
})

# Mapping from a "canonical" name to a pair (HACL*, _hashlib.*, hashlib.*)
# constructors. If the constructor name is None, then this means that the
# algorithm can only be used by the "agile" new() interfaces.

class HashAPI(namedtuple("HashAPI", "builtin openssl hashlib")):

Expand All @@ -50,6 +48,9 @@ def fullname(self, typ):
raise AssertionError(f"unknown type: {typ}")


# Mapping from a "canonical" name to a pair (HACL*, _hashlib.*, hashlib.*)
# constructors. If the constructor name is None, then this means that the
# algorithm can only be used by the "agile" new() interfaces.
_EXPLICIT_CONSTRUCTORS = MappingProxyType({
"md5": HashAPI("_md5.md5", "openssl_md5", "md5"),
"sha1": HashAPI("_sha1.sha1", "openssl_sha1", "sha1"),
Expand All @@ -66,7 +67,6 @@ def fullname(self, typ):
"blake2s": HashAPI("_blake2.blake2s", None, "blake2s"),
"blake2b": HashAPI("_blake2.blake2b", None, "blake2b"),
})

assert _EXPLICIT_CONSTRUCTORS.keys() == CANONICAL_DIGEST_NAMES

_EXPLICIT_HMAC_CONSTRUCTORS = {
Expand All @@ -78,6 +78,8 @@ def fullname(self, typ):
}
_EXPLICIT_HMAC_CONSTRUCTORS['shake_128'] = None
_EXPLICIT_HMAC_CONSTRUCTORS['shake_256'] = None
# Strictly speaking, HMAC-BLAKE is meaningless as BLAKE2 is already a
# keyed hash function. However, as it's exposed by HACL*, we test it.
_EXPLICIT_HMAC_CONSTRUCTORS['blake2s'] = '_hmac.compute_blake2s_32'
_EXPLICIT_HMAC_CONSTRUCTORS['blake2b'] = '_hmac.compute_blake2b_32'
_EXPLICIT_HMAC_CONSTRUCTORS = MappingProxyType(_EXPLICIT_HMAC_CONSTRUCTORS)
Expand Down
Loading








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/python/cpython/pull/136570/commits/879cc7345c90902cebcfdc6327ce6e442f5efaee

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy