(self, wrapper: dict[str, typing.Any])
| 78 | } |
| 79 | |
| 80 | def decrypt(self, wrapper: dict[str, typing.Any]) -> dict[str, typing.Any]: |
| 81 | try: |
| 82 | initialization_vector = base64.b64decode(wrapper[constants.BLOB_IV_KEY]) |
| 83 | ciphertext = base64.b64decode(wrapper[constants.BLOB_DATA_KEY]) |
| 84 | except (KeyError, binascii.Error, ValueError) as err: |
| 85 | raise sync_errors.OctobotSyncCryptoFormatError( |
| 86 | f"Invalid encrypted share envelope: {err}" |
| 87 | ) from err |
| 88 | try: |
| 89 | plaintext = AESGCM(self._key).decrypt(initialization_vector, ciphertext, None) |
| 90 | except InvalidTag as err: |
| 91 | raise sync_errors.OctobotSyncCryptoDecryptError( |
| 92 | "Failed to decrypt share payload" |
| 93 | ) from err |
| 94 | return json.loads(plaintext.decode("utf-8")) |
| 95 | |
| 96 | |
| 97 | def _collection_aes_key(wallet_private_key: str, collection: str) -> bytes: |
no outgoing calls
no test coverage detected