Funktionierender Prototyp des Serious Games zur Vermittlung von Wissen zu Software-Engineering-Arbeitsmodellen.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

rfc3161.py 4.2KB

1 year ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  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. # Time-Stamp Protocol (TSP)
  10. #
  11. # ASN.1 source from:
  12. # https://www.rfc-editor.org/rfc/rfc3161.txt
  13. #
  14. from pyasn1.type import constraint
  15. from pyasn1.type import namedtype
  16. from pyasn1.type import namedval
  17. from pyasn1.type import tag
  18. from pyasn1.type import univ
  19. from pyasn1.type import useful
  20. from pyasn1_modules import rfc4210
  21. from pyasn1_modules import rfc5280
  22. from pyasn1_modules import rfc5652
  23. Extensions = rfc5280.Extensions
  24. AlgorithmIdentifier = rfc5280.AlgorithmIdentifier
  25. GeneralName = rfc5280.GeneralName
  26. ContentInfo = rfc5652.ContentInfo
  27. PKIFreeText = rfc4210.PKIFreeText
  28. id_ct_TSTInfo = univ.ObjectIdentifier('1.2.840.113549.1.9.16.1.4')
  29. class Accuracy(univ.Sequence):
  30. pass
  31. Accuracy.componentType = namedtype.NamedTypes(
  32. namedtype.OptionalNamedType('seconds', univ.Integer()),
  33. namedtype.OptionalNamedType('millis', univ.Integer().subtype(subtypeSpec=constraint.ValueRangeConstraint(1, 999)).subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 0))),
  34. namedtype.OptionalNamedType('micros', univ.Integer().subtype(subtypeSpec=constraint.ValueRangeConstraint(1, 999)).subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 1)))
  35. )
  36. class MessageImprint(univ.Sequence):
  37. pass
  38. MessageImprint.componentType = namedtype.NamedTypes(
  39. namedtype.NamedType('hashAlgorithm', AlgorithmIdentifier()),
  40. namedtype.NamedType('hashedMessage', univ.OctetString())
  41. )
  42. class PKIFailureInfo(univ.BitString):
  43. pass
  44. PKIFailureInfo.namedValues = namedval.NamedValues(
  45. ('badAlg', 0),
  46. ('badRequest', 2),
  47. ('badDataFormat', 5),
  48. ('timeNotAvailable', 14),
  49. ('unacceptedPolicy', 15),
  50. ('unacceptedExtension', 16),
  51. ('addInfoNotAvailable', 17),
  52. ('systemFailure', 25)
  53. )
  54. class PKIStatus(univ.Integer):
  55. pass
  56. PKIStatus.namedValues = namedval.NamedValues(
  57. ('granted', 0),
  58. ('grantedWithMods', 1),
  59. ('rejection', 2),
  60. ('waiting', 3),
  61. ('revocationWarning', 4),
  62. ('revocationNotification', 5)
  63. )
  64. class PKIStatusInfo(univ.Sequence):
  65. pass
  66. PKIStatusInfo.componentType = namedtype.NamedTypes(
  67. namedtype.NamedType('status', PKIStatus()),
  68. namedtype.OptionalNamedType('statusString', PKIFreeText()),
  69. namedtype.OptionalNamedType('failInfo', PKIFailureInfo())
  70. )
  71. class TSAPolicyId(univ.ObjectIdentifier):
  72. pass
  73. class TSTInfo(univ.Sequence):
  74. pass
  75. TSTInfo.componentType = namedtype.NamedTypes(
  76. namedtype.NamedType('version', univ.Integer(namedValues=namedval.NamedValues(('v1', 1)))),
  77. namedtype.NamedType('policy', TSAPolicyId()),
  78. namedtype.NamedType('messageImprint', MessageImprint()),
  79. namedtype.NamedType('serialNumber', univ.Integer()),
  80. namedtype.NamedType('genTime', useful.GeneralizedTime()),
  81. namedtype.OptionalNamedType('accuracy', Accuracy()),
  82. namedtype.DefaultedNamedType('ordering', univ.Boolean().subtype(value=0)),
  83. namedtype.OptionalNamedType('nonce', univ.Integer()),
  84. namedtype.OptionalNamedType('tsa', GeneralName().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 0))),
  85. namedtype.OptionalNamedType('extensions', Extensions().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 1)))
  86. )
  87. class TimeStampReq(univ.Sequence):
  88. pass
  89. TimeStampReq.componentType = namedtype.NamedTypes(
  90. namedtype.NamedType('version', univ.Integer(namedValues=namedval.NamedValues(('v1', 1)))),
  91. namedtype.NamedType('messageImprint', MessageImprint()),
  92. namedtype.OptionalNamedType('reqPolicy', TSAPolicyId()),
  93. namedtype.OptionalNamedType('nonce', univ.Integer()),
  94. namedtype.DefaultedNamedType('certReq', univ.Boolean().subtype(value=0)),
  95. namedtype.OptionalNamedType('extensions', Extensions().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 0)))
  96. )
  97. class TimeStampToken(ContentInfo):
  98. pass
  99. class TimeStampResp(univ.Sequence):
  100. pass
  101. TimeStampResp.componentType = namedtype.NamedTypes(
  102. namedtype.NamedType('status', PKIStatusInfo()),
  103. namedtype.OptionalNamedType('timeStampToken', TimeStampToken())
  104. )