diff --git a/docs/internals/data-structures.rst b/docs/internals/data-structures.rst index fe35e4ad5..e33ce550d 100644 --- a/docs/internals/data-structures.rst +++ b/docs/internals/data-structures.rst @@ -933,7 +933,7 @@ in the configuration file. The internal data structure is as follows: version - currently always an integer, 1 + currently always an integer, 2 repository_id the ``id`` field in the ``config`` ``INI`` file of the repository. diff --git a/src/borg/crypto/key.py b/src/borg/crypto/key.py index 55307bb90..4e0e598c4 100644 --- a/src/borg/crypto/key.py +++ b/src/borg/crypto/key.py @@ -461,8 +461,8 @@ class FlexiKey: if data: data = msgpack.unpackb(data) key = Key(internal_dict=data) - if key.version != 1: - raise IntegrityError("Invalid key file header") + if key.version not in (1, 2): # legacy: item.Key can still process v1 keys + raise UnsupportedKeyFormatError() self.repository_id = key.repository_id self.crypt_key = key.crypt_key self.id_key = key.id_key @@ -575,7 +575,7 @@ class FlexiKey: def _save(self, passphrase, algorithm): key = Key( - version=1, + version=2, repository_id=self.repository_id, crypt_key=self.crypt_key, id_key=self.id_key, diff --git a/src/borg/item.pyx b/src/borg/item.pyx index 4027e626d..5d38e0fe6 100644 --- a/src/borg/item.pyx +++ b/src/borg/item.pyx @@ -459,7 +459,7 @@ class Key(PropDict): if k in ('repository_id', 'crypt_key', 'id_key'): v = fix_bytes_value(d, k) self._dict[k] = v - if 'crypt_key' not in self._dict: # legacy, we're loading an old key + if 'crypt_key' not in self._dict: # legacy, we're loading an old v1 key k = fix_bytes_value(d, 'enc_key') + fix_bytes_value(d, 'enc_hmac_key') assert isinstance(k, bytes), "k == %r" % k assert len(k) in (32 + 32, 32 + 128) # 256+256 or 256+1024 bits