rfc3274.py 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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. # 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. # CMS Compressed Data Content Type
  11. #
  12. # ASN.1 source from:
  13. # https://www.rfc-editor.org/rfc/rfc3274.txt
  14. #
  15. from pyasn1.type import namedtype
  16. from pyasn1.type import univ
  17. from pyasn1_modules import rfc5280
  18. from pyasn1_modules import rfc5652
  19. class CompressionAlgorithmIdentifier(rfc5280.AlgorithmIdentifier):
  20. pass
  21. # The CMS Compressed Data Content Type
  22. id_ct_compressedData = univ.ObjectIdentifier('1.2.840.113549.1.9.16.1.9')
  23. class CompressedData(univ.Sequence):
  24. pass
  25. CompressedData.componentType = namedtype.NamedTypes(
  26. namedtype.NamedType('version', rfc5652.CMSVersion()), # Always set to 0
  27. namedtype.NamedType('compressionAlgorithm', CompressionAlgorithmIdentifier()),
  28. namedtype.NamedType('encapContentInfo', rfc5652.EncapsulatedContentInfo())
  29. )
  30. # Algorithm identifier for the zLib Compression Algorithm
  31. # This includes cpa_zlibCompress as defined in RFC 6268,
  32. # from https://www.rfc-editor.org/rfc/rfc6268.txt
  33. id_alg_zlibCompress = univ.ObjectIdentifier('1.2.840.113549.1.9.16.3.8')
  34. cpa_zlibCompress = rfc5280.AlgorithmIdentifier()
  35. cpa_zlibCompress['algorithm'] = id_alg_zlibCompress
  36. # cpa_zlibCompress['parameters'] are absent
  37. # Map of Content Type OIDs to Content Types is added to thr
  38. # ones that are in rfc5652.py
  39. _cmsContentTypesMapUpdate = {
  40. id_ct_compressedData: CompressedData(),
  41. }
  42. rfc5652.cmsContentTypesMap.update(_cmsContentTypesMapUpdate)