rfc5917.py 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. #
  2. # This file is part of pyasn1-modules software.
  3. #
  4. # Created by Russ Housley.
  5. #
  6. # Copyright (c) 2019, Vigil Security, LLC
  7. # License: http://snmplabs.com/pyasn1/license.html
  8. #
  9. # Clearance Sponsor Attribute
  10. #
  11. # ASN.1 source from:
  12. # https://www.rfc-editor.org/rfc/rfc5917.txt
  13. # https://www.rfc-editor.org/errata/eid4558
  14. # https://www.rfc-editor.org/errata/eid5883
  15. #
  16. from pyasn1.type import char
  17. from pyasn1.type import constraint
  18. from pyasn1.type import namedtype
  19. from pyasn1.type import univ
  20. from pyasn1_modules import rfc5280
  21. # DirectoryString is the same as RFC 5280, except for two things:
  22. # 1. the length is limited to 64;
  23. # 2. only the 'utf8String' choice remains because the ASN.1
  24. # specification says: ( WITH COMPONENTS { utf8String PRESENT } )
  25. class DirectoryString(univ.Choice):
  26. componentType = namedtype.NamedTypes(
  27. namedtype.NamedType('utf8String', char.UTF8String().subtype(
  28. subtypeSpec=constraint.ValueSizeConstraint(1, 64))),
  29. )
  30. # Clearance Sponsor Attribute
  31. id_clearanceSponsor = univ.ObjectIdentifier((2, 16, 840, 1, 101, 2, 1, 5, 68))
  32. ub_clearance_sponsor = univ.Integer(64)
  33. at_clearanceSponsor = rfc5280.Attribute()
  34. at_clearanceSponsor['type'] = id_clearanceSponsor
  35. at_clearanceSponsor['values'][0] = DirectoryString()
  36. # Add to the map of Attribute Type OIDs to Attributes in rfc5280.py.
  37. _certificateAttributesMapUpdate = {
  38. id_clearanceSponsor: DirectoryString(),
  39. }
  40. rfc5280.certificateAttributesMap.update(_certificateAttributesMapUpdate)