Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Handle OpenSSL PEM RSA keys and x509 certificates in native Python.
Python
branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
Crypto moved number.py
keys
pyasn1
.gitignore
README
__init__.py
rsa_pem.py
sequence_parser.py
test.py
x509_pem.py

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/

Something went wrong with that request. Please try again.