MCPcopy
hub / github.com/borgbackup/borg / decrypt

Method decrypt

src/borg/crypto/key.py:878–888  ·  view source on GitHub ↗
(self, id, data)

Source from the content-addressed store, hash-verified

876 return self.cipher.encrypt(data, header=header, iv=iv, aad=id)
877
878 def decrypt(self, id, data):
879 # to decrypt existing data, we need to get a cipher configured for the sessionid and iv from header
880 self.assert_type(data[0], id)
881 iv_48bit = data[2:8]
882 sessionid = bytes(data[8:32])
883 iv = int.from_bytes(iv_48bit, "big")
884 cipher = self._get_cipher(sessionid, iv)
885 try:
886 return cipher.decrypt(data, aad=id)
887 except IntegrityError as e:
888 raise IntegrityError(f"Chunk {bin_to_hex(id)}: Could not decrypt [{str(e)}]")
889
890 def init_from_given_data(self, *, crypt_key, id_key, chunk_seed):
891 assert len(crypt_key) in (32 + 32, 32 + 128)

Callers

nothing calls this directly

Calls 5

_get_cipherMethod · 0.95
IntegrityErrorClass · 0.85
bin_to_hexFunction · 0.85
assert_typeMethod · 0.80
decryptMethod · 0.45

Tested by

no test coverage detected