pkcs12.py 1.2 KB

1234567891011121314151617181920212223242526272829303132333435
  1. #
  2. # PKCS#12 syntax
  3. #
  4. # ASN.1 source from:
  5. # ftp://ftp.rsasecurity.com/pub/pkcs/pkcs-12/pkcs-12.asn
  6. #
  7. # Sample captures could be obtained with "openssl pkcs12" command
  8. #
  9. from pyasn1.type import tag, namedtype, namedval, univ, constraint
  10. from pyasn1_modules.rfc2459 import *
  11. from pyasn1_modules import rfc2251
  12. class Attributes(univ.SetOf):
  13. componentType = rfc2251.Attribute()
  14. class Version(univ.Integer): pass
  15. class CertificationRequestInfo(univ.Sequence):
  16. componentType = namedtype.NamedTypes(
  17. namedtype.NamedType('version', Version()),
  18. namedtype.NamedType('subject', Name()),
  19. namedtype.NamedType('subjectPublicKeyInfo', SubjectPublicKeyInfo()),
  20. namedtype.NamedType('attributes', Attributes().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatConstructed, 0)))
  21. )
  22. class Signature(univ.BitString): pass
  23. class SignatureAlgorithmIdentifier(AlgorithmIdentifier): pass
  24. class CertificationRequest(univ.Sequence):
  25. componentType = namedtype.NamedTypes(
  26. namedtype.NamedType('certificationRequestInfo', CertificationRequestInfo()),
  27. namedtype.NamedType('signatureAlgorithm', SignatureAlgorithmIdentifier()),
  28. namedtype.NamedType('signature', Signature())
  29. )