DSA:

#!/usr/bin/env python
# -*- coding=utf-8 -*-
#author: xjump.me#at#gmail.com
#file: gendsa.py

from M2Crypto import DSA, BIO
dsa = DSA.gen_params(1024)
mem = BIO.MemoryBuffer()
dsa.gen_key()
dsa.save_key_bio(mem, cipher=None)
dsa.save_pub_key_bio(mem)
print mem.getvalue()

RSA:

#!/usr/bin/env python
# -*- coding=utf-8 -*-
#author: xjump.me#at#gmail.com
#file: genrsa.py

from M2Crypto import RSA, BIO

mem = BIO.MemoryBuffer()
rsa = RSA.gen_key(1024,3,lambda *arg:None)
rsa.save_pub_key_bio(mem)
rsa.save_key_bio(mem, None)
print mem.read_all()

M2Crypto win32的egg包(OpenSSL已静态链接):M2Crypto-0_22_dev-py2_7-win32.zip

Python27 win32的安装包:python-2.7.3.msi

Python27 setuptools:setuptools-0.6c11.win32-py2.7.exe