summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2020-07-28 19:29:46 (GMT)
committerGitHub <noreply@github.com>2020-07-28 19:29:46 (GMT)
commitaa16ac74330f277559441fdd3d4c5c46bd39d0bb (patch)
tree7f855d5ce7e79656501f3b612171ae2d1f61000d /Lib
parent67020a3e133e07e1934274a1fad45b5ce9481e64 (diff)
downloadcpython-aa16ac74330f277559441fdd3d4c5c46bd39d0bb.zip
cpython-aa16ac74330f277559441fdd3d4c5c46bd39d0bb.tar.gz
cpython-aa16ac74330f277559441fdd3d4c5c46bd39d0bb.tar.bz2
[3.9] Improve blake2 comment for Victor (GH-20981) (GH-20982)
Signed-off-by: Christian Heimes <christian@python.org> (cherry picked from commit 8a0fe7b4544ba28eeea6e16ddb646bb0b5d2918e) Co-authored-by: Christian Heimes <christian@python.org>
Diffstat (limited to 'Lib')
-rw-r--r--Lib/hashlib.py12
1 files changed, 7 insertions, 5 deletions
diff --git a/Lib/hashlib.py b/Lib/hashlib.py
index 1b6e502..58c340d 100644
--- a/Lib/hashlib.py
+++ b/Lib/hashlib.py
@@ -70,6 +70,11 @@ __all__ = __always_supported + ('new', 'algorithms_guaranteed',
__builtin_constructor_cache = {}
+# Prefer our blake2 implementation
+# OpenSSL 1.1.0 comes with a limited implementation of blake2b/s. The OpenSSL
+# implementations neither support keyed blake2 (blake2 MAC) nor advanced
+# features like salt, personalization, or tree hashing. OpenSSL hash-only
+# variants are available as 'blake2b512' and 'blake2s256', though.
__block_openssl_constructor = {
'blake2b', 'blake2s',
}
@@ -120,7 +125,7 @@ def __get_builtin_constructor(name):
def __get_openssl_constructor(name):
if name in __block_openssl_constructor:
- # Prefer our blake2 and sha3 implementation.
+ # Prefer our builtin blake2 implementation.
return __get_builtin_constructor(name)
try:
# MD5, SHA1, and SHA2 are in all supported OpenSSL versions
@@ -149,10 +154,7 @@ def __hash_new(name, data=b'', **kwargs):
optionally initialized with data (which must be a bytes-like object).
"""
if name in __block_openssl_constructor:
- # Prefer our blake2 and sha3 implementation
- # OpenSSL 1.1.0 comes with a limited implementation of blake2b/s.
- # It does neither support keyed blake2 nor advanced features like
- # salt, personal, tree hashing or SSE.
+ # Prefer our builtin blake2 implementation.
return __get_builtin_constructor(name)(data, **kwargs)
try:
return _hashlib.new(name, data, **kwargs)