Skip to content

Commit

Permalink
Merge pull request #257 from evgenyz/fix-hashes-fips
Browse files Browse the repository at this point in the history
Do not rely on hashlib.algorithms_available
  • Loading branch information
Mab879 authored Nov 6, 2024
2 parents 5f71100 + 7fdd6b2 commit eced57b
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion org_fedora_oscap/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,16 @@ def get_hashing_algorithm(fingerprint):

expected_hash_ids = {'md5', 'sha1', 'sha224', 'sha256', 'sha384', 'sha512'}
available_hash_ids = expected_hash_ids.intersection(hashlib.algorithms_available)
hashes = (hashlib.new(hash_id) for hash_id in available_hash_ids)

hashes = []
for hash_id in available_hash_ids:
try:
hash_obj = hashlib.new(hash_id)
hashes.append(hash_obj)
except ValueError as e:
# We have an unavailable algorithm, that is a part of hashlib.algorithms_available,
# for example see https://github.com/python/cpython/issues/91257.
pass

if len(fingerprint) % 2 == 1:
return None
Expand Down

0 comments on commit eced57b

Please sign in to comment.