11686f
From 56caa0af4f21d696df50be5fc15b74c74239d130 Mon Sep 17 00:00:00 2001
11686f
From: Oyvind Albrigtsen <oalbrigt@redhat.com>
11686f
Date: Mon, 28 Feb 2022 11:23:55 +0100
11686f
Subject: [PATCH] Use usedforsecurity=False for md5() calls to make suds work
11686f
 on FIPS enabled systems
11686f
11686f
---
11686f
 suds/reader.py | 7 ++++++-
11686f
 suds/wsse.py   | 7 ++++++-
11686f
 2 files changed, 12 insertions(+), 2 deletions(-)
11686f
11686f
diff --git a/suds/reader.py b/suds/reader.py
11686f
index 31c5ee7..d31b147 100644
11686f
--- a/suds/reader.py
11686f
+++ b/suds/reader.py
11686f
@@ -58,7 +58,12 @@ def mangle(self, name, x):
11686f
         @rtype: str
11686f
 
11686f
         """
11686f
-        h = md5(name.encode()).hexdigest()
11686f
+        try:
11686f
+            h = md5(name.encode()).hexdigest()
11686f
+        except ValueError:
11686f
+            # FIPS requires usedforsecurity=False and might not be
11686f
+            # available on all distros: https://bugs.python.org/issue9216
11686f
+            h = md5(name.encode(), usedforsecurity=False).hexdigest()
11686f
         return '%s-%s' % (h, x)
11686f
 
11686f
 
11686f
diff --git a/suds/wsse.py b/suds/wsse.py
11686f
index 96d9eb6..a871657 100644
11686f
--- a/suds/wsse.py
11686f
+++ b/suds/wsse.py
11686f
@@ -158,7 +158,12 @@ def setnonce(self, text=None):
11686f
             s.append(self.username)
11686f
             s.append(self.password)
11686f
             s.append(Token.sysdate())
11686f
-            m = md5()
11686f
+            try:
11686f
+                m = md5()
11686f
+            except ValueError:
11686f
+                # FIPS requires usedforsecurity=False and might not be
11686f
+                # available on all distros: https://bugs.python.org/issue9216
11686f
+                m = md5(usedforsecurity=False)
11686f
             m.update(':'.join(s))
11686f
             self.nonce = m.hexdigest()
11686f
         else: