mirror of https://github.com/borgbackup/borg.git
increase Key.version to 2
Old borg (< 2.0) can not read/process the new keys that have crypt_key instead of enc_key and enc_hmac_key.
This commit is contained in:
parent
3ee69bc7ba
commit
d5df53732d
|
@ -933,7 +933,7 @@ in the configuration file.
|
||||||
The internal data structure is as follows:
|
The internal data structure is as follows:
|
||||||
|
|
||||||
version
|
version
|
||||||
currently always an integer, 1
|
currently always an integer, 2
|
||||||
|
|
||||||
repository_id
|
repository_id
|
||||||
the ``id`` field in the ``config`` ``INI`` file of the repository.
|
the ``id`` field in the ``config`` ``INI`` file of the repository.
|
||||||
|
|
|
@ -461,8 +461,8 @@ class FlexiKey:
|
||||||
if data:
|
if data:
|
||||||
data = msgpack.unpackb(data)
|
data = msgpack.unpackb(data)
|
||||||
key = Key(internal_dict=data)
|
key = Key(internal_dict=data)
|
||||||
if key.version != 1:
|
if key.version not in (1, 2): # legacy: item.Key can still process v1 keys
|
||||||
raise IntegrityError("Invalid key file header")
|
raise UnsupportedKeyFormatError()
|
||||||
self.repository_id = key.repository_id
|
self.repository_id = key.repository_id
|
||||||
self.crypt_key = key.crypt_key
|
self.crypt_key = key.crypt_key
|
||||||
self.id_key = key.id_key
|
self.id_key = key.id_key
|
||||||
|
@ -575,7 +575,7 @@ class FlexiKey:
|
||||||
|
|
||||||
def _save(self, passphrase, algorithm):
|
def _save(self, passphrase, algorithm):
|
||||||
key = Key(
|
key = Key(
|
||||||
version=1,
|
version=2,
|
||||||
repository_id=self.repository_id,
|
repository_id=self.repository_id,
|
||||||
crypt_key=self.crypt_key,
|
crypt_key=self.crypt_key,
|
||||||
id_key=self.id_key,
|
id_key=self.id_key,
|
||||||
|
|
|
@ -459,7 +459,7 @@ class Key(PropDict):
|
||||||
if k in ('repository_id', 'crypt_key', 'id_key'):
|
if k in ('repository_id', 'crypt_key', 'id_key'):
|
||||||
v = fix_bytes_value(d, k)
|
v = fix_bytes_value(d, k)
|
||||||
self._dict[k] = v
|
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')
|
k = fix_bytes_value(d, 'enc_key') + fix_bytes_value(d, 'enc_hmac_key')
|
||||||
assert isinstance(k, bytes), "k == %r" % k
|
assert isinstance(k, bytes), "k == %r" % k
|
||||||
assert len(k) in (32 + 32, 32 + 128) # 256+256 or 256+1024 bits
|
assert len(k) in (32 + 32, 32 + 128) # 256+256 or 256+1024 bits
|
||||||
|
|
Loading…
Reference in New Issue