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.

rfc5934.py 23KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786
  1. # This file is being contributed to pyasn1-modules software.
  2. #
  3. # Created by Russ Housley with assistance from asn1ate v.0.6.0.
  4. #
  5. # Copyright (c) 2019, Vigil Security, LLC
  6. # License: http://snmplabs.com/pyasn1/license.html
  7. #
  8. # Trust Anchor Format
  9. #
  10. # ASN.1 source from:
  11. # https://www.rfc-editor.org/rfc/rfc5934.txt
  12. from pyasn1.type import univ, char, namedtype, namedval, tag, constraint, useful
  13. from pyasn1_modules import rfc2985
  14. from pyasn1_modules import rfc5280
  15. from pyasn1_modules import rfc5652
  16. from pyasn1_modules import rfc5914
  17. MAX = float('inf')
  18. def _OID(*components):
  19. output = []
  20. for x in tuple(components):
  21. if isinstance(x, univ.ObjectIdentifier):
  22. output.extend(list(x))
  23. else:
  24. output.append(int(x))
  25. return univ.ObjectIdentifier(output)
  26. # Imports from RFC 2985
  27. SingleAttribute = rfc2985.SingleAttribute
  28. # Imports from RFC5914
  29. CertPathControls = rfc5914.CertPathControls
  30. TrustAnchorChoice = rfc5914.TrustAnchorChoice
  31. TrustAnchorTitle = rfc5914.TrustAnchorTitle
  32. # Imports from RFC 5280
  33. AlgorithmIdentifier = rfc5280.AlgorithmIdentifier
  34. AnotherName = rfc5280.AnotherName
  35. Attribute = rfc5280.Attribute
  36. Certificate = rfc5280.Certificate
  37. CertificateSerialNumber = rfc5280.CertificateSerialNumber
  38. Extension = rfc5280.Extension
  39. Extensions = rfc5280.Extensions
  40. KeyIdentifier = rfc5280.KeyIdentifier
  41. Name = rfc5280.Name
  42. SubjectPublicKeyInfo = rfc5280.SubjectPublicKeyInfo
  43. TBSCertificate = rfc5280.TBSCertificate
  44. Validity = rfc5280.Validity
  45. # Object Identifier Arc for TAMP Message Content Types
  46. id_tamp = univ.ObjectIdentifier('2.16.840.1.101.2.1.2.77')
  47. # TAMP Status Query Message
  48. id_ct_TAMP_statusQuery = _OID(id_tamp, 1)
  49. class TAMPVersion(univ.Integer):
  50. pass
  51. TAMPVersion.namedValues = namedval.NamedValues(
  52. ('v1', 1),
  53. ('v2', 2)
  54. )
  55. class TerseOrVerbose(univ.Enumerated):
  56. pass
  57. TerseOrVerbose.namedValues = namedval.NamedValues(
  58. ('terse', 1),
  59. ('verbose', 2)
  60. )
  61. class HardwareSerialEntry(univ.Choice):
  62. pass
  63. HardwareSerialEntry.componentType = namedtype.NamedTypes(
  64. namedtype.NamedType('all', univ.Null()),
  65. namedtype.NamedType('single', univ.OctetString()),
  66. namedtype.NamedType('block', univ.Sequence(componentType=namedtype.NamedTypes(
  67. namedtype.NamedType('low', univ.OctetString()),
  68. namedtype.NamedType('high', univ.OctetString())
  69. ))
  70. )
  71. )
  72. class HardwareModules(univ.Sequence):
  73. pass
  74. HardwareModules.componentType = namedtype.NamedTypes(
  75. namedtype.NamedType('hwType', univ.ObjectIdentifier()),
  76. namedtype.NamedType('hwSerialEntries', univ.SequenceOf(
  77. componentType=HardwareSerialEntry()).subtype(
  78. subtypeSpec=constraint.ValueSizeConstraint(1, MAX)))
  79. )
  80. class HardwareModuleIdentifierList(univ.SequenceOf):
  81. pass
  82. HardwareModuleIdentifierList.componentType = HardwareModules()
  83. HardwareModuleIdentifierList.subtypeSpec=constraint.ValueSizeConstraint(1, MAX)
  84. class Community(univ.ObjectIdentifier):
  85. pass
  86. class CommunityIdentifierList(univ.SequenceOf):
  87. pass
  88. CommunityIdentifierList.componentType = Community()
  89. CommunityIdentifierList.subtypeSpec=constraint.ValueSizeConstraint(0, MAX)
  90. class TargetIdentifier(univ.Choice):
  91. pass
  92. TargetIdentifier.componentType = namedtype.NamedTypes(
  93. namedtype.NamedType('hwModules', HardwareModuleIdentifierList().subtype(
  94. implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 1))),
  95. namedtype.NamedType('communities', CommunityIdentifierList().subtype(
  96. implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 2))),
  97. namedtype.NamedType('allModules', univ.Null().subtype(
  98. implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 3))),
  99. namedtype.NamedType('uri', char.IA5String().subtype(
  100. implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 4))),
  101. namedtype.NamedType('otherName', AnotherName().subtype(
  102. implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 5)))
  103. )
  104. class SeqNumber(univ.Integer):
  105. pass
  106. SeqNumber.subtypeSpec = constraint.ValueRangeConstraint(0, 9223372036854775807)
  107. class TAMPMsgRef(univ.Sequence):
  108. pass
  109. TAMPMsgRef.componentType = namedtype.NamedTypes(
  110. namedtype.NamedType('target', TargetIdentifier()),
  111. namedtype.NamedType('seqNum', SeqNumber())
  112. )
  113. class TAMPStatusQuery(univ.Sequence):
  114. pass
  115. TAMPStatusQuery.componentType = namedtype.NamedTypes(
  116. namedtype.DefaultedNamedType('version', TAMPVersion().subtype(
  117. implicitTag=tag.Tag(tag.tagClassContext,
  118. tag.tagFormatSimple, 0)).subtype(value='v2')),
  119. namedtype.DefaultedNamedType('terse', TerseOrVerbose().subtype(
  120. implicitTag=tag.Tag(tag.tagClassContext,
  121. tag.tagFormatSimple, 1)).subtype(value='verbose')),
  122. namedtype.NamedType('query', TAMPMsgRef())
  123. )
  124. tamp_status_query = rfc5652.ContentInfo()
  125. tamp_status_query['contentType'] = id_ct_TAMP_statusQuery
  126. tamp_status_query['content'] = TAMPStatusQuery()
  127. # TAMP Status Response Message
  128. id_ct_TAMP_statusResponse = _OID(id_tamp, 2)
  129. class KeyIdentifiers(univ.SequenceOf):
  130. pass
  131. KeyIdentifiers.componentType = KeyIdentifier()
  132. KeyIdentifiers.subtypeSpec=constraint.ValueSizeConstraint(1, MAX)
  133. class TrustAnchorChoiceList(univ.SequenceOf):
  134. pass
  135. TrustAnchorChoiceList.componentType = TrustAnchorChoice()
  136. TrustAnchorChoiceList.subtypeSpec=constraint.ValueSizeConstraint(1, MAX)
  137. class TAMPSequenceNumber(univ.Sequence):
  138. pass
  139. TAMPSequenceNumber.componentType = namedtype.NamedTypes(
  140. namedtype.NamedType('keyId', KeyIdentifier()),
  141. namedtype.NamedType('seqNumber', SeqNumber())
  142. )
  143. class TAMPSequenceNumbers(univ.SequenceOf):
  144. pass
  145. TAMPSequenceNumbers.componentType = TAMPSequenceNumber()
  146. TAMPSequenceNumbers.subtypeSpec=constraint.ValueSizeConstraint(1, MAX)
  147. class TerseStatusResponse(univ.Sequence):
  148. pass
  149. TerseStatusResponse.componentType = namedtype.NamedTypes(
  150. namedtype.NamedType('taKeyIds', KeyIdentifiers()),
  151. namedtype.OptionalNamedType('communities', CommunityIdentifierList())
  152. )
  153. class VerboseStatusResponse(univ.Sequence):
  154. pass
  155. VerboseStatusResponse.componentType = namedtype.NamedTypes(
  156. namedtype.NamedType('taInfo', TrustAnchorChoiceList()),
  157. namedtype.OptionalNamedType('continPubKeyDecryptAlg',
  158. AlgorithmIdentifier().subtype(implicitTag=tag.Tag(
  159. tag.tagClassContext, tag.tagFormatSimple, 0))),
  160. namedtype.OptionalNamedType('communities',
  161. CommunityIdentifierList().subtype(implicitTag=tag.Tag(
  162. tag.tagClassContext, tag.tagFormatSimple, 1))),
  163. namedtype.OptionalNamedType('tampSeqNumbers',
  164. TAMPSequenceNumbers().subtype(implicitTag=tag.Tag(
  165. tag.tagClassContext, tag.tagFormatSimple, 2)))
  166. )
  167. class StatusResponse(univ.Choice):
  168. pass
  169. StatusResponse.componentType = namedtype.NamedTypes(
  170. namedtype.NamedType('terseResponse', TerseStatusResponse().subtype(
  171. implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatConstructed, 0))),
  172. namedtype.NamedType('verboseResponse', VerboseStatusResponse().subtype(
  173. implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatConstructed, 1)))
  174. )
  175. class TAMPStatusResponse(univ.Sequence):
  176. pass
  177. TAMPStatusResponse.componentType = namedtype.NamedTypes(
  178. namedtype.DefaultedNamedType('version', TAMPVersion().subtype(
  179. implicitTag=tag.Tag(tag.tagClassContext,
  180. tag.tagFormatSimple, 0)).subtype(value='v2')),
  181. namedtype.NamedType('query', TAMPMsgRef()),
  182. namedtype.NamedType('response', StatusResponse()),
  183. namedtype.DefaultedNamedType('usesApex', univ.Boolean().subtype(value=1))
  184. )
  185. tamp_status_response = rfc5652.ContentInfo()
  186. tamp_status_response['contentType'] = id_ct_TAMP_statusResponse
  187. tamp_status_response['content'] = TAMPStatusResponse()
  188. # Trust Anchor Update Message
  189. id_ct_TAMP_update = _OID(id_tamp, 3)
  190. class TBSCertificateChangeInfo(univ.Sequence):
  191. pass
  192. TBSCertificateChangeInfo.componentType = namedtype.NamedTypes(
  193. namedtype.OptionalNamedType('serialNumber', CertificateSerialNumber()),
  194. namedtype.OptionalNamedType('signature', AlgorithmIdentifier().subtype(
  195. implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 0))),
  196. namedtype.OptionalNamedType('issuer', Name().subtype(implicitTag=tag.Tag(
  197. tag.tagClassContext, tag.tagFormatSimple, 1))),
  198. namedtype.OptionalNamedType('validity', Validity().subtype(
  199. implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 2))),
  200. namedtype.OptionalNamedType('subject', Name().subtype(implicitTag=tag.Tag(
  201. tag.tagClassContext, tag.tagFormatSimple, 3))),
  202. namedtype.NamedType('subjectPublicKeyInfo', SubjectPublicKeyInfo().subtype(
  203. implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 4))),
  204. namedtype.OptionalNamedType('exts', Extensions().subtype(explicitTag=tag.Tag(
  205. tag.tagClassContext, tag.tagFormatSimple, 5)))
  206. )
  207. class TrustAnchorChangeInfo(univ.Sequence):
  208. pass
  209. TrustAnchorChangeInfo.componentType = namedtype.NamedTypes(
  210. namedtype.NamedType('pubKey', SubjectPublicKeyInfo()),
  211. namedtype.OptionalNamedType('keyId', KeyIdentifier()),
  212. namedtype.OptionalNamedType('taTitle', TrustAnchorTitle()),
  213. namedtype.OptionalNamedType('certPath', CertPathControls()),
  214. namedtype.OptionalNamedType('exts', Extensions().subtype(
  215. implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 1)))
  216. )
  217. class TrustAnchorChangeInfoChoice(univ.Choice):
  218. pass
  219. TrustAnchorChangeInfoChoice.componentType = namedtype.NamedTypes(
  220. namedtype.NamedType('tbsCertChange', TBSCertificateChangeInfo().subtype(
  221. implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatConstructed, 0))),
  222. namedtype.NamedType('taChange', TrustAnchorChangeInfo().subtype(
  223. implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatConstructed, 1)))
  224. )
  225. class TrustAnchorUpdate(univ.Choice):
  226. pass
  227. TrustAnchorUpdate.componentType = namedtype.NamedTypes(
  228. namedtype.NamedType('add', TrustAnchorChoice().subtype(
  229. implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 1))),
  230. namedtype.NamedType('remove', SubjectPublicKeyInfo().subtype(
  231. implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 2))),
  232. namedtype.NamedType('change', TrustAnchorChangeInfoChoice().subtype(
  233. explicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatConstructed, 3)))
  234. )
  235. class TAMPUpdate(univ.Sequence):
  236. pass
  237. TAMPUpdate.componentType = namedtype.NamedTypes(
  238. namedtype.DefaultedNamedType('version',
  239. TAMPVersion().subtype(implicitTag=tag.Tag(tag.tagClassContext,
  240. tag.tagFormatSimple, 0)).subtype(value='v2')),
  241. namedtype.DefaultedNamedType('terse',
  242. TerseOrVerbose().subtype(implicitTag=tag.Tag(tag.tagClassContext,
  243. tag.tagFormatSimple, 1)).subtype(value='verbose')),
  244. namedtype.NamedType('msgRef', TAMPMsgRef()),
  245. namedtype.NamedType('updates',
  246. univ.SequenceOf(componentType=TrustAnchorUpdate()).subtype(
  247. subtypeSpec=constraint.ValueSizeConstraint(1, MAX))),
  248. namedtype.OptionalNamedType('tampSeqNumbers',
  249. TAMPSequenceNumbers().subtype(implicitTag=tag.Tag(
  250. tag.tagClassContext, tag.tagFormatSimple, 2)))
  251. )
  252. tamp_update = rfc5652.ContentInfo()
  253. tamp_update['contentType'] = id_ct_TAMP_update
  254. tamp_update['content'] = TAMPUpdate()
  255. # Trust Anchor Update Confirm Message
  256. id_ct_TAMP_updateConfirm = _OID(id_tamp, 4)
  257. class StatusCode(univ.Enumerated):
  258. pass
  259. StatusCode.namedValues = namedval.NamedValues(
  260. ('success', 0),
  261. ('decodeFailure', 1),
  262. ('badContentInfo', 2),
  263. ('badSignedData', 3),
  264. ('badEncapContent', 4),
  265. ('badCertificate', 5),
  266. ('badSignerInfo', 6),
  267. ('badSignedAttrs', 7),
  268. ('badUnsignedAttrs', 8),
  269. ('missingContent', 9),
  270. ('noTrustAnchor', 10),
  271. ('notAuthorized', 11),
  272. ('badDigestAlgorithm', 12),
  273. ('badSignatureAlgorithm', 13),
  274. ('unsupportedKeySize', 14),
  275. ('unsupportedParameters', 15),
  276. ('signatureFailure', 16),
  277. ('insufficientMemory', 17),
  278. ('unsupportedTAMPMsgType', 18),
  279. ('apexTAMPAnchor', 19),
  280. ('improperTAAddition', 20),
  281. ('seqNumFailure', 21),
  282. ('contingencyPublicKeyDecrypt', 22),
  283. ('incorrectTarget', 23),
  284. ('communityUpdateFailed', 24),
  285. ('trustAnchorNotFound', 25),
  286. ('unsupportedTAAlgorithm', 26),
  287. ('unsupportedTAKeySize', 27),
  288. ('unsupportedContinPubKeyDecryptAlg', 28),
  289. ('missingSignature', 29),
  290. ('resourcesBusy', 30),
  291. ('versionNumberMismatch', 31),
  292. ('missingPolicySet', 32),
  293. ('revokedCertificate', 33),
  294. ('unsupportedTrustAnchorFormat', 34),
  295. ('improperTAChange', 35),
  296. ('malformed', 36),
  297. ('cmsError', 37),
  298. ('unsupportedTargetIdentifier', 38),
  299. ('other', 127)
  300. )
  301. class StatusCodeList(univ.SequenceOf):
  302. pass
  303. StatusCodeList.componentType = StatusCode()
  304. StatusCodeList.subtypeSpec=constraint.ValueSizeConstraint(1, MAX)
  305. class TerseUpdateConfirm(StatusCodeList):
  306. pass
  307. class VerboseUpdateConfirm(univ.Sequence):
  308. pass
  309. VerboseUpdateConfirm.componentType = namedtype.NamedTypes(
  310. namedtype.NamedType('status', StatusCodeList()),
  311. namedtype.NamedType('taInfo', TrustAnchorChoiceList()),
  312. namedtype.OptionalNamedType('tampSeqNumbers', TAMPSequenceNumbers()),
  313. namedtype.DefaultedNamedType('usesApex', univ.Boolean().subtype(value=1))
  314. )
  315. class UpdateConfirm(univ.Choice):
  316. pass
  317. UpdateConfirm.componentType = namedtype.NamedTypes(
  318. namedtype.NamedType('terseConfirm', TerseUpdateConfirm().subtype(
  319. implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 0))),
  320. namedtype.NamedType('verboseConfirm', VerboseUpdateConfirm().subtype(
  321. implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatConstructed, 1)))
  322. )
  323. class TAMPUpdateConfirm(univ.Sequence):
  324. pass
  325. TAMPUpdateConfirm.componentType = namedtype.NamedTypes(
  326. namedtype.DefaultedNamedType('version', TAMPVersion().subtype(
  327. implicitTag=tag.Tag(tag.tagClassContext,
  328. tag.tagFormatSimple, 0)).subtype(value='v2')),
  329. namedtype.NamedType('update', TAMPMsgRef()),
  330. namedtype.NamedType('confirm', UpdateConfirm())
  331. )
  332. tamp_update_confirm = rfc5652.ContentInfo()
  333. tamp_update_confirm['contentType'] = id_ct_TAMP_updateConfirm
  334. tamp_update_confirm['content'] = TAMPUpdateConfirm()
  335. # Apex Trust Anchor Update Message
  336. id_ct_TAMP_apexUpdate = _OID(id_tamp, 5)
  337. class TAMPApexUpdate(univ.Sequence):
  338. pass
  339. TAMPApexUpdate.componentType = namedtype.NamedTypes(
  340. namedtype.DefaultedNamedType('version',
  341. TAMPVersion().subtype(implicitTag=tag.Tag(tag.tagClassContext,
  342. tag.tagFormatSimple, 0)).subtype(value='v2')),
  343. namedtype.DefaultedNamedType('terse',
  344. TerseOrVerbose().subtype(implicitTag=tag.Tag(tag.tagClassContext,
  345. tag.tagFormatSimple, 1)).subtype(value='verbose')),
  346. namedtype.NamedType('msgRef', TAMPMsgRef()),
  347. namedtype.NamedType('clearTrustAnchors', univ.Boolean()),
  348. namedtype.NamedType('clearCommunities', univ.Boolean()),
  349. namedtype.OptionalNamedType('seqNumber', SeqNumber()),
  350. namedtype.NamedType('apexTA', TrustAnchorChoice())
  351. )
  352. tamp_apex_update = rfc5652.ContentInfo()
  353. tamp_apex_update['contentType'] = id_ct_TAMP_apexUpdate
  354. tamp_apex_update['content'] = TAMPApexUpdate()
  355. # Apex Trust Anchor Update Confirm Message
  356. id_ct_TAMP_apexUpdateConfirm = _OID(id_tamp, 6)
  357. class TerseApexUpdateConfirm(StatusCode):
  358. pass
  359. class VerboseApexUpdateConfirm(univ.Sequence):
  360. pass
  361. VerboseApexUpdateConfirm.componentType = namedtype.NamedTypes(
  362. namedtype.NamedType('status', StatusCode()),
  363. namedtype.NamedType('taInfo', TrustAnchorChoiceList()),
  364. namedtype.OptionalNamedType('communities',
  365. CommunityIdentifierList().subtype(implicitTag=tag.Tag(tag.tagClassContext,
  366. tag.tagFormatSimple, 0))),
  367. namedtype.OptionalNamedType('tampSeqNumbers',
  368. TAMPSequenceNumbers().subtype(implicitTag=tag.Tag(tag.tagClassContext,
  369. tag.tagFormatSimple, 1)))
  370. )
  371. class ApexUpdateConfirm(univ.Choice):
  372. pass
  373. ApexUpdateConfirm.componentType = namedtype.NamedTypes(
  374. namedtype.NamedType('terseApexConfirm',
  375. TerseApexUpdateConfirm().subtype(implicitTag=tag.Tag(tag.tagClassContext,
  376. tag.tagFormatSimple, 0))),
  377. namedtype.NamedType('verboseApexConfirm',
  378. VerboseApexUpdateConfirm().subtype(implicitTag=tag.Tag(tag.tagClassContext,
  379. tag.tagFormatConstructed, 1)))
  380. )
  381. class TAMPApexUpdateConfirm(univ.Sequence):
  382. pass
  383. TAMPApexUpdateConfirm.componentType = namedtype.NamedTypes(
  384. namedtype.DefaultedNamedType('version',
  385. TAMPVersion().subtype(implicitTag=tag.Tag(tag.tagClassContext,
  386. tag.tagFormatSimple, 0)).subtype(value='v2')),
  387. namedtype.NamedType('apexReplace', TAMPMsgRef()),
  388. namedtype.NamedType('apexConfirm', ApexUpdateConfirm())
  389. )
  390. tamp_apex_update_confirm = rfc5652.ContentInfo()
  391. tamp_apex_update_confirm['contentType'] = id_ct_TAMP_apexUpdateConfirm
  392. tamp_apex_update_confirm['content'] = TAMPApexUpdateConfirm()
  393. # Community Update Message
  394. id_ct_TAMP_communityUpdate = _OID(id_tamp, 7)
  395. class CommunityUpdates(univ.Sequence):
  396. pass
  397. CommunityUpdates.componentType = namedtype.NamedTypes(
  398. namedtype.OptionalNamedType('remove',
  399. CommunityIdentifierList().subtype(implicitTag=tag.Tag(tag.tagClassContext,
  400. tag.tagFormatSimple, 1))),
  401. namedtype.OptionalNamedType('add',
  402. CommunityIdentifierList().subtype(implicitTag=tag.Tag(tag.tagClassContext,
  403. tag.tagFormatSimple, 2)))
  404. )
  405. class TAMPCommunityUpdate(univ.Sequence):
  406. pass
  407. TAMPCommunityUpdate.componentType = namedtype.NamedTypes(
  408. namedtype.DefaultedNamedType('version',
  409. TAMPVersion().subtype(implicitTag=tag.Tag(tag.tagClassContext,
  410. tag.tagFormatSimple, 0)).subtype(value='v2')),
  411. namedtype.DefaultedNamedType('terse',
  412. TerseOrVerbose().subtype(implicitTag=tag.Tag(tag.tagClassContext,
  413. tag.tagFormatSimple, 1)).subtype(value='verbose')),
  414. namedtype.NamedType('msgRef', TAMPMsgRef()),
  415. namedtype.NamedType('updates', CommunityUpdates())
  416. )
  417. tamp_community_update = rfc5652.ContentInfo()
  418. tamp_community_update['contentType'] = id_ct_TAMP_communityUpdate
  419. tamp_community_update['content'] = TAMPCommunityUpdate()
  420. # Community Update Confirm Message
  421. id_ct_TAMP_communityUpdateConfirm = _OID(id_tamp, 8)
  422. class TerseCommunityConfirm(StatusCode):
  423. pass
  424. class VerboseCommunityConfirm(univ.Sequence):
  425. pass
  426. VerboseCommunityConfirm.componentType = namedtype.NamedTypes(
  427. namedtype.NamedType('status', StatusCode()),
  428. namedtype.OptionalNamedType('communities', CommunityIdentifierList())
  429. )
  430. class CommunityConfirm(univ.Choice):
  431. pass
  432. CommunityConfirm.componentType = namedtype.NamedTypes(
  433. namedtype.NamedType('terseCommConfirm',
  434. TerseCommunityConfirm().subtype(implicitTag=tag.Tag(tag.tagClassContext,
  435. tag.tagFormatSimple, 0))),
  436. namedtype.NamedType('verboseCommConfirm',
  437. VerboseCommunityConfirm().subtype(implicitTag=tag.Tag(tag.tagClassContext,
  438. tag.tagFormatConstructed, 1)))
  439. )
  440. class TAMPCommunityUpdateConfirm(univ.Sequence):
  441. pass
  442. TAMPCommunityUpdateConfirm.componentType = namedtype.NamedTypes(
  443. namedtype.DefaultedNamedType('version',
  444. TAMPVersion().subtype(implicitTag=tag.Tag(tag.tagClassContext,
  445. tag.tagFormatSimple, 0)).subtype(value='v2')),
  446. namedtype.NamedType('update', TAMPMsgRef()),
  447. namedtype.NamedType('commConfirm', CommunityConfirm())
  448. )
  449. tamp_community_update_confirm = rfc5652.ContentInfo()
  450. tamp_community_update_confirm['contentType'] = id_ct_TAMP_communityUpdateConfirm
  451. tamp_community_update_confirm['content'] = TAMPCommunityUpdateConfirm()
  452. # Sequence Number Adjust Message
  453. id_ct_TAMP_seqNumAdjust = _OID(id_tamp, 10)
  454. class SequenceNumberAdjust(univ.Sequence):
  455. pass
  456. SequenceNumberAdjust.componentType = namedtype.NamedTypes(
  457. namedtype.DefaultedNamedType('version',
  458. TAMPVersion().subtype(implicitTag=tag.Tag(tag.tagClassContext,
  459. tag.tagFormatSimple, 0)).subtype(value='v2')),
  460. namedtype.NamedType('msgRef', TAMPMsgRef())
  461. )
  462. tamp_sequence_number_adjust = rfc5652.ContentInfo()
  463. tamp_sequence_number_adjust['contentType'] = id_ct_TAMP_seqNumAdjust
  464. tamp_sequence_number_adjust['content'] = SequenceNumberAdjust()
  465. # Sequence Number Adjust Confirm Message
  466. id_ct_TAMP_seqNumAdjustConfirm = _OID(id_tamp, 11)
  467. class SequenceNumberAdjustConfirm(univ.Sequence):
  468. pass
  469. SequenceNumberAdjustConfirm.componentType = namedtype.NamedTypes(
  470. namedtype.DefaultedNamedType('version',
  471. TAMPVersion().subtype(implicitTag=tag.Tag(tag.tagClassContext,
  472. tag.tagFormatSimple, 0)).subtype(value='v2')),
  473. namedtype.NamedType('adjust', TAMPMsgRef()),
  474. namedtype.NamedType('status', StatusCode())
  475. )
  476. tamp_sequence_number_adjust_confirm = rfc5652.ContentInfo()
  477. tamp_sequence_number_adjust_confirm['contentType'] = id_ct_TAMP_seqNumAdjustConfirm
  478. tamp_sequence_number_adjust_confirm['content'] = SequenceNumberAdjustConfirm()
  479. # TAMP Error Message
  480. id_ct_TAMP_error = _OID(id_tamp, 9)
  481. class TAMPError(univ.Sequence):
  482. pass
  483. TAMPError.componentType = namedtype.NamedTypes(
  484. namedtype.DefaultedNamedType('version',
  485. TAMPVersion().subtype(implicitTag=tag.Tag(tag.tagClassContext,
  486. tag.tagFormatSimple, 0)).subtype(value='v2')),
  487. namedtype.NamedType('msgType', univ.ObjectIdentifier()),
  488. namedtype.NamedType('status', StatusCode()),
  489. namedtype.OptionalNamedType('msgRef', TAMPMsgRef())
  490. )
  491. tamp_error = rfc5652.ContentInfo()
  492. tamp_error['contentType'] = id_ct_TAMP_error
  493. tamp_error['content'] = TAMPError()
  494. # Object Identifier Arc for Attributes
  495. id_attributes = univ.ObjectIdentifier('2.16.840.1.101.2.1.5')
  496. # contingency-public-key-decrypt-key unsigned attribute
  497. id_aa_TAMP_contingencyPublicKeyDecryptKey = _OID(id_attributes, 63)
  498. class PlaintextSymmetricKey(univ.OctetString):
  499. pass
  500. contingency_public_key_decrypt_key = Attribute()
  501. contingency_public_key_decrypt_key['type'] = id_aa_TAMP_contingencyPublicKeyDecryptKey
  502. contingency_public_key_decrypt_key['values'][0] = PlaintextSymmetricKey()
  503. # id-pe-wrappedApexContinKey extension
  504. id_pe_wrappedApexContinKey =univ.ObjectIdentifier('1.3.6.1.5.5.7.1.20')
  505. class ApexContingencyKey(univ.Sequence):
  506. pass
  507. ApexContingencyKey.componentType = namedtype.NamedTypes(
  508. namedtype.NamedType('wrapAlgorithm', AlgorithmIdentifier()),
  509. namedtype.NamedType('wrappedContinPubKey', univ.OctetString())
  510. )
  511. wrappedApexContinKey = Extension()
  512. wrappedApexContinKey['extnID'] = id_pe_wrappedApexContinKey
  513. wrappedApexContinKey['critical'] = 0
  514. wrappedApexContinKey['extnValue'] = univ.OctetString()
  515. # Add to the map of CMS Content Type OIDs to Content Types in
  516. # rfc5652.py
  517. _cmsContentTypesMapUpdate = {
  518. id_ct_TAMP_statusQuery: TAMPStatusQuery(),
  519. id_ct_TAMP_statusResponse: TAMPStatusResponse(),
  520. id_ct_TAMP_update: TAMPUpdate(),
  521. id_ct_TAMP_updateConfirm: TAMPUpdateConfirm(),
  522. id_ct_TAMP_apexUpdate: TAMPApexUpdate(),
  523. id_ct_TAMP_apexUpdateConfirm: TAMPApexUpdateConfirm(),
  524. id_ct_TAMP_communityUpdate: TAMPCommunityUpdate(),
  525. id_ct_TAMP_communityUpdateConfirm: TAMPCommunityUpdateConfirm(),
  526. id_ct_TAMP_seqNumAdjust: SequenceNumberAdjust(),
  527. id_ct_TAMP_seqNumAdjustConfirm: SequenceNumberAdjustConfirm(),
  528. id_ct_TAMP_error: TAMPError(),
  529. }
  530. rfc5652.cmsContentTypesMap.update(_cmsContentTypesMapUpdate)
  531. # Add to the map of CMS Attribute OIDs to Attribute Values in
  532. # rfc5652.py
  533. _cmsAttributesMapUpdate = {
  534. id_aa_TAMP_contingencyPublicKeyDecryptKey: PlaintextSymmetricKey(),
  535. }
  536. rfc5652.cmsAttributesMap.update(_cmsAttributesMapUpdate)
  537. # Add to the map of Certificate Extension OIDs to Extensions in
  538. # rfc5280.py
  539. _certificateExtensionsMap = {
  540. id_pe_wrappedApexContinKey: ApexContingencyKey(),
  541. }
  542. rfc5280.certificateExtensionsMap.update(_certificateExtensionsMap)