1
0
Fork 0
mirror of https://github.com/borgbackup/borg.git synced 2024-12-26 01:37:20 +00:00

key: compress(chunk) return data

This commit is contained in:
Marian Beermann 2017-03-31 12:17:58 +02:00
parent a27f585eaa
commit 5a20fc08de

View file

@ -152,8 +152,7 @@ def id_hash(self, data):
def compress(self, chunk):
meta, data = chunk
data = meta.get('compress', self.compressor).compress(data)
return Chunk(data, **meta)
return meta.get('compress', self.compressor).compress(data)
def encrypt(self, chunk):
pass
@ -255,8 +254,8 @@ def id_hash(self, data):
return sha256(data).digest()
def encrypt(self, chunk):
chunk = self.compress(chunk)
return b''.join([self.TYPE_STR, chunk.data])
data = self.compress(chunk)
return b''.join([self.TYPE_STR, data])
def decrypt(self, id, data, decompress=True):
if data[0] != self.TYPE:
@ -333,10 +332,10 @@ class AESKeyBase(KeyBase):
MAC = hmac_sha256
def encrypt(self, chunk):
chunk = self.compress(chunk)
self.nonce_manager.ensure_reservation(num_aes_blocks(len(chunk.data)))
data = self.compress(chunk)
self.nonce_manager.ensure_reservation(num_aes_blocks(len(data)))
self.enc_cipher.reset()
data = b''.join((self.enc_cipher.iv[8:], self.enc_cipher.encrypt(chunk.data)))
data = b''.join((self.enc_cipher.iv[8:], self.enc_cipher.encrypt(data)))
assert (self.MAC is blake2b_256 and len(self.enc_hmac_key) == 128 or
self.MAC is hmac_sha256 and len(self.enc_hmac_key) == 32)
hmac = self.MAC(self.enc_hmac_key, data)
@ -745,8 +744,8 @@ class AuthenticatedKey(ID_BLAKE2b_256, RepoKey):
STORAGE = KeyBlobStorage.REPO
def encrypt(self, chunk):
chunk = self.compress(chunk)
return b''.join([self.TYPE_STR, chunk.data])
data = self.compress(chunk)
return b''.join([self.TYPE_STR, data])
def decrypt(self, id, data, decompress=True):
if data[0] != self.TYPE: