python-suds/SOURCES/bz1921920-fix-fips-issue.patch

48 lines
1.6 KiB
Diff
Raw Normal View History

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