Re: RSA exponent
Dan Berger <[email protected]>
| Newsgroups | gmane.comp.python.cryptography |
|---|---|
| Message-ID | <[email protected]> |
It's likely because OpenSSL (and the M2 wrapper) are returning an MPI - which has it's length as the first four bytes and remainder being the number in big-endian byte order. On Tue, 2004-08-03 at 21:39 +0200, Larry Bugbee wrote: > 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 -- ...Dan Berger [[email protected]] Department of Computer Science Surge Building, Room 357 University of California, Riverside http://www.cs.ucr.edu/~dberger "Man had always assumed that he was more intelligent than dolphins because he had achieved so much... the wheel, New York, wars, and so on, whilst all the dolphins had ever done was muck about in the water having a good time. But conversely the dolphins believed themselves to be more intelligent than man for precisely the same reasons." - Douglas Adams, The Hitchhiker's Guide to the Galaxy
signature.asc
(application/pgp-signature, 189 B)
-----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.3 (GNU/Linux) iD8DBQBBEBTVhHyVxVGhKFYRAuwuAJ448CPk4FTBk87iTx7Hgf5yZVFkmwCgpXMX rUqj9CqgbuEeAX5l7+WpchA= =Poz5 -----END PGP SIGNATURE-----