diff --git a/src/borg/crypto/key.py b/src/borg/crypto/key.py index 3a08120c6c8..8d6d6cdf4d6 100644 --- a/src/borg/crypto/key.py +++ b/src/borg/crypto/key.py @@ -432,19 +432,19 @@ def decrypt_key_file(self, data, passphrase): unpacker = get_limited_unpacker('key') unpacker.feed(data) data = unpacker.unpack() - enc_key = EncryptedKey(internal_dict=data) - if enc_key.version == 1: - return self.decrypt_key_file_v1(enc_key, passphrase) - elif enc_key.version == 2: - return self.decrypt_key_file_v2(enc_key, passphrase) + encrypted_key = EncryptedKey(internal_dict=data) + if encrypted_key.version == 1: + return self.decrypt_key_file_v1(encrypted_key, passphrase) + elif encrypted_key.version == 2: + return self.decrypt_key_file_v2(encrypted_key, passphrase) else: raise Exception('Your borg key is stored in an unsupported format. Try using a newer version of borg') - def decrypt_key_file_v1(self, enc_key, passphrase): - assert enc_key.algorithm == 'sha256' - key = passphrase.kdf(enc_key.salt, enc_key.iterations, 32) - data = AES(key, b'\0'*16).decrypt(enc_key.data) - if hmac_sha256(key, data) == enc_key.hash: + def decrypt_key_file_v1(self, encrypted_key, passphrase): + assert encrypted_key.algorithm == 'sha256' + key = passphrase.kdf(encrypted_key.salt, encrypted_key.iterations, 32) + data = AES(key, b'\0'*16).decrypt(encrypted_key.data) + if hmac_sha256(key, data) == encrypted_key.hash: return data return None