rfc4073.py 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. #
  2. # This file is part of pyasn1-modules software.
  3. #
  4. # Created by Russ Housley with some assistance from asn1ate v.0.6.0.
  5. # Modified by Russ Housley to add a map for use with opentypes.
  6. #
  7. # Copyright (c) 2019, Vigil Security, LLC
  8. # License: http://snmplabs.com/pyasn1/license.html
  9. #
  10. # Protecting Multiple Contents with the CMS
  11. #
  12. # ASN.1 source from:
  13. # https://www.rfc-editor.org/rfc/rfc4073.txt
  14. #
  15. from pyasn1.type import constraint
  16. from pyasn1.type import namedtype
  17. from pyasn1.type import univ
  18. from pyasn1_modules import rfc5652
  19. MAX = float('inf')
  20. # Content Collection Content Type and Object Identifier
  21. id_ct_contentCollection = univ.ObjectIdentifier('1.2.840.113549.1.9.16.1.19')
  22. class ContentCollection(univ.SequenceOf):
  23. pass
  24. ContentCollection.componentType = rfc5652.ContentInfo()
  25. ContentCollection.sizeSpec = constraint.ValueSizeConstraint(1, MAX)
  26. # Content With Attributes Content Type and Object Identifier
  27. id_ct_contentWithAttrs = univ.ObjectIdentifier('1.2.840.113549.1.9.16.1.20')
  28. class ContentWithAttributes(univ.Sequence):
  29. pass
  30. ContentWithAttributes.componentType = namedtype.NamedTypes(
  31. namedtype.NamedType('content', rfc5652.ContentInfo()),
  32. namedtype.NamedType('attrs', univ.SequenceOf(
  33. componentType=rfc5652.Attribute()).subtype(
  34. sizeSpec=constraint.ValueSizeConstraint(1, MAX)))
  35. )
  36. # Map of Content Type OIDs to Content Types is added to the
  37. # ones that are in rfc5652.py
  38. _cmsContentTypesMapUpdate = {
  39. id_ct_contentCollection: ContentCollection(),
  40. id_ct_contentWithAttrs: ContentWithAttributes(),
  41. }
  42. rfc5652.cmsContentTypesMap.update(_cmsContentTypesMapUpdate)