SecurityInnovation / PGPy

Pretty Good Privacy for Python
BSD 3-Clause "New" or "Revised" License
317 stars 98 forks source link

Encrypt a signed message #318

Open lenekaethe opened 4 years ago

lenekaethe commented 4 years ago

How do I encrypt a signed message? Having a private key sec and a public key pub I tried to encrypt the signed message mes with:

mes |= sec.sign(mes)
enc_mes = pub.encrypt(mes)

Decrypting enc_mes sets enc_mes.is_signed to False. However, importing enc_mes into Kleopatra, it says that there would be a valid signature. Why does pgpy not find that valid signature? How do I keep is_signed true during encryption so that I can verify the decrypted message using pgpy?

Commod0re commented 3 years ago

can you show what you're doing when you decrypt the message?

this basic procedure should work:

mes |= sec.sign(mes)
enc_mes = pub.encrypt(mes)
...

dec_mes = sec.decrypt(enc_mes)
# at this point, dec_mes.is_signed should be True

if dec_mes.is_signed is False at that point, then, you may have found a bug and I'd love to see a full example of how to reproduce it so we can fix it