Skip to content

Commit

Permalink
Fix hashlib.md5 error with FIPS-compliant OpenSSL builds (#221)
Browse files Browse the repository at this point in the history
  • Loading branch information
nightlark committed Jul 30, 2024
1 parent a8d032a commit 6d6fbe9
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion surfactant/fileinfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
# SPDX-License-Identifier: MIT
import os
import stat
import sys
from hashlib import md5, sha1, sha256


Expand Down Expand Up @@ -54,7 +55,12 @@ def calc_file_hashes(filename):
"""
sha256_hash = sha256()
sha1_hash = sha1()
md5_hash = md5()
# hashlib.md5 usedforsecurity flag was added in Python 3.9
if sys.version_info >= (3, 9):
# avoid error with FIPS-compliant OpenSSL library builds complaining about md5
md5_hash = md5(usedforsecurity=False)
else:
md5_hash = md5()
b = bytearray(4096)
mv = memoryview(b)
try:
Expand Down

0 comments on commit 6d6fbe9

Please sign in to comment.