Handle OpenSSL PEM RSA keys and x509 certificates in native Python.
Python
Latest commit d670d72 May 31, 2011 Andrew D. Yates added convenience key function wrappers f_public and f_private; updat…
…ed unittests

README

rsa_x509_pem
Handle OpenSSL PEM RSA keys and x509 certificates in native Python.

© 2011 Andrew D. Yates
andrewyates.name@gmail.com

https://andrewdyates@github.com/andrewdyates/rsa_x509_pem.git
https://github.com/andrewdyates

See test.py for unit tests and additional sample usage.

========

SAMPLE USE:

# Read "private_rsa_key.pem", make private RSA key, sign something, verify
>>> data = open("private_rsa_key.pem").read()
... key_dict = parse(data)
... key = get_key(key_dict)
... signature = key.sign("Hello.", None)
... assert key.verify("Hello.", signature)

# Read "rsa_cert.pem", make public RSA key, verify some signature, print
>>> data = open("rsa_cert.pem").read()
... cert_dict = parse(data)
... key = get_key(cert_dict)
... assert key.verify("Hello.", my_signature)
... print cert_dict["subject"]
... print cert_dict["body"]

# Return "nice" public and private key functions from a key object
>>> f_my_public = f_public(key)
... f_my_private = f_private(key)
... msg = "hello"
... assert msg == f_my_public(f_my_public(msg))
... assert msg == f_my_private(f_my_public(msg))


RUN UNIT TESTS:

$ python test.py

========

Sources:

RSA implementation: PyCrypto
http://www.dlitz.net/software/pycrypto/

PEM implementation: PyASN1
http://pyasn1.sourceforge.net/