Skip to content

Commit 3292133

Browse files
authored
added safe hmac comparison (#170)
1 parent 81839c0 commit 3292133

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

Adyen/util.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ def is_valid_hmac(dict_object, hmac_key):
4545
del dict_object['additionalData']
4646
merchant_sign = generate_hpp_sig(dict_object, hmac_key)
4747
merchant_sign_str = merchant_sign.decode("utf-8")
48-
return merchant_sign_str == expected_sign
48+
return hmac.compare_digest(merchant_sign_str, expected_sign)
4949

5050

5151
def generate_notification_sig(dict_object, hmac_key):
@@ -97,4 +97,4 @@ def is_valid_hmac_notification(dict_object, hmac_key):
9797
del dict_object['additionalData']
9898
merchant_sign = generate_notification_sig(dict_object, hmac_key)
9999
merchant_sign_str = merchant_sign.decode("utf-8")
100-
return merchant_sign_str == expected_sign
100+
return hmac.compare_digest(merchant_sign_str, expected_sign)

0 commit comments

Comments
 (0)