MCPcopy Create free account
hub / github.com/SecurityInnovation/PGPy / _decrypt

Function _decrypt

pgpy/symenc.py:38–56  ·  view source on GitHub ↗
(ct, key, alg, iv=None)

Source from the content-addressed store, hash-verified

36
37
38def _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())

Callers 4

decrypt_keyblobMethod · 0.85
decrypt_skMethod · 0.85
decryptMethod · 0.85
decryptMethod · 0.85

Calls 2

cipherMethod · 0.80
updateMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…