Explorar o código

use hmac.compare_digest instead of ==, fixes 6470

Thomas Waldmann %!s(int64=3) %!d(string=hai) anos
pai
achega
f8cb7147a7
Modificáronse 1 ficheiros con 1 adicións e 1 borrados
  1. 1 1
      src/borg/crypto/key.py

+ 1 - 1
src/borg/crypto/key.py

@@ -641,7 +641,7 @@ class KeyfileKeyBase(AESKeyBase):
         assert enc_key.algorithm == 'sha256'
         assert enc_key.algorithm == 'sha256'
         key = passphrase.kdf(enc_key.salt, enc_key.iterations, 32)
         key = passphrase.kdf(enc_key.salt, enc_key.iterations, 32)
         data = AES(is_encrypt=False, key=key).decrypt(enc_key.data)
         data = AES(is_encrypt=False, key=key).decrypt(enc_key.data)
-        if hmac_sha256(key, data) == enc_key.hash:
+        if compare_digest(hmac_sha256(key, data), enc_key.hash):
             return data
             return data
 
 
     def encrypt_key_file(self, data, passphrase):
     def encrypt_key_file(self, data, passphrase):