3.9: hashlib sha512_{224,256} md5_sha1 algos "unknown" when used by Pythonic names
Sorry for missing it earlier. Using the latest nightly (pypy-c-jit-105829-51afa45d7c16-linux64
) with ssl module rebuilt against system OpenSSL 3.0.5.
>>>> hashlib.algorithms_available
{'md5', 'sha1', 'sha224', 'sha256', 'sha384', 'sha512', 'blake2b', 'blake2s', 'sha3_224', 'sha3_256', 'sha3_384', 'sha3_512', 'shake_128', 'shake_256', 'sm3', 'sha512_224', 'md5_sha1', 'sha512_256'}
However, the three last algorithms are unusable, giving an error alike:
>>>> hashlib.new("sha512_224")
Traceback (most recent call last):
File "/tmp/pypy-c-jit-105829-51afa45d7c16-linux64/lib/pypy3.9/hashlib.py", line 161, in __hash_new
return _hashlib.new(name, data, **kwargs)
File "/tmp/pypy-c-jit-105829-51afa45d7c16-linux64/lib/pypy3.9/_hashlib/__init__.py", line 29, in new
h = HASH(name, usedforsecurity=usedforsecurity)
File "/tmp/pypy-c-jit-105829-51afa45d7c16-linux64/lib/pypy3.9/_hashlib/__init__.py", line 41, in __init__
digest_type = self.digest_type_by_name()
File "/tmp/pypy-c-jit-105829-51afa45d7c16-linux64/lib/pypy3.9/_hashlib/__init__.py", line 76, in digest_type_by_name
raise ValueError("unknown hash function")
ValueError: unknown hash function
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/tmp/pypy-c-jit-105829-51afa45d7c16-linux64/lib/pypy3.9/hashlib.py", line 167, in __hash_new
return __get_builtin_constructor(name)(data)
File "/tmp/pypy-c-jit-105829-51afa45d7c16-linux64/lib/pypy3.9/hashlib.py", line 124, in __get_builtin_constructor
raise ValueError('unsupported hash type ' + name)
ValueError: unsupported hash type sha512_224
Interesting enough, if I use the "openssl name" for it, it seems to work:
>>>> hashlib.new("SHA512-224")
<sha512-224 HASH object at 0x140365606114256>
>>>> hashlib.new("md5-sha1")
<md5-sha1 HASH object at 0x140365603030032>
FWICS, CPython uses a mapping from Python algorithm names to OpenSSL SN_*
constants:
https://github.com/python/cpython/blob/3.9/Modules/_hashopenssl.c#L151