mirror of
https://github.com/python/cpython.git
synced 2025-08-22 17:55:18 +00:00
bpo-37630: Use SHA3 and SHAKE XOF from OpenSSL (GH-16049)
OpenSSL 1.1.1 comes with SHA3 and SHAKE builtin. Signed-off-by: Christian Heimes <christian@python.org> Automerge-Triggered-By: @tiran
This commit is contained in:
parent
b17e49e0de
commit
d5b3f6b7f9
6 changed files with 845 additions and 21 deletions
|
@ -71,8 +71,6 @@ __all__ = __always_supported + ('new', 'algorithms_guaranteed',
|
|||
__builtin_constructor_cache = {}
|
||||
|
||||
__block_openssl_constructor = {
|
||||
'sha3_224', 'sha3_256', 'sha3_384', 'sha3_512',
|
||||
'shake_128', 'shake_256',
|
||||
'blake2b', 'blake2s',
|
||||
}
|
||||
|
||||
|
@ -125,6 +123,8 @@ def __get_openssl_constructor(name):
|
|||
# Prefer our blake2 and sha3 implementation.
|
||||
return __get_builtin_constructor(name)
|
||||
try:
|
||||
# MD5, SHA1, and SHA2 are in all supported OpenSSL versions
|
||||
# SHA3/shake are available in OpenSSL 1.1.1+
|
||||
f = getattr(_hashlib, 'openssl_' + name)
|
||||
# Allow the C module to raise ValueError. The function will be
|
||||
# defined but the hash not actually available thanks to OpenSSL.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue