825eac
From 75e4a9eb929520d95cb55b2d850af7ba849fd014 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
825eac
index 31c5ee7..3354b5d 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
+            # 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()
825eac
+        except AttributeError:
825eac
+            h = md5(name.encode()).hexdigest()
11686f
         return '%s-%s' % (h, x)
11686f
 
11686f
 
11686f
diff --git a/suds/wsse.py b/suds/wsse.py
825eac
index 96d9eb6..474d15a 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
+                # FIPS requires usedforsecurity=False and might not be
11686f
+                # available on all distros: https://bugs.python.org/issue9216
11686f
+                m = md5(usedforsecurity=False)
825eac
+            except AttributeError:
825eac
+                m = md5()
11686f
             m.update(':'.join(s))
11686f
             self.nonce = m.hexdigest()
11686f
         else: