Explorar o código

Merge pull request #6494 from ThomasWaldmann/use-compare_digest-1.1

use hmac.compare_digest instead of ==, fixes 6470
TW %!s(int64=3) %!d(string=hai) anos
pai
achega
aeeaf742d4
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'
         key = passphrase.kdf(enc_key.salt, enc_key.iterations, 32)
         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
 
     def encrypt_key_file(self, data, passphrase):