Fix: add support for fips-enabled systems using Python3.6 or greater.

FIPS restricts usage of md5 and requires the flag 'usedforsecurity' to be set False in order to avoid error:

ValueError: [digital envelope routines: EVP_DigestInit_ex] disabled for FIPS

Change-Id: I99a4ad0bf78bbeb898fb9dcfc79c03a14d596235
This commit is contained in:
Drew Welch 2022-03-09 15:48:33 -06:00
parent 24f867fa73
commit c1504e053f
1 changed files with 8 additions and 1 deletions

View File

@ -17,6 +17,7 @@
import hashlib
import pkg_resources
import sys
from xml.dom import minidom
import xml.etree.ElementTree as XML
@ -53,7 +54,13 @@ class XmlJob(object):
self.name = name
def md5(self):
return hashlib.md5(self.output()).hexdigest()
if sys.version_info[:2] >= (3, 6):
# allows md5 use on fips-enabled systems
hash_func = hashlib.new("md5", usedforsecurity=False)
hash_func.update(self.output())
return hash_func.hexdigest()
else:
return hashlib.md5(self.output()).hexdigest()
def output(self):
out = minidom.parseString(XML.tostring(self.xml, encoding="UTF-8"))