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.

rfc3852.py 20KB

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