1
0
Fork 0
mirror of https://github.com/borgbackup/borg.git synced 2025-03-04 02:28:34 +00:00

give a more helpful error msg for unsupported encrypted key format, fixes #6561

This commit is contained in:
Thomas Waldmann 2022-04-24 21:55:41 +02:00
parent 55f9028611
commit 05d7ee9ed8

View file

@ -629,8 +629,10 @@ class KeyfileKeyBase(AESKeyBase):
unpacker.feed(data)
data = unpacker.unpack()
enc_key = EncryptedKey(internal_dict=data)
assert enc_key.version == 1
assert enc_key.algorithm == 'sha256'
if enc_key.version != 1:
raise Error("encrypted key version %d is not supported by this borg version." % enc_key.version)
if enc_key.algorithm != 'sha256':
raise Error("encrypted key algorithm '%s' is not supported by this borg version." % enc_key.algorithm)
key = passphrase.kdf(enc_key.salt, enc_key.iterations, 32)
data = AES(key, b'\0'*16).decrypt(enc_key.data)
if hmac.compare_digest(hmac_sha256(key, data), enc_key.hash):