diff --git a/RNS/Cryptography/HKDF.py b/RNS/Cryptography/HKDF.py index dddcbdf..13b3186 100644 --- a/RNS/Cryptography/HKDF.py +++ b/RNS/Cryptography/HKDF.py @@ -6,7 +6,7 @@ def hkdf(length=None, derive_from=None, salt=None, context=None): hash_len = 32 def hmac_sha256(key, data): - return HMAC.new(key, data, hashlib.sha256).digest() + return HMAC.new(key, data).digest() if length == None or length < 1: raise ValueError("Invalid output key length") diff --git a/RNS/Cryptography/HMAC.py b/RNS/Cryptography/HMAC.py index a7c94fd..848a231 100644 --- a/RNS/Cryptography/HMAC.py +++ b/RNS/Cryptography/HMAC.py @@ -24,7 +24,7 @@ class HMAC: "_hmac", "_inner", "_outer", "block_size", "digest_size" ) - def __init__(self, key, msg=None, digestmod=''): + def __init__(self, key, msg=None, digestmod=_hashlib.sha256): """Create a new HMAC object. key: bytes or buffer, key for the keyed hash object. msg: bytes or buffer, Initial input for the hash or None. @@ -137,7 +137,7 @@ class HMAC: h = self._current() return h.hexdigest() -def new(key, msg=None, digestmod=''): +def new(key, msg=None, digestmod=_hashlib.sha256): """Create a new hashing object and return it. key: bytes or buffer, The starting key for the hash. msg: bytes or buffer, Initial input for the hash, or None.