diff options
author | Gregory P. Smith <greg@krypto.org> | 2023-02-15 22:08:20 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-02-15 22:08:20 -0800 |
commit | 0b13575e74ff3321364a3389eda6b4e92792afe1 (patch) | |
tree | 1fc6775cb290958f1c4d0e98c17300629f8aa9c4 /Lib/hashlib.py | |
parent | 89ac665891dec1988bedec2ce9b2c4d016502a49 (diff) | |
download | cpython-0b13575e74ff3321364a3389eda6b4e92792afe1.tar.gz cpython-0b13575e74ff3321364a3389eda6b4e92792afe1.zip |
gh-99108: Refactor _sha256 & _sha512 into _sha2. (#101924)
This merges their code. They're backed by the same single HACL* static library, having them be a single module simplifies maintenance.
This should unbreak the wasm enscripten builds that currently fail due to linking in --whole-archive mode and the HACL* library appearing twice.
Long unnoticed error fixed: _sha512.SHA384Type was doubly assigned and was actually SHA512Type. Nobody depends on those internal names.
Also rename LIBHACL_ make vars to LIBHACL_SHA2_ in preperation for other future HACL things.
Diffstat (limited to 'Lib/hashlib.py')
-rw-r--r-- | Lib/hashlib.py | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/Lib/hashlib.py b/Lib/hashlib.py index 21b5e912f3c..1b16441cb60 100644 --- a/Lib/hashlib.py +++ b/Lib/hashlib.py @@ -92,13 +92,13 @@ def __get_builtin_constructor(name): import _md5 cache['MD5'] = cache['md5'] = _md5.md5 elif name in {'SHA256', 'sha256', 'SHA224', 'sha224'}: - import _sha256 - cache['SHA224'] = cache['sha224'] = _sha256.sha224 - cache['SHA256'] = cache['sha256'] = _sha256.sha256 + import _sha2 + cache['SHA224'] = cache['sha224'] = _sha2.sha224 + cache['SHA256'] = cache['sha256'] = _sha2.sha256 elif name in {'SHA512', 'sha512', 'SHA384', 'sha384'}: - import _sha512 - cache['SHA384'] = cache['sha384'] = _sha512.sha384 - cache['SHA512'] = cache['sha512'] = _sha512.sha512 + import _sha2 + cache['SHA384'] = cache['sha384'] = _sha2.sha384 + cache['SHA512'] = cache['sha512'] = _sha2.sha512 elif name in {'blake2b', 'blake2s'}: import _blake2 cache['blake2b'] = _blake2.blake2b |