rfc6955.py 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  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. # Diffie-Hellman Proof-of-Possession Algorithms
  10. #
  11. # ASN.1 source from:
  12. # https://www.rfc-editor.org/rfc/rfc6955.txt
  13. #
  14. from pyasn1.type import namedtype
  15. from pyasn1.type import univ
  16. from pyasn1_modules import rfc3279
  17. from pyasn1_modules import rfc5280
  18. from pyasn1_modules import rfc5652
  19. # Imports from RFC 5652
  20. MessageDigest = rfc5652.MessageDigest
  21. IssuerAndSerialNumber = rfc5652.IssuerAndSerialNumber
  22. # Imports from RFC 5280
  23. id_pkix = rfc5280.id_pkix
  24. # Imports from RFC 3279
  25. Dss_Sig_Value = rfc3279.Dss_Sig_Value
  26. DomainParameters = rfc3279.DomainParameters
  27. # Static DH Proof-of-Possession
  28. class DhSigStatic(univ.Sequence):
  29. componentType = namedtype.NamedTypes(
  30. namedtype.OptionalNamedType('issuerAndSerial', IssuerAndSerialNumber()),
  31. namedtype.NamedType('hashValue', MessageDigest())
  32. )
  33. # Object Identifiers
  34. id_dh_sig_hmac_sha1 = id_pkix + (6, 3, )
  35. id_dhPop_static_sha1_hmac_sha1 = univ.ObjectIdentifier(id_dh_sig_hmac_sha1)
  36. id_alg_dh_pop = id_pkix + (6, 4, )
  37. id_alg_dhPop_sha1 = univ.ObjectIdentifier(id_alg_dh_pop)
  38. id_alg_dhPop_sha224 = id_pkix + (6, 5, )
  39. id_alg_dhPop_sha256 = id_pkix + (6, 6, )
  40. id_alg_dhPop_sha384 = id_pkix + (6, 7, )
  41. id_alg_dhPop_sha512 = id_pkix + (6, 8, )
  42. id_alg_dhPop_static_sha224_hmac_sha224 = id_pkix + (6, 15, )
  43. id_alg_dhPop_static_sha256_hmac_sha256 = id_pkix + (6, 16, )
  44. id_alg_dhPop_static_sha384_hmac_sha384 = id_pkix + (6, 17, )
  45. id_alg_dhPop_static_sha512_hmac_sha512 = id_pkix + (6, 18, )
  46. id_alg_ecdhPop_static_sha224_hmac_sha224 = id_pkix + (6, 25, )
  47. id_alg_ecdhPop_static_sha256_hmac_sha256 = id_pkix + (6, 26, )
  48. id_alg_ecdhPop_static_sha384_hmac_sha384 = id_pkix + (6, 27, )
  49. id_alg_ecdhPop_static_sha512_hmac_sha512 = id_pkix + (6, 28, )
  50. # Update the Algorithm Identifier map in rfc5280.py
  51. _algorithmIdentifierMapUpdate = {
  52. id_alg_dh_pop: DomainParameters(),
  53. id_alg_dhPop_sha224: DomainParameters(),
  54. id_alg_dhPop_sha256: DomainParameters(),
  55. id_alg_dhPop_sha384: DomainParameters(),
  56. id_alg_dhPop_sha512: DomainParameters(),
  57. id_dh_sig_hmac_sha1: univ.Null(""),
  58. id_alg_dhPop_static_sha224_hmac_sha224: univ.Null(""),
  59. id_alg_dhPop_static_sha256_hmac_sha256: univ.Null(""),
  60. id_alg_dhPop_static_sha384_hmac_sha384: univ.Null(""),
  61. id_alg_dhPop_static_sha512_hmac_sha512: univ.Null(""),
  62. id_alg_ecdhPop_static_sha224_hmac_sha224: univ.Null(""),
  63. id_alg_ecdhPop_static_sha256_hmac_sha256: univ.Null(""),
  64. id_alg_ecdhPop_static_sha384_hmac_sha384: univ.Null(""),
  65. id_alg_ecdhPop_static_sha512_hmac_sha512: univ.Null(""),
  66. }
  67. rfc5280.algorithmIdentifierMap.update(_algorithmIdentifierMapUpdate)