chg: [FIPS] in some cases, the `usedforsecurity` is not used. So fail if

the FIPS compliance is required and then the `usedforsecurity` is
disabled
pull/823/head
Alexandre Dulaunoy 2022-01-27 15:29:15 +01:00
parent 02bc129341
commit 6e018a4582
No known key found for this signature in database
GPG Key ID: 09E2CD4944E6CBCD
1 changed files with 4 additions and 1 deletions

View File

@ -353,7 +353,10 @@ class MISPAttribute(AbstractMISP):
if '|' in self.type or self.type == 'malware-sample':
hashes = []
for v in self.value.split('|'):
h = hashlib.new(algorithm, usedforsecurity=False)
try:
h = hashlib.new(algorithm)
except ValueError e:
h = hashlib.new(algorithm, usedforsecurity=False)
h.update(v.encode("utf-8"))
hashes.append(h.hexdigest())
return hashes