rfc3280.py 45 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537
  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-2017, Ilya Etingof <etingof@gmail.com>
  7. # License: http://pyasn1.sf.net/license.html
  8. #
  9. # Internet X.509 Public Key Infrastructure Certificate and Certificate
  10. # Revocation List (CRL) Profile
  11. #
  12. # ASN.1 source from:
  13. # http://www.ietf.org/rfc/rfc3280.txt
  14. #
  15. from pyasn1.type import univ, char, namedtype, namedval, tag, constraint, useful
  16. MAX = 64
  17. def _OID(*components):
  18. output = []
  19. for x in tuple(components):
  20. if isinstance(x, univ.ObjectIdentifier):
  21. output.extend(list(x))
  22. else:
  23. output.append(int(x))
  24. return univ.ObjectIdentifier(output)
  25. unformatted_postal_address = univ.Integer(16)
  26. ub_organizational_units = univ.Integer(4)
  27. ub_organizational_unit_name_length = univ.Integer(32)
  28. class OrganizationalUnitName(char.PrintableString):
  29. pass
  30. OrganizationalUnitName.subtypeSpec = constraint.ValueSizeConstraint(1, ub_organizational_unit_name_length)
  31. class OrganizationalUnitNames(univ.SequenceOf):
  32. pass
  33. OrganizationalUnitNames.componentType = OrganizationalUnitName()
  34. OrganizationalUnitNames.subtypeSpec = constraint.ValueSizeConstraint(1, ub_organizational_units)
  35. class AttributeType(univ.ObjectIdentifier):
  36. pass
  37. id_at = _OID(2, 5, 4)
  38. id_at_name = _OID(id_at, 41)
  39. ub_pds_parameter_length = univ.Integer(30)
  40. class PDSParameter(univ.Set):
  41. pass
  42. PDSParameter.componentType = namedtype.NamedTypes(
  43. namedtype.OptionalNamedType('printable-string', char.PrintableString().subtype(
  44. subtypeSpec=constraint.ValueSizeConstraint(1, ub_pds_parameter_length))),
  45. namedtype.OptionalNamedType('teletex-string', char.TeletexString().subtype(
  46. subtypeSpec=constraint.ValueSizeConstraint(1, ub_pds_parameter_length)))
  47. )
  48. class PhysicalDeliveryOrganizationName(PDSParameter):
  49. pass
  50. ub_organization_name_length = univ.Integer(64)
  51. ub_domain_defined_attribute_type_length = univ.Integer(8)
  52. ub_domain_defined_attribute_value_length = univ.Integer(128)
  53. class TeletexDomainDefinedAttribute(univ.Sequence):
  54. pass
  55. TeletexDomainDefinedAttribute.componentType = namedtype.NamedTypes(
  56. namedtype.NamedType('type', char.TeletexString().subtype(
  57. subtypeSpec=constraint.ValueSizeConstraint(1, ub_domain_defined_attribute_type_length))),
  58. namedtype.NamedType('value', char.TeletexString().subtype(
  59. subtypeSpec=constraint.ValueSizeConstraint(1, ub_domain_defined_attribute_value_length)))
  60. )
  61. id_pkix = _OID(1, 3, 6, 1, 5, 5, 7)
  62. id_qt = _OID(id_pkix, 2)
  63. class PresentationAddress(univ.Sequence):
  64. pass
  65. PresentationAddress.componentType = namedtype.NamedTypes(
  66. namedtype.OptionalNamedType('pSelector', univ.OctetString().subtype(
  67. explicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 0))),
  68. namedtype.OptionalNamedType('sSelector', univ.OctetString().subtype(
  69. explicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 1))),
  70. namedtype.OptionalNamedType('tSelector', univ.OctetString().subtype(
  71. explicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 2))),
  72. namedtype.NamedType('nAddresses', univ.SetOf(componentType=univ.OctetString()).subtype(
  73. explicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 3)))
  74. )
  75. class AlgorithmIdentifier(univ.Sequence):
  76. pass
  77. AlgorithmIdentifier.componentType = namedtype.NamedTypes(
  78. namedtype.NamedType('algorithm', univ.ObjectIdentifier()),
  79. namedtype.OptionalNamedType('parameters', univ.Any())
  80. )
  81. class UniqueIdentifier(univ.BitString):
  82. pass
  83. class Extension(univ.Sequence):
  84. pass
  85. Extension.componentType = namedtype.NamedTypes(
  86. namedtype.NamedType('extnID', univ.ObjectIdentifier()),
  87. namedtype.DefaultedNamedType('critical', univ.Boolean().subtype(value=0)),
  88. namedtype.NamedType('extnValue', univ.OctetString())
  89. )
  90. class Extensions(univ.SequenceOf):
  91. pass
  92. Extensions.componentType = Extension()
  93. Extensions.subtypeSpec = constraint.ValueSizeConstraint(1, MAX)
  94. class CertificateSerialNumber(univ.Integer):
  95. pass
  96. class SubjectPublicKeyInfo(univ.Sequence):
  97. pass
  98. SubjectPublicKeyInfo.componentType = namedtype.NamedTypes(
  99. namedtype.NamedType('algorithm', AlgorithmIdentifier()),
  100. namedtype.NamedType('subjectPublicKey', univ.BitString())
  101. )
  102. class Time(univ.Choice):
  103. pass
  104. Time.componentType = namedtype.NamedTypes(
  105. namedtype.NamedType('utcTime', useful.UTCTime()),
  106. namedtype.NamedType('generalTime', useful.GeneralizedTime())
  107. )
  108. class Validity(univ.Sequence):
  109. pass
  110. Validity.componentType = namedtype.NamedTypes(
  111. namedtype.NamedType('notBefore', Time()),
  112. namedtype.NamedType('notAfter', Time())
  113. )
  114. class Version(univ.Integer):
  115. pass
  116. Version.namedValues = namedval.NamedValues(
  117. ('v1', 0),
  118. ('v2', 1),
  119. ('v3', 2)
  120. )
  121. class AttributeValue(univ.Any):
  122. pass
  123. class AttributeTypeAndValue(univ.Sequence):
  124. pass
  125. AttributeTypeAndValue.componentType = namedtype.NamedTypes(
  126. namedtype.NamedType('type', AttributeType()),
  127. namedtype.NamedType('value', AttributeValue())
  128. )
  129. class RelativeDistinguishedName(univ.SetOf):
  130. pass
  131. RelativeDistinguishedName.componentType = AttributeTypeAndValue()
  132. RelativeDistinguishedName.subtypeSpec = constraint.ValueSizeConstraint(1, MAX)
  133. class RDNSequence(univ.SequenceOf):
  134. pass
  135. RDNSequence.componentType = RelativeDistinguishedName()
  136. class Name(univ.Choice):
  137. pass
  138. Name.componentType = namedtype.NamedTypes(
  139. namedtype.NamedType('rdnSequence', RDNSequence())
  140. )
  141. class TBSCertificate(univ.Sequence):
  142. pass
  143. TBSCertificate.componentType = namedtype.NamedTypes(
  144. namedtype.DefaultedNamedType('version',
  145. Version().subtype(explicitTag=tag.Tag(tag.tagClassContext,
  146. tag.tagFormatSimple, 0)).subtype(value="v1")),
  147. namedtype.NamedType('serialNumber', CertificateSerialNumber()),
  148. namedtype.NamedType('signature', AlgorithmIdentifier()),
  149. namedtype.NamedType('issuer', Name()),
  150. namedtype.NamedType('validity', Validity()),
  151. namedtype.NamedType('subject', Name()),
  152. namedtype.NamedType('subjectPublicKeyInfo', SubjectPublicKeyInfo()),
  153. namedtype.OptionalNamedType('issuerUniqueID', UniqueIdentifier().subtype(
  154. implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 1))),
  155. namedtype.OptionalNamedType('subjectUniqueID', UniqueIdentifier().subtype(
  156. implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 2))),
  157. namedtype.OptionalNamedType('extensions',
  158. Extensions().subtype(explicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 3)))
  159. )
  160. class Certificate(univ.Sequence):
  161. pass
  162. Certificate.componentType = namedtype.NamedTypes(
  163. namedtype.NamedType('tbsCertificate', TBSCertificate()),
  164. namedtype.NamedType('signatureAlgorithm', AlgorithmIdentifier()),
  165. namedtype.NamedType('signature', univ.BitString())
  166. )
  167. ub_surname_length = univ.Integer(40)
  168. class TeletexOrganizationName(char.TeletexString):
  169. pass
  170. TeletexOrganizationName.subtypeSpec = constraint.ValueSizeConstraint(1, ub_organization_name_length)
  171. ub_e163_4_sub_address_length = univ.Integer(40)
  172. teletex_common_name = univ.Integer(2)
  173. ub_country_name_alpha_length = univ.Integer(2)
  174. ub_country_name_numeric_length = univ.Integer(3)
  175. class CountryName(univ.Choice):
  176. pass
  177. CountryName.tagSet = univ.Choice.tagSet.tagExplicitly(tag.Tag(tag.tagClassApplication, tag.tagFormatConstructed, 1))
  178. CountryName.componentType = namedtype.NamedTypes(
  179. namedtype.NamedType('x121-dcc-code', char.NumericString().subtype(
  180. subtypeSpec=constraint.ValueSizeConstraint(ub_country_name_numeric_length, ub_country_name_numeric_length))),
  181. namedtype.NamedType('iso-3166-alpha2-code', char.PrintableString().subtype(
  182. subtypeSpec=constraint.ValueSizeConstraint(ub_country_name_alpha_length, ub_country_name_alpha_length)))
  183. )
  184. extension_OR_address_components = univ.Integer(12)
  185. id_at_dnQualifier = _OID(id_at, 46)
  186. ub_e163_4_number_length = univ.Integer(15)
  187. class ExtendedNetworkAddress(univ.Choice):
  188. pass
  189. ExtendedNetworkAddress.componentType = namedtype.NamedTypes(
  190. namedtype.NamedType('e163-4-address', univ.Sequence(componentType=namedtype.NamedTypes(
  191. namedtype.NamedType('number', char.NumericString().subtype(
  192. subtypeSpec=constraint.ValueSizeConstraint(1, ub_e163_4_number_length)).subtype(
  193. implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 0))),
  194. namedtype.OptionalNamedType('sub-address', char.NumericString().subtype(
  195. subtypeSpec=constraint.ValueSizeConstraint(1, ub_e163_4_sub_address_length)).subtype(
  196. implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 1)))
  197. ))
  198. ),
  199. namedtype.NamedType('psap-address', PresentationAddress().subtype(
  200. implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatConstructed, 0)))
  201. )
  202. terminal_type = univ.Integer(23)
  203. id_domainComponent = _OID(0, 9, 2342, 19200300, 100, 1, 25)
  204. ub_state_name = univ.Integer(128)
  205. class X520StateOrProvinceName(univ.Choice):
  206. pass
  207. X520StateOrProvinceName.componentType = namedtype.NamedTypes(
  208. namedtype.NamedType('teletexString',
  209. char.TeletexString().subtype(subtypeSpec=constraint.ValueSizeConstraint(1, ub_state_name))),
  210. namedtype.NamedType('printableString',
  211. char.PrintableString().subtype(subtypeSpec=constraint.ValueSizeConstraint(1, ub_state_name))),
  212. namedtype.NamedType('universalString',
  213. char.UniversalString().subtype(subtypeSpec=constraint.ValueSizeConstraint(1, ub_state_name))),
  214. namedtype.NamedType('utf8String',
  215. char.UTF8String().subtype(subtypeSpec=constraint.ValueSizeConstraint(1, ub_state_name))),
  216. namedtype.NamedType('bmpString',
  217. char.BMPString().subtype(subtypeSpec=constraint.ValueSizeConstraint(1, ub_state_name)))
  218. )
  219. ub_organization_name = univ.Integer(64)
  220. class X520OrganizationName(univ.Choice):
  221. pass
  222. X520OrganizationName.componentType = namedtype.NamedTypes(
  223. namedtype.NamedType('teletexString', char.TeletexString().subtype(
  224. subtypeSpec=constraint.ValueSizeConstraint(1, ub_organization_name))),
  225. namedtype.NamedType('printableString', char.PrintableString().subtype(
  226. subtypeSpec=constraint.ValueSizeConstraint(1, ub_organization_name))),
  227. namedtype.NamedType('universalString', char.UniversalString().subtype(
  228. subtypeSpec=constraint.ValueSizeConstraint(1, ub_organization_name))),
  229. namedtype.NamedType('utf8String',
  230. char.UTF8String().subtype(subtypeSpec=constraint.ValueSizeConstraint(1, ub_organization_name))),
  231. namedtype.NamedType('bmpString',
  232. char.BMPString().subtype(subtypeSpec=constraint.ValueSizeConstraint(1, ub_organization_name)))
  233. )
  234. ub_emailaddress_length = univ.Integer(128)
  235. class ExtensionPhysicalDeliveryAddressComponents(PDSParameter):
  236. pass
  237. id_at_surname = _OID(id_at, 4)
  238. ub_common_name_length = univ.Integer(64)
  239. id_ad = _OID(id_pkix, 48)
  240. ub_numeric_user_id_length = univ.Integer(32)
  241. class NumericUserIdentifier(char.NumericString):
  242. pass
  243. NumericUserIdentifier.subtypeSpec = constraint.ValueSizeConstraint(1, ub_numeric_user_id_length)
  244. class OrganizationName(char.PrintableString):
  245. pass
  246. OrganizationName.subtypeSpec = constraint.ValueSizeConstraint(1, ub_organization_name_length)
  247. ub_domain_name_length = univ.Integer(16)
  248. class AdministrationDomainName(univ.Choice):
  249. pass
  250. AdministrationDomainName.tagSet = univ.Choice.tagSet.tagExplicitly(
  251. tag.Tag(tag.tagClassApplication, tag.tagFormatConstructed, 2))
  252. AdministrationDomainName.componentType = namedtype.NamedTypes(
  253. namedtype.NamedType('numeric', char.NumericString().subtype(
  254. subtypeSpec=constraint.ValueSizeConstraint(0, ub_domain_name_length))),
  255. namedtype.NamedType('printable', char.PrintableString().subtype(
  256. subtypeSpec=constraint.ValueSizeConstraint(0, ub_domain_name_length)))
  257. )
  258. class PrivateDomainName(univ.Choice):
  259. pass
  260. PrivateDomainName.componentType = namedtype.NamedTypes(
  261. namedtype.NamedType('numeric', char.NumericString().subtype(
  262. subtypeSpec=constraint.ValueSizeConstraint(1, ub_domain_name_length))),
  263. namedtype.NamedType('printable', char.PrintableString().subtype(
  264. subtypeSpec=constraint.ValueSizeConstraint(1, ub_domain_name_length)))
  265. )
  266. ub_generation_qualifier_length = univ.Integer(3)
  267. ub_given_name_length = univ.Integer(16)
  268. ub_initials_length = univ.Integer(5)
  269. class PersonalName(univ.Set):
  270. pass
  271. PersonalName.componentType = namedtype.NamedTypes(
  272. namedtype.NamedType('surname', char.PrintableString().subtype(
  273. subtypeSpec=constraint.ValueSizeConstraint(1, ub_surname_length)).subtype(
  274. implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 0))),
  275. namedtype.OptionalNamedType('given-name', char.PrintableString().subtype(
  276. subtypeSpec=constraint.ValueSizeConstraint(1, ub_given_name_length)).subtype(
  277. implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 1))),
  278. namedtype.OptionalNamedType('initials', char.PrintableString().subtype(
  279. subtypeSpec=constraint.ValueSizeConstraint(1, ub_initials_length)).subtype(
  280. implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 2))),
  281. namedtype.OptionalNamedType('generation-qualifier', char.PrintableString().subtype(
  282. subtypeSpec=constraint.ValueSizeConstraint(1, ub_generation_qualifier_length)).subtype(
  283. implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 3)))
  284. )
  285. ub_terminal_id_length = univ.Integer(24)
  286. class TerminalIdentifier(char.PrintableString):
  287. pass
  288. TerminalIdentifier.subtypeSpec = constraint.ValueSizeConstraint(1, ub_terminal_id_length)
  289. ub_x121_address_length = univ.Integer(16)
  290. class X121Address(char.NumericString):
  291. pass
  292. X121Address.subtypeSpec = constraint.ValueSizeConstraint(1, ub_x121_address_length)
  293. class NetworkAddress(X121Address):
  294. pass
  295. class BuiltInStandardAttributes(univ.Sequence):
  296. pass
  297. BuiltInStandardAttributes.componentType = namedtype.NamedTypes(
  298. namedtype.OptionalNamedType('country-name', CountryName()),
  299. namedtype.OptionalNamedType('administration-domain-name', AdministrationDomainName()),
  300. namedtype.OptionalNamedType('network-address', NetworkAddress().subtype(
  301. implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 0))),
  302. namedtype.OptionalNamedType('terminal-identifier', TerminalIdentifier().subtype(
  303. implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 1))),
  304. namedtype.OptionalNamedType('private-domain-name', PrivateDomainName().subtype(
  305. explicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatConstructed, 2))),
  306. namedtype.OptionalNamedType('organization-name', OrganizationName().subtype(
  307. implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 3))),
  308. namedtype.OptionalNamedType('numeric-user-identifier', NumericUserIdentifier().subtype(
  309. implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 4))),
  310. namedtype.OptionalNamedType('personal-name', PersonalName().subtype(
  311. implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatConstructed, 5))),
  312. namedtype.OptionalNamedType('organizational-unit-names', OrganizationalUnitNames().subtype(
  313. implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 6)))
  314. )
  315. ub_domain_defined_attributes = univ.Integer(4)
  316. class BuiltInDomainDefinedAttribute(univ.Sequence):
  317. pass
  318. BuiltInDomainDefinedAttribute.componentType = namedtype.NamedTypes(
  319. namedtype.NamedType('type', char.PrintableString().subtype(
  320. subtypeSpec=constraint.ValueSizeConstraint(1, ub_domain_defined_attribute_type_length))),
  321. namedtype.NamedType('value', char.PrintableString().subtype(
  322. subtypeSpec=constraint.ValueSizeConstraint(1, ub_domain_defined_attribute_value_length)))
  323. )
  324. class BuiltInDomainDefinedAttributes(univ.SequenceOf):
  325. pass
  326. BuiltInDomainDefinedAttributes.componentType = BuiltInDomainDefinedAttribute()
  327. BuiltInDomainDefinedAttributes.subtypeSpec = constraint.ValueSizeConstraint(1, ub_domain_defined_attributes)
  328. ub_extension_attributes = univ.Integer(256)
  329. class ExtensionAttribute(univ.Sequence):
  330. pass
  331. ExtensionAttribute.componentType = namedtype.NamedTypes(
  332. namedtype.NamedType('extension-attribute-type', univ.Integer().subtype(
  333. subtypeSpec=constraint.ValueRangeConstraint(0, ub_extension_attributes)).subtype(
  334. implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 0))),
  335. namedtype.NamedType('extension-attribute-value',
  336. univ.Any().subtype(explicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 1)))
  337. )
  338. class ExtensionAttributes(univ.SetOf):
  339. pass
  340. ExtensionAttributes.componentType = ExtensionAttribute()
  341. ExtensionAttributes.subtypeSpec = constraint.ValueSizeConstraint(1, ub_extension_attributes)
  342. class ORAddress(univ.Sequence):
  343. pass
  344. ORAddress.componentType = namedtype.NamedTypes(
  345. namedtype.NamedType('built-in-standard-attributes', BuiltInStandardAttributes()),
  346. namedtype.OptionalNamedType('built-in-domain-defined-attributes', BuiltInDomainDefinedAttributes()),
  347. namedtype.OptionalNamedType('extension-attributes', ExtensionAttributes())
  348. )
  349. id_pe = _OID(id_pkix, 1)
  350. ub_title = univ.Integer(64)
  351. class X520Title(univ.Choice):
  352. pass
  353. X520Title.componentType = namedtype.NamedTypes(
  354. namedtype.NamedType('teletexString',
  355. char.TeletexString().subtype(subtypeSpec=constraint.ValueSizeConstraint(1, ub_title))),
  356. namedtype.NamedType('printableString',
  357. char.PrintableString().subtype(subtypeSpec=constraint.ValueSizeConstraint(1, ub_title))),
  358. namedtype.NamedType('universalString',
  359. char.UniversalString().subtype(subtypeSpec=constraint.ValueSizeConstraint(1, ub_title))),
  360. namedtype.NamedType('utf8String',
  361. char.UTF8String().subtype(subtypeSpec=constraint.ValueSizeConstraint(1, ub_title))),
  362. namedtype.NamedType('bmpString', char.BMPString().subtype(subtypeSpec=constraint.ValueSizeConstraint(1, ub_title)))
  363. )
  364. id_at_organizationalUnitName = _OID(id_at, 11)
  365. class EmailAddress(char.IA5String):
  366. pass
  367. EmailAddress.subtypeSpec = constraint.ValueSizeConstraint(1, ub_emailaddress_length)
  368. physical_delivery_country_name = univ.Integer(8)
  369. id_at_givenName = _OID(id_at, 42)
  370. class TeletexCommonName(char.TeletexString):
  371. pass
  372. TeletexCommonName.subtypeSpec = constraint.ValueSizeConstraint(1, ub_common_name_length)
  373. id_qt_cps = _OID(id_qt, 1)
  374. class LocalPostalAttributes(PDSParameter):
  375. pass
  376. class StreetAddress(PDSParameter):
  377. pass
  378. id_kp = _OID(id_pkix, 3)
  379. class DirectoryString(univ.Choice):
  380. pass
  381. DirectoryString.componentType = namedtype.NamedTypes(
  382. namedtype.NamedType('teletexString',
  383. char.TeletexString().subtype(subtypeSpec=constraint.ValueSizeConstraint(1, MAX))),
  384. namedtype.NamedType('printableString',
  385. char.PrintableString().subtype(subtypeSpec=constraint.ValueSizeConstraint(1, MAX))),
  386. namedtype.NamedType('universalString',
  387. char.UniversalString().subtype(subtypeSpec=constraint.ValueSizeConstraint(1, MAX))),
  388. namedtype.NamedType('utf8String', char.UTF8String().subtype(subtypeSpec=constraint.ValueSizeConstraint(1, MAX))),
  389. namedtype.NamedType('bmpString', char.BMPString().subtype(subtypeSpec=constraint.ValueSizeConstraint(1, MAX)))
  390. )
  391. class DomainComponent(char.IA5String):
  392. pass
  393. id_at_initials = _OID(id_at, 43)
  394. id_qt_unotice = _OID(id_qt, 2)
  395. ub_pds_name_length = univ.Integer(16)
  396. class PDSName(char.PrintableString):
  397. pass
  398. PDSName.subtypeSpec = constraint.ValueSizeConstraint(1, ub_pds_name_length)
  399. class PosteRestanteAddress(PDSParameter):
  400. pass
  401. class DistinguishedName(RDNSequence):
  402. pass
  403. class CommonName(char.PrintableString):
  404. pass
  405. CommonName.subtypeSpec = constraint.ValueSizeConstraint(1, ub_common_name_length)
  406. ub_serial_number = univ.Integer(64)
  407. class X520SerialNumber(char.PrintableString):
  408. pass
  409. X520SerialNumber.subtypeSpec = constraint.ValueSizeConstraint(1, ub_serial_number)
  410. id_at_generationQualifier = _OID(id_at, 44)
  411. ub_organizational_unit_name = univ.Integer(64)
  412. id_ad_ocsp = _OID(id_ad, 1)
  413. class TeletexOrganizationalUnitName(char.TeletexString):
  414. pass
  415. TeletexOrganizationalUnitName.subtypeSpec = constraint.ValueSizeConstraint(1, ub_organizational_unit_name_length)
  416. class TeletexPersonalName(univ.Set):
  417. pass
  418. TeletexPersonalName.componentType = namedtype.NamedTypes(
  419. namedtype.NamedType('surname', char.TeletexString().subtype(
  420. subtypeSpec=constraint.ValueSizeConstraint(1, ub_surname_length)).subtype(
  421. implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 0))),
  422. namedtype.OptionalNamedType('given-name', char.TeletexString().subtype(
  423. subtypeSpec=constraint.ValueSizeConstraint(1, ub_given_name_length)).subtype(
  424. implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 1))),
  425. namedtype.OptionalNamedType('initials', char.TeletexString().subtype(
  426. subtypeSpec=constraint.ValueSizeConstraint(1, ub_initials_length)).subtype(
  427. implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 2))),
  428. namedtype.OptionalNamedType('generation-qualifier', char.TeletexString().subtype(
  429. subtypeSpec=constraint.ValueSizeConstraint(1, ub_generation_qualifier_length)).subtype(
  430. implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 3)))
  431. )
  432. class TeletexDomainDefinedAttributes(univ.SequenceOf):
  433. pass
  434. TeletexDomainDefinedAttributes.componentType = TeletexDomainDefinedAttribute()
  435. TeletexDomainDefinedAttributes.subtypeSpec = constraint.ValueSizeConstraint(1, ub_domain_defined_attributes)
  436. class TBSCertList(univ.Sequence):
  437. pass
  438. TBSCertList.componentType = namedtype.NamedTypes(
  439. namedtype.OptionalNamedType('version', Version()),
  440. namedtype.NamedType('signature', AlgorithmIdentifier()),
  441. namedtype.NamedType('issuer', Name()),
  442. namedtype.NamedType('thisUpdate', Time()),
  443. namedtype.OptionalNamedType('nextUpdate', Time()),
  444. namedtype.OptionalNamedType('revokedCertificates',
  445. univ.SequenceOf(componentType=univ.Sequence(componentType=namedtype.NamedTypes(
  446. namedtype.NamedType('userCertificate', CertificateSerialNumber()),
  447. namedtype.NamedType('revocationDate', Time()),
  448. namedtype.OptionalNamedType('crlEntryExtensions', Extensions())
  449. ))
  450. )),
  451. namedtype.OptionalNamedType('crlExtensions',
  452. Extensions().subtype(explicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 0)))
  453. )
  454. local_postal_attributes = univ.Integer(21)
  455. pkcs_9 = _OID(1, 2, 840, 113549, 1, 9)
  456. class PhysicalDeliveryCountryName(univ.Choice):
  457. pass
  458. PhysicalDeliveryCountryName.componentType = namedtype.NamedTypes(
  459. namedtype.NamedType('x121-dcc-code', char.NumericString().subtype(
  460. subtypeSpec=constraint.ValueSizeConstraint(ub_country_name_numeric_length, ub_country_name_numeric_length))),
  461. namedtype.NamedType('iso-3166-alpha2-code', char.PrintableString().subtype(
  462. subtypeSpec=constraint.ValueSizeConstraint(ub_country_name_alpha_length, ub_country_name_alpha_length)))
  463. )
  464. ub_name = univ.Integer(32768)
  465. class X520name(univ.Choice):
  466. pass
  467. X520name.componentType = namedtype.NamedTypes(
  468. namedtype.NamedType('teletexString',
  469. char.TeletexString().subtype(subtypeSpec=constraint.ValueSizeConstraint(1, ub_name))),
  470. namedtype.NamedType('printableString',
  471. char.PrintableString().subtype(subtypeSpec=constraint.ValueSizeConstraint(1, ub_name))),
  472. namedtype.NamedType('universalString',
  473. char.UniversalString().subtype(subtypeSpec=constraint.ValueSizeConstraint(1, ub_name))),
  474. namedtype.NamedType('utf8String',
  475. char.UTF8String().subtype(subtypeSpec=constraint.ValueSizeConstraint(1, ub_name))),
  476. namedtype.NamedType('bmpString', char.BMPString().subtype(subtypeSpec=constraint.ValueSizeConstraint(1, ub_name)))
  477. )
  478. id_emailAddress = _OID(pkcs_9, 1)
  479. class TerminalType(univ.Integer):
  480. pass
  481. TerminalType.namedValues = namedval.NamedValues(
  482. ('telex', 3),
  483. ('teletex', 4),
  484. ('g3-facsimile', 5),
  485. ('g4-facsimile', 6),
  486. ('ia5-terminal', 7),
  487. ('videotex', 8)
  488. )
  489. class X520OrganizationalUnitName(univ.Choice):
  490. pass
  491. X520OrganizationalUnitName.componentType = namedtype.NamedTypes(
  492. namedtype.NamedType('teletexString', char.TeletexString().subtype(
  493. subtypeSpec=constraint.ValueSizeConstraint(1, ub_organizational_unit_name))),
  494. namedtype.NamedType('printableString', char.PrintableString().subtype(
  495. subtypeSpec=constraint.ValueSizeConstraint(1, ub_organizational_unit_name))),
  496. namedtype.NamedType('universalString', char.UniversalString().subtype(
  497. subtypeSpec=constraint.ValueSizeConstraint(1, ub_organizational_unit_name))),
  498. namedtype.NamedType('utf8String', char.UTF8String().subtype(
  499. subtypeSpec=constraint.ValueSizeConstraint(1, ub_organizational_unit_name))),
  500. namedtype.NamedType('bmpString', char.BMPString().subtype(
  501. subtypeSpec=constraint.ValueSizeConstraint(1, ub_organizational_unit_name)))
  502. )
  503. id_at_commonName = _OID(id_at, 3)
  504. pds_name = univ.Integer(7)
  505. post_office_box_address = univ.Integer(18)
  506. ub_locality_name = univ.Integer(128)
  507. class X520LocalityName(univ.Choice):
  508. pass
  509. X520LocalityName.componentType = namedtype.NamedTypes(
  510. namedtype.NamedType('teletexString',
  511. char.TeletexString().subtype(subtypeSpec=constraint.ValueSizeConstraint(1, ub_locality_name))),
  512. namedtype.NamedType('printableString', char.PrintableString().subtype(
  513. subtypeSpec=constraint.ValueSizeConstraint(1, ub_locality_name))),
  514. namedtype.NamedType('universalString', char.UniversalString().subtype(
  515. subtypeSpec=constraint.ValueSizeConstraint(1, ub_locality_name))),
  516. namedtype.NamedType('utf8String',
  517. char.UTF8String().subtype(subtypeSpec=constraint.ValueSizeConstraint(1, ub_locality_name))),
  518. namedtype.NamedType('bmpString',
  519. char.BMPString().subtype(subtypeSpec=constraint.ValueSizeConstraint(1, ub_locality_name)))
  520. )
  521. id_ad_timeStamping = _OID(id_ad, 3)
  522. id_at_countryName = _OID(id_at, 6)
  523. physical_delivery_personal_name = univ.Integer(13)
  524. teletex_personal_name = univ.Integer(4)
  525. teletex_organizational_unit_names = univ.Integer(5)
  526. class PhysicalDeliveryPersonalName(PDSParameter):
  527. pass
  528. ub_postal_code_length = univ.Integer(16)
  529. class PostalCode(univ.Choice):
  530. pass
  531. PostalCode.componentType = namedtype.NamedTypes(
  532. namedtype.NamedType('numeric-code', char.NumericString().subtype(
  533. subtypeSpec=constraint.ValueSizeConstraint(1, ub_postal_code_length))),
  534. namedtype.NamedType('printable-code', char.PrintableString().subtype(
  535. subtypeSpec=constraint.ValueSizeConstraint(1, ub_postal_code_length)))
  536. )
  537. class X520countryName(char.PrintableString):
  538. pass
  539. X520countryName.subtypeSpec = constraint.ValueSizeConstraint(2, 2)
  540. postal_code = univ.Integer(9)
  541. id_ad_caRepository = _OID(id_ad, 5)
  542. extension_physical_delivery_address_components = univ.Integer(15)
  543. class PostOfficeBoxAddress(PDSParameter):
  544. pass
  545. class PhysicalDeliveryOfficeName(PDSParameter):
  546. pass
  547. id_at_title = _OID(id_at, 12)
  548. id_at_serialNumber = _OID(id_at, 5)
  549. id_ad_caIssuers = _OID(id_ad, 2)
  550. ub_integer_options = univ.Integer(256)
  551. class CertificateList(univ.Sequence):
  552. pass
  553. CertificateList.componentType = namedtype.NamedTypes(
  554. namedtype.NamedType('tbsCertList', TBSCertList()),
  555. namedtype.NamedType('signatureAlgorithm', AlgorithmIdentifier()),
  556. namedtype.NamedType('signature', univ.BitString())
  557. )
  558. class PhysicalDeliveryOfficeNumber(PDSParameter):
  559. pass
  560. class TeletexOrganizationalUnitNames(univ.SequenceOf):
  561. pass
  562. TeletexOrganizationalUnitNames.componentType = TeletexOrganizationalUnitName()
  563. TeletexOrganizationalUnitNames.subtypeSpec = constraint.ValueSizeConstraint(1, ub_organizational_units)
  564. physical_delivery_office_name = univ.Integer(10)
  565. ub_common_name = univ.Integer(64)
  566. class ExtensionORAddressComponents(PDSParameter):
  567. pass
  568. ub_pseudonym = univ.Integer(128)
  569. poste_restante_address = univ.Integer(19)
  570. id_at_organizationName = _OID(id_at, 10)
  571. physical_delivery_office_number = univ.Integer(11)
  572. id_at_pseudonym = _OID(id_at, 65)
  573. class X520CommonName(univ.Choice):
  574. pass
  575. X520CommonName.componentType = namedtype.NamedTypes(
  576. namedtype.NamedType('teletexString',
  577. char.TeletexString().subtype(subtypeSpec=constraint.ValueSizeConstraint(1, ub_common_name))),
  578. namedtype.NamedType('printableString',
  579. char.PrintableString().subtype(subtypeSpec=constraint.ValueSizeConstraint(1, ub_common_name))),
  580. namedtype.NamedType('universalString',
  581. char.UniversalString().subtype(subtypeSpec=constraint.ValueSizeConstraint(1, ub_common_name))),
  582. namedtype.NamedType('utf8String',
  583. char.UTF8String().subtype(subtypeSpec=constraint.ValueSizeConstraint(1, ub_common_name))),
  584. namedtype.NamedType('bmpString',
  585. char.BMPString().subtype(subtypeSpec=constraint.ValueSizeConstraint(1, ub_common_name)))
  586. )
  587. physical_delivery_organization_name = univ.Integer(14)
  588. class X520dnQualifier(char.PrintableString):
  589. pass
  590. id_at_stateOrProvinceName = _OID(id_at, 8)
  591. common_name = univ.Integer(1)
  592. id_at_localityName = _OID(id_at, 7)
  593. ub_match = univ.Integer(128)
  594. ub_unformatted_address_length = univ.Integer(180)
  595. class Attribute(univ.Sequence):
  596. pass
  597. Attribute.componentType = namedtype.NamedTypes(
  598. namedtype.NamedType('type', AttributeType()),
  599. namedtype.NamedType('values', univ.SetOf(componentType=AttributeValue()))
  600. )
  601. extended_network_address = univ.Integer(22)
  602. unique_postal_name = univ.Integer(20)
  603. ub_pds_physical_address_lines = univ.Integer(6)
  604. class UnformattedPostalAddress(univ.Set):
  605. pass
  606. UnformattedPostalAddress.componentType = namedtype.NamedTypes(
  607. namedtype.OptionalNamedType('printable-address', univ.SequenceOf(componentType=char.PrintableString().subtype(
  608. subtypeSpec=constraint.ValueSizeConstraint(1, ub_pds_parameter_length)))),
  609. namedtype.OptionalNamedType('teletex-string', char.TeletexString().subtype(
  610. subtypeSpec=constraint.ValueSizeConstraint(1, ub_unformatted_address_length)))
  611. )
  612. class UniquePostalName(PDSParameter):
  613. pass
  614. class X520Pseudonym(univ.Choice):
  615. pass
  616. X520Pseudonym.componentType = namedtype.NamedTypes(
  617. namedtype.NamedType('teletexString',
  618. char.TeletexString().subtype(subtypeSpec=constraint.ValueSizeConstraint(1, ub_pseudonym))),
  619. namedtype.NamedType('printableString',
  620. char.PrintableString().subtype(subtypeSpec=constraint.ValueSizeConstraint(1, ub_pseudonym))),
  621. namedtype.NamedType('universalString',
  622. char.UniversalString().subtype(subtypeSpec=constraint.ValueSizeConstraint(1, ub_pseudonym))),
  623. namedtype.NamedType('utf8String',
  624. char.UTF8String().subtype(subtypeSpec=constraint.ValueSizeConstraint(1, ub_pseudonym))),
  625. namedtype.NamedType('bmpString',
  626. char.BMPString().subtype(subtypeSpec=constraint.ValueSizeConstraint(1, ub_pseudonym)))
  627. )
  628. teletex_organization_name = univ.Integer(3)
  629. teletex_domain_defined_attributes = univ.Integer(6)
  630. street_address = univ.Integer(17)
  631. id_kp_OCSPSigning = _OID(id_kp, 9)
  632. id_ce = _OID(2, 5, 29)
  633. id_ce_certificatePolicies = _OID(id_ce, 32)
  634. class EDIPartyName(univ.Sequence):
  635. pass
  636. EDIPartyName.componentType = namedtype.NamedTypes(
  637. namedtype.OptionalNamedType('nameAssigner', DirectoryString().subtype(
  638. implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 0))),
  639. namedtype.NamedType('partyName',
  640. DirectoryString().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 1)))
  641. )
  642. class AnotherName(univ.Sequence):
  643. pass
  644. AnotherName.componentType = namedtype.NamedTypes(
  645. namedtype.NamedType('type-id', univ.ObjectIdentifier()),
  646. namedtype.NamedType('value', univ.Any().subtype(explicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 0)))
  647. )
  648. class GeneralName(univ.Choice):
  649. pass
  650. GeneralName.componentType = namedtype.NamedTypes(
  651. namedtype.NamedType('otherName',
  652. AnotherName().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatConstructed, 0))),
  653. namedtype.NamedType('rfc822Name',
  654. char.IA5String().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 1))),
  655. namedtype.NamedType('dNSName',
  656. char.IA5String().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 2))),
  657. namedtype.NamedType('x400Address',
  658. ORAddress().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 3))),
  659. namedtype.NamedType('directoryName',
  660. Name().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatConstructed, 4))),
  661. namedtype.NamedType('ediPartyName',
  662. EDIPartyName().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatConstructed, 5))),
  663. namedtype.NamedType('uniformResourceIdentifier',
  664. char.IA5String().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 6))),
  665. namedtype.NamedType('iPAddress',
  666. univ.OctetString().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 7))),
  667. namedtype.NamedType('registeredID', univ.ObjectIdentifier().subtype(
  668. implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 8)))
  669. )
  670. class GeneralNames(univ.SequenceOf):
  671. pass
  672. GeneralNames.componentType = GeneralName()
  673. GeneralNames.subtypeSpec = constraint.ValueSizeConstraint(1, MAX)
  674. class IssuerAltName(GeneralNames):
  675. pass
  676. id_ce_cRLDistributionPoints = _OID(id_ce, 31)
  677. class CertPolicyId(univ.ObjectIdentifier):
  678. pass
  679. class PolicyMappings(univ.SequenceOf):
  680. pass
  681. PolicyMappings.componentType = univ.Sequence(componentType=namedtype.NamedTypes(
  682. namedtype.NamedType('issuerDomainPolicy', CertPolicyId()),
  683. namedtype.NamedType('subjectDomainPolicy', CertPolicyId())
  684. ))
  685. PolicyMappings.subtypeSpec = constraint.ValueSizeConstraint(1, MAX)
  686. class PolicyQualifierId(univ.ObjectIdentifier):
  687. pass
  688. holdInstruction = _OID(2, 2, 840, 10040, 2)
  689. id_ce_subjectDirectoryAttributes = _OID(id_ce, 9)
  690. id_holdinstruction_callissuer = _OID(holdInstruction, 2)
  691. class SubjectDirectoryAttributes(univ.SequenceOf):
  692. pass
  693. SubjectDirectoryAttributes.componentType = Attribute()
  694. SubjectDirectoryAttributes.subtypeSpec = constraint.ValueSizeConstraint(1, MAX)
  695. anyPolicy = _OID(id_ce_certificatePolicies, 0)
  696. id_ce_subjectAltName = _OID(id_ce, 17)
  697. id_kp_emailProtection = _OID(id_kp, 4)
  698. class ReasonFlags(univ.BitString):
  699. pass
  700. ReasonFlags.namedValues = namedval.NamedValues(
  701. ('unused', 0),
  702. ('keyCompromise', 1),
  703. ('cACompromise', 2),
  704. ('affiliationChanged', 3),
  705. ('superseded', 4),
  706. ('cessationOfOperation', 5),
  707. ('certificateHold', 6),
  708. ('privilegeWithdrawn', 7),
  709. ('aACompromise', 8)
  710. )
  711. class DistributionPointName(univ.Choice):
  712. pass
  713. DistributionPointName.componentType = namedtype.NamedTypes(
  714. namedtype.NamedType('fullName',
  715. GeneralNames().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 0))),
  716. namedtype.NamedType('nameRelativeToCRLIssuer', RelativeDistinguishedName().subtype(
  717. implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 1)))
  718. )
  719. class DistributionPoint(univ.Sequence):
  720. pass
  721. DistributionPoint.componentType = namedtype.NamedTypes(
  722. namedtype.OptionalNamedType('distributionPoint', DistributionPointName().subtype(
  723. implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatConstructed, 0))),
  724. namedtype.OptionalNamedType('reasons', ReasonFlags().subtype(
  725. implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 1))),
  726. namedtype.OptionalNamedType('cRLIssuer', GeneralNames().subtype(
  727. implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 2)))
  728. )
  729. id_ce_keyUsage = _OID(id_ce, 15)
  730. class PolicyQualifierInfo(univ.Sequence):
  731. pass
  732. PolicyQualifierInfo.componentType = namedtype.NamedTypes(
  733. namedtype.NamedType('policyQualifierId', PolicyQualifierId()),
  734. namedtype.NamedType('qualifier', univ.Any())
  735. )
  736. class PolicyInformation(univ.Sequence):
  737. pass
  738. PolicyInformation.componentType = namedtype.NamedTypes(
  739. namedtype.NamedType('policyIdentifier', CertPolicyId()),
  740. namedtype.OptionalNamedType('policyQualifiers', univ.SequenceOf(componentType=PolicyQualifierInfo()))
  741. )
  742. class CertificatePolicies(univ.SequenceOf):
  743. pass
  744. CertificatePolicies.componentType = PolicyInformation()
  745. CertificatePolicies.subtypeSpec = constraint.ValueSizeConstraint(1, MAX)
  746. id_ce_basicConstraints = _OID(id_ce, 19)
  747. class HoldInstructionCode(univ.ObjectIdentifier):
  748. pass
  749. class KeyPurposeId(univ.ObjectIdentifier):
  750. pass
  751. class ExtKeyUsageSyntax(univ.SequenceOf):
  752. pass
  753. ExtKeyUsageSyntax.componentType = KeyPurposeId()
  754. ExtKeyUsageSyntax.subtypeSpec = constraint.ValueSizeConstraint(1, MAX)
  755. class SubjectAltName(GeneralNames):
  756. pass
  757. class BasicConstraints(univ.Sequence):
  758. pass
  759. BasicConstraints.componentType = namedtype.NamedTypes(
  760. namedtype.DefaultedNamedType('cA', univ.Boolean().subtype(value=0)),
  761. namedtype.OptionalNamedType('pathLenConstraint',
  762. univ.Integer().subtype(subtypeSpec=constraint.ValueRangeConstraint(0, MAX)))
  763. )
  764. class SkipCerts(univ.Integer):
  765. pass
  766. SkipCerts.subtypeSpec = constraint.ValueRangeConstraint(0, MAX)
  767. class InhibitAnyPolicy(SkipCerts):
  768. pass
  769. class CRLNumber(univ.Integer):
  770. pass
  771. CRLNumber.subtypeSpec = constraint.ValueRangeConstraint(0, MAX)
  772. class BaseCRLNumber(CRLNumber):
  773. pass
  774. class KeyIdentifier(univ.OctetString):
  775. pass
  776. class AuthorityKeyIdentifier(univ.Sequence):
  777. pass
  778. AuthorityKeyIdentifier.componentType = namedtype.NamedTypes(
  779. namedtype.OptionalNamedType('keyIdentifier', KeyIdentifier().subtype(
  780. implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 0))),
  781. namedtype.OptionalNamedType('authorityCertIssuer', GeneralNames().subtype(
  782. implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 1))),
  783. namedtype.OptionalNamedType('authorityCertSerialNumber', CertificateSerialNumber().subtype(
  784. implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 2)))
  785. )
  786. id_ce_nameConstraints = _OID(id_ce, 30)
  787. id_kp_serverAuth = _OID(id_kp, 1)
  788. id_ce_freshestCRL = _OID(id_ce, 46)
  789. id_ce_cRLReasons = _OID(id_ce, 21)
  790. class CRLDistributionPoints(univ.SequenceOf):
  791. pass
  792. CRLDistributionPoints.componentType = DistributionPoint()
  793. CRLDistributionPoints.subtypeSpec = constraint.ValueSizeConstraint(1, MAX)
  794. class FreshestCRL(CRLDistributionPoints):
  795. pass
  796. id_ce_inhibitAnyPolicy = _OID(id_ce, 54)
  797. class CRLReason(univ.Enumerated):
  798. pass
  799. CRLReason.namedValues = namedval.NamedValues(
  800. ('unspecified', 0),
  801. ('keyCompromise', 1),
  802. ('cACompromise', 2),
  803. ('affiliationChanged', 3),
  804. ('superseded', 4),
  805. ('cessationOfOperation', 5),
  806. ('certificateHold', 6),
  807. ('removeFromCRL', 8),
  808. ('privilegeWithdrawn', 9),
  809. ('aACompromise', 10)
  810. )
  811. class BaseDistance(univ.Integer):
  812. pass
  813. BaseDistance.subtypeSpec = constraint.ValueRangeConstraint(0, MAX)
  814. class GeneralSubtree(univ.Sequence):
  815. pass
  816. GeneralSubtree.componentType = namedtype.NamedTypes(
  817. namedtype.NamedType('base', GeneralName()),
  818. namedtype.DefaultedNamedType('minimum', BaseDistance().subtype(
  819. implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 0)).subtype(value=0)),
  820. namedtype.OptionalNamedType('maximum', BaseDistance().subtype(
  821. implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 1)))
  822. )
  823. class GeneralSubtrees(univ.SequenceOf):
  824. pass
  825. GeneralSubtrees.componentType = GeneralSubtree()
  826. GeneralSubtrees.subtypeSpec = constraint.ValueSizeConstraint(1, MAX)
  827. class NameConstraints(univ.Sequence):
  828. pass
  829. NameConstraints.componentType = namedtype.NamedTypes(
  830. namedtype.OptionalNamedType('permittedSubtrees', GeneralSubtrees().subtype(
  831. implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 0))),
  832. namedtype.OptionalNamedType('excludedSubtrees', GeneralSubtrees().subtype(
  833. implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 1)))
  834. )
  835. id_pe_authorityInfoAccess = _OID(id_pe, 1)
  836. id_pe_subjectInfoAccess = _OID(id_pe, 11)
  837. id_ce_certificateIssuer = _OID(id_ce, 29)
  838. id_ce_invalidityDate = _OID(id_ce, 24)
  839. class DirectoryString(univ.Choice):
  840. pass
  841. DirectoryString.componentType = namedtype.NamedTypes(
  842. namedtype.NamedType('any', univ.Any())
  843. )
  844. id_ce_authorityKeyIdentifier = _OID(id_ce, 35)
  845. class AccessDescription(univ.Sequence):
  846. pass
  847. AccessDescription.componentType = namedtype.NamedTypes(
  848. namedtype.NamedType('accessMethod', univ.ObjectIdentifier()),
  849. namedtype.NamedType('accessLocation', GeneralName())
  850. )
  851. class AuthorityInfoAccessSyntax(univ.SequenceOf):
  852. pass
  853. AuthorityInfoAccessSyntax.componentType = AccessDescription()
  854. AuthorityInfoAccessSyntax.subtypeSpec = constraint.ValueSizeConstraint(1, MAX)
  855. id_ce_issuingDistributionPoint = _OID(id_ce, 28)
  856. class CPSuri(char.IA5String):
  857. pass
  858. class DisplayText(univ.Choice):
  859. pass
  860. DisplayText.componentType = namedtype.NamedTypes(
  861. namedtype.NamedType('ia5String', char.IA5String().subtype(subtypeSpec=constraint.ValueSizeConstraint(1, 200))),
  862. namedtype.NamedType('visibleString',
  863. char.VisibleString().subtype(subtypeSpec=constraint.ValueSizeConstraint(1, 200))),
  864. namedtype.NamedType('bmpString', char.BMPString().subtype(subtypeSpec=constraint.ValueSizeConstraint(1, 200))),
  865. namedtype.NamedType('utf8String', char.UTF8String().subtype(subtypeSpec=constraint.ValueSizeConstraint(1, 200)))
  866. )
  867. class NoticeReference(univ.Sequence):
  868. pass
  869. NoticeReference.componentType = namedtype.NamedTypes(
  870. namedtype.NamedType('organization', DisplayText()),
  871. namedtype.NamedType('noticeNumbers', univ.SequenceOf(componentType=univ.Integer()))
  872. )
  873. class UserNotice(univ.Sequence):
  874. pass
  875. UserNotice.componentType = namedtype.NamedTypes(
  876. namedtype.OptionalNamedType('noticeRef', NoticeReference()),
  877. namedtype.OptionalNamedType('explicitText', DisplayText())
  878. )
  879. class PrivateKeyUsagePeriod(univ.Sequence):
  880. pass
  881. PrivateKeyUsagePeriod.componentType = namedtype.NamedTypes(
  882. namedtype.OptionalNamedType('notBefore', useful.GeneralizedTime().subtype(
  883. implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 0))),
  884. namedtype.OptionalNamedType('notAfter', useful.GeneralizedTime().subtype(
  885. implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 1)))
  886. )
  887. id_ce_subjectKeyIdentifier = _OID(id_ce, 14)
  888. class CertificateIssuer(GeneralNames):
  889. pass
  890. class InvalidityDate(useful.GeneralizedTime):
  891. pass
  892. class SubjectInfoAccessSyntax(univ.SequenceOf):
  893. pass
  894. SubjectInfoAccessSyntax.componentType = AccessDescription()
  895. SubjectInfoAccessSyntax.subtypeSpec = constraint.ValueSizeConstraint(1, MAX)
  896. class KeyUsage(univ.BitString):
  897. pass
  898. KeyUsage.namedValues = namedval.NamedValues(
  899. ('digitalSignature', 0),
  900. ('nonRepudiation', 1),
  901. ('keyEncipherment', 2),
  902. ('dataEncipherment', 3),
  903. ('keyAgreement', 4),
  904. ('keyCertSign', 5),
  905. ('cRLSign', 6),
  906. ('encipherOnly', 7),
  907. ('decipherOnly', 8)
  908. )
  909. id_ce_extKeyUsage = _OID(id_ce, 37)
  910. anyExtendedKeyUsage = _OID(id_ce_extKeyUsage, 0)
  911. id_ce_privateKeyUsagePeriod = _OID(id_ce, 16)
  912. id_ce_policyMappings = _OID(id_ce, 33)
  913. id_ce_cRLNumber = _OID(id_ce, 20)
  914. id_ce_policyConstraints = _OID(id_ce, 36)
  915. id_holdinstruction_none = _OID(holdInstruction, 1)
  916. id_holdinstruction_reject = _OID(holdInstruction, 3)
  917. id_kp_timeStamping = _OID(id_kp, 8)
  918. class PolicyConstraints(univ.Sequence):
  919. pass
  920. PolicyConstraints.componentType = namedtype.NamedTypes(
  921. namedtype.OptionalNamedType('requireExplicitPolicy',
  922. SkipCerts().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 0))),
  923. namedtype.OptionalNamedType('inhibitPolicyMapping',
  924. SkipCerts().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 1)))
  925. )
  926. class SubjectKeyIdentifier(KeyIdentifier):
  927. pass
  928. id_kp_clientAuth = _OID(id_kp, 2)
  929. id_ce_deltaCRLIndicator = _OID(id_ce, 27)
  930. id_ce_issuerAltName = _OID(id_ce, 18)
  931. id_kp_codeSigning = _OID(id_kp, 3)
  932. id_ce_holdInstructionCode = _OID(id_ce, 23)
  933. class IssuingDistributionPoint(univ.Sequence):
  934. pass
  935. IssuingDistributionPoint.componentType = namedtype.NamedTypes(
  936. namedtype.OptionalNamedType('distributionPoint', DistributionPointName().subtype(
  937. implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatConstructed, 0))),
  938. namedtype.DefaultedNamedType('onlyContainsUserCerts', univ.Boolean().subtype(
  939. implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 1)).subtype(value=0)),
  940. namedtype.DefaultedNamedType('onlyContainsCACerts', univ.Boolean().subtype(
  941. implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 2)).subtype(value=0)),
  942. namedtype.OptionalNamedType('onlySomeReasons', ReasonFlags().subtype(
  943. implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 3))),
  944. namedtype.DefaultedNamedType('indirectCRL', univ.Boolean().subtype(
  945. implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 4)).subtype(value=0)),
  946. namedtype.DefaultedNamedType('onlyContainsAttributeCerts', univ.Boolean().subtype(
  947. implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 5)).subtype(value=0))
  948. )