bpo-40695: Limit hashlib builtin hash fallback (GH-20259)
:mod:`hashlib` no longer falls back to builtin hash implementations when OpenSSL provides a hash digest and the algorithm is blocked by security policy. Signed-off-by: Christian Heimes <christian@python.org>
This commit is contained in:
parent
3f59b55316
commit
4cc2f9348c
|
@ -127,8 +127,9 @@ def __get_openssl_constructor(name):
|
||||||
# SHA3/shake are available in OpenSSL 1.1.1+
|
# SHA3/shake are available in OpenSSL 1.1.1+
|
||||||
f = getattr(_hashlib, 'openssl_' + name)
|
f = getattr(_hashlib, 'openssl_' + name)
|
||||||
# Allow the C module to raise ValueError. The function will be
|
# Allow the C module to raise ValueError. The function will be
|
||||||
# defined but the hash not actually available thanks to OpenSSL.
|
# defined but the hash not actually available. Don't fall back to
|
||||||
f()
|
# builtin if the current security policy blocks a digest, bpo#40695.
|
||||||
|
f(usedforsecurity=False)
|
||||||
# Use the C function directly (very fast)
|
# Use the C function directly (very fast)
|
||||||
return f
|
return f
|
||||||
except (AttributeError, ValueError):
|
except (AttributeError, ValueError):
|
||||||
|
|
|
@ -0,0 +1,3 @@
|
||||||
|
:mod:`hashlib` no longer falls back to builtin hash implementations when
|
||||||
|
OpenSSL provides a hash digest and the algorithm is blocked by security
|
||||||
|
policy.
|
Loading…
Reference in New Issue