rfc5636.py 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. # This file is being contributed to pyasn1-modules software.
  2. #
  3. # Created by Russ Housley.
  4. #
  5. # Copyright (c) 2019, Vigil Security, LLC
  6. # License: http://snmplabs.com/pyasn1/license.html
  7. #
  8. # Traceable Anonymous Certificate
  9. #
  10. # ASN.1 source from:
  11. # https://www.rfc-editor.org/rfc/rfc5480.txt
  12. from pyasn1.type import namedtype
  13. from pyasn1.type import univ
  14. from pyasn1.type import useful
  15. from pyasn1_modules import rfc5652
  16. # Imports from RFC 5652
  17. ContentInfo = rfc5652.ContentInfo
  18. EncapsulatedContentInfo = rfc5652.EncapsulatedContentInfo
  19. id_data = rfc5652.id_data
  20. # Object Identifiers
  21. id_KISA = univ.ObjectIdentifier((1, 2, 410, 200004,))
  22. id_npki = id_KISA + (10,)
  23. id_attribute = id_npki + (1,)
  24. id_kisa_tac = id_attribute + (1,)
  25. id_kisa_tac_token = id_kisa_tac + (1,)
  26. id_kisa_tac_tokenandblindbash = id_kisa_tac + (2,)
  27. id_kisa_tac_tokenandpartially = id_kisa_tac + (3,)
  28. # Structures for Traceable Anonymous Certificate (TAC)
  29. class UserKey(univ.OctetString):
  30. pass
  31. class Timeout(useful.GeneralizedTime):
  32. pass
  33. class BlinedCertificateHash(univ.OctetString):
  34. pass
  35. class PartiallySignedCertificateHash(univ.OctetString):
  36. pass
  37. class Token(ContentInfo):
  38. pass
  39. class TokenandBlindHash(ContentInfo):
  40. pass
  41. class TokenandPartiallySignedCertificateHash(ContentInfo):
  42. pass
  43. # Added to the module in RFC 5636 for the CMS Content Type Map
  44. class TACToken(univ.Sequence):
  45. componentType = namedtype.NamedTypes(
  46. namedtype.NamedType('userKey', UserKey()),
  47. namedtype.NamedType('timeout', Timeout())
  48. )
  49. class TACTokenandBlindHash(univ.Sequence):
  50. componentType = namedtype.NamedTypes(
  51. namedtype.NamedType('token', Token()),
  52. namedtype.NamedType('blinded', BlinedCertificateHash())
  53. )
  54. class TACTokenandPartiallySignedCertificateHash(univ.Sequence):
  55. componentType = namedtype.NamedTypes(
  56. namedtype.NamedType('token', Token()),
  57. namedtype.NamedType('partially', PartiallySignedCertificateHash())
  58. )
  59. # Add to the CMS Content Type Map in rfc5752.py
  60. _cmsContentTypesMapUpdate = {
  61. id_kisa_tac_token: TACToken(),
  62. id_kisa_tac_tokenandblindbash: TACTokenandBlindHash(),
  63. id_kisa_tac_tokenandpartially: TACTokenandPartiallySignedCertificateHash(),
  64. }
  65. rfc5652.cmsContentTypesMap.update(_cmsContentTypesMapUpdate)