rfc4476.py 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. #
  2. # This file is part of pyasn1-modules software.
  3. #
  4. # Created by Russ Housley with assistance from asn1ate v.0.6.0.
  5. #
  6. # Copyright (c) 2019, Vigil Security, LLC
  7. # License: http://snmplabs.com/pyasn1/license.html
  8. #
  9. # Attribute Certificate Policies Extension
  10. #
  11. # ASN.1 source from:
  12. # https://www.rfc-editor.org/rfc/rfc4476.txt
  13. #
  14. from pyasn1.type import char
  15. from pyasn1.type import constraint
  16. from pyasn1.type import namedtype
  17. from pyasn1.type import univ
  18. from pyasn1_modules import rfc5280
  19. MAX = float('inf')
  20. # Imports from RFC 5280
  21. PolicyQualifierId = rfc5280.PolicyQualifierId
  22. PolicyQualifierInfo = rfc5280.PolicyQualifierInfo
  23. UserNotice = rfc5280.UserNotice
  24. id_pkix = rfc5280.id_pkix
  25. # Object Identifiers
  26. id_pe = id_pkix + (1,)
  27. id_pe_acPolicies = id_pe + (15,)
  28. id_qt = id_pkix + (2,)
  29. id_qt_acps = id_qt + (4,)
  30. id_qt_acunotice = id_qt + (5,)
  31. # Attribute Certificate Policies Extension
  32. class ACUserNotice(UserNotice):
  33. pass
  34. class ACPSuri(char.IA5String):
  35. pass
  36. class AcPolicyId(univ.ObjectIdentifier):
  37. pass
  38. class PolicyInformation(univ.Sequence):
  39. componentType = namedtype.NamedTypes(
  40. namedtype.NamedType('policyIdentifier', AcPolicyId()),
  41. namedtype.OptionalNamedType('policyQualifiers',
  42. univ.SequenceOf(componentType=PolicyQualifierInfo()).subtype(
  43. subtypeSpec=constraint.ValueSizeConstraint(1, MAX)))
  44. )
  45. class AcPoliciesSyntax(univ.SequenceOf):
  46. componentType = PolicyInformation()
  47. subtypeSpec = constraint.ValueSizeConstraint(1, MAX)
  48. # Update the policy qualifier map in rfc5280.py
  49. _policyQualifierInfoMapUpdate = {
  50. id_qt_acps: ACPSuri(),
  51. id_qt_acunotice: UserNotice(),
  52. }
  53. rfc5280.policyQualifierInfoMap.update(_policyQualifierInfoMapUpdate)
  54. # Update the certificate extension map in rfc5280.py
  55. _certificateExtensionsMapUpdate = {
  56. id_pe_acPolicies: AcPoliciesSyntax(),
  57. }
  58. rfc5280.certificateExtensionsMap.update(_certificateExtensionsMapUpdate)