(self, id, data)
| 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) |
nothing calls this directly
no test coverage detected