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#
15from pyasn1.type import univ, char, namedtype, namedval, tag, constraint, useful
16
17MAX = float('inf')
18
19
20def _OID(*components):
21    output = []
22    for x in tuple(components):
23        if isinstance(x, univ.ObjectIdentifier):
24            output.extend(list(x))
25        else:
26            output.append(int(x))
27
28    return univ.ObjectIdentifier(output)
29
30
31unformatted_postal_address = univ.Integer(16)
32
33ub_organizational_units = univ.Integer(4)
34
35ub_organizational_unit_name_length = univ.Integer(32)
36
37
38class OrganizationalUnitName(char.PrintableString):
39    pass
40
41
42OrganizationalUnitName.subtypeSpec = constraint.ValueSizeConstraint(1, ub_organizational_unit_name_length)
43
44
45class OrganizationalUnitNames(univ.SequenceOf):
46    pass
47
48
49OrganizationalUnitNames.componentType = OrganizationalUnitName()
50OrganizationalUnitNames.subtypeSpec = constraint.ValueSizeConstraint(1, ub_organizational_units)
51
52
53class AttributeType(univ.ObjectIdentifier):
54    pass
55
56
57id_at = _OID(2, 5, 4)
58
59id_at_name = _OID(id_at, 41)
60
61ub_pds_parameter_length = univ.Integer(30)
62
63
64class PDSParameter(univ.Set):
65    pass
66
67
68PDSParameter.componentType = namedtype.NamedTypes(
69    namedtype.OptionalNamedType('printable-string', char.PrintableString().subtype(
70        subtypeSpec=constraint.ValueSizeConstraint(1, ub_pds_parameter_length))),
71    namedtype.OptionalNamedType('teletex-string', char.TeletexString().subtype(
72        subtypeSpec=constraint.ValueSizeConstraint(1, ub_pds_parameter_length)))
73)
74
75
76class PhysicalDeliveryOrganizationName(PDSParameter):
77    pass
78
79
80ub_organization_name_length = univ.Integer(64)
81
82ub_domain_defined_attribute_type_length = univ.Integer(8)
83
84ub_domain_defined_attribute_value_length = univ.Integer(128)
85
86
87class TeletexDomainDefinedAttribute(univ.Sequence):
88    pass
89
90
91TeletexDomainDefinedAttribute.componentType = namedtype.NamedTypes(
92    namedtype.NamedType('type', char.TeletexString().subtype(
93        subtypeSpec=constraint.ValueSizeConstraint(1, ub_domain_defined_attribute_type_length))),
94    namedtype.NamedType('value', char.TeletexString().subtype(
95        subtypeSpec=constraint.ValueSizeConstraint(1, ub_domain_defined_attribute_value_length)))
96)
97
98id_pkix = _OID(1, 3, 6, 1, 5, 5, 7)
99
100id_qt = _OID(id_pkix, 2)
101
102
103class PresentationAddress(univ.Sequence):
104    pass
105
106
107PresentationAddress.componentType = namedtype.NamedTypes(
108    namedtype.OptionalNamedType('pSelector', univ.OctetString().subtype(
109        explicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 0))),
110    namedtype.OptionalNamedType('sSelector', univ.OctetString().subtype(
111        explicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 1))),
112    namedtype.OptionalNamedType('tSelector', univ.OctetString().subtype(
113        explicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 2))),
114    namedtype.NamedType('nAddresses', univ.SetOf(componentType=univ.OctetString()).subtype(
115        explicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 3)))
116)
117
118
119class AlgorithmIdentifier(univ.Sequence):
120    pass
121
122
123AlgorithmIdentifier.componentType = namedtype.NamedTypes(
124    namedtype.NamedType('algorithm', univ.ObjectIdentifier()),
125    namedtype.OptionalNamedType('parameters', univ.Any())
126)
127
128
129class UniqueIdentifier(univ.BitString):
130    pass
131
132
133class Extension(univ.Sequence):
134    pass
135
136
137Extension.componentType = namedtype.NamedTypes(
138    namedtype.NamedType('extnID', univ.ObjectIdentifier()),
139    namedtype.DefaultedNamedType('critical', univ.Boolean().subtype(value=0)),
140    namedtype.NamedType('extnValue', univ.OctetString())
141)
142
143
144class Extensions(univ.SequenceOf):
145    pass
146
147
148Extensions.componentType = Extension()
149Extensions.subtypeSpec = constraint.ValueSizeConstraint(1, MAX)
150
151
152class CertificateSerialNumber(univ.Integer):
153    pass
154
155
156class SubjectPublicKeyInfo(univ.Sequence):
157    pass
158
159
160SubjectPublicKeyInfo.componentType = namedtype.NamedTypes(
161    namedtype.NamedType('algorithm', AlgorithmIdentifier()),
162    namedtype.NamedType('subjectPublicKey', univ.BitString())
163)
164
165
166class Time(univ.Choice):
167    pass
168
169
170Time.componentType = namedtype.NamedTypes(
171    namedtype.NamedType('utcTime', useful.UTCTime()),
172    namedtype.NamedType('generalTime', useful.GeneralizedTime())
173)
174
175
176class Validity(univ.Sequence):
177    pass
178
179
180Validity.componentType = namedtype.NamedTypes(
181    namedtype.NamedType('notBefore', Time()),
182    namedtype.NamedType('notAfter', Time())
183)
184
185
186class Version(univ.Integer):
187    pass
188
189
190Version.namedValues = namedval.NamedValues(
191    ('v1', 0),
192    ('v2', 1),
193    ('v3', 2)
194)
195
196
197class AttributeValue(univ.Any):
198    pass
199
200
201class AttributeTypeAndValue(univ.Sequence):
202    pass
203
204
205AttributeTypeAndValue.componentType = namedtype.NamedTypes(
206    namedtype.NamedType('type', AttributeType()),
207    namedtype.NamedType('value', AttributeValue())
208)
209
210
211class RelativeDistinguishedName(univ.SetOf):
212    pass
213
214
215RelativeDistinguishedName.componentType = AttributeTypeAndValue()
216RelativeDistinguishedName.subtypeSpec = constraint.ValueSizeConstraint(1, MAX)
217
218
219class RDNSequence(univ.SequenceOf):
220    pass
221
222
223RDNSequence.componentType = RelativeDistinguishedName()
224
225
226class Name(univ.Choice):
227    pass
228
229
230Name.componentType = namedtype.NamedTypes(
231    namedtype.NamedType('rdnSequence', RDNSequence())
232)
233
234
235class TBSCertificate(univ.Sequence):
236    pass
237
238
239TBSCertificate.componentType = namedtype.NamedTypes(
240    namedtype.DefaultedNamedType('version',
241                                 Version().subtype(explicitTag=tag.Tag(tag.tagClassContext,
242                                                                       tag.tagFormatSimple, 0)).subtype(value="v1")),
243    namedtype.NamedType('serialNumber', CertificateSerialNumber()),
244    namedtype.NamedType('signature', AlgorithmIdentifier()),
245    namedtype.NamedType('issuer', Name()),
246    namedtype.NamedType('validity', Validity()),
247    namedtype.NamedType('subject', Name()),
248    namedtype.NamedType('subjectPublicKeyInfo', SubjectPublicKeyInfo()),
249    namedtype.OptionalNamedType('issuerUniqueID', UniqueIdentifier().subtype(
250        implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 1))),
251    namedtype.OptionalNamedType('subjectUniqueID', UniqueIdentifier().subtype(
252        implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 2))),
253    namedtype.OptionalNamedType('extensions',
254                                Extensions().subtype(explicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 3)))
255)
256
257
258class Certificate(univ.Sequence):
259    pass
260
261
262Certificate.componentType = namedtype.NamedTypes(
263    namedtype.NamedType('tbsCertificate', TBSCertificate()),
264    namedtype.NamedType('signatureAlgorithm', AlgorithmIdentifier()),
265    namedtype.NamedType('signature', univ.BitString())
266)
267
268ub_surname_length = univ.Integer(40)
269
270
271class TeletexOrganizationName(char.TeletexString):
272    pass
273
274
275TeletexOrganizationName.subtypeSpec = constraint.ValueSizeConstraint(1, ub_organization_name_length)
276
277ub_e163_4_sub_address_length = univ.Integer(40)
278
279teletex_common_name = univ.Integer(2)
280
281ub_country_name_alpha_length = univ.Integer(2)
282
283ub_country_name_numeric_length = univ.Integer(3)
284
285
286class CountryName(univ.Choice):
287    pass
288
289
290CountryName.tagSet = univ.Choice.tagSet.tagExplicitly(tag.Tag(tag.tagClassApplication, tag.tagFormatConstructed, 1))
291CountryName.componentType = namedtype.NamedTypes(
292    namedtype.NamedType('x121-dcc-code', char.NumericString().subtype(
293        subtypeSpec=constraint.ValueSizeConstraint(ub_country_name_numeric_length, ub_country_name_numeric_length))),
294    namedtype.NamedType('iso-3166-alpha2-code', char.PrintableString().subtype(
295        subtypeSpec=constraint.ValueSizeConstraint(ub_country_name_alpha_length, ub_country_name_alpha_length)))
296)
297
298extension_OR_address_components = univ.Integer(12)
299
300id_at_dnQualifier = _OID(id_at, 46)
301
302ub_e163_4_number_length = univ.Integer(15)
303
304
305class ExtendedNetworkAddress(univ.Choice):
306    pass
307
308
309ExtendedNetworkAddress.componentType = namedtype.NamedTypes(
310    namedtype.NamedType('e163-4-address', univ.Sequence(componentType=namedtype.NamedTypes(
311        namedtype.NamedType('number', char.NumericString().subtype(
312            subtypeSpec=constraint.ValueSizeConstraint(1, ub_e163_4_number_length)).subtype(
313            implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 0))),
314        namedtype.OptionalNamedType('sub-address', char.NumericString().subtype(
315            subtypeSpec=constraint.ValueSizeConstraint(1, ub_e163_4_sub_address_length)).subtype(
316            implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 1)))
317    ))
318                        ),
319    namedtype.NamedType('psap-address', PresentationAddress().subtype(
320        implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatConstructed, 0)))
321)
322
323terminal_type = univ.Integer(23)
324
325id_domainComponent = _OID(0, 9, 2342, 19200300, 100, 1, 25)
326
327ub_state_name = univ.Integer(128)
328
329
330class X520StateOrProvinceName(univ.Choice):
331    pass
332
333
334X520StateOrProvinceName.componentType = namedtype.NamedTypes(
335    namedtype.NamedType('teletexString',
336                        char.TeletexString().subtype(subtypeSpec=constraint.ValueSizeConstraint(1, ub_state_name))),
337    namedtype.NamedType('printableString',
338                        char.PrintableString().subtype(subtypeSpec=constraint.ValueSizeConstraint(1, ub_state_name))),
339    namedtype.NamedType('universalString',
340                        char.UniversalString().subtype(subtypeSpec=constraint.ValueSizeConstraint(1, ub_state_name))),
341    namedtype.NamedType('utf8String',
342                        char.UTF8String().subtype(subtypeSpec=constraint.ValueSizeConstraint(1, ub_state_name))),
343    namedtype.NamedType('bmpString',
344                        char.BMPString().subtype(subtypeSpec=constraint.ValueSizeConstraint(1, ub_state_name)))
345)
346
347ub_organization_name = univ.Integer(64)
348
349
350class X520OrganizationName(univ.Choice):
351    pass
352
353
354X520OrganizationName.componentType = namedtype.NamedTypes(
355    namedtype.NamedType('teletexString', char.TeletexString().subtype(
356        subtypeSpec=constraint.ValueSizeConstraint(1, ub_organization_name))),
357    namedtype.NamedType('printableString', char.PrintableString().subtype(
358        subtypeSpec=constraint.ValueSizeConstraint(1, ub_organization_name))),
359    namedtype.NamedType('universalString', char.UniversalString().subtype(
360        subtypeSpec=constraint.ValueSizeConstraint(1, ub_organization_name))),
361    namedtype.NamedType('utf8String',
362                        char.UTF8String().subtype(subtypeSpec=constraint.ValueSizeConstraint(1, ub_organization_name))),
363    namedtype.NamedType('bmpString',
364                        char.BMPString().subtype(subtypeSpec=constraint.ValueSizeConstraint(1, ub_organization_name)))
365)
366
367ub_emailaddress_length = univ.Integer(128)
368
369
370class ExtensionPhysicalDeliveryAddressComponents(PDSParameter):
371    pass
372
373
374id_at_surname = _OID(id_at, 4)
375
376ub_common_name_length = univ.Integer(64)
377
378id_ad = _OID(id_pkix, 48)
379
380ub_numeric_user_id_length = univ.Integer(32)
381
382
383class NumericUserIdentifier(char.NumericString):
384    pass
385
386
387NumericUserIdentifier.subtypeSpec = constraint.ValueSizeConstraint(1, ub_numeric_user_id_length)
388
389
390class OrganizationName(char.PrintableString):
391    pass
392
393
394OrganizationName.subtypeSpec = constraint.ValueSizeConstraint(1, ub_organization_name_length)
395
396ub_domain_name_length = univ.Integer(16)
397
398
399class AdministrationDomainName(univ.Choice):
400    pass
401
402
403AdministrationDomainName.tagSet = univ.Choice.tagSet.tagExplicitly(
404    tag.Tag(tag.tagClassApplication, tag.tagFormatConstructed, 2))
405AdministrationDomainName.componentType = namedtype.NamedTypes(
406    namedtype.NamedType('numeric', char.NumericString().subtype(
407        subtypeSpec=constraint.ValueSizeConstraint(0, ub_domain_name_length))),
408    namedtype.NamedType('printable', char.PrintableString().subtype(
409        subtypeSpec=constraint.ValueSizeConstraint(0, ub_domain_name_length)))
410)
411
412
413class PrivateDomainName(univ.Choice):
414    pass
415
416
417PrivateDomainName.componentType = namedtype.NamedTypes(
418    namedtype.NamedType('numeric', char.NumericString().subtype(
419        subtypeSpec=constraint.ValueSizeConstraint(1, ub_domain_name_length))),
420    namedtype.NamedType('printable', char.PrintableString().subtype(
421        subtypeSpec=constraint.ValueSizeConstraint(1, ub_domain_name_length)))
422)
423
424ub_generation_qualifier_length = univ.Integer(3)
425
426ub_given_name_length = univ.Integer(16)
427
428ub_initials_length = univ.Integer(5)
429
430
431class PersonalName(univ.Set):
432    pass
433
434
435PersonalName.componentType = namedtype.NamedTypes(
436    namedtype.NamedType('surname', char.PrintableString().subtype(
437        subtypeSpec=constraint.ValueSizeConstraint(1, ub_surname_length)).subtype(
438        implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 0))),
439    namedtype.OptionalNamedType('given-name', char.PrintableString().subtype(
440        subtypeSpec=constraint.ValueSizeConstraint(1, ub_given_name_length)).subtype(
441        implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 1))),
442    namedtype.OptionalNamedType('initials', char.PrintableString().subtype(
443        subtypeSpec=constraint.ValueSizeConstraint(1, ub_initials_length)).subtype(
444        implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 2))),
445    namedtype.OptionalNamedType('generation-qualifier', char.PrintableString().subtype(
446        subtypeSpec=constraint.ValueSizeConstraint(1, ub_generation_qualifier_length)).subtype(
447        implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 3)))
448)
449
450ub_terminal_id_length = univ.Integer(24)
451
452
453class TerminalIdentifier(char.PrintableString):
454    pass
455
456
457TerminalIdentifier.subtypeSpec = constraint.ValueSizeConstraint(1, ub_terminal_id_length)
458
459ub_x121_address_length = univ.Integer(16)
460
461
462class X121Address(char.NumericString):
463    pass
464
465
466X121Address.subtypeSpec = constraint.ValueSizeConstraint(1, ub_x121_address_length)
467
468
469class NetworkAddress(X121Address):
470    pass
471
472
473class BuiltInStandardAttributes(univ.Sequence):
474    pass
475
476
477BuiltInStandardAttributes.componentType = namedtype.NamedTypes(
478    namedtype.OptionalNamedType('country-name', CountryName()),
479    namedtype.OptionalNamedType('administration-domain-name', AdministrationDomainName()),
480    namedtype.OptionalNamedType('network-address', NetworkAddress().subtype(
481        implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 0))),
482    namedtype.OptionalNamedType('terminal-identifier', TerminalIdentifier().subtype(
483        implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 1))),
484    namedtype.OptionalNamedType('private-domain-name', PrivateDomainName().subtype(
485        explicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatConstructed, 2))),
486    namedtype.OptionalNamedType('organization-name', OrganizationName().subtype(
487        implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 3))),
488    namedtype.OptionalNamedType('numeric-user-identifier', NumericUserIdentifier().subtype(
489        implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 4))),
490    namedtype.OptionalNamedType('personal-name', PersonalName().subtype(
491        implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatConstructed, 5))),
492    namedtype.OptionalNamedType('organizational-unit-names', OrganizationalUnitNames().subtype(
493        implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 6)))
494)
495
496ub_domain_defined_attributes = univ.Integer(4)
497
498
499class BuiltInDomainDefinedAttribute(univ.Sequence):
500    pass
501
502
503BuiltInDomainDefinedAttribute.componentType = namedtype.NamedTypes(
504    namedtype.NamedType('type', char.PrintableString().subtype(
505        subtypeSpec=constraint.ValueSizeConstraint(1, ub_domain_defined_attribute_type_length))),
506    namedtype.NamedType('value', char.PrintableString().subtype(
507        subtypeSpec=constraint.ValueSizeConstraint(1, ub_domain_defined_attribute_value_length)))
508)
509
510
511class BuiltInDomainDefinedAttributes(univ.SequenceOf):
512    pass
513
514
515BuiltInDomainDefinedAttributes.componentType = BuiltInDomainDefinedAttribute()
516BuiltInDomainDefinedAttributes.subtypeSpec = constraint.ValueSizeConstraint(1, ub_domain_defined_attributes)
517
518ub_extension_attributes = univ.Integer(256)
519
520
521class ExtensionAttribute(univ.Sequence):
522    pass
523
524
525ExtensionAttribute.componentType = namedtype.NamedTypes(
526    namedtype.NamedType('extension-attribute-type', univ.Integer().subtype(
527        subtypeSpec=constraint.ValueRangeConstraint(0, ub_extension_attributes)).subtype(
528        implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 0))),
529    namedtype.NamedType('extension-attribute-value',
530                        univ.Any().subtype(explicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 1)))
531)
532
533
534class ExtensionAttributes(univ.SetOf):
535    pass
536
537
538ExtensionAttributes.componentType = ExtensionAttribute()
539ExtensionAttributes.subtypeSpec = constraint.ValueSizeConstraint(1, ub_extension_attributes)
540
541
542class ORAddress(univ.Sequence):
543    pass
544
545
546ORAddress.componentType = namedtype.NamedTypes(
547    namedtype.NamedType('built-in-standard-attributes', BuiltInStandardAttributes()),
548    namedtype.OptionalNamedType('built-in-domain-defined-attributes', BuiltInDomainDefinedAttributes()),
549    namedtype.OptionalNamedType('extension-attributes', ExtensionAttributes())
550)
551
552id_pe = _OID(id_pkix, 1)
553
554ub_title = univ.Integer(64)
555
556
557class X520Title(univ.Choice):
558    pass
559
560
561X520Title.componentType = namedtype.NamedTypes(
562    namedtype.NamedType('teletexString',
563                        char.TeletexString().subtype(subtypeSpec=constraint.ValueSizeConstraint(1, ub_title))),
564    namedtype.NamedType('printableString',
565                        char.PrintableString().subtype(subtypeSpec=constraint.ValueSizeConstraint(1, ub_title))),
566    namedtype.NamedType('universalString',
567                        char.UniversalString().subtype(subtypeSpec=constraint.ValueSizeConstraint(1, ub_title))),
568    namedtype.NamedType('utf8String',
569                        char.UTF8String().subtype(subtypeSpec=constraint.ValueSizeConstraint(1, ub_title))),
570    namedtype.NamedType('bmpString', char.BMPString().subtype(subtypeSpec=constraint.ValueSizeConstraint(1, ub_title)))
571)
572
573id_at_organizationalUnitName = _OID(id_at, 11)
574
575
576class EmailAddress(char.IA5String):
577    pass
578
579
580EmailAddress.subtypeSpec = constraint.ValueSizeConstraint(1, ub_emailaddress_length)
581
582physical_delivery_country_name = univ.Integer(8)
583
584id_at_givenName = _OID(id_at, 42)
585
586
587class TeletexCommonName(char.TeletexString):
588    pass
589
590
591TeletexCommonName.subtypeSpec = constraint.ValueSizeConstraint(1, ub_common_name_length)
592
593id_qt_cps = _OID(id_qt, 1)
594
595
596class LocalPostalAttributes(PDSParameter):
597    pass
598
599
600class StreetAddress(PDSParameter):
601    pass
602
603
604id_kp = _OID(id_pkix, 3)
605
606
607class DirectoryString(univ.Choice):
608    pass
609
610
611DirectoryString.componentType = namedtype.NamedTypes(
612    namedtype.NamedType('teletexString',
613                        char.TeletexString().subtype(subtypeSpec=constraint.ValueSizeConstraint(1, MAX))),
614    namedtype.NamedType('printableString',
615                        char.PrintableString().subtype(subtypeSpec=constraint.ValueSizeConstraint(1, MAX))),
616    namedtype.NamedType('universalString',
617                        char.UniversalString().subtype(subtypeSpec=constraint.ValueSizeConstraint(1, MAX))),
618    namedtype.NamedType('utf8String', char.UTF8String().subtype(subtypeSpec=constraint.ValueSizeConstraint(1, MAX))),
619    namedtype.NamedType('bmpString', char.BMPString().subtype(subtypeSpec=constraint.ValueSizeConstraint(1, MAX)))
620)
621
622
623class DomainComponent(char.IA5String):
624    pass
625
626
627id_at_initials = _OID(id_at, 43)
628
629id_qt_unotice = _OID(id_qt, 2)
630
631ub_pds_name_length = univ.Integer(16)
632
633
634class PDSName(char.PrintableString):
635    pass
636
637
638PDSName.subtypeSpec = constraint.ValueSizeConstraint(1, ub_pds_name_length)
639
640
641class PosteRestanteAddress(PDSParameter):
642    pass
643
644
645class DistinguishedName(RDNSequence):
646    pass
647
648
649class CommonName(char.PrintableString):
650    pass
651
652
653CommonName.subtypeSpec = constraint.ValueSizeConstraint(1, ub_common_name_length)
654
655ub_serial_number = univ.Integer(64)
656
657
658class X520SerialNumber(char.PrintableString):
659    pass
660
661
662X520SerialNumber.subtypeSpec = constraint.ValueSizeConstraint(1, ub_serial_number)
663
664id_at_generationQualifier = _OID(id_at, 44)
665
666ub_organizational_unit_name = univ.Integer(64)
667
668id_ad_ocsp = _OID(id_ad, 1)
669
670
671class TeletexOrganizationalUnitName(char.TeletexString):
672    pass
673
674
675TeletexOrganizationalUnitName.subtypeSpec = constraint.ValueSizeConstraint(1, ub_organizational_unit_name_length)
676
677
678class TeletexPersonalName(univ.Set):
679    pass
680
681
682TeletexPersonalName.componentType = namedtype.NamedTypes(
683    namedtype.NamedType('surname', char.TeletexString().subtype(
684        subtypeSpec=constraint.ValueSizeConstraint(1, ub_surname_length)).subtype(
685        implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 0))),
686    namedtype.OptionalNamedType('given-name', char.TeletexString().subtype(
687        subtypeSpec=constraint.ValueSizeConstraint(1, ub_given_name_length)).subtype(
688        implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 1))),
689    namedtype.OptionalNamedType('initials', char.TeletexString().subtype(
690        subtypeSpec=constraint.ValueSizeConstraint(1, ub_initials_length)).subtype(
691        implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 2))),
692    namedtype.OptionalNamedType('generation-qualifier', char.TeletexString().subtype(
693        subtypeSpec=constraint.ValueSizeConstraint(1, ub_generation_qualifier_length)).subtype(
694        implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 3)))
695)
696
697
698class TeletexDomainDefinedAttributes(univ.SequenceOf):
699    pass
700
701
702TeletexDomainDefinedAttributes.componentType = TeletexDomainDefinedAttribute()
703TeletexDomainDefinedAttributes.subtypeSpec = constraint.ValueSizeConstraint(1, ub_domain_defined_attributes)
704
705
706class TBSCertList(univ.Sequence):
707    pass
708
709
710TBSCertList.componentType = namedtype.NamedTypes(
711    namedtype.OptionalNamedType('version', Version()),
712    namedtype.NamedType('signature', AlgorithmIdentifier()),
713    namedtype.NamedType('issuer', Name()),
714    namedtype.NamedType('thisUpdate', Time()),
715    namedtype.OptionalNamedType('nextUpdate', Time()),
716    namedtype.OptionalNamedType('revokedCertificates',
717                                univ.SequenceOf(componentType=univ.Sequence(componentType=namedtype.NamedTypes(
718                                    namedtype.NamedType('userCertificate', CertificateSerialNumber()),
719                                    namedtype.NamedType('revocationDate', Time()),
720                                    namedtype.OptionalNamedType('crlEntryExtensions', Extensions())
721                                ))
722                                )),
723    namedtype.OptionalNamedType('crlExtensions',
724                                Extensions().subtype(explicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 0)))
725)
726
727local_postal_attributes = univ.Integer(21)
728
729pkcs_9 = _OID(1, 2, 840, 113549, 1, 9)
730
731
732class PhysicalDeliveryCountryName(univ.Choice):
733    pass
734
735
736PhysicalDeliveryCountryName.componentType = namedtype.NamedTypes(
737    namedtype.NamedType('x121-dcc-code', char.NumericString().subtype(
738        subtypeSpec=constraint.ValueSizeConstraint(ub_country_name_numeric_length, ub_country_name_numeric_length))),
739    namedtype.NamedType('iso-3166-alpha2-code', char.PrintableString().subtype(
740        subtypeSpec=constraint.ValueSizeConstraint(ub_country_name_alpha_length, ub_country_name_alpha_length)))
741)
742
743ub_name = univ.Integer(32768)
744
745
746class X520name(univ.Choice):
747    pass
748
749
750X520name.componentType = namedtype.NamedTypes(
751    namedtype.NamedType('teletexString',
752                        char.TeletexString().subtype(subtypeSpec=constraint.ValueSizeConstraint(1, ub_name))),
753    namedtype.NamedType('printableString',
754                        char.PrintableString().subtype(subtypeSpec=constraint.ValueSizeConstraint(1, ub_name))),
755    namedtype.NamedType('universalString',
756                        char.UniversalString().subtype(subtypeSpec=constraint.ValueSizeConstraint(1, ub_name))),
757    namedtype.NamedType('utf8String',
758                        char.UTF8String().subtype(subtypeSpec=constraint.ValueSizeConstraint(1, ub_name))),
759    namedtype.NamedType('bmpString', char.BMPString().subtype(subtypeSpec=constraint.ValueSizeConstraint(1, ub_name)))
760)
761
762id_emailAddress = _OID(pkcs_9, 1)
763
764
765class TerminalType(univ.Integer):
766    pass
767
768
769TerminalType.namedValues = namedval.NamedValues(
770    ('telex', 3),
771    ('teletex', 4),
772    ('g3-facsimile', 5),
773    ('g4-facsimile', 6),
774    ('ia5-terminal', 7),
775    ('videotex', 8)
776)
777
778
779class X520OrganizationalUnitName(univ.Choice):
780    pass
781
782
783X520OrganizationalUnitName.componentType = namedtype.NamedTypes(
784    namedtype.NamedType('teletexString', char.TeletexString().subtype(
785        subtypeSpec=constraint.ValueSizeConstraint(1, ub_organizational_unit_name))),
786    namedtype.NamedType('printableString', char.PrintableString().subtype(
787        subtypeSpec=constraint.ValueSizeConstraint(1, ub_organizational_unit_name))),
788    namedtype.NamedType('universalString', char.UniversalString().subtype(
789        subtypeSpec=constraint.ValueSizeConstraint(1, ub_organizational_unit_name))),
790    namedtype.NamedType('utf8String', char.UTF8String().subtype(
791        subtypeSpec=constraint.ValueSizeConstraint(1, ub_organizational_unit_name))),
792    namedtype.NamedType('bmpString', char.BMPString().subtype(
793        subtypeSpec=constraint.ValueSizeConstraint(1, ub_organizational_unit_name)))
794)
795
796id_at_commonName = _OID(id_at, 3)
797
798pds_name = univ.Integer(7)
799
800post_office_box_address = univ.Integer(18)
801
802ub_locality_name = univ.Integer(128)
803
804
805class X520LocalityName(univ.Choice):
806    pass
807
808
809X520LocalityName.componentType = namedtype.NamedTypes(
810    namedtype.NamedType('teletexString',
811                        char.TeletexString().subtype(subtypeSpec=constraint.ValueSizeConstraint(1, ub_locality_name))),
812    namedtype.NamedType('printableString', char.PrintableString().subtype(
813        subtypeSpec=constraint.ValueSizeConstraint(1, ub_locality_name))),
814    namedtype.NamedType('universalString', char.UniversalString().subtype(
815        subtypeSpec=constraint.ValueSizeConstraint(1, ub_locality_name))),
816    namedtype.NamedType('utf8String',
817                        char.UTF8String().subtype(subtypeSpec=constraint.ValueSizeConstraint(1, ub_locality_name))),
818    namedtype.NamedType('bmpString',
819                        char.BMPString().subtype(subtypeSpec=constraint.ValueSizeConstraint(1, ub_locality_name)))
820)
821
822id_ad_timeStamping = _OID(id_ad, 3)
823
824id_at_countryName = _OID(id_at, 6)
825
826physical_delivery_personal_name = univ.Integer(13)
827
828teletex_personal_name = univ.Integer(4)
829
830teletex_organizational_unit_names = univ.Integer(5)
831
832
833class PhysicalDeliveryPersonalName(PDSParameter):
834    pass
835
836
837ub_postal_code_length = univ.Integer(16)
838
839
840class PostalCode(univ.Choice):
841    pass
842
843
844PostalCode.componentType = namedtype.NamedTypes(
845    namedtype.NamedType('numeric-code', char.NumericString().subtype(
846        subtypeSpec=constraint.ValueSizeConstraint(1, ub_postal_code_length))),
847    namedtype.NamedType('printable-code', char.PrintableString().subtype(
848        subtypeSpec=constraint.ValueSizeConstraint(1, ub_postal_code_length)))
849)
850
851
852class X520countryName(char.PrintableString):
853    pass
854
855
856X520countryName.subtypeSpec = constraint.ValueSizeConstraint(2, 2)
857
858postal_code = univ.Integer(9)
859
860id_ad_caRepository = _OID(id_ad, 5)
861
862extension_physical_delivery_address_components = univ.Integer(15)
863
864
865class PostOfficeBoxAddress(PDSParameter):
866    pass
867
868
869class PhysicalDeliveryOfficeName(PDSParameter):
870    pass
871
872
873id_at_title = _OID(id_at, 12)
874
875id_at_serialNumber = _OID(id_at, 5)
876
877id_ad_caIssuers = _OID(id_ad, 2)
878
879ub_integer_options = univ.Integer(256)
880
881
882class CertificateList(univ.Sequence):
883    pass
884
885
886CertificateList.componentType = namedtype.NamedTypes(
887    namedtype.NamedType('tbsCertList', TBSCertList()),
888    namedtype.NamedType('signatureAlgorithm', AlgorithmIdentifier()),
889    namedtype.NamedType('signature', univ.BitString())
890)
891
892
893class PhysicalDeliveryOfficeNumber(PDSParameter):
894    pass
895
896
897class TeletexOrganizationalUnitNames(univ.SequenceOf):
898    pass
899
900
901TeletexOrganizationalUnitNames.componentType = TeletexOrganizationalUnitName()
902TeletexOrganizationalUnitNames.subtypeSpec = constraint.ValueSizeConstraint(1, ub_organizational_units)
903
904physical_delivery_office_name = univ.Integer(10)
905
906ub_common_name = univ.Integer(64)
907
908
909class ExtensionORAddressComponents(PDSParameter):
910    pass
911
912
913ub_pseudonym = univ.Integer(128)
914
915poste_restante_address = univ.Integer(19)
916
917id_at_organizationName = _OID(id_at, 10)
918
919physical_delivery_office_number = univ.Integer(11)
920
921id_at_pseudonym = _OID(id_at, 65)
922
923
924class X520CommonName(univ.Choice):
925    pass
926
927
928X520CommonName.componentType = namedtype.NamedTypes(
929    namedtype.NamedType('teletexString',
930                        char.TeletexString().subtype(subtypeSpec=constraint.ValueSizeConstraint(1, ub_common_name))),
931    namedtype.NamedType('printableString',
932                        char.PrintableString().subtype(subtypeSpec=constraint.ValueSizeConstraint(1, ub_common_name))),
933    namedtype.NamedType('universalString',
934                        char.UniversalString().subtype(subtypeSpec=constraint.ValueSizeConstraint(1, ub_common_name))),
935    namedtype.NamedType('utf8String',
936                        char.UTF8String().subtype(subtypeSpec=constraint.ValueSizeConstraint(1, ub_common_name))),
937    namedtype.NamedType('bmpString',
938                        char.BMPString().subtype(subtypeSpec=constraint.ValueSizeConstraint(1, ub_common_name)))
939)
940
941physical_delivery_organization_name = univ.Integer(14)
942
943
944class X520dnQualifier(char.PrintableString):
945    pass
946
947
948id_at_stateOrProvinceName = _OID(id_at, 8)
949
950common_name = univ.Integer(1)
951
952id_at_localityName = _OID(id_at, 7)
953
954ub_match = univ.Integer(128)
955
956ub_unformatted_address_length = univ.Integer(180)
957
958
959class Attribute(univ.Sequence):
960    pass
961
962
963Attribute.componentType = namedtype.NamedTypes(
964    namedtype.NamedType('type', AttributeType()),
965    namedtype.NamedType('values', univ.SetOf(componentType=AttributeValue()))
966)
967
968extended_network_address = univ.Integer(22)
969
970unique_postal_name = univ.Integer(20)
971
972ub_pds_physical_address_lines = univ.Integer(6)
973
974
975class UnformattedPostalAddress(univ.Set):
976    pass
977
978
979UnformattedPostalAddress.componentType = namedtype.NamedTypes(
980    namedtype.OptionalNamedType('printable-address', univ.SequenceOf(componentType=char.PrintableString().subtype(
981        subtypeSpec=constraint.ValueSizeConstraint(1, ub_pds_parameter_length)))),
982    namedtype.OptionalNamedType('teletex-string', char.TeletexString().subtype(
983        subtypeSpec=constraint.ValueSizeConstraint(1, ub_unformatted_address_length)))
984)
985
986
987class UniquePostalName(PDSParameter):
988    pass
989
990
991class X520Pseudonym(univ.Choice):
992    pass
993
994
995X520Pseudonym.componentType = namedtype.NamedTypes(
996    namedtype.NamedType('teletexString',
997                        char.TeletexString().subtype(subtypeSpec=constraint.ValueSizeConstraint(1, ub_pseudonym))),
998    namedtype.NamedType('printableString',
999                        char.PrintableString().subtype(subtypeSpec=constraint.ValueSizeConstraint(1, ub_pseudonym))),
1000    namedtype.NamedType('universalString',
1001                        char.UniversalString().subtype(subtypeSpec=constraint.ValueSizeConstraint(1, ub_pseudonym))),
1002    namedtype.NamedType('utf8String',
1003                        char.UTF8String().subtype(subtypeSpec=constraint.ValueSizeConstraint(1, ub_pseudonym))),
1004    namedtype.NamedType('bmpString',
1005                        char.BMPString().subtype(subtypeSpec=constraint.ValueSizeConstraint(1, ub_pseudonym)))
1006)
1007
1008teletex_organization_name = univ.Integer(3)
1009
1010teletex_domain_defined_attributes = univ.Integer(6)
1011
1012street_address = univ.Integer(17)
1013
1014id_kp_OCSPSigning = _OID(id_kp, 9)
1015
1016id_ce = _OID(2, 5, 29)
1017
1018id_ce_certificatePolicies = _OID(id_ce, 32)
1019
1020
1021class EDIPartyName(univ.Sequence):
1022    pass
1023
1024
1025EDIPartyName.componentType = namedtype.NamedTypes(
1026    namedtype.OptionalNamedType('nameAssigner', DirectoryString().subtype(
1027        implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 0))),
1028    namedtype.NamedType('partyName',
1029                        DirectoryString().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 1)))
1030)
1031
1032
1033class AnotherName(univ.Sequence):
1034    pass
1035
1036
1037AnotherName.componentType = namedtype.NamedTypes(
1038    namedtype.NamedType('type-id', univ.ObjectIdentifier()),
1039    namedtype.NamedType('value', univ.Any().subtype(explicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 0)))
1040)
1041
1042
1043class GeneralName(univ.Choice):
1044    pass
1045
1046
1047GeneralName.componentType = namedtype.NamedTypes(
1048    namedtype.NamedType('otherName',
1049                        AnotherName().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatConstructed, 0))),
1050    namedtype.NamedType('rfc822Name',
1051                        char.IA5String().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 1))),
1052    namedtype.NamedType('dNSName',
1053                        char.IA5String().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 2))),
1054    namedtype.NamedType('x400Address',
1055                        ORAddress().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 3))),
1056    namedtype.NamedType('directoryName',
1057                        Name().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatConstructed, 4))),
1058    namedtype.NamedType('ediPartyName',
1059                        EDIPartyName().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatConstructed, 5))),
1060    namedtype.NamedType('uniformResourceIdentifier',
1061                        char.IA5String().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 6))),
1062    namedtype.NamedType('iPAddress',
1063                        univ.OctetString().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 7))),
1064    namedtype.NamedType('registeredID', univ.ObjectIdentifier().subtype(
1065        implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 8)))
1066)
1067
1068
1069class GeneralNames(univ.SequenceOf):
1070    pass
1071
1072
1073GeneralNames.componentType = GeneralName()
1074GeneralNames.subtypeSpec = constraint.ValueSizeConstraint(1, MAX)
1075
1076
1077class IssuerAltName(GeneralNames):
1078    pass
1079
1080
1081id_ce_cRLDistributionPoints = _OID(id_ce, 31)
1082
1083
1084class CertPolicyId(univ.ObjectIdentifier):
1085    pass
1086
1087
1088class PolicyMappings(univ.SequenceOf):
1089    pass
1090
1091
1092PolicyMappings.componentType = univ.Sequence(componentType=namedtype.NamedTypes(
1093    namedtype.NamedType('issuerDomainPolicy', CertPolicyId()),
1094    namedtype.NamedType('subjectDomainPolicy', CertPolicyId())
1095))
1096
1097PolicyMappings.subtypeSpec = constraint.ValueSizeConstraint(1, MAX)
1098
1099
1100class PolicyQualifierId(univ.ObjectIdentifier):
1101    pass
1102
1103
1104holdInstruction = _OID(2, 2, 840, 10040, 2)
1105
1106id_ce_subjectDirectoryAttributes = _OID(id_ce, 9)
1107
1108id_holdinstruction_callissuer = _OID(holdInstruction, 2)
1109
1110
1111class SubjectDirectoryAttributes(univ.SequenceOf):
1112    pass
1113
1114
1115SubjectDirectoryAttributes.componentType = Attribute()
1116SubjectDirectoryAttributes.subtypeSpec = constraint.ValueSizeConstraint(1, MAX)
1117
1118anyPolicy = _OID(id_ce_certificatePolicies, 0)
1119
1120id_ce_subjectAltName = _OID(id_ce, 17)
1121
1122id_kp_emailProtection = _OID(id_kp, 4)
1123
1124
1125class ReasonFlags(univ.BitString):
1126    pass
1127
1128
1129ReasonFlags.namedValues = namedval.NamedValues(
1130    ('unused', 0),
1131    ('keyCompromise', 1),
1132    ('cACompromise', 2),
1133    ('affiliationChanged', 3),
1134    ('superseded', 4),
1135    ('cessationOfOperation', 5),
1136    ('certificateHold', 6),
1137    ('privilegeWithdrawn', 7),
1138    ('aACompromise', 8)
1139)
1140
1141
1142class DistributionPointName(univ.Choice):
1143    pass
1144
1145
1146DistributionPointName.componentType = namedtype.NamedTypes(
1147    namedtype.NamedType('fullName',
1148                        GeneralNames().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 0))),
1149    namedtype.NamedType('nameRelativeToCRLIssuer', RelativeDistinguishedName().subtype(
1150        implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 1)))
1151)
1152
1153
1154class DistributionPoint(univ.Sequence):
1155    pass
1156
1157
1158DistributionPoint.componentType = namedtype.NamedTypes(
1159    namedtype.OptionalNamedType('distributionPoint', DistributionPointName().subtype(
1160        implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatConstructed, 0))),
1161    namedtype.OptionalNamedType('reasons', ReasonFlags().subtype(
1162        implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 1))),
1163    namedtype.OptionalNamedType('cRLIssuer', GeneralNames().subtype(
1164        implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 2)))
1165)
1166
1167id_ce_keyUsage = _OID(id_ce, 15)
1168
1169
1170class PolicyQualifierInfo(univ.Sequence):
1171    pass
1172
1173
1174PolicyQualifierInfo.componentType = namedtype.NamedTypes(
1175    namedtype.NamedType('policyQualifierId', PolicyQualifierId()),
1176    namedtype.NamedType('qualifier', univ.Any())
1177)
1178
1179
1180class PolicyInformation(univ.Sequence):
1181    pass
1182
1183
1184PolicyInformation.componentType = namedtype.NamedTypes(
1185    namedtype.NamedType('policyIdentifier', CertPolicyId()),
1186    namedtype.OptionalNamedType('policyQualifiers', univ.SequenceOf(componentType=PolicyQualifierInfo()))
1187)
1188
1189
1190class CertificatePolicies(univ.SequenceOf):
1191    pass
1192
1193
1194CertificatePolicies.componentType = PolicyInformation()
1195CertificatePolicies.subtypeSpec = constraint.ValueSizeConstraint(1, MAX)
1196
1197id_ce_basicConstraints = _OID(id_ce, 19)
1198
1199
1200class HoldInstructionCode(univ.ObjectIdentifier):
1201    pass
1202
1203
1204class KeyPurposeId(univ.ObjectIdentifier):
1205    pass
1206
1207
1208class ExtKeyUsageSyntax(univ.SequenceOf):
1209    pass
1210
1211
1212ExtKeyUsageSyntax.componentType = KeyPurposeId()
1213ExtKeyUsageSyntax.subtypeSpec = constraint.ValueSizeConstraint(1, MAX)
1214
1215
1216class SubjectAltName(GeneralNames):
1217    pass
1218
1219
1220class BasicConstraints(univ.Sequence):
1221    pass
1222
1223
1224BasicConstraints.componentType = namedtype.NamedTypes(
1225    namedtype.DefaultedNamedType('cA', univ.Boolean().subtype(value=0)),
1226    namedtype.OptionalNamedType('pathLenConstraint',
1227                                univ.Integer().subtype(subtypeSpec=constraint.ValueRangeConstraint(0, MAX)))
1228)
1229
1230
1231class SkipCerts(univ.Integer):
1232    pass
1233
1234
1235SkipCerts.subtypeSpec = constraint.ValueRangeConstraint(0, MAX)
1236
1237
1238class InhibitAnyPolicy(SkipCerts):
1239    pass
1240
1241
1242class CRLNumber(univ.Integer):
1243    pass
1244
1245
1246CRLNumber.subtypeSpec = constraint.ValueRangeConstraint(0, MAX)
1247
1248
1249class BaseCRLNumber(CRLNumber):
1250    pass
1251
1252
1253class KeyIdentifier(univ.OctetString):
1254    pass
1255
1256
1257class AuthorityKeyIdentifier(univ.Sequence):
1258    pass
1259
1260
1261AuthorityKeyIdentifier.componentType = namedtype.NamedTypes(
1262    namedtype.OptionalNamedType('keyIdentifier', KeyIdentifier().subtype(
1263        implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 0))),
1264    namedtype.OptionalNamedType('authorityCertIssuer', GeneralNames().subtype(
1265        implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 1))),
1266    namedtype.OptionalNamedType('authorityCertSerialNumber', CertificateSerialNumber().subtype(
1267        implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 2)))
1268)
1269
1270id_ce_nameConstraints = _OID(id_ce, 30)
1271
1272id_kp_serverAuth = _OID(id_kp, 1)
1273
1274id_ce_freshestCRL = _OID(id_ce, 46)
1275
1276id_ce_cRLReasons = _OID(id_ce, 21)
1277
1278
1279class CRLDistributionPoints(univ.SequenceOf):
1280    pass
1281
1282
1283CRLDistributionPoints.componentType = DistributionPoint()
1284CRLDistributionPoints.subtypeSpec = constraint.ValueSizeConstraint(1, MAX)
1285
1286
1287class FreshestCRL(CRLDistributionPoints):
1288    pass
1289
1290
1291id_ce_inhibitAnyPolicy = _OID(id_ce, 54)
1292
1293
1294class CRLReason(univ.Enumerated):
1295    pass
1296
1297
1298CRLReason.namedValues = namedval.NamedValues(
1299    ('unspecified', 0),
1300    ('keyCompromise', 1),
1301    ('cACompromise', 2),
1302    ('affiliationChanged', 3),
1303    ('superseded', 4),
1304    ('cessationOfOperation', 5),
1305    ('certificateHold', 6),
1306    ('removeFromCRL', 8),
1307    ('privilegeWithdrawn', 9),
1308    ('aACompromise', 10)
1309)
1310
1311
1312class BaseDistance(univ.Integer):
1313    pass
1314
1315
1316BaseDistance.subtypeSpec = constraint.ValueRangeConstraint(0, MAX)
1317
1318
1319class GeneralSubtree(univ.Sequence):
1320    pass
1321
1322
1323GeneralSubtree.componentType = namedtype.NamedTypes(
1324    namedtype.NamedType('base', GeneralName()),
1325    namedtype.DefaultedNamedType('minimum', BaseDistance().subtype(
1326        implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 0)).subtype(value=0)),
1327    namedtype.OptionalNamedType('maximum', BaseDistance().subtype(
1328        implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 1)))
1329)
1330
1331
1332class GeneralSubtrees(univ.SequenceOf):
1333    pass
1334
1335
1336GeneralSubtrees.componentType = GeneralSubtree()
1337GeneralSubtrees.subtypeSpec = constraint.ValueSizeConstraint(1, MAX)
1338
1339
1340class NameConstraints(univ.Sequence):
1341    pass
1342
1343
1344NameConstraints.componentType = namedtype.NamedTypes(
1345    namedtype.OptionalNamedType('permittedSubtrees', GeneralSubtrees().subtype(
1346        implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 0))),
1347    namedtype.OptionalNamedType('excludedSubtrees', GeneralSubtrees().subtype(
1348        implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 1)))
1349)
1350
1351id_pe_authorityInfoAccess = _OID(id_pe, 1)
1352
1353id_pe_subjectInfoAccess = _OID(id_pe, 11)
1354
1355id_ce_certificateIssuer = _OID(id_ce, 29)
1356
1357id_ce_invalidityDate = _OID(id_ce, 24)
1358
1359
1360class DirectoryString(univ.Choice):
1361    pass
1362
1363
1364DirectoryString.componentType = namedtype.NamedTypes(
1365    namedtype.NamedType('any', univ.Any())
1366)
1367
1368id_ce_authorityKeyIdentifier = _OID(id_ce, 35)
1369
1370
1371class AccessDescription(univ.Sequence):
1372    pass
1373
1374
1375AccessDescription.componentType = namedtype.NamedTypes(
1376    namedtype.NamedType('accessMethod', univ.ObjectIdentifier()),
1377    namedtype.NamedType('accessLocation', GeneralName())
1378)
1379
1380
1381class AuthorityInfoAccessSyntax(univ.SequenceOf):
1382    pass
1383
1384
1385AuthorityInfoAccessSyntax.componentType = AccessDescription()
1386AuthorityInfoAccessSyntax.subtypeSpec = constraint.ValueSizeConstraint(1, MAX)
1387
1388id_ce_issuingDistributionPoint = _OID(id_ce, 28)
1389
1390
1391class CPSuri(char.IA5String):
1392    pass
1393
1394
1395class DisplayText(univ.Choice):
1396    pass
1397
1398
1399DisplayText.componentType = namedtype.NamedTypes(
1400    namedtype.NamedType('ia5String', char.IA5String().subtype(subtypeSpec=constraint.ValueSizeConstraint(1, 200))),
1401    namedtype.NamedType('visibleString',
1402                        char.VisibleString().subtype(subtypeSpec=constraint.ValueSizeConstraint(1, 200))),
1403    namedtype.NamedType('bmpString', char.BMPString().subtype(subtypeSpec=constraint.ValueSizeConstraint(1, 200))),
1404    namedtype.NamedType('utf8String', char.UTF8String().subtype(subtypeSpec=constraint.ValueSizeConstraint(1, 200)))
1405)
1406
1407
1408class NoticeReference(univ.Sequence):
1409    pass
1410
1411
1412NoticeReference.componentType = namedtype.NamedTypes(
1413    namedtype.NamedType('organization', DisplayText()),
1414    namedtype.NamedType('noticeNumbers', univ.SequenceOf(componentType=univ.Integer()))
1415)
1416
1417
1418class UserNotice(univ.Sequence):
1419    pass
1420
1421
1422UserNotice.componentType = namedtype.NamedTypes(
1423    namedtype.OptionalNamedType('noticeRef', NoticeReference()),
1424    namedtype.OptionalNamedType('explicitText', DisplayText())
1425)
1426
1427
1428class PrivateKeyUsagePeriod(univ.Sequence):
1429    pass
1430
1431
1432PrivateKeyUsagePeriod.componentType = namedtype.NamedTypes(
1433    namedtype.OptionalNamedType('notBefore', useful.GeneralizedTime().subtype(
1434        implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 0))),
1435    namedtype.OptionalNamedType('notAfter', useful.GeneralizedTime().subtype(
1436        implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 1)))
1437)
1438
1439id_ce_subjectKeyIdentifier = _OID(id_ce, 14)
1440
1441
1442class CertificateIssuer(GeneralNames):
1443    pass
1444
1445
1446class InvalidityDate(useful.GeneralizedTime):
1447    pass
1448
1449
1450class SubjectInfoAccessSyntax(univ.SequenceOf):
1451    pass
1452
1453
1454SubjectInfoAccessSyntax.componentType = AccessDescription()
1455SubjectInfoAccessSyntax.subtypeSpec = constraint.ValueSizeConstraint(1, MAX)
1456
1457
1458class KeyUsage(univ.BitString):
1459    pass
1460
1461
1462KeyUsage.namedValues = namedval.NamedValues(
1463    ('digitalSignature', 0),
1464    ('nonRepudiation', 1),
1465    ('keyEncipherment', 2),
1466    ('dataEncipherment', 3),
1467    ('keyAgreement', 4),
1468    ('keyCertSign', 5),
1469    ('cRLSign', 6),
1470    ('encipherOnly', 7),
1471    ('decipherOnly', 8)
1472)
1473
1474id_ce_extKeyUsage = _OID(id_ce, 37)
1475
1476anyExtendedKeyUsage = _OID(id_ce_extKeyUsage, 0)
1477
1478id_ce_privateKeyUsagePeriod = _OID(id_ce, 16)
1479
1480id_ce_policyMappings = _OID(id_ce, 33)
1481
1482id_ce_cRLNumber = _OID(id_ce, 20)
1483
1484id_ce_policyConstraints = _OID(id_ce, 36)
1485
1486id_holdinstruction_none = _OID(holdInstruction, 1)
1487
1488id_holdinstruction_reject = _OID(holdInstruction, 3)
1489
1490id_kp_timeStamping = _OID(id_kp, 8)
1491
1492
1493class PolicyConstraints(univ.Sequence):
1494    pass
1495
1496
1497PolicyConstraints.componentType = namedtype.NamedTypes(
1498    namedtype.OptionalNamedType('requireExplicitPolicy',
1499                                SkipCerts().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 0))),
1500    namedtype.OptionalNamedType('inhibitPolicyMapping',
1501                                SkipCerts().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 1)))
1502)
1503
1504
1505class SubjectKeyIdentifier(KeyIdentifier):
1506    pass
1507
1508
1509id_kp_clientAuth = _OID(id_kp, 2)
1510
1511id_ce_deltaCRLIndicator = _OID(id_ce, 27)
1512
1513id_ce_issuerAltName = _OID(id_ce, 18)
1514
1515id_kp_codeSigning = _OID(id_kp, 3)
1516
1517id_ce_holdInstructionCode = _OID(id_ce, 23)
1518
1519
1520class IssuingDistributionPoint(univ.Sequence):
1521    pass
1522
1523
1524IssuingDistributionPoint.componentType = namedtype.NamedTypes(
1525    namedtype.OptionalNamedType('distributionPoint', DistributionPointName().subtype(
1526        implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatConstructed, 0))),
1527    namedtype.DefaultedNamedType('onlyContainsUserCerts', univ.Boolean().subtype(
1528        implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 1)).subtype(value=0)),
1529    namedtype.DefaultedNamedType('onlyContainsCACerts', univ.Boolean().subtype(
1530        implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 2)).subtype(value=0)),
1531    namedtype.OptionalNamedType('onlySomeReasons', ReasonFlags().subtype(
1532        implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 3))),
1533    namedtype.DefaultedNamedType('indirectCRL', univ.Boolean().subtype(
1534        implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 4)).subtype(value=0)),
1535    namedtype.DefaultedNamedType('onlyContainsAttributeCerts', univ.Boolean().subtype(
1536        implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 5)).subtype(value=0))
1537)
1538