Python Crytographic Toolkit, AES and OpenPGP

M

ml1n

Hello,
Does anybody have an example of using Crypto.Cipher.AES to encrypt an
OpenPGP literal data packet? I can't get MODE_PGP to work at all (gpg
doesn't recognise the unencrypted packet), with MODE_CFB gpg correctly
identifies the packet after decryption but it's body is incorrect
(suggesting the first 2 bytes decrypt/encrypt ok but the rest
doesn't?). I know the plain text version of the packet is ok because I
can add it to the stream without encryption and gpg will process it ok.

Here is what I'm trying (text is the pre constructed packet):

aes_obj =
Crypto.Cipher.AES.new(self.sessionKey,Crypto.Cipher.AES.MODE_CFB,"\x00"*16)
padding = self.randPool.get_bytes(Crypto.Cipher.AES.block_size)
padding = "%s%s" % (padding,padding[-2:])
self.enc_text = aes_obj.encrypt("%s%s" % (padding,text))

I'm sure I'm missing something obvious, Any pointers gratefully
recieved.

Thanks.
M.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top