codekingpro/portable-devtools
114k
1# coding: utf-82#3# This file is part of pyasn1-modules software.4#5# Created by Stanisław Pitucha with asn1ate tool.6# Copyright (c) 2005-2020, Ilya Etingof <etingof@gmail.com>7# License: http://snmplabs.com/pyasn1/license.html8#9# Internet X.509 Public Key Infrastructure Certificate and Certificate10# Revocation List (CRL) Profile11#12# ASN.1 source from:13# http://www.ietf.org/rfc/rfc3280.txt14#15from pyasn1.type import char16from pyasn1.type import constraint17from pyasn1.type import namedtype18from pyasn1.type import namedval19from pyasn1.type import tag20from pyasn1.type import univ21from pyasn1.type import useful22 23MAX = float('inf')24 25 26def _OID(*components):27 output = []28 for x in tuple(components):29 if isinstance(x, univ.ObjectIdentifier):30 output.extend(list(x))31 else:32 output.append(int(x))33 34 return univ.ObjectIdentifier(output)35 36 37unformatted_postal_address = univ.Integer(16)38 39ub_organizational_units = univ.Integer(4)40 41ub_organizational_unit_name_length = univ.Integer(32)42 43 44class OrganizationalUnitName(char.PrintableString):45 pass46 47 48OrganizationalUnitName.subtypeSpec = constraint.ValueSizeConstraint(1, ub_organizational_unit_name_length)49 50 51class OrganizationalUnitNames(univ.SequenceOf):52 pass53 54 55OrganizationalUnitNames.componentType = OrganizationalUnitName()56OrganizationalUnitNames.sizeSpec = constraint.ValueSizeConstraint(1, ub_organizational_units)57 58 59class AttributeType(univ.ObjectIdentifier):60 pass61 62 63id_at = _OID(2, 5, 4)64 65id_at_name = _OID(id_at, 41)66 67ub_pds_parameter_length = univ.Integer(30)68 69 70class PDSParameter(univ.Set):71 pass72 73 74PDSParameter.componentType = namedtype.NamedTypes(75 namedtype.OptionalNamedType('printable-string', char.PrintableString().subtype(76 subtypeSpec=constraint.ValueSizeConstraint(1, ub_pds_parameter_length))),77 namedtype.OptionalNamedType('teletex-string', char.TeletexString().subtype(78 subtypeSpec=constraint.ValueSizeConstraint(1, ub_pds_parameter_length)))79)80 81 82class PhysicalDeliveryOrganizationName(PDSParameter):83 pass84 85 86ub_organization_name_length = univ.Integer(64)87 88ub_domain_defined_attribute_type_length = univ.Integer(8)89 90ub_domain_defined_attribute_value_length = univ.Integer(128)91 92 93class TeletexDomainDefinedAttribute(univ.Sequence):94 pass95 96 97TeletexDomainDefinedAttribute.componentType = namedtype.NamedTypes(98 namedtype.NamedType('type', char.TeletexString().subtype(99 subtypeSpec=constraint.ValueSizeConstraint(1, ub_domain_defined_attribute_type_length))),100 namedtype.NamedType('value', char.TeletexString().subtype(101 subtypeSpec=constraint.ValueSizeConstraint(1, ub_domain_defined_attribute_value_length)))102)103 104id_pkix = _OID(1, 3, 6, 1, 5, 5, 7)105 106id_qt = _OID(id_pkix, 2)107 108 109class PresentationAddress(univ.Sequence):110 pass111 112 113PresentationAddress.componentType = namedtype.NamedTypes(114 namedtype.OptionalNamedType('pSelector', univ.OctetString().subtype(115 explicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 0))),116 namedtype.OptionalNamedType('sSelector', univ.OctetString().subtype(117 explicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 1))),118 namedtype.OptionalNamedType('tSelector', univ.OctetString().subtype(119 explicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 2))),120 namedtype.NamedType('nAddresses', univ.SetOf(componentType=univ.OctetString()).subtype(121 explicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 3)))122)123 124 125class AlgorithmIdentifier(univ.Sequence):126 pass127 128 129AlgorithmIdentifier.componentType = namedtype.NamedTypes(130 namedtype.NamedType('algorithm', univ.ObjectIdentifier()),131 namedtype.OptionalNamedType('parameters', univ.Any())132)133 134 135class UniqueIdentifier(univ.BitString):136 pass137 138 139class Extension(univ.Sequence):140 pass141 142 143Extension.componentType = namedtype.NamedTypes(144 namedtype.NamedType('extnID', univ.ObjectIdentifier()),145 namedtype.DefaultedNamedType('critical', univ.Boolean().subtype(value=0)),146 namedtype.NamedType('extnValue', univ.OctetString())147)148 149 150class Extensions(univ.SequenceOf):151 pass152 153 154Extensions.componentType = Extension()155Extensions.sizeSpec = constraint.ValueSizeConstraint(1, MAX)156 157 158class CertificateSerialNumber(univ.Integer):159 pass160 161 162class SubjectPublicKeyInfo(univ.Sequence):163 pass164 165 166SubjectPublicKeyInfo.componentType = namedtype.NamedTypes(167 namedtype.NamedType('algorithm', AlgorithmIdentifier()),168 namedtype.NamedType('subjectPublicKey', univ.BitString())169)170 171 172class Time(univ.Choice):173 pass174 175 176Time.componentType = namedtype.NamedTypes(177 namedtype.NamedType('utcTime', useful.UTCTime()),178 namedtype.NamedType('generalTime', useful.GeneralizedTime())179)180 181 182class Validity(univ.Sequence):183 pass184 185 186Validity.componentType = namedtype.NamedTypes(187 namedtype.NamedType('notBefore', Time()),188 namedtype.NamedType('notAfter', Time())189)190 191 192class Version(univ.Integer):193 pass194 195 196Version.namedValues = namedval.NamedValues(197 ('v1', 0),198 ('v2', 1),199 ('v3', 2)200)201 202 203class AttributeValue(univ.Any):204 pass205 206 207class AttributeTypeAndValue(univ.Sequence):208 pass209 210 211AttributeTypeAndValue.componentType = namedtype.NamedTypes(212 namedtype.NamedType('type', AttributeType()),213 namedtype.NamedType('value', AttributeValue())214)215 216 217class RelativeDistinguishedName(univ.SetOf):218 pass219 220 221RelativeDistinguishedName.componentType = AttributeTypeAndValue()222RelativeDistinguishedName.sizeSpec = constraint.ValueSizeConstraint(1, MAX)223 224 225class RDNSequence(univ.SequenceOf):226 pass227 228 229RDNSequence.componentType = RelativeDistinguishedName()230 231 232class Name(univ.Choice):233 pass234 235 236Name.componentType = namedtype.NamedTypes(237 namedtype.NamedType('rdnSequence', RDNSequence())238)239 240 241class TBSCertificate(univ.Sequence):242 pass243 244 245TBSCertificate.componentType = namedtype.NamedTypes(246 namedtype.DefaultedNamedType('version',247 Version().subtype(explicitTag=tag.Tag(tag.tagClassContext,248 tag.tagFormatSimple, 0)).subtype(value="v1")),249 namedtype.NamedType('serialNumber', CertificateSerialNumber()),250 namedtype.NamedType('signature', AlgorithmIdentifier()),251 namedtype.NamedType('issuer', Name()),252 namedtype.NamedType('validity', Validity()),253 namedtype.NamedType('subject', Name()),254 namedtype.NamedType('subjectPublicKeyInfo', SubjectPublicKeyInfo()),255 namedtype.OptionalNamedType('issuerUniqueID', UniqueIdentifier().subtype(256 implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 1))),257 namedtype.OptionalNamedType('subjectUniqueID', UniqueIdentifier().subtype(258 implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 2))),259 namedtype.OptionalNamedType('extensions',260 Extensions().subtype(explicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 3)))261)262 263 264class Certificate(univ.Sequence):265 pass266 267 268Certificate.componentType = namedtype.NamedTypes(269 namedtype.NamedType('tbsCertificate', TBSCertificate()),270 namedtype.NamedType('signatureAlgorithm', AlgorithmIdentifier()),271 namedtype.NamedType('signature', univ.BitString())272)273 274ub_surname_length = univ.Integer(40)275 276 277class TeletexOrganizationName(char.TeletexString):278 pass279 280 281TeletexOrganizationName.subtypeSpec = constraint.ValueSizeConstraint(1, ub_organization_name_length)282 283ub_e163_4_sub_address_length = univ.Integer(40)284 285teletex_common_name = univ.Integer(2)286 287ub_country_name_alpha_length = univ.Integer(2)288 289ub_country_name_numeric_length = univ.Integer(3)290 291 292class CountryName(univ.Choice):293 pass294 295 296CountryName.tagSet = univ.Choice.tagSet.tagExplicitly(tag.Tag(tag.tagClassApplication, tag.tagFormatConstructed, 1))297CountryName.componentType = namedtype.NamedTypes(298 namedtype.NamedType('x121-dcc-code', char.NumericString().subtype(299 subtypeSpec=constraint.ValueSizeConstraint(ub_country_name_numeric_length, ub_country_name_numeric_length))),300 namedtype.NamedType('iso-3166-alpha2-code', char.PrintableString().subtype(301 subtypeSpec=constraint.ValueSizeConstraint(ub_country_name_alpha_length, ub_country_name_alpha_length)))302)303 304extension_OR_address_components = univ.Integer(12)305 306id_at_dnQualifier = _OID(id_at, 46)307 308ub_e163_4_number_length = univ.Integer(15)309 310 311class ExtendedNetworkAddress(univ.Choice):312 pass313 314 315ExtendedNetworkAddress.componentType = namedtype.NamedTypes(316 namedtype.NamedType('e163-4-address', univ.Sequence(componentType=namedtype.NamedTypes(317 namedtype.NamedType('number', char.NumericString().subtype(318 subtypeSpec=constraint.ValueSizeConstraint(1, ub_e163_4_number_length)).subtype(319 implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 0))),320 namedtype.OptionalNamedType('sub-address', char.NumericString().subtype(321 subtypeSpec=constraint.ValueSizeConstraint(1, ub_e163_4_sub_address_length)).subtype(322 implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 1)))323 ))324 ),325 namedtype.NamedType('psap-address', PresentationAddress().subtype(326 implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatConstructed, 0)))327)328 329terminal_type = univ.Integer(23)330 331id_domainComponent = _OID(0, 9, 2342, 19200300, 100, 1, 25)332 333ub_state_name = univ.Integer(128)334 335 336class X520StateOrProvinceName(univ.Choice):337 pass338 339 340X520StateOrProvinceName.componentType = namedtype.NamedTypes(341 namedtype.NamedType('teletexString',342 char.TeletexString().subtype(subtypeSpec=constraint.ValueSizeConstraint(1, ub_state_name))),343 namedtype.NamedType('printableString',344 char.PrintableString().subtype(subtypeSpec=constraint.ValueSizeConstraint(1, ub_state_name))),345 namedtype.NamedType('universalString',346 char.UniversalString().subtype(subtypeSpec=constraint.ValueSizeConstraint(1, ub_state_name))),347 namedtype.NamedType('utf8String',348 char.UTF8String().subtype(subtypeSpec=constraint.ValueSizeConstraint(1, ub_state_name))),349 namedtype.NamedType('bmpString',350 char.BMPString().subtype(subtypeSpec=constraint.ValueSizeConstraint(1, ub_state_name)))351)352 353ub_organization_name = univ.Integer(64)354 355 356class X520OrganizationName(univ.Choice):357 pass358 359 360X520OrganizationName.componentType = namedtype.NamedTypes(361 namedtype.NamedType('teletexString', char.TeletexString().subtype(362 subtypeSpec=constraint.ValueSizeConstraint(1, ub_organization_name))),363 namedtype.NamedType('printableString', char.PrintableString().subtype(364 subtypeSpec=constraint.ValueSizeConstraint(1, ub_organization_name))),365 namedtype.NamedType('universalString', char.UniversalString().subtype(366 subtypeSpec=constraint.ValueSizeConstraint(1, ub_organization_name))),367 namedtype.NamedType('utf8String',368 char.UTF8String().subtype(subtypeSpec=constraint.ValueSizeConstraint(1, ub_organization_name))),369 namedtype.NamedType('bmpString',370 char.BMPString().subtype(subtypeSpec=constraint.ValueSizeConstraint(1, ub_organization_name)))371)372 373ub_emailaddress_length = univ.Integer(128)374 375 376class ExtensionPhysicalDeliveryAddressComponents(PDSParameter):377 pass378 379 380id_at_surname = _OID(id_at, 4)381 382ub_common_name_length = univ.Integer(64)383 384id_ad = _OID(id_pkix, 48)385 386ub_numeric_user_id_length = univ.Integer(32)387 388 389class NumericUserIdentifier(char.NumericString):390 pass391 392 393NumericUserIdentifier.subtypeSpec = constraint.ValueSizeConstraint(1, ub_numeric_user_id_length)394 395 396class OrganizationName(char.PrintableString):397 pass398 399 400OrganizationName.subtypeSpec = constraint.ValueSizeConstraint(1, ub_organization_name_length)401 402ub_domain_name_length = univ.Integer(16)403 404 405class AdministrationDomainName(univ.Choice):406 pass407 408 409AdministrationDomainName.tagSet = univ.Choice.tagSet.tagExplicitly(410 tag.Tag(tag.tagClassApplication, tag.tagFormatConstructed, 2))411AdministrationDomainName.componentType = namedtype.NamedTypes(412 namedtype.NamedType('numeric', char.NumericString().subtype(413 subtypeSpec=constraint.ValueSizeConstraint(0, ub_domain_name_length))),414 namedtype.NamedType('printable', char.PrintableString().subtype(415 subtypeSpec=constraint.ValueSizeConstraint(0, ub_domain_name_length)))416)417 418 419class PrivateDomainName(univ.Choice):420 pass421 422 423PrivateDomainName.componentType = namedtype.NamedTypes(424 namedtype.NamedType('numeric', char.NumericString().subtype(425 subtypeSpec=constraint.ValueSizeConstraint(1, ub_domain_name_length))),426 namedtype.NamedType('printable', char.PrintableString().subtype(427 subtypeSpec=constraint.ValueSizeConstraint(1, ub_domain_name_length)))428)429 430ub_generation_qualifier_length = univ.Integer(3)431 432ub_given_name_length = univ.Integer(16)433 434ub_initials_length = univ.Integer(5)435 436 437class PersonalName(univ.Set):438 pass439 440 441PersonalName.componentType = namedtype.NamedTypes(442 namedtype.NamedType('surname', char.PrintableString().subtype(443 subtypeSpec=constraint.ValueSizeConstraint(1, ub_surname_length)).subtype(444 implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 0))),445 namedtype.OptionalNamedType('given-name', char.PrintableString().subtype(446 subtypeSpec=constraint.ValueSizeConstraint(1, ub_given_name_length)).subtype(447 implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 1))),448 namedtype.OptionalNamedType('initials', char.PrintableString().subtype(449 subtypeSpec=constraint.ValueSizeConstraint(1, ub_initials_length)).subtype(450 implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 2))),451 namedtype.OptionalNamedType('generation-qualifier', char.PrintableString().subtype(452 subtypeSpec=constraint.ValueSizeConstraint(1, ub_generation_qualifier_length)).subtype(453 implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 3)))454)455 456ub_terminal_id_length = univ.Integer(24)457 458 459class TerminalIdentifier(char.PrintableString):460 pass461 462 463TerminalIdentifier.subtypeSpec = constraint.ValueSizeConstraint(1, ub_terminal_id_length)464 465ub_x121_address_length = univ.Integer(16)466 467 468class X121Address(char.NumericString):469 pass470 471 472X121Address.subtypeSpec = constraint.ValueSizeConstraint(1, ub_x121_address_length)473 474 475class NetworkAddress(X121Address):476 pass477 478 479class BuiltInStandardAttributes(univ.Sequence):480 pass481 482 483BuiltInStandardAttributes.componentType = namedtype.NamedTypes(484 namedtype.OptionalNamedType('country-name', CountryName()),485 namedtype.OptionalNamedType('administration-domain-name', AdministrationDomainName()),486 namedtype.OptionalNamedType('network-address', NetworkAddress().subtype(487 implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 0))),488 namedtype.OptionalNamedType('terminal-identifier', TerminalIdentifier().subtype(489 implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 1))),490 namedtype.OptionalNamedType('private-domain-name', PrivateDomainName().subtype(491 explicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatConstructed, 2))),492 namedtype.OptionalNamedType('organization-name', OrganizationName().subtype(493 implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 3))),494 namedtype.OptionalNamedType('numeric-user-identifier', NumericUserIdentifier().subtype(495 implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 4))),496 namedtype.OptionalNamedType('personal-name', PersonalName().subtype(497 implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatConstructed, 5))),498 namedtype.OptionalNamedType('organizational-unit-names', OrganizationalUnitNames().subtype(499 implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 6)))500)501 502ub_domain_defined_attributes = univ.Integer(4)503 504 505class BuiltInDomainDefinedAttribute(univ.Sequence):506 pass507 508 509BuiltInDomainDefinedAttribute.componentType = namedtype.NamedTypes(510 namedtype.NamedType('type', char.PrintableString().subtype(511 subtypeSpec=constraint.ValueSizeConstraint(1, ub_domain_defined_attribute_type_length))),512 namedtype.NamedType('value', char.PrintableString().subtype(513 subtypeSpec=constraint.ValueSizeConstraint(1, ub_domain_defined_attribute_value_length)))514)515 516 517class BuiltInDomainDefinedAttributes(univ.SequenceOf):518 pass519 520 521BuiltInDomainDefinedAttributes.componentType = BuiltInDomainDefinedAttribute()522BuiltInDomainDefinedAttributes.sizeSpec = constraint.ValueSizeConstraint(1, ub_domain_defined_attributes)523 524ub_extension_attributes = univ.Integer(256)525 526 527class ExtensionAttribute(univ.Sequence):528 pass529 530 531ExtensionAttribute.componentType = namedtype.NamedTypes(532 namedtype.NamedType('extension-attribute-type', univ.Integer().subtype(533 subtypeSpec=constraint.ValueRangeConstraint(0, ub_extension_attributes)).subtype(534 implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 0))),535 namedtype.NamedType('extension-attribute-value',536 univ.Any().subtype(explicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 1)))537)538 539 540class ExtensionAttributes(univ.SetOf):541 pass542 543 544ExtensionAttributes.componentType = ExtensionAttribute()545ExtensionAttributes.sizeSpec = constraint.ValueSizeConstraint(1, ub_extension_attributes)546 547 548class ORAddress(univ.Sequence):549 pass550 551 552ORAddress.componentType = namedtype.NamedTypes(553 namedtype.NamedType('built-in-standard-attributes', BuiltInStandardAttributes()),554 namedtype.OptionalNamedType('built-in-domain-defined-attributes', BuiltInDomainDefinedAttributes()),555 namedtype.OptionalNamedType('extension-attributes', ExtensionAttributes())556)557 558id_pe = _OID(id_pkix, 1)559 560ub_title = univ.Integer(64)561 562 563class X520Title(univ.Choice):564 pass565 566 567X520Title.componentType = namedtype.NamedTypes(568 namedtype.NamedType('teletexString',569 char.TeletexString().subtype(subtypeSpec=constraint.ValueSizeConstraint(1, ub_title))),570 namedtype.NamedType('printableString',571 char.PrintableString().subtype(subtypeSpec=constraint.ValueSizeConstraint(1, ub_title))),572 namedtype.NamedType('universalString',573 char.UniversalString().subtype(subtypeSpec=constraint.ValueSizeConstraint(1, ub_title))),574 namedtype.NamedType('utf8String',575 char.UTF8String().subtype(subtypeSpec=constraint.ValueSizeConstraint(1, ub_title))),576 namedtype.NamedType('bmpString', char.BMPString().subtype(subtypeSpec=constraint.ValueSizeConstraint(1, ub_title)))577)578 579id_at_organizationalUnitName = _OID(id_at, 11)580 581 582class EmailAddress(char.IA5String):583 pass584 585 586EmailAddress.subtypeSpec = constraint.ValueSizeConstraint(1, ub_emailaddress_length)587 588physical_delivery_country_name = univ.Integer(8)589 590id_at_givenName = _OID(id_at, 42)591 592 593class TeletexCommonName(char.TeletexString):594 pass595 596 597TeletexCommonName.subtypeSpec = constraint.ValueSizeConstraint(1, ub_common_name_length)598 599id_qt_cps = _OID(id_qt, 1)600 601 602class LocalPostalAttributes(PDSParameter):603 pass604 605 606class StreetAddress(PDSParameter):607 pass608 609 610id_kp = _OID(id_pkix, 3)611 612 613class DirectoryString(univ.Choice):614 pass615 616 617DirectoryString.componentType = namedtype.NamedTypes(618 namedtype.NamedType('teletexString',619 char.TeletexString().subtype(subtypeSpec=constraint.ValueSizeConstraint(1, MAX))),620 namedtype.NamedType('printableString',621 char.PrintableString().subtype(subtypeSpec=constraint.ValueSizeConstraint(1, MAX))),622 namedtype.NamedType('universalString',623 char.UniversalString().subtype(subtypeSpec=constraint.ValueSizeConstraint(1, MAX))),624 namedtype.NamedType('utf8String', char.UTF8String().subtype(subtypeSpec=constraint.ValueSizeConstraint(1, MAX))),625 namedtype.NamedType('bmpString', char.BMPString().subtype(subtypeSpec=constraint.ValueSizeConstraint(1, MAX)))626)627 628 629class DomainComponent(char.IA5String):630 pass631 632 633id_at_initials = _OID(id_at, 43)634 635id_qt_unotice = _OID(id_qt, 2)636 637ub_pds_name_length = univ.Integer(16)638 639 640class PDSName(char.PrintableString):641 pass642 643 644PDSName.subtypeSpec = constraint.ValueSizeConstraint(1, ub_pds_name_length)645 646 647class PosteRestanteAddress(PDSParameter):648 pass649 650 651class DistinguishedName(RDNSequence):652 pass653 654 655class CommonName(char.PrintableString):656 pass657 658 659CommonName.subtypeSpec = constraint.ValueSizeConstraint(1, ub_common_name_length)660 661ub_serial_number = univ.Integer(64)662 663 664class X520SerialNumber(char.PrintableString):665 pass666 667 668X520SerialNumber.subtypeSpec = constraint.ValueSizeConstraint(1, ub_serial_number)669 670id_at_generationQualifier = _OID(id_at, 44)671 672ub_organizational_unit_name = univ.Integer(64)673 674id_ad_ocsp = _OID(id_ad, 1)675 676 677class TeletexOrganizationalUnitName(char.TeletexString):678 pass679 680 681TeletexOrganizationalUnitName.subtypeSpec = constraint.ValueSizeConstraint(1, ub_organizational_unit_name_length)682 683 684class TeletexPersonalName(univ.Set):685 pass686 687 688TeletexPersonalName.componentType = namedtype.NamedTypes(689 namedtype.NamedType('surname', char.TeletexString().subtype(690 subtypeSpec=constraint.ValueSizeConstraint(1, ub_surname_length)).subtype(691 implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 0))),692 namedtype.OptionalNamedType('given-name', char.TeletexString().subtype(693 subtypeSpec=constraint.ValueSizeConstraint(1, ub_given_name_length)).subtype(694 implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 1))),695 namedtype.OptionalNamedType('initials', char.TeletexString().subtype(696 subtypeSpec=constraint.ValueSizeConstraint(1, ub_initials_length)).subtype(697 implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 2))),698 namedtype.OptionalNamedType('generation-qualifier', char.TeletexString().subtype(699 subtypeSpec=constraint.ValueSizeConstraint(1, ub_generation_qualifier_length)).subtype(700 implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 3)))701)702 703 704class TeletexDomainDefinedAttributes(univ.SequenceOf):705 pass706 707 708TeletexDomainDefinedAttributes.componentType = TeletexDomainDefinedAttribute()709TeletexDomainDefinedAttributes.sizeSpec = constraint.ValueSizeConstraint(1, ub_domain_defined_attributes)710 711 712class TBSCertList(univ.Sequence):713 pass714 715 716TBSCertList.componentType = namedtype.NamedTypes(717 namedtype.OptionalNamedType('version', Version()),718 namedtype.NamedType('signature', AlgorithmIdentifier()),719 namedtype.NamedType('issuer', Name()),720 namedtype.NamedType('thisUpdate', Time()),721 namedtype.OptionalNamedType('nextUpdate', Time()),722 namedtype.OptionalNamedType('revokedCertificates',723 univ.SequenceOf(componentType=univ.Sequence(componentType=namedtype.NamedTypes(724 namedtype.NamedType('userCertificate', CertificateSerialNumber()),725 namedtype.NamedType('revocationDate', Time()),726 namedtype.OptionalNamedType('crlEntryExtensions', Extensions())727 ))728 )),729 namedtype.OptionalNamedType('crlExtensions',730 Extensions().subtype(explicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 0)))731)732 733local_postal_attributes = univ.Integer(21)734 735pkcs_9 = _OID(1, 2, 840, 113549, 1, 9)736 737 738class PhysicalDeliveryCountryName(univ.Choice):739 pass740 741 742PhysicalDeliveryCountryName.componentType = namedtype.NamedTypes(743 namedtype.NamedType('x121-dcc-code', char.NumericString().subtype(744 subtypeSpec=constraint.ValueSizeConstraint(ub_country_name_numeric_length, ub_country_name_numeric_length))),745 namedtype.NamedType('iso-3166-alpha2-code', char.PrintableString().subtype(746 subtypeSpec=constraint.ValueSizeConstraint(ub_country_name_alpha_length, ub_country_name_alpha_length)))747)748 749ub_name = univ.Integer(32768)750 751 752class X520name(univ.Choice):753 pass754 755 756X520name.componentType = namedtype.NamedTypes(757 namedtype.NamedType('teletexString',758 char.TeletexString().subtype(subtypeSpec=constraint.ValueSizeConstraint(1, ub_name))),759 namedtype.NamedType('printableString',760 char.PrintableString().subtype(subtypeSpec=constraint.ValueSizeConstraint(1, ub_name))),761 namedtype.NamedType('universalString',762 char.UniversalString().subtype(subtypeSpec=constraint.ValueSizeConstraint(1, ub_name))),763 namedtype.NamedType('utf8String',764 char.UTF8String().subtype(subtypeSpec=constraint.ValueSizeConstraint(1, ub_name))),765 namedtype.NamedType('bmpString', char.BMPString().subtype(subtypeSpec=constraint.ValueSizeConstraint(1, ub_name)))766)767 768id_emailAddress = _OID(pkcs_9, 1)769 770 771class TerminalType(univ.Integer):772 pass773 774 775TerminalType.namedValues = namedval.NamedValues(776 ('telex', 3),777 ('teletex', 4),778 ('g3-facsimile', 5),779 ('g4-facsimile', 6),780 ('ia5-terminal', 7),781 ('videotex', 8)782)783 784 785class X520OrganizationalUnitName(univ.Choice):786 pass787 788 789X520OrganizationalUnitName.componentType = namedtype.NamedTypes(790 namedtype.NamedType('teletexString', char.TeletexString().subtype(791 subtypeSpec=constraint.ValueSizeConstraint(1, ub_organizational_unit_name))),792 namedtype.NamedType('printableString', char.PrintableString().subtype(793 subtypeSpec=constraint.ValueSizeConstraint(1, ub_organizational_unit_name))),794 namedtype.NamedType('universalString', char.UniversalString().subtype(795 subtypeSpec=constraint.ValueSizeConstraint(1, ub_organizational_unit_name))),796 namedtype.NamedType('utf8String', char.UTF8String().subtype(797 subtypeSpec=constraint.ValueSizeConstraint(1, ub_organizational_unit_name))),798 namedtype.NamedType('bmpString', char.BMPString().subtype(799 subtypeSpec=constraint.ValueSizeConstraint(1, ub_organizational_unit_name)))800)801 802id_at_commonName = _OID(id_at, 3)803 804pds_name = univ.Integer(7)805 806post_office_box_address = univ.Integer(18)807 808ub_locality_name = univ.Integer(128)809 810 811class X520LocalityName(univ.Choice):812 pass813 814 815X520LocalityName.componentType = namedtype.NamedTypes(816 namedtype.NamedType('teletexString',817 char.TeletexString().subtype(subtypeSpec=constraint.ValueSizeConstraint(1, ub_locality_name))),818 namedtype.NamedType('printableString', char.PrintableString().subtype(819 subtypeSpec=constraint.ValueSizeConstraint(1, ub_locality_name))),820 namedtype.NamedType('universalString', char.UniversalString().subtype(821 subtypeSpec=constraint.ValueSizeConstraint(1, ub_locality_name))),822 namedtype.NamedType('utf8String',823 char.UTF8String().subtype(subtypeSpec=constraint.ValueSizeConstraint(1, ub_locality_name))),824 namedtype.NamedType('bmpString',825 char.BMPString().subtype(subtypeSpec=constraint.ValueSizeConstraint(1, ub_locality_name)))826)827 828id_ad_timeStamping = _OID(id_ad, 3)829 830id_at_countryName = _OID(id_at, 6)831 832physical_delivery_personal_name = univ.Integer(13)833 834teletex_personal_name = univ.Integer(4)835 836teletex_organizational_unit_names = univ.Integer(5)837 838 839class PhysicalDeliveryPersonalName(PDSParameter):840 pass841 842 843ub_postal_code_length = univ.Integer(16)844 845 846class PostalCode(univ.Choice):847 pass848 849 850PostalCode.componentType = namedtype.NamedTypes(851 namedtype.NamedType('numeric-code', char.NumericString().subtype(852 subtypeSpec=constraint.ValueSizeConstraint(1, ub_postal_code_length))),853 namedtype.NamedType('printable-code', char.PrintableString().subtype(854 subtypeSpec=constraint.ValueSizeConstraint(1, ub_postal_code_length)))855)856 857 858class X520countryName(char.PrintableString):859 pass860 861 862X520countryName.subtypeSpec = constraint.ValueSizeConstraint(2, 2)863 864postal_code = univ.Integer(9)865 866id_ad_caRepository = _OID(id_ad, 5)867 868extension_physical_delivery_address_components = univ.Integer(15)869 870 871class PostOfficeBoxAddress(PDSParameter):872 pass873 874 875class PhysicalDeliveryOfficeName(PDSParameter):876 pass877 878 879id_at_title = _OID(id_at, 12)880 881id_at_serialNumber = _OID(id_at, 5)882 883id_ad_caIssuers = _OID(id_ad, 2)884 885ub_integer_options = univ.Integer(256)886 887 888class CertificateList(univ.Sequence):889 pass890 891 892CertificateList.componentType = namedtype.NamedTypes(893 namedtype.NamedType('tbsCertList', TBSCertList()),894 namedtype.NamedType('signatureAlgorithm', AlgorithmIdentifier()),895 namedtype.NamedType('signature', univ.BitString())896)897 898 899class PhysicalDeliveryOfficeNumber(PDSParameter):900 pass901 902 903class TeletexOrganizationalUnitNames(univ.SequenceOf):904 pass905 906 907TeletexOrganizationalUnitNames.componentType = TeletexOrganizationalUnitName()908TeletexOrganizationalUnitNames.sizeSpec = constraint.ValueSizeConstraint(1, ub_organizational_units)909 910physical_delivery_office_name = univ.Integer(10)911 912ub_common_name = univ.Integer(64)913 914 915class ExtensionORAddressComponents(PDSParameter):916 pass917 918 919ub_pseudonym = univ.Integer(128)920 921poste_restante_address = univ.Integer(19)922 923id_at_organizationName = _OID(id_at, 10)924 925physical_delivery_office_number = univ.Integer(11)926 927id_at_pseudonym = _OID(id_at, 65)928 929 930class X520CommonName(univ.Choice):931 pass932 933 934X520CommonName.componentType = namedtype.NamedTypes(935 namedtype.NamedType('teletexString',936 char.TeletexString().subtype(subtypeSpec=constraint.ValueSizeConstraint(1, ub_common_name))),937 namedtype.NamedType('printableString',938 char.PrintableString().subtype(subtypeSpec=constraint.ValueSizeConstraint(1, ub_common_name))),939 namedtype.NamedType('universalString',940 char.UniversalString().subtype(subtypeSpec=constraint.ValueSizeConstraint(1, ub_common_name))),941 namedtype.NamedType('utf8String',942 char.UTF8String().subtype(subtypeSpec=constraint.ValueSizeConstraint(1, ub_common_name))),943 namedtype.NamedType('bmpString',944 char.BMPString().subtype(subtypeSpec=constraint.ValueSizeConstraint(1, ub_common_name)))945)946 947physical_delivery_organization_name = univ.Integer(14)948 949 950class X520dnQualifier(char.PrintableString):951 pass952 953 954id_at_stateOrProvinceName = _OID(id_at, 8)955 956common_name = univ.Integer(1)957 958id_at_localityName = _OID(id_at, 7)959 960ub_match = univ.Integer(128)961 962ub_unformatted_address_length = univ.Integer(180)963 964 965class Attribute(univ.Sequence):966 pass967 968 969Attribute.componentType = namedtype.NamedTypes(970 namedtype.NamedType('type', AttributeType()),971 namedtype.NamedType('values', univ.SetOf(componentType=AttributeValue()))972)973 974extended_network_address = univ.Integer(22)975 976unique_postal_name = univ.Integer(20)977 978ub_pds_physical_address_lines = univ.Integer(6)979 980 981class UnformattedPostalAddress(univ.Set):982 pass983 984 985UnformattedPostalAddress.componentType = namedtype.NamedTypes(986 namedtype.OptionalNamedType('printable-address', univ.SequenceOf(componentType=char.PrintableString().subtype(987 subtypeSpec=constraint.ValueSizeConstraint(1, ub_pds_parameter_length)))),988 namedtype.OptionalNamedType('teletex-string', char.TeletexString().subtype(989 subtypeSpec=constraint.ValueSizeConstraint(1, ub_unformatted_address_length)))990)991 992 993class UniquePostalName(PDSParameter):994 pass995 996 997class X520Pseudonym(univ.Choice):998 pass999 1000 1001X520Pseudonym.componentType = namedtype.NamedTypes(1002 namedtype.NamedType('teletexString',1003 char.TeletexString().subtype(subtypeSpec=constraint.ValueSizeConstraint(1, ub_pseudonym))),1004 namedtype.NamedType('printableString',1005 char.PrintableString().subtype(subtypeSpec=constraint.ValueSizeConstraint(1, ub_pseudonym))),1006 namedtype.NamedType('universalString',1007 char.UniversalString().subtype(subtypeSpec=constraint.ValueSizeConstraint(1, ub_pseudonym))),1008 namedtype.NamedType('utf8String',1009 char.UTF8String().subtype(subtypeSpec=constraint.ValueSizeConstraint(1, ub_pseudonym))),1010 namedtype.NamedType('bmpString',1011 char.BMPString().subtype(subtypeSpec=constraint.ValueSizeConstraint(1, ub_pseudonym)))1012)1013 1014teletex_organization_name = univ.Integer(3)1015 1016teletex_domain_defined_attributes = univ.Integer(6)1017 1018street_address = univ.Integer(17)1019 1020id_kp_OCSPSigning = _OID(id_kp, 9)1021 1022id_ce = _OID(2, 5, 29)1023 1024id_ce_certificatePolicies = _OID(id_ce, 32)1025 1026 1027class EDIPartyName(univ.Sequence):1028 pass1029 1030 1031EDIPartyName.componentType = namedtype.NamedTypes(1032 namedtype.OptionalNamedType('nameAssigner', DirectoryString().subtype(1033 implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 0))),1034 namedtype.NamedType('partyName',1035 DirectoryString().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 1)))1036)1037 1038 1039class AnotherName(univ.Sequence):1040 pass1041 1042 1043AnotherName.componentType = namedtype.NamedTypes(1044 namedtype.NamedType('type-id', univ.ObjectIdentifier()),1045 namedtype.NamedType('value', univ.Any().subtype(explicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 0)))1046)1047 1048 1049class GeneralName(univ.Choice):1050 pass1051 1052 1053GeneralName.componentType = namedtype.NamedTypes(1054 namedtype.NamedType('otherName',1055 AnotherName().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatConstructed, 0))),1056 namedtype.NamedType('rfc822Name',1057 char.IA5String().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 1))),1058 namedtype.NamedType('dNSName',1059 char.IA5String().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 2))),1060 namedtype.NamedType('x400Address',1061 ORAddress().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 3))),1062 namedtype.NamedType('directoryName',1063 Name().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatConstructed, 4))),1064 namedtype.NamedType('ediPartyName',1065 EDIPartyName().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatConstructed, 5))),1066 namedtype.NamedType('uniformResourceIdentifier',1067 char.IA5String().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 6))),1068 namedtype.NamedType('iPAddress',1069 univ.OctetString().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 7))),1070 namedtype.NamedType('registeredID', univ.ObjectIdentifier().subtype(1071 implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 8)))1072)1073 1074 1075class GeneralNames(univ.SequenceOf):1076 pass1077 1078 1079GeneralNames.componentType = GeneralName()1080GeneralNames.sizeSpec = constraint.ValueSizeConstraint(1, MAX)1081 1082 1083class IssuerAltName(GeneralNames):1084 pass1085 1086 1087id_ce_cRLDistributionPoints = _OID(id_ce, 31)1088 1089 1090class CertPolicyId(univ.ObjectIdentifier):1091 pass1092 1093 1094class PolicyMappings(univ.SequenceOf):1095 pass1096 1097 1098PolicyMappings.componentType = univ.Sequence(componentType=namedtype.NamedTypes(1099 namedtype.NamedType('issuerDomainPolicy', CertPolicyId()),1100 namedtype.NamedType('subjectDomainPolicy', CertPolicyId())1101))1102 1103PolicyMappings.sizeSpec = constraint.ValueSizeConstraint(1, MAX)1104 1105 1106class PolicyQualifierId(univ.ObjectIdentifier):1107 pass1108 1109 1110holdInstruction = _OID(2, 2, 840, 10040, 2)1111 1112id_ce_subjectDirectoryAttributes = _OID(id_ce, 9)1113 1114id_holdinstruction_callissuer = _OID(holdInstruction, 2)1115 1116 1117class SubjectDirectoryAttributes(univ.SequenceOf):1118 pass1119 1120 1121SubjectDirectoryAttributes.componentType = Attribute()1122SubjectDirectoryAttributes.sizeSpec = constraint.ValueSizeConstraint(1, MAX)1123 1124anyPolicy = _OID(id_ce_certificatePolicies, 0)1125 1126id_ce_subjectAltName = _OID(id_ce, 17)1127 1128id_kp_emailProtection = _OID(id_kp, 4)1129 1130 1131class ReasonFlags(univ.BitString):1132 pass1133 1134 1135ReasonFlags.namedValues = namedval.NamedValues(1136 ('unused', 0),1137 ('keyCompromise', 1),1138 ('cACompromise', 2),1139 ('affiliationChanged', 3),1140 ('superseded', 4),1141 ('cessationOfOperation', 5),1142 ('certificateHold', 6),1143 ('privilegeWithdrawn', 7),1144 ('aACompromise', 8)1145)1146 1147 1148class DistributionPointName(univ.Choice):1149 pass1150 1151 1152DistributionPointName.componentType = namedtype.NamedTypes(1153 namedtype.NamedType('fullName',1154 GeneralNames().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 0))),1155 namedtype.NamedType('nameRelativeToCRLIssuer', RelativeDistinguishedName().subtype(1156 implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 1)))1157)1158 1159 1160class DistributionPoint(univ.Sequence):1161 pass1162 1163 1164DistributionPoint.componentType = namedtype.NamedTypes(1165 namedtype.OptionalNamedType('distributionPoint', DistributionPointName().subtype(1166 implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatConstructed, 0))),1167 namedtype.OptionalNamedType('reasons', ReasonFlags().subtype(1168 implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 1))),1169 namedtype.OptionalNamedType('cRLIssuer', GeneralNames().subtype(1170 implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 2)))1171)1172 1173id_ce_keyUsage = _OID(id_ce, 15)1174 1175 1176class PolicyQualifierInfo(univ.Sequence):1177 pass1178 1179 1180PolicyQualifierInfo.componentType = namedtype.NamedTypes(1181 namedtype.NamedType('policyQualifierId', PolicyQualifierId()),1182 namedtype.NamedType('qualifier', univ.Any())1183)1184 1185 1186class PolicyInformation(univ.Sequence):1187 pass1188 1189 1190PolicyInformation.componentType = namedtype.NamedTypes(1191 namedtype.NamedType('policyIdentifier', CertPolicyId()),1192 namedtype.OptionalNamedType('policyQualifiers', univ.SequenceOf(componentType=PolicyQualifierInfo()))1193)1194 1195 1196class CertificatePolicies(univ.SequenceOf):1197 pass1198 1199 1200CertificatePolicies.componentType = PolicyInformation()