RSA exponent

Larry Bugbee <[email protected]>
Newsgroups gmane.comp.python.cryptography
Message-ID <LISTSERV%[email protected]>
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
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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.