summaryrefslogtreecommitdiff
path: root/modules/language/python/module/hashlib.py
diff options
context:
space:
mode:
Diffstat (limited to 'modules/language/python/module/hashlib.py')
-rw-r--r--modules/language/python/module/hashlib.py55
1 files changed, 36 insertions, 19 deletions
diff --git a/modules/language/python/module/hashlib.py b/modules/language/python/module/hashlib.py
index 343f116..dd6892a 100644
--- a/modules/language/python/module/hashlib.py
+++ b/modules/language/python/module/hashlib.py
@@ -84,27 +84,42 @@ def __get_builtin_constructor(name):
elif name in ('MD5', 'md5'):
import _md5
cache['MD5'] = cache['md5'] = _md5.md5
- elif name in ('SHA256', 'sha256', 'SHA224', 'sha224'):
+ elif name in ('SHA256', 'sha256'):
import _sha256
- cache['SHA224'] = cache['sha224'] = _sha256.sha224
cache['SHA256'] = cache['sha256'] = _sha256.sha256
- elif name in ('SHA512', 'sha512', 'SHA384', 'sha384'):
+ elif name in ('SHA224', 'sha224'):
+ import _sha224
+ cache['SHA224'] = cache['sha224'] = _sha224.sha224
+ elif name in ('SHA512', 'sha512'):
import _sha512
- cache['SHA384'] = cache['sha384'] = _sha512.sha384
cache['SHA512'] = cache['sha512'] = _sha512.sha512
- elif name in ('blake2b', 'blake2s'):
- import _blake2
- cache['blake2b'] = _blake2.blake2b
- cache['blake2s'] = _blake2.blake2s
- elif name in {'sha3_224', 'sha3_256', 'sha3_384', 'sha3_512',
- 'shake_128', 'shake_256'}:
- import _sha3
- cache['sha3_224'] = _sha3.sha3_224
- cache['sha3_256'] = _sha3.sha3_256
- cache['sha3_384'] = _sha3.sha3_384
- cache['sha3_512'] = _sha3.sha3_512
- cache['shake_128'] = _sha3.shake_128
- cache['shake_256'] = _sha3.shake_256
+ elif name in ('SHA384', 'sha384'):
+ import _sha384
+ cache['SHA384'] = cache['sha384'] = _sha384.sha384
+ elif name in ('blake2b',):
+ import _blake2b
+ cache['blake2b'] = _blake2b.blake2b
+ elif name in ('blake2s',):
+ import _blake2s
+ cache['blake2s'] = _blake2s.blake2s
+ elif name in ('sha3_224',):
+ import _sha3_224
+ cache['sha3_224'] = _sha3_224.sha3_224
+ elif name in ('sha3_256',):
+ import _sha3_256
+ cache['sha3_256'] = _sha3_256.sha3_256
+ elif name in ('sha3_384',):
+ import _sha3_384
+ cache['sha3_384'] = _sha3_384.sha3_384
+ elif name in ('sha3_512',):
+ import _sha3_512
+ cache['sha3_512'] = _sha3_512.sha3_512
+ elif name in ('shake_128',):
+ import _shake_128
+ cache['shake_128'] = _shake_128.shake_128
+ elif name in ('shake_256',):
+ import _shake_256
+ cache['shake_256'] = _shake_256.shake_256
except ImportError:
pass # no extension module, this hash is unsupported.
@@ -169,7 +184,8 @@ except ImportError:
try:
# OpenSSL's PKCS5_PBKDF2_HMAC requires OpenSSL 1.0+ with HMAC and SHA
- from _hashlib import pbkdf2_hmac
+ from _hashlib import pbkdf2_hmac as _hmac
+ pbkdf2_hmac = _hmac
except ImportError:
_trans_5C = bytes((x ^ 0x5C) for x in range(256))
_trans_36 = bytes((x ^ 0x36) for x in range(256))
@@ -233,7 +249,8 @@ except ImportError:
try:
# OpenSSL's scrypt requires OpenSSL 1.1+
- from _hashlib import scrypt
+ from _hashlib import scrypt as _scrypt
+ scrypt = _scrypt
except ImportError:
pass