[PYTHON-CRYPTO] RSA exponent

Larry Bugbee bugbee at SEANET.COM
Tue Aug 3 21:39:18 CEST 2004


I could use some help...

When I generate a RSA key pair I use 65537 as the exponent.  Later when I go
to extract the exponent I get 50397185.  In hex it's actually 00 00 00 03 01
00 01, but if I discard the 4 high order bytes, 01 00 01 evaluates to 65537.
 Perhaps you have a suggestion?

Here is a minimalist version of my code.

from M2Crypto import RSA
X-Mozilla-Status: 8000
X-Mozilla-Status2: 00000000
key = RSA.gen_key(1024, 65537)
print type(key.e)
print len(key.e)
for c in key.e:
    print ord(c),
print
e = 0
for c in key.e:
# e = (e << 8) + ord(c)
 e = (e*256) + ord(c)
print e

I get the same results on both MacOSX and Win2000.
 - OSX 10.3.4, python 2.3, openssl 0.9.7b, M2Crypto 0.13 (with DSA patches)
 - Win2000, python 2.3.4, openssl 0.9.7b, M2Crypto 0.13 (no patches)

OpenSSL is not the latest version, but I should be OK.

Thanks,

Larry




More information about the python-crypto mailing list