]> git.ipfire.org Git - thirdparty/starlette.git/commitdiff
Fix md5_hexdigest wrapper on FIPS enabled systems (#1410)
authorAdrian Garcia Badaracco <1755071+adriangb@users.noreply.github.com>
Fri, 14 Jan 2022 09:40:18 +0000 (01:40 -0800)
committerGitHub <noreply@github.com>
Fri, 14 Jan 2022 09:40:18 +0000 (10:40 +0100)
* Fix md5_hexdigest wrapper on FIPS enabled systems

* Update _compat.py

* lint

starlette/_compat.py

index 82aa72f38b5ebea8bc3127197ddfc00767ef8c04..116561917f3abebb2aa1911c8297d1ddd0e4969f 100644 (file)
@@ -11,7 +11,10 @@ import hashlib
 # See issue: https://github.com/encode/starlette/issues/1365
 try:
 
-    hashlib.md5(b"data", usedforsecurity=True)  # type: ignore[call-arg]
+    # check if the Python version supports the parameter
+    # using usedforsecurity=False to avoid an exception on FIPS systems
+    # that reject usedforsecurity=True
+    hashlib.md5(b"data", usedforsecurity=False)  # type: ignore[call-arg]
 
     def md5_hexdigest(
         data: bytes, *, usedforsecurity: bool = True