rfc3370.py 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  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. # Cryptographic Message Syntax (CMS) Algorithms
  10. #
  11. # ASN.1 source from:
  12. # https://www.rfc-editor.org/rfc/rfc3370.txt
  13. #
  14. from pyasn1.type import univ
  15. from pyasn1_modules import rfc3279
  16. from pyasn1_modules import rfc5280
  17. from pyasn1_modules import rfc5751
  18. from pyasn1_modules import rfc5753
  19. from pyasn1_modules import rfc5990
  20. from pyasn1_modules import rfc8018
  21. # Imports from RFC 5280
  22. AlgorithmIdentifier = rfc5280.AlgorithmIdentifier
  23. # Imports from RFC 3279
  24. dhpublicnumber = rfc3279.dhpublicnumber
  25. dh_public_number = dhpublicnumber
  26. DHPublicKey = rfc3279.DHPublicKey
  27. DomainParameters = rfc3279.DomainParameters
  28. DHDomainParameters = DomainParameters
  29. Dss_Parms = rfc3279.Dss_Parms
  30. Dss_Sig_Value = rfc3279.Dss_Sig_Value
  31. md5 = rfc3279.md5
  32. md5WithRSAEncryption = rfc3279.md5WithRSAEncryption
  33. RSAPublicKey = rfc3279.RSAPublicKey
  34. rsaEncryption = rfc3279.rsaEncryption
  35. ValidationParms = rfc3279.ValidationParms
  36. id_dsa = rfc3279.id_dsa
  37. id_dsa_with_sha1 = rfc3279.id_dsa_with_sha1
  38. id_sha1 = rfc3279.id_sha1
  39. sha_1 = id_sha1
  40. sha1WithRSAEncryption = rfc3279.sha1WithRSAEncryption
  41. # Imports from RFC 5753
  42. CBCParameter = rfc5753.CBCParameter
  43. CBCParameter = rfc5753.IV
  44. KeyWrapAlgorithm = rfc5753.KeyWrapAlgorithm
  45. # Imports from RFC 5990
  46. id_alg_CMS3DESwrap = rfc5990.id_alg_CMS3DESwrap
  47. # Imports from RFC 8018
  48. des_EDE3_CBC = rfc8018.des_EDE3_CBC
  49. des_ede3_cbc = des_EDE3_CBC
  50. rc2CBC = rfc8018.rc2CBC
  51. rc2_cbc = rc2CBC
  52. RC2_CBC_Parameter = rfc8018.RC2_CBC_Parameter
  53. RC2CBCParameter = RC2_CBC_Parameter
  54. PBKDF2_params = rfc8018.PBKDF2_params
  55. id_PBKDF2 = rfc8018.id_PBKDF2
  56. # The few things that are not already defined elsewhere
  57. hMAC_SHA1 = univ.ObjectIdentifier('1.3.6.1.5.5.8.1.2')
  58. id_alg_ESDH = univ.ObjectIdentifier('1.2.840.113549.1.9.16.3.5')
  59. id_alg_SSDH = univ.ObjectIdentifier('1.2.840.113549.1.9.16.3.10')
  60. id_alg_CMSRC2wrap = univ.ObjectIdentifier('1.2.840.113549.1.9.16.3.7')
  61. class RC2ParameterVersion(univ.Integer):
  62. pass
  63. class RC2wrapParameter(RC2ParameterVersion):
  64. pass
  65. class Dss_Pub_Key(univ.Integer):
  66. pass
  67. # Update the Algorithm Identifier map in rfc5280.py.
  68. _algorithmIdentifierMapUpdate = {
  69. hMAC_SHA1: univ.Null(""),
  70. id_alg_CMSRC2wrap: RC2wrapParameter(),
  71. id_alg_ESDH: KeyWrapAlgorithm(),
  72. id_alg_SSDH: KeyWrapAlgorithm(),
  73. }
  74. rfc5280.algorithmIdentifierMap.update(_algorithmIdentifierMapUpdate)
  75. # Update the S/MIME Capabilities map in rfc5751.py.
  76. _smimeCapabilityMapUpdate = {
  77. id_alg_CMSRC2wrap: RC2wrapParameter(),
  78. id_alg_ESDH: KeyWrapAlgorithm(),
  79. id_alg_SSDH: KeyWrapAlgorithm(),
  80. }
  81. rfc5751.smimeCapabilityMap.update(_smimeCapabilityMapUpdate)