rfc3565.py 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. # This file is being contributed to pyasn1-modules software.
  2. #
  3. # Created by Russ Housley.
  4. # Modified by Russ Housley to add maps for use with opentypes.
  5. #
  6. # Copyright (c) 2019, Vigil Security, LLC
  7. # License: http://snmplabs.com/pyasn1/license.html
  8. #
  9. # Use of the Advanced Encryption Standard (AES) Encryption
  10. # Algorithm in the Cryptographic Message Syntax (CMS)
  11. #
  12. # ASN.1 source from:
  13. # https://www.rfc-editor.org/rfc/rfc3565.txt
  14. from pyasn1.type import constraint
  15. from pyasn1.type import univ
  16. from pyasn1_modules import rfc5280
  17. class AlgorithmIdentifier(rfc5280.AlgorithmIdentifier):
  18. pass
  19. class AES_IV(univ.OctetString):
  20. pass
  21. AES_IV.subtypeSpec = constraint.ValueSizeConstraint(16, 16)
  22. id_aes128_CBC = univ.ObjectIdentifier('2.16.840.1.101.3.4.1.2')
  23. id_aes192_CBC = univ.ObjectIdentifier('2.16.840.1.101.3.4.1.22')
  24. id_aes256_CBC = univ.ObjectIdentifier('2.16.840.1.101.3.4.1.42')
  25. id_aes128_wrap = univ.ObjectIdentifier('2.16.840.1.101.3.4.1.5')
  26. id_aes192_wrap = univ.ObjectIdentifier('2.16.840.1.101.3.4.1.25')
  27. id_aes256_wrap = univ.ObjectIdentifier('2.16.840.1.101.3.4.1.45')
  28. # Update the Algorithm Identifier map
  29. _algorithmIdentifierMapUpdate = {
  30. id_aes128_CBC: AES_IV(),
  31. id_aes192_CBC: AES_IV(),
  32. id_aes256_CBC: AES_IV(),
  33. id_aes128_wrap: univ.Null(),
  34. id_aes192_wrap: univ.Null(),
  35. id_aes256_wrap: univ.Null(),
  36. }
  37. rfc5280.algorithmIdentifierMap.update(_algorithmIdentifierMapUpdate)