Python Crytographic Toolkit, AES and OpenPGP

Discussion in 'Python' started by ml1n, Oct 24, 2006.

  1. ml1n

    ml1n Guest

    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.
    ml1n, Oct 24, 2006
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    2
    Views:
    4,909
  2. Nate Wiger

    New AES gem available -- fast-aes

    Nate Wiger, Jan 20, 2010, in forum: Ruby
    Replies:
    3
    Views:
    194
    Pål Bergström
    Jul 1, 2010
  3. Bing Du Test

    Crypt::OpenPGP memory use

    Bing Du Test, Jul 7, 2003, in forum: Perl Misc
    Replies:
    0
    Views:
    102
    Bing Du Test
    Jul 7, 2003
  4. BG

    make (OpenPGP)

    BG, Jan 6, 2004, in forum: Perl Misc
    Replies:
    1
    Views:
    95
    Sisyphus
    Jan 9, 2004
  5. Gilian

    Crypt::OpenPGP problem

    Gilian, Jun 16, 2004, in forum: Perl Misc
    Replies:
    1
    Views:
    162
    Sisyphus
    Jun 16, 2004
Loading...

Share This Page