From 6e018a45822a909e9a4876da76fbdcaf91f999bd Mon Sep 17 00:00:00 2001 From: Alexandre Dulaunoy Date: Thu, 27 Jan 2022 15:29:15 +0100 Subject: [PATCH] chg: [FIPS] in some cases, the `usedforsecurity` is not used. So fail if the FIPS compliance is required and then the `usedforsecurity` is disabled --- pymisp/mispevent.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pymisp/mispevent.py b/pymisp/mispevent.py index c5dcf19..dbc4de5 100644 --- a/pymisp/mispevent.py +++ b/pymisp/mispevent.py @@ -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