python-pgp icon indicating copy to clipboard operation
python-pgp copied to clipboard

ValueError: MODE_OPENPGP requires an IV

Open pts opened this issue 6 years ago • 0 comments

When trying to decrypt a symmetric key encrypted PGP message, I'm getting the error ValueError: MODE_OPENPGP requires an IV. Am I using it correctly?

$ unzip example.bin.gpg.zip
$ python3 -c 'import pgp; m = pgp.read_message(
      open("example.bin.gpg", "rb").read()); g = m.get_message("abc");
      print([g]); print([g.data])'
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/tmp/python-pgp/pgp/message.py", line 613, in get_message
    return self.message_data_obj.decrypt(sym_algo, sess_key)
  File "/tmp/tinygpgs/python-pgp/pgp/message.py", line 487, in decrypt
    encrypted_iv)
  File "/tmp/python-pgp/pgp/utils.py", line 294, in get_symmetric_cipher
    segment_size=segment_size)
  File "/usr/lib/python3/dist-packages/Crypto/Cipher/CAST.py", line 103, in new
    return CAST128Cipher(key, *args, **kwargs)
  File "/usr/lib/python3/dist-packages/Crypto/Cipher/CAST.py", line 68, in __init__
    blockalgo.BlockAlgo.__init__(self, _CAST, key, *args, **kwargs)
  File "/usr/lib/python3/dist-packages/Crypto/Cipher/blockalgo.py", line 155, in __init__
    raise ValueError("MODE_OPENPGP requires an IV")
ValueError: MODE_OPENPGP requires an IV

I'm using Python 3.5.3 and PyCrypto 2.6.1 on Debian 9: sudo apt-get install python3-crypto. I'm using python-pgp at commit 62a3da543680b9713be7eb9727556d37d6c3fae5.

The example file is example.bin.gpg.zip, the passphrase is abc.

pts avatar Dec 02 '19 10:12 pts