summaryrefslogtreecommitdiffstats
path: root/Lib/uuid.py
diff options
context:
space:
mode:
authorChristian Heimes <christian@python.org>2019-09-13 00:30:00 (GMT)
committerGregory P. Smith <greg@krypto.org>2019-09-13 00:30:00 (GMT)
commit7cad53e6b084435a220e6604010f1fa5778bd0b1 (patch)
treea54b4906b9e9fc18bd5319fe87ad8a7fc071b3a7 /Lib/uuid.py
parent3a4f66707e824ef3a8384827590ebaa6ca463dc0 (diff)
downloadcpython-7cad53e6b084435a220e6604010f1fa5778bd0b1.zip
cpython-7cad53e6b084435a220e6604010f1fa5778bd0b1.tar.gz
cpython-7cad53e6b084435a220e6604010f1fa5778bd0b1.tar.bz2
bpo-9216: Add usedforsecurity to hashlib constructors (GH-16044)
The usedforsecurity keyword only argument added to the hash constructors is useful for FIPS builds and similar restrictive environment with non-technical requirements that legacy algorithms be forbidden by their implementations without being explicitly annotated as not being used for any security related purposes. Linux distros with FIPS support benefit from this being standard rather than making up their own way(s) to do it. Contributed and Signed-off-by: Christian Heimes christian@python.org
Diffstat (limited to 'Lib/uuid.py')
-rw-r--r--Lib/uuid.py7
1 files changed, 5 insertions, 2 deletions
diff --git a/Lib/uuid.py b/Lib/uuid.py
index 188e16b..5f3bc9e 100644
--- a/Lib/uuid.py
+++ b/Lib/uuid.py
@@ -772,8 +772,11 @@ def uuid1(node=None, clock_seq=None):
def uuid3(namespace, name):
"""Generate a UUID from the MD5 hash of a namespace UUID and a name."""
from hashlib import md5
- hash = md5(namespace.bytes + bytes(name, "utf-8")).digest()
- return UUID(bytes=hash[:16], version=3)
+ digest = md5(
+ namespace.bytes + bytes(name, "utf-8"),
+ usedforsecurity=False
+ ).digest()
+ return UUID(bytes=digest[:16], version=3)
def uuid4():
"""Generate a random UUID."""