Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Pycrypto RSA Issue

1 view
Skip to first unread message

Jordan Apgar

unread,
Feb 9, 2010, 1:09:53 PM2/9/10
to
I am trying to encrypt public data along with another tuple and then
decrypt it after sending. RSA is needed for negotiation of keys for
AES. But I just get garbage after I decrypt it. This is what I'm
attempting to do:

from Crypto.PublicKey import RSA
from Crypto import Random

gkey = RSA.generate(384, Random.new().read)
string = str((gkey.publickey().__getstate__(),
(333,444)))
print string
print
data = gkey.encrypt(string,"")
print "data:",data
print
print "decrypt"
print "decrypt,", gkey.decrypt(data)
print "done"

All I get are junk values when printing the decrypted value.

Legrandin

unread,
Feb 9, 2010, 1:27:36 PM2/9/10
to

> gkey = RSA.generate(384, Random.new().read)
> string = str((gkey.publickey().__getstate__(),(333,444)))

You are encrypting with RSA a piece of data which is way
larger than the key size (48 bytes).

Jordan Apgar

unread,
Feb 9, 2010, 2:14:27 PM2/9/10
to
On Feb 9, 1:27 pm, Legrandin <pheenso...@farifluset.mailexpire.com>
wrote:

ah thanks Legrandin

0 new messages