Skip to content

Commit

Permalink
fix: include all hashlib.new inputs (#379)
Browse files Browse the repository at this point in the history
* fix: include all hashlib.new inputs

* Update web_handlers.py
  • Loading branch information
asmfstatoil authored Oct 3, 2024
1 parent eb644c6 commit de319cf
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions tagreader/web_handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,16 @@ def hexdigest(self):
return self._hash_obj.hexdigest()


def patched_hashlib_new(name, data=b""):
def patched_hashlib_new(name, data=b"", usedforsecurity=True):
if name.lower() == "md4":
return MD4(data)
else:
return hashlib_new_method(name, data)
# Try / Catch easier than detecting python version
try:
return hashlib_new_method(name, data=data, usedforsecurity=usedforsecurity)
except TypeError:
# Required for python 3.8
return hashlib_new_method(name, data=data)


# Monkey-patch md4 in hashlib.new due to missing support for md4 in later releases of Python:
Expand Down

0 comments on commit de319cf

Please sign in to comment.