django-signature 0.3.1

Django application to generate and sign Models
Application to generate x509 certificates and sign models with PKCS#7 standard


There is an simple PKI example:

from signature.models import Key, Certificate, CertificateRequest
from datetime import datetime

ca_pwd = "R00tz"
c_pwd = "1234"

# CA and Client keys
ca_key = Key.generate(ca_pwd)
c_key = Key.generate(c_pwd)

# CA Cert
ca_cert = Certificate()
ca_cert.CN = "Admin"
ca_cert.C = "FR"
ca_cert.key = ca_key
ca_cert.days = 150
ca_cert.is_ca = True

# Client's request
rqst = CertificateRequest()
rqst.CN = "World Company"
rqst.C = "FR"
rqst.key = c_key

# Sign client's request and return certificate
# (you can give to Client's certificate CA capabilities with ca=True)
c_cert = ca_cert.sign_request(rqst, 150, ca_pwd, ca=False)

# Verify created certificate :

# Revoke certificate :
c_cert.revoke(c_cert, ca_pwd)

# Import a Key / Certificate:
imported = Key.new_from_pem(pem_str, passphrase="gigowatt", user=None)
imported = Certificate.new_from_pem(pem_str)

For more examples, see SignaturePKITestCase into tests/test_project/apps/testapp/

There is an simple signature example:

# Sign Text
text = "This is a data"
data_signed = c_cert.sign_text(text, c_pwd)
result = c_cert.verify_smime(data_signed)

# Sign Model (get text)
auth1 = Author(name="Raymond E. Feist", title="MR")
data_signed = c_cert.sign_model(auth1, c_pwd)
result = c_cert.verify_smime(data_signed)

# Sign Model (get Signature)
auth1 = Author(name="Raymond E. Feist", title="MR")
signed = c_cert.make_signature(auth1, self.c_pwd)

For more examples, see SignatureTestCase into tests/test_project/apps/testapp/

Main features:

  • PKI :
  • Generate (or load) RSA keys and store them in Django models
  • Generate x509 certificates and store them in Django models
  • Load x509 certificat and find relations with other Certificates and Keys
  • Generate (or load) x509 Requests and store them in Django models
  • Generate self-signed x509 for root CA
  • Verify certificate chain (with CRLs)
  • Sign Certificate Requests
  • Digital signature
  • Sign/verify text with PKCS#7 standard
  • Sign/verify simple modelswith PKCS#7 standard
  • Support FileField (with sha512 digest)
  • Good test coverage

last updated on:
August 31st, 2011, 10:27 GMT
license type:
GPL v3 
developed by:
Johan Charpentier
ROOT \ Internet \ HTTP (WWW)
Download Button

In a hurry? Add it to your Download Basket!

user rating



Rate it!

Add your review!