M2Crypto question

Ng Pheng Siong ngps at madcap.dyndns.org
Fri Nov 17 08:57:23 EST 2000


According to  <krjackson at lbl.gov>:
> Does anyone know if it's possible to generate a new RSA key pair
> programatically?  I see a gen_key function in DSA.py to generate a DSA
> key pair, but I can't seem to locate similar functionality for RSA keys.

/usr/local/home/ngps:$ python1
Python 1.5.2 (#2, Mar 12 2000, 12:38:38)  [GCC 2.95.2 19991024 (release)] on freebsd4
Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam
>>> import os
>>> os.system('openssl genrsa > xxx.pem')
warning, not much extra random data, consider using the -rand option
Generating RSA private key, 512 bit long modulus
..............................++++++++++++
.................................++++++++++++
e is 65537 (0x10001)
0
>>> print open('xxx.pem').read()
-----BEGIN RSA PRIVATE KEY-----
MIIBOwIBAAJBAJobLsVZRgV6R4+HEYSKYxXb3lKc/wwAYSTf8FjrI4OuQNF41vQi
iRzcLAilLYe0Ayhk2/HTNU3c/hRNdmglxwcCAwEAAQJASPtImiOeOqffTgS8chWL
uWVoE53QV6GyX+FCFQo+xnQ6kr/Ta4JaC984fMQEcgb9ggDfI2EYGyTdaZoP9D/C
yQIhAMaf6G8YW3p06c6iz35/gLaRmOhDCdyXbeVfMmrx98ibAiEAxp8t/I39kK3b
xzsWmHCWFWzNR1emgIZa911CGHM0VAUCIQCUMLo6KPIXayMGCHLG7loZ3Ic4wsuY
yWI0v9Hd+KnmAQIhAMXT597DogmHUP7X+IJuqN3AF5n2UC11JId6iImHvVftAiAM
a6wz3azZ38Uf2xz1qChFSmrTYqNhh3arozocZIHD1g==
-----END RSA PRIVATE KEY-----

;-)

IIRC, M2Crypto's first release had rsa_genkey(). I took it out
while I was trying to get rid of the global PyObject pointers
used to hold callbacks.

I'll probably put rsa_genkey() back in the next release. For now,
os.system() is it.

Cheers.

-- 
Ng Pheng Siong <ngps at post1.com> * http://www.post1.com/home/ngps




More information about the Python-list mailing list