rfc5697.py 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. # This file is being contributed to pyasn1-modules software.
  2. #
  3. # Created by Russ Housley.
  4. #
  5. # Copyright (c) 2019, Vigil Security, LLC
  6. # License: http://snmplabs.com/pyasn1/license.html
  7. #
  8. # Other Certificates Extension
  9. #
  10. # ASN.1 source from:
  11. # https://www.rfc-editor.org/rfc/rfc5697.txt
  12. from pyasn1.type import namedtype
  13. from pyasn1.type import univ
  14. from pyasn1_modules import rfc5280
  15. from pyasn1_modules import rfc4055
  16. # Imports from RFC 5280
  17. AlgorithmIdentifier = rfc5280.AlgorithmIdentifier
  18. CertificateSerialNumber = rfc5280.CertificateSerialNumber
  19. GeneralNames = rfc5280.GeneralNames
  20. # Imports from RFC 4055
  21. id_sha1 = rfc4055.id_sha1
  22. # Imports from RFC 5055
  23. # These are defined here because a module for RFC 5055 does not exist yet
  24. class SCVPIssuerSerial(univ.Sequence):
  25. componentType = namedtype.NamedTypes(
  26. namedtype.NamedType('issuer', GeneralNames()),
  27. namedtype.NamedType('serialNumber', CertificateSerialNumber())
  28. )
  29. sha1_alg_id = AlgorithmIdentifier()
  30. sha1_alg_id['algorithm'] = id_sha1
  31. class SCVPCertID(univ.Sequence):
  32. componentType = namedtype.NamedTypes(
  33. namedtype.NamedType('certHash', univ.OctetString()),
  34. namedtype.NamedType('issuerSerial', SCVPIssuerSerial()),
  35. namedtype.DefaultedNamedType('hashAlgorithm', sha1_alg_id)
  36. )
  37. # Other Certificates Extension
  38. id_pe_otherCerts = univ.ObjectIdentifier((1, 3, 6, 1, 5, 5, 7, 1, 19,))
  39. class OtherCertificates(univ.SequenceOf):
  40. componentType = SCVPCertID()
  41. # Update of certificate extension map in rfc5280.py
  42. _certificateExtensionsMapUpdate = {
  43. id_pe_otherCerts: OtherCertificates(),
  44. }
  45. rfc5280.certificateExtensionsMap.update(_certificateExtensionsMapUpdate)