(ct, key, alg, iv=None)
| 36 | |
| 37 | |
| 38 | def _decrypt(ct, key, alg, iv=None): |
| 39 | if iv is None: |
| 40 | """ |
| 41 | Instead of using an IV, OpenPGP prefixes a string of length |
| 42 | equal to the block size of the cipher plus two to the data before it |
| 43 | is encrypted. The first block-size octets (for example, 8 octets for |
| 44 | a 64-bit block length) are random, and the following two octets are |
| 45 | copies of the last two octets of the IV. |
| 46 | """ |
| 47 | iv = b'\x00' * (alg.block_size // 8) |
| 48 | |
| 49 | try: |
| 50 | decryptor = Cipher(alg.cipher(key), modes.CFB(iv), default_backend()).decryptor() |
| 51 | |
| 52 | except UnsupportedAlgorithm as ex: # pragma: no cover |
| 53 | raise PGPDecryptionError from ex |
| 54 | |
| 55 | else: |
| 56 | return bytearray(decryptor.update(ct) + decryptor.finalize()) |
no test coverage detected
searching dependent graphs…