rfc6032.py 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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. # CMS Encrypted Key Package Content Type
  10. #
  11. # ASN.1 source from:
  12. # https://www.rfc-editor.org/rfc/rfc6032.txt
  13. #
  14. from pyasn1.type import namedtype
  15. from pyasn1.type import tag
  16. from pyasn1.type import univ
  17. from pyasn1_modules import rfc5652
  18. from pyasn1_modules import rfc5083
  19. # Content Decryption Key Identifier attribute
  20. id_aa_KP_contentDecryptKeyID = univ.ObjectIdentifier('2.16.840.1.101.2.1.5.66')
  21. class ContentDecryptKeyID(univ.OctetString):
  22. pass
  23. aa_content_decrypt_key_identifier = rfc5652.Attribute()
  24. aa_content_decrypt_key_identifier['attrType'] = id_aa_KP_contentDecryptKeyID
  25. aa_content_decrypt_key_identifier['attrValues'][0] = ContentDecryptKeyID()
  26. # Encrypted Key Package Content Type
  27. id_ct_KP_encryptedKeyPkg = univ.ObjectIdentifier('2.16.840.1.101.2.1.2.78.2')
  28. class EncryptedKeyPackage(univ.Choice):
  29. pass
  30. EncryptedKeyPackage.componentType = namedtype.NamedTypes(
  31. namedtype.NamedType('encrypted', rfc5652.EncryptedData()),
  32. namedtype.NamedType('enveloped', rfc5652.EnvelopedData().subtype(
  33. implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 0))),
  34. namedtype.NamedType('authEnveloped', rfc5083.AuthEnvelopedData().subtype(
  35. implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 1)))
  36. )
  37. # Map of Attribute Type OIDs to Attributes are
  38. # added to the ones that are in rfc5652.py
  39. _cmsAttributesMapUpdate = {
  40. id_aa_KP_contentDecryptKeyID: ContentDecryptKeyID(),
  41. }
  42. rfc5652.cmsAttributesMap.update(_cmsAttributesMapUpdate)
  43. # Map of Content Type OIDs to Content Types are
  44. # added to the ones that are in rfc5652.py
  45. _cmsContentTypesMapUpdate = {
  46. id_ct_KP_encryptedKeyPkg: EncryptedKeyPackage(),
  47. }
  48. rfc5652.cmsContentTypesMap.update(_cmsContentTypesMapUpdate)