Development of an internal social media platform with personalised dashboards for students
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.

rfc5652.py 20KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706
  1. # coding: utf-8
  2. #
  3. # This file is part of pyasn1-modules software.
  4. #
  5. # Created by Stanisław Pitucha with asn1ate tool.
  6. # Copyright (c) 2005-2018, Ilya Etingof <etingof@gmail.com>
  7. # License: http://snmplabs.com/pyasn1/license.html
  8. #
  9. # Cryptographic Message Syntax (CMS)
  10. #
  11. # ASN.1 source from:
  12. # http://www.ietf.org/rfc/rfc5652.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 rfc3281
  21. from pyasn1_modules import rfc5280
  22. MAX = float('inf')
  23. def _buildOid(*components):
  24. output = []
  25. for x in tuple(components):
  26. if isinstance(x, univ.ObjectIdentifier):
  27. output.extend(list(x))
  28. else:
  29. output.append(int(x))
  30. return univ.ObjectIdentifier(output)
  31. class AttCertVersionV1(univ.Integer):
  32. pass
  33. AttCertVersionV1.namedValues = namedval.NamedValues(
  34. ('v1', 0)
  35. )
  36. class AttributeCertificateInfoV1(univ.Sequence):
  37. pass
  38. AttributeCertificateInfoV1.componentType = namedtype.NamedTypes(
  39. namedtype.DefaultedNamedType('version', AttCertVersionV1().subtype(value="v1")),
  40. namedtype.NamedType(
  41. 'subject', univ.Choice(
  42. componentType=namedtype.NamedTypes(
  43. namedtype.NamedType('baseCertificateID', rfc3281.IssuerSerial().subtype(explicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 0))),
  44. namedtype.NamedType('subjectName', rfc5280.GeneralNames().subtype(explicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 1)))
  45. )
  46. )
  47. ),
  48. namedtype.NamedType('issuer', rfc5280.GeneralNames()),
  49. namedtype.NamedType('signature', rfc5280.AlgorithmIdentifier()),
  50. namedtype.NamedType('serialNumber', rfc5280.CertificateSerialNumber()),
  51. namedtype.NamedType('attCertValidityPeriod', rfc3281.AttCertValidityPeriod()),
  52. namedtype.NamedType('attributes', univ.SequenceOf(componentType=rfc5280.Attribute())),
  53. namedtype.OptionalNamedType('issuerUniqueID', rfc5280.UniqueIdentifier()),
  54. namedtype.OptionalNamedType('extensions', rfc5280.Extensions())
  55. )
  56. class AttributeCertificateV1(univ.Sequence):
  57. pass
  58. AttributeCertificateV1.componentType = namedtype.NamedTypes(
  59. namedtype.NamedType('acInfo', AttributeCertificateInfoV1()),
  60. namedtype.NamedType('signatureAlgorithm', rfc5280.AlgorithmIdentifier()),
  61. namedtype.NamedType('signature', univ.BitString())
  62. )
  63. class AttributeValue(univ.Any):
  64. pass
  65. class Attribute(univ.Sequence):
  66. pass
  67. Attribute.componentType = namedtype.NamedTypes(
  68. namedtype.NamedType('attrType', univ.ObjectIdentifier()),
  69. namedtype.NamedType('attrValues', univ.SetOf(componentType=AttributeValue()))
  70. )
  71. class SignedAttributes(univ.SetOf):
  72. pass
  73. SignedAttributes.componentType = Attribute()
  74. SignedAttributes.subtypeSpec = constraint.ValueSizeConstraint(1, MAX)
  75. class AttributeCertificateV2(rfc3281.AttributeCertificate):
  76. pass
  77. class OtherKeyAttribute(univ.Sequence):
  78. pass
  79. OtherKeyAttribute.componentType = namedtype.NamedTypes(
  80. namedtype.NamedType('keyAttrId', univ.ObjectIdentifier()),
  81. namedtype.OptionalNamedType('keyAttr', univ.Any())
  82. )
  83. class UnauthAttributes(univ.SetOf):
  84. pass
  85. UnauthAttributes.componentType = Attribute()
  86. UnauthAttributes.subtypeSpec = constraint.ValueSizeConstraint(1, MAX)
  87. id_encryptedData = _buildOid(1, 2, 840, 113549, 1, 7, 6)
  88. class SignatureValue(univ.OctetString):
  89. pass
  90. class IssuerAndSerialNumber(univ.Sequence):
  91. pass
  92. IssuerAndSerialNumber.componentType = namedtype.NamedTypes(
  93. namedtype.NamedType('issuer', rfc5280.Name()),
  94. namedtype.NamedType('serialNumber', rfc5280.CertificateSerialNumber())
  95. )
  96. class SubjectKeyIdentifier(univ.OctetString):
  97. pass
  98. class RecipientKeyIdentifier(univ.Sequence):
  99. pass
  100. RecipientKeyIdentifier.componentType = namedtype.NamedTypes(
  101. namedtype.NamedType('subjectKeyIdentifier', SubjectKeyIdentifier()),
  102. namedtype.OptionalNamedType('date', useful.GeneralizedTime()),
  103. namedtype.OptionalNamedType('other', OtherKeyAttribute())
  104. )
  105. class KeyAgreeRecipientIdentifier(univ.Choice):
  106. pass
  107. KeyAgreeRecipientIdentifier.componentType = namedtype.NamedTypes(
  108. namedtype.NamedType('issuerAndSerialNumber', IssuerAndSerialNumber()),
  109. namedtype.NamedType('rKeyId', RecipientKeyIdentifier().subtype(
  110. implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatConstructed, 0)))
  111. )
  112. class EncryptedKey(univ.OctetString):
  113. pass
  114. class RecipientEncryptedKey(univ.Sequence):
  115. pass
  116. RecipientEncryptedKey.componentType = namedtype.NamedTypes(
  117. namedtype.NamedType('rid', KeyAgreeRecipientIdentifier()),
  118. namedtype.NamedType('encryptedKey', EncryptedKey())
  119. )
  120. class RecipientEncryptedKeys(univ.SequenceOf):
  121. pass
  122. RecipientEncryptedKeys.componentType = RecipientEncryptedKey()
  123. class MessageAuthenticationCode(univ.OctetString):
  124. pass
  125. class CMSVersion(univ.Integer):
  126. pass
  127. CMSVersion.namedValues = namedval.NamedValues(
  128. ('v0', 0),
  129. ('v1', 1),
  130. ('v2', 2),
  131. ('v3', 3),
  132. ('v4', 4),
  133. ('v5', 5)
  134. )
  135. class OtherCertificateFormat(univ.Sequence):
  136. pass
  137. OtherCertificateFormat.componentType = namedtype.NamedTypes(
  138. namedtype.NamedType('otherCertFormat', univ.ObjectIdentifier()),
  139. namedtype.NamedType('otherCert', univ.Any())
  140. )
  141. class ExtendedCertificateInfo(univ.Sequence):
  142. pass
  143. ExtendedCertificateInfo.componentType = namedtype.NamedTypes(
  144. namedtype.NamedType('version', CMSVersion()),
  145. namedtype.NamedType('certificate', rfc5280.Certificate()),
  146. namedtype.NamedType('attributes', UnauthAttributes())
  147. )
  148. class Signature(univ.BitString):
  149. pass
  150. class SignatureAlgorithmIdentifier(rfc5280.AlgorithmIdentifier):
  151. pass
  152. class ExtendedCertificate(univ.Sequence):
  153. pass
  154. ExtendedCertificate.componentType = namedtype.NamedTypes(
  155. namedtype.NamedType('extendedCertificateInfo', ExtendedCertificateInfo()),
  156. namedtype.NamedType('signatureAlgorithm', SignatureAlgorithmIdentifier()),
  157. namedtype.NamedType('signature', Signature())
  158. )
  159. class CertificateChoices(univ.Choice):
  160. pass
  161. CertificateChoices.componentType = namedtype.NamedTypes(
  162. namedtype.NamedType('certificate', rfc5280.Certificate()),
  163. namedtype.NamedType('extendedCertificate', ExtendedCertificate().subtype(
  164. implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatConstructed, 0))),
  165. namedtype.NamedType('v1AttrCert', AttributeCertificateV1().subtype(
  166. implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 1))),
  167. namedtype.NamedType('v2AttrCert', AttributeCertificateV2().subtype(
  168. implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 2))),
  169. namedtype.NamedType('other', OtherCertificateFormat().subtype(
  170. implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatConstructed, 3)))
  171. )
  172. class CertificateSet(univ.SetOf):
  173. pass
  174. CertificateSet.componentType = CertificateChoices()
  175. class OtherRevocationInfoFormat(univ.Sequence):
  176. pass
  177. OtherRevocationInfoFormat.componentType = namedtype.NamedTypes(
  178. namedtype.NamedType('otherRevInfoFormat', univ.ObjectIdentifier()),
  179. namedtype.NamedType('otherRevInfo', univ.Any())
  180. )
  181. class RevocationInfoChoice(univ.Choice):
  182. pass
  183. RevocationInfoChoice.componentType = namedtype.NamedTypes(
  184. namedtype.NamedType('crl', rfc5280.CertificateList()),
  185. namedtype.NamedType('other', OtherRevocationInfoFormat().subtype(
  186. implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatConstructed, 1)))
  187. )
  188. class RevocationInfoChoices(univ.SetOf):
  189. pass
  190. RevocationInfoChoices.componentType = RevocationInfoChoice()
  191. class OriginatorInfo(univ.Sequence):
  192. pass
  193. OriginatorInfo.componentType = namedtype.NamedTypes(
  194. namedtype.OptionalNamedType('certs', CertificateSet().subtype(
  195. implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 0))),
  196. namedtype.OptionalNamedType('crls', RevocationInfoChoices().subtype(
  197. implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 1)))
  198. )
  199. class ContentType(univ.ObjectIdentifier):
  200. pass
  201. class EncryptedContent(univ.OctetString):
  202. pass
  203. class ContentEncryptionAlgorithmIdentifier(rfc5280.AlgorithmIdentifier):
  204. pass
  205. class EncryptedContentInfo(univ.Sequence):
  206. pass
  207. EncryptedContentInfo.componentType = namedtype.NamedTypes(
  208. namedtype.NamedType('contentType', ContentType()),
  209. namedtype.NamedType('contentEncryptionAlgorithm', ContentEncryptionAlgorithmIdentifier()),
  210. namedtype.OptionalNamedType('encryptedContent', EncryptedContent().subtype(
  211. implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 0)))
  212. )
  213. class UnprotectedAttributes(univ.SetOf):
  214. pass
  215. UnprotectedAttributes.componentType = Attribute()
  216. UnprotectedAttributes.subtypeSpec = constraint.ValueSizeConstraint(1, MAX)
  217. class KeyEncryptionAlgorithmIdentifier(rfc5280.AlgorithmIdentifier):
  218. pass
  219. class KEKIdentifier(univ.Sequence):
  220. pass
  221. KEKIdentifier.componentType = namedtype.NamedTypes(
  222. namedtype.NamedType('keyIdentifier', univ.OctetString()),
  223. namedtype.OptionalNamedType('date', useful.GeneralizedTime()),
  224. namedtype.OptionalNamedType('other', OtherKeyAttribute())
  225. )
  226. class KEKRecipientInfo(univ.Sequence):
  227. pass
  228. KEKRecipientInfo.componentType = namedtype.NamedTypes(
  229. namedtype.NamedType('version', CMSVersion()),
  230. namedtype.NamedType('kekid', KEKIdentifier()),
  231. namedtype.NamedType('keyEncryptionAlgorithm', KeyEncryptionAlgorithmIdentifier()),
  232. namedtype.NamedType('encryptedKey', EncryptedKey())
  233. )
  234. class KeyDerivationAlgorithmIdentifier(rfc5280.AlgorithmIdentifier):
  235. pass
  236. class PasswordRecipientInfo(univ.Sequence):
  237. pass
  238. PasswordRecipientInfo.componentType = namedtype.NamedTypes(
  239. namedtype.NamedType('version', CMSVersion()),
  240. namedtype.OptionalNamedType('keyDerivationAlgorithm', KeyDerivationAlgorithmIdentifier().subtype(
  241. implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 0))),
  242. namedtype.NamedType('keyEncryptionAlgorithm', KeyEncryptionAlgorithmIdentifier()),
  243. namedtype.NamedType('encryptedKey', EncryptedKey())
  244. )
  245. class RecipientIdentifier(univ.Choice):
  246. pass
  247. RecipientIdentifier.componentType = namedtype.NamedTypes(
  248. namedtype.NamedType('issuerAndSerialNumber', IssuerAndSerialNumber()),
  249. namedtype.NamedType('subjectKeyIdentifier', SubjectKeyIdentifier().subtype(
  250. implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 0)))
  251. )
  252. class KeyTransRecipientInfo(univ.Sequence):
  253. pass
  254. KeyTransRecipientInfo.componentType = namedtype.NamedTypes(
  255. namedtype.NamedType('version', CMSVersion()),
  256. namedtype.NamedType('rid', RecipientIdentifier()),
  257. namedtype.NamedType('keyEncryptionAlgorithm', KeyEncryptionAlgorithmIdentifier()),
  258. namedtype.NamedType('encryptedKey', EncryptedKey())
  259. )
  260. class UserKeyingMaterial(univ.OctetString):
  261. pass
  262. class OriginatorPublicKey(univ.Sequence):
  263. pass
  264. OriginatorPublicKey.componentType = namedtype.NamedTypes(
  265. namedtype.NamedType('algorithm', rfc5280.AlgorithmIdentifier()),
  266. namedtype.NamedType('publicKey', univ.BitString())
  267. )
  268. class OriginatorIdentifierOrKey(univ.Choice):
  269. pass
  270. OriginatorIdentifierOrKey.componentType = namedtype.NamedTypes(
  271. namedtype.NamedType('issuerAndSerialNumber', IssuerAndSerialNumber()),
  272. namedtype.NamedType('subjectKeyIdentifier', SubjectKeyIdentifier().subtype(
  273. implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 0))),
  274. namedtype.NamedType('originatorKey', OriginatorPublicKey().subtype(
  275. implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatConstructed, 1)))
  276. )
  277. class KeyAgreeRecipientInfo(univ.Sequence):
  278. pass
  279. KeyAgreeRecipientInfo.componentType = namedtype.NamedTypes(
  280. namedtype.NamedType('version', CMSVersion()),
  281. namedtype.NamedType('originator', OriginatorIdentifierOrKey().subtype(
  282. explicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatConstructed, 0))),
  283. namedtype.OptionalNamedType('ukm', UserKeyingMaterial().subtype(
  284. explicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 1))),
  285. namedtype.NamedType('keyEncryptionAlgorithm', KeyEncryptionAlgorithmIdentifier()),
  286. namedtype.NamedType('recipientEncryptedKeys', RecipientEncryptedKeys())
  287. )
  288. class OtherRecipientInfo(univ.Sequence):
  289. pass
  290. OtherRecipientInfo.componentType = namedtype.NamedTypes(
  291. namedtype.NamedType('oriType', univ.ObjectIdentifier()),
  292. namedtype.NamedType('oriValue', univ.Any())
  293. )
  294. class RecipientInfo(univ.Choice):
  295. pass
  296. RecipientInfo.componentType = namedtype.NamedTypes(
  297. namedtype.NamedType('ktri', KeyTransRecipientInfo()),
  298. namedtype.NamedType('kari', KeyAgreeRecipientInfo().subtype(
  299. implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatConstructed, 1))),
  300. namedtype.NamedType('kekri', KEKRecipientInfo().subtype(
  301. implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatConstructed, 2))),
  302. namedtype.NamedType('pwri', PasswordRecipientInfo().subtype(
  303. implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatConstructed, 3))),
  304. namedtype.NamedType('ori', OtherRecipientInfo().subtype(
  305. implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatConstructed, 4)))
  306. )
  307. class RecipientInfos(univ.SetOf):
  308. pass
  309. RecipientInfos.componentType = RecipientInfo()
  310. RecipientInfos.subtypeSpec = constraint.ValueSizeConstraint(1, MAX)
  311. class EnvelopedData(univ.Sequence):
  312. pass
  313. EnvelopedData.componentType = namedtype.NamedTypes(
  314. namedtype.NamedType('version', CMSVersion()),
  315. namedtype.OptionalNamedType('originatorInfo', OriginatorInfo().subtype(
  316. implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatConstructed, 0))),
  317. namedtype.NamedType('recipientInfos', RecipientInfos()),
  318. namedtype.NamedType('encryptedContentInfo', EncryptedContentInfo()),
  319. namedtype.OptionalNamedType('unprotectedAttrs', UnprotectedAttributes().subtype(
  320. implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 1)))
  321. )
  322. class DigestAlgorithmIdentifier(rfc5280.AlgorithmIdentifier):
  323. pass
  324. id_ct_contentInfo = _buildOid(1, 2, 840, 113549, 1, 9, 16, 1, 6)
  325. id_digestedData = _buildOid(1, 2, 840, 113549, 1, 7, 5)
  326. class EncryptedData(univ.Sequence):
  327. pass
  328. EncryptedData.componentType = namedtype.NamedTypes(
  329. namedtype.NamedType('version', CMSVersion()),
  330. namedtype.NamedType('encryptedContentInfo', EncryptedContentInfo()),
  331. namedtype.OptionalNamedType('unprotectedAttrs', UnprotectedAttributes().subtype(
  332. implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 1)))
  333. )
  334. id_messageDigest = _buildOid(1, 2, 840, 113549, 1, 9, 4)
  335. id_signedData = _buildOid(1, 2, 840, 113549, 1, 7, 2)
  336. class MessageAuthenticationCodeAlgorithm(rfc5280.AlgorithmIdentifier):
  337. pass
  338. class UnsignedAttributes(univ.SetOf):
  339. pass
  340. UnsignedAttributes.componentType = Attribute()
  341. UnsignedAttributes.subtypeSpec = constraint.ValueSizeConstraint(1, MAX)
  342. class SignerIdentifier(univ.Choice):
  343. pass
  344. SignerIdentifier.componentType = namedtype.NamedTypes(
  345. namedtype.NamedType('issuerAndSerialNumber', IssuerAndSerialNumber()),
  346. namedtype.NamedType('subjectKeyIdentifier', SubjectKeyIdentifier().subtype(
  347. implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 0)))
  348. )
  349. class SignerInfo(univ.Sequence):
  350. pass
  351. SignerInfo.componentType = namedtype.NamedTypes(
  352. namedtype.NamedType('version', CMSVersion()),
  353. namedtype.NamedType('sid', SignerIdentifier()),
  354. namedtype.NamedType('digestAlgorithm', DigestAlgorithmIdentifier()),
  355. namedtype.OptionalNamedType('signedAttrs', SignedAttributes().subtype(
  356. implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 0))),
  357. namedtype.NamedType('signatureAlgorithm', SignatureAlgorithmIdentifier()),
  358. namedtype.NamedType('signature', SignatureValue()),
  359. namedtype.OptionalNamedType('unsignedAttrs', UnsignedAttributes().subtype(
  360. implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 1)))
  361. )
  362. class SignerInfos(univ.SetOf):
  363. pass
  364. SignerInfos.componentType = SignerInfo()
  365. class Countersignature(SignerInfo):
  366. pass
  367. class ContentInfo(univ.Sequence):
  368. pass
  369. ContentInfo.componentType = namedtype.NamedTypes(
  370. namedtype.NamedType('contentType', ContentType()),
  371. namedtype.NamedType('content', univ.Any().subtype(explicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 0)))
  372. )
  373. class EncapsulatedContentInfo(univ.Sequence):
  374. pass
  375. EncapsulatedContentInfo.componentType = namedtype.NamedTypes(
  376. namedtype.NamedType('eContentType', ContentType()),
  377. namedtype.OptionalNamedType('eContent', univ.OctetString().subtype(
  378. explicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 0)))
  379. )
  380. id_countersignature = _buildOid(1, 2, 840, 113549, 1, 9, 6)
  381. id_data = _buildOid(1, 2, 840, 113549, 1, 7, 1)
  382. class MessageDigest(univ.OctetString):
  383. pass
  384. class AuthAttributes(univ.SetOf):
  385. pass
  386. AuthAttributes.componentType = Attribute()
  387. AuthAttributes.subtypeSpec = constraint.ValueSizeConstraint(1, MAX)
  388. class Time(univ.Choice):
  389. pass
  390. Time.componentType = namedtype.NamedTypes(
  391. namedtype.NamedType('utcTime', useful.UTCTime()),
  392. namedtype.NamedType('generalTime', useful.GeneralizedTime())
  393. )
  394. class AuthenticatedData(univ.Sequence):
  395. pass
  396. AuthenticatedData.componentType = namedtype.NamedTypes(
  397. namedtype.NamedType('version', CMSVersion()),
  398. namedtype.OptionalNamedType('originatorInfo', OriginatorInfo().subtype(
  399. implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatConstructed, 0))),
  400. namedtype.NamedType('recipientInfos', RecipientInfos()),
  401. namedtype.NamedType('macAlgorithm', MessageAuthenticationCodeAlgorithm()),
  402. namedtype.OptionalNamedType('digestAlgorithm', DigestAlgorithmIdentifier().subtype(
  403. implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 1))),
  404. namedtype.NamedType('encapContentInfo', EncapsulatedContentInfo()),
  405. namedtype.OptionalNamedType('authAttrs', AuthAttributes().subtype(
  406. implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 2))),
  407. namedtype.NamedType('mac', MessageAuthenticationCode()),
  408. namedtype.OptionalNamedType('unauthAttrs', UnauthAttributes().subtype(
  409. implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 3)))
  410. )
  411. id_contentType = _buildOid(1, 2, 840, 113549, 1, 9, 3)
  412. class ExtendedCertificateOrCertificate(univ.Choice):
  413. pass
  414. ExtendedCertificateOrCertificate.componentType = namedtype.NamedTypes(
  415. namedtype.NamedType('certificate', rfc5280.Certificate()),
  416. namedtype.NamedType('extendedCertificate', ExtendedCertificate().subtype(
  417. implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatConstructed, 0)))
  418. )
  419. class Digest(univ.OctetString):
  420. pass
  421. class DigestedData(univ.Sequence):
  422. pass
  423. DigestedData.componentType = namedtype.NamedTypes(
  424. namedtype.NamedType('version', CMSVersion()),
  425. namedtype.NamedType('digestAlgorithm', DigestAlgorithmIdentifier()),
  426. namedtype.NamedType('encapContentInfo', EncapsulatedContentInfo()),
  427. namedtype.NamedType('digest', Digest())
  428. )
  429. id_envelopedData = _buildOid(1, 2, 840, 113549, 1, 7, 3)
  430. class DigestAlgorithmIdentifiers(univ.SetOf):
  431. pass
  432. DigestAlgorithmIdentifiers.componentType = DigestAlgorithmIdentifier()
  433. class SignedData(univ.Sequence):
  434. pass
  435. SignedData.componentType = namedtype.NamedTypes(
  436. namedtype.NamedType('version', CMSVersion()),
  437. namedtype.NamedType('digestAlgorithms', DigestAlgorithmIdentifiers()),
  438. namedtype.NamedType('encapContentInfo', EncapsulatedContentInfo()),
  439. namedtype.OptionalNamedType('certificates', CertificateSet().subtype(
  440. implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 0))),
  441. namedtype.OptionalNamedType('crls', RevocationInfoChoices().subtype(
  442. implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 1))),
  443. namedtype.NamedType('signerInfos', SignerInfos())
  444. )
  445. id_signingTime = _buildOid(1, 2, 840, 113549, 1, 9, 5)
  446. class SigningTime(Time):
  447. pass
  448. id_ct_authData = _buildOid(1, 2, 840, 113549, 1, 9, 16, 1, 2)