Team Ai
Datasetpublic

codekingpro/portable-devtools

sourceHugging Faceupdated 5mo agoView on Hugging Face
1likes14kdownloads
rfc5280.py1659 linesDownload Raw Back to pyasn1_modules
1# coding: utf-82#3# This file is part of pyasn1-modules software.4#5# Created by Stanisław Pitucha with asn1ate tool.6# Updated by Russ Housley for ORAddress Extension Attribute opentype support.7# Updated by Russ Housley for AlgorithmIdentifier opentype support.8#9# Copyright (c) 2005-2020, Ilya Etingof <etingof@gmail.com>10# License: http://snmplabs.com/pyasn1/license.html11#12# Internet X.509 Public Key Infrastructure Certificate and Certificate13# Revocation List (CRL) Profile14#15# ASN.1 source from:16# https://www.rfc-editor.org/rfc/rfc5280.txt17#18from pyasn1.type import char19from pyasn1.type import constraint20from pyasn1.type import namedtype21from pyasn1.type import namedval22from pyasn1.type import opentype23from pyasn1.type import tag24from pyasn1.type import univ25from pyasn1.type import useful26 27MAX = float('inf')28 29 30def _buildOid(*components):31    output = []32    for x in tuple(components):33        if isinstance(x, univ.ObjectIdentifier):34            output.extend(list(x))35        else:36            output.append(int(x))37 38    return univ.ObjectIdentifier(output)39 40 41ub_e163_4_sub_address_length = univ.Integer(40)42 43ub_e163_4_number_length = univ.Integer(15)44 45unformatted_postal_address = univ.Integer(16)46 47 48class TerminalType(univ.Integer):49    pass50 51 52TerminalType.namedValues = namedval.NamedValues(53    ('telex', 3),54    ('teletex', 4),55    ('g3-facsimile', 5),56    ('g4-facsimile', 6),57    ('ia5-terminal', 7),58    ('videotex', 8)59)60 61 62class Extension(univ.Sequence):63    pass64 65 66Extension.componentType = namedtype.NamedTypes(67    namedtype.NamedType('extnID', univ.ObjectIdentifier()),68    namedtype.DefaultedNamedType('critical', univ.Boolean().subtype(value=0)),69    namedtype.NamedType('extnValue', univ.OctetString())70)71 72 73class Extensions(univ.SequenceOf):74    pass75 76 77Extensions.componentType = Extension()78Extensions.sizeSpec = constraint.ValueSizeConstraint(1, MAX)79 80physical_delivery_personal_name = univ.Integer(13)81 82ub_unformatted_address_length = univ.Integer(180)83 84ub_pds_parameter_length = univ.Integer(30)85 86ub_pds_physical_address_lines = univ.Integer(6)87 88 89class UnformattedPostalAddress(univ.Set):90    pass91 92 93UnformattedPostalAddress.componentType = namedtype.NamedTypes(94    namedtype.OptionalNamedType('printable-address', univ.SequenceOf(componentType=char.PrintableString().subtype(95        subtypeSpec=constraint.ValueSizeConstraint(1, ub_pds_parameter_length)))),96    namedtype.OptionalNamedType('teletex-string', char.TeletexString().subtype(97        subtypeSpec=constraint.ValueSizeConstraint(1, ub_unformatted_address_length)))98)99 100ub_organization_name = univ.Integer(64)101 102 103class X520OrganizationName(univ.Choice):104    pass105 106 107X520OrganizationName.componentType = namedtype.NamedTypes(108    namedtype.NamedType('teletexString', char.TeletexString().subtype(109        subtypeSpec=constraint.ValueSizeConstraint(1, ub_organization_name))),110    namedtype.NamedType('printableString', char.PrintableString().subtype(111        subtypeSpec=constraint.ValueSizeConstraint(1, ub_organization_name))),112    namedtype.NamedType('universalString', char.UniversalString().subtype(113        subtypeSpec=constraint.ValueSizeConstraint(1, ub_organization_name))),114    namedtype.NamedType('utf8String',115                        char.UTF8String().subtype(subtypeSpec=constraint.ValueSizeConstraint(1, ub_organization_name))),116    namedtype.NamedType('bmpString',117                        char.BMPString().subtype(subtypeSpec=constraint.ValueSizeConstraint(1, ub_organization_name)))118)119 120ub_x121_address_length = univ.Integer(16)121 122pds_name = univ.Integer(7)123 124id_pkix = _buildOid(1, 3, 6, 1, 5, 5, 7)125 126id_kp = _buildOid(id_pkix, 3)127 128ub_postal_code_length = univ.Integer(16)129 130 131class PostalCode(univ.Choice):132    pass133 134 135PostalCode.componentType = namedtype.NamedTypes(136    namedtype.NamedType('numeric-code', char.NumericString().subtype(137        subtypeSpec=constraint.ValueSizeConstraint(1, ub_postal_code_length))),138    namedtype.NamedType('printable-code', char.PrintableString().subtype(139        subtypeSpec=constraint.ValueSizeConstraint(1, ub_postal_code_length)))140)141 142ub_generation_qualifier_length = univ.Integer(3)143 144unique_postal_name = univ.Integer(20)145 146 147class DomainComponent(char.IA5String):148    pass149 150 151ub_domain_defined_attribute_value_length = univ.Integer(128)152 153ub_match = univ.Integer(128)154 155id_at = _buildOid(2, 5, 4)156 157 158class AttributeType(univ.ObjectIdentifier):159    pass160 161 162id_at_organizationalUnitName = _buildOid(id_at, 11)163 164terminal_type = univ.Integer(23)165 166 167class PDSParameter(univ.Set):168    pass169 170 171PDSParameter.componentType = namedtype.NamedTypes(172    namedtype.OptionalNamedType('printable-string', char.PrintableString().subtype(173        subtypeSpec=constraint.ValueSizeConstraint(1, ub_pds_parameter_length))),174    namedtype.OptionalNamedType('teletex-string', char.TeletexString().subtype(175        subtypeSpec=constraint.ValueSizeConstraint(1, ub_pds_parameter_length)))176)177 178 179class PhysicalDeliveryPersonalName(PDSParameter):180    pass181 182 183ub_surname_length = univ.Integer(40)184 185id_ad = _buildOid(id_pkix, 48)186 187ub_domain_defined_attribute_type_length = univ.Integer(8)188 189 190class TeletexDomainDefinedAttribute(univ.Sequence):191    pass192 193 194TeletexDomainDefinedAttribute.componentType = namedtype.NamedTypes(195    namedtype.NamedType('type', char.TeletexString().subtype(196        subtypeSpec=constraint.ValueSizeConstraint(1, ub_domain_defined_attribute_type_length))),197    namedtype.NamedType('value', char.TeletexString().subtype(198        subtypeSpec=constraint.ValueSizeConstraint(1, ub_domain_defined_attribute_value_length)))199)200 201ub_domain_defined_attributes = univ.Integer(4)202 203 204class TeletexDomainDefinedAttributes(univ.SequenceOf):205    pass206 207 208TeletexDomainDefinedAttributes.componentType = TeletexDomainDefinedAttribute()209TeletexDomainDefinedAttributes.sizeSpec = constraint.ValueSizeConstraint(1, ub_domain_defined_attributes)210 211extended_network_address = univ.Integer(22)212 213ub_locality_name = univ.Integer(128)214 215 216class X520LocalityName(univ.Choice):217    pass218 219 220X520LocalityName.componentType = namedtype.NamedTypes(221    namedtype.NamedType('teletexString',222                        char.TeletexString().subtype(subtypeSpec=constraint.ValueSizeConstraint(1, ub_locality_name))),223    namedtype.NamedType('printableString', char.PrintableString().subtype(224        subtypeSpec=constraint.ValueSizeConstraint(1, ub_locality_name))),225    namedtype.NamedType('universalString', char.UniversalString().subtype(226        subtypeSpec=constraint.ValueSizeConstraint(1, ub_locality_name))),227    namedtype.NamedType('utf8String',228                        char.UTF8String().subtype(subtypeSpec=constraint.ValueSizeConstraint(1, ub_locality_name))),229    namedtype.NamedType('bmpString',230                        char.BMPString().subtype(subtypeSpec=constraint.ValueSizeConstraint(1, ub_locality_name)))231)232 233teletex_organization_name = univ.Integer(3)234 235ub_given_name_length = univ.Integer(16)236 237ub_initials_length = univ.Integer(5)238 239 240class PersonalName(univ.Set):241    pass242 243 244PersonalName.componentType = namedtype.NamedTypes(245    namedtype.NamedType('surname', char.PrintableString().subtype(246        subtypeSpec=constraint.ValueSizeConstraint(1, ub_surname_length)).subtype(247        implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 0))),248    namedtype.OptionalNamedType('given-name', char.PrintableString().subtype(249        subtypeSpec=constraint.ValueSizeConstraint(1, ub_given_name_length)).subtype(250        implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 1))),251    namedtype.OptionalNamedType('initials', char.PrintableString().subtype(252        subtypeSpec=constraint.ValueSizeConstraint(1, ub_initials_length)).subtype(253        implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 2))),254    namedtype.OptionalNamedType('generation-qualifier', char.PrintableString().subtype(255        subtypeSpec=constraint.ValueSizeConstraint(1, ub_generation_qualifier_length)).subtype(256        implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 3)))257)258 259ub_organizational_unit_name_length = univ.Integer(32)260 261 262class OrganizationalUnitName(char.PrintableString):263    pass264 265 266OrganizationalUnitName.subtypeSpec = constraint.ValueSizeConstraint(1, ub_organizational_unit_name_length)267 268id_at_generationQualifier = _buildOid(id_at, 44)269 270 271class Version(univ.Integer):272    pass273 274 275Version.namedValues = namedval.NamedValues(276    ('v1', 0),277    ('v2', 1),278    ('v3', 2)279)280 281 282class CertificateSerialNumber(univ.Integer):283    pass284 285 286algorithmIdentifierMap = {}287 288 289class AlgorithmIdentifier(univ.Sequence):290    componentType = namedtype.NamedTypes(291        namedtype.NamedType('algorithm', univ.ObjectIdentifier()),292        namedtype.OptionalNamedType('parameters', univ.Any(),293            openType=opentype.OpenType('algorithm', algorithmIdentifierMap)294        )295    )296 297 298class Time(univ.Choice):299    pass300 301 302Time.componentType = namedtype.NamedTypes(303    namedtype.NamedType('utcTime', useful.UTCTime()),304    namedtype.NamedType('generalTime', useful.GeneralizedTime())305)306 307 308class AttributeValue(univ.Any):309    pass310 311 312certificateAttributesMap = {}313 314 315class AttributeTypeAndValue(univ.Sequence):316    componentType = namedtype.NamedTypes(317        namedtype.NamedType('type', AttributeType()),318        namedtype.NamedType(319            'value', AttributeValue(),320            openType=opentype.OpenType('type', certificateAttributesMap)321        )322    )323 324 325class RelativeDistinguishedName(univ.SetOf):326    pass327 328 329RelativeDistinguishedName.componentType = AttributeTypeAndValue()330RelativeDistinguishedName.sizeSpec = constraint.ValueSizeConstraint(1, MAX)331 332 333class RDNSequence(univ.SequenceOf):334    pass335 336 337RDNSequence.componentType = RelativeDistinguishedName()338 339 340class Name(univ.Choice):341    pass342 343 344Name.componentType = namedtype.NamedTypes(345    namedtype.NamedType('rdnSequence', RDNSequence())346)347 348 349class TBSCertList(univ.Sequence):350    pass351 352 353TBSCertList.componentType = namedtype.NamedTypes(354    namedtype.OptionalNamedType('version', Version()),355    namedtype.NamedType('signature', AlgorithmIdentifier()),356    namedtype.NamedType('issuer', Name()),357    namedtype.NamedType('thisUpdate', Time()),358    namedtype.OptionalNamedType('nextUpdate', Time()),359    namedtype.OptionalNamedType(360        'revokedCertificates', univ.SequenceOf(361            componentType=univ.Sequence(362                componentType=namedtype.NamedTypes(363                    namedtype.NamedType('userCertificate', CertificateSerialNumber()),364                    namedtype.NamedType('revocationDate', Time()),365                    namedtype.OptionalNamedType('crlEntryExtensions', Extensions())366                )367            )368        )369    ),370    namedtype.OptionalNamedType(371        'crlExtensions', Extensions().subtype(explicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 0)))372)373 374 375class CertificateList(univ.Sequence):376    pass377 378 379CertificateList.componentType = namedtype.NamedTypes(380    namedtype.NamedType('tbsCertList', TBSCertList()),381    namedtype.NamedType('signatureAlgorithm', AlgorithmIdentifier()),382    namedtype.NamedType('signature', univ.BitString())383)384 385 386class PhysicalDeliveryOfficeName(PDSParameter):387    pass388 389 390ub_extension_attributes = univ.Integer(256)391 392certificateExtensionsMap = {393}394 395oraddressExtensionAttributeMap = {396}397 398 399class ExtensionAttribute(univ.Sequence):400    componentType = namedtype.NamedTypes(401        namedtype.NamedType(402            'extension-attribute-type',403            univ.Integer().subtype(subtypeSpec=constraint.ValueRangeConstraint(0, ub_extension_attributes)).subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 0))),404        namedtype.NamedType(405            'extension-attribute-value',406            univ.Any().subtype(explicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 1)),407            openType=opentype.OpenType('extension-attribute-type', oraddressExtensionAttributeMap))408    )409 410id_qt = _buildOid(id_pkix, 2)411 412id_qt_cps = _buildOid(id_qt, 1)413 414id_at_stateOrProvinceName = _buildOid(id_at, 8)415 416id_at_title = _buildOid(id_at, 12)417 418id_at_serialNumber = _buildOid(id_at, 5)419 420 421class X520dnQualifier(char.PrintableString):422    pass423 424 425class PosteRestanteAddress(PDSParameter):426    pass427 428 429poste_restante_address = univ.Integer(19)430 431 432class UniqueIdentifier(univ.BitString):433    pass434 435 436class Validity(univ.Sequence):437    pass438 439 440Validity.componentType = namedtype.NamedTypes(441    namedtype.NamedType('notBefore', Time()),442    namedtype.NamedType('notAfter', Time())443)444 445 446class SubjectPublicKeyInfo(univ.Sequence):447    pass448 449 450SubjectPublicKeyInfo.componentType = namedtype.NamedTypes(451    namedtype.NamedType('algorithm', AlgorithmIdentifier()),452    namedtype.NamedType('subjectPublicKey', univ.BitString())453)454 455 456class TBSCertificate(univ.Sequence):457    pass458 459 460TBSCertificate.componentType = namedtype.NamedTypes(461    namedtype.DefaultedNamedType('version',462                                 Version().subtype(explicitTag=tag.Tag(tag.tagClassContext,463                                                                       tag.tagFormatSimple, 0)).subtype(value="v1")),464    namedtype.NamedType('serialNumber', CertificateSerialNumber()),465    namedtype.NamedType('signature', AlgorithmIdentifier()),466    namedtype.NamedType('issuer', Name()),467    namedtype.NamedType('validity', Validity()),468    namedtype.NamedType('subject', Name()),469    namedtype.NamedType('subjectPublicKeyInfo', SubjectPublicKeyInfo()),470    namedtype.OptionalNamedType('issuerUniqueID', UniqueIdentifier().subtype(471        implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 1))),472    namedtype.OptionalNamedType('subjectUniqueID', UniqueIdentifier().subtype(473        implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 2))),474    namedtype.OptionalNamedType('extensions',475                                Extensions().subtype(explicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 3)))476)477 478physical_delivery_office_name = univ.Integer(10)479 480ub_name = univ.Integer(32768)481 482 483class X520name(univ.Choice):484    pass485 486 487X520name.componentType = namedtype.NamedTypes(488    namedtype.NamedType('teletexString',489                        char.TeletexString().subtype(subtypeSpec=constraint.ValueSizeConstraint(1, ub_name))),490    namedtype.NamedType('printableString',491                        char.PrintableString().subtype(subtypeSpec=constraint.ValueSizeConstraint(1, ub_name))),492    namedtype.NamedType('universalString',493                        char.UniversalString().subtype(subtypeSpec=constraint.ValueSizeConstraint(1, ub_name))),494    namedtype.NamedType('utf8String',495                        char.UTF8String().subtype(subtypeSpec=constraint.ValueSizeConstraint(1, ub_name))),496    namedtype.NamedType('bmpString', char.BMPString().subtype(subtypeSpec=constraint.ValueSizeConstraint(1, ub_name)))497)498 499id_at_dnQualifier = _buildOid(id_at, 46)500 501ub_serial_number = univ.Integer(64)502 503ub_pseudonym = univ.Integer(128)504 505pkcs_9 = _buildOid(1, 2, 840, 113549, 1, 9)506 507 508class X121Address(char.NumericString):509    pass510 511 512X121Address.subtypeSpec = constraint.ValueSizeConstraint(1, ub_x121_address_length)513 514 515class NetworkAddress(X121Address):516    pass517 518 519ub_integer_options = univ.Integer(256)520 521id_at_commonName = _buildOid(id_at, 3)522 523ub_organization_name_length = univ.Integer(64)524 525id_ad_ocsp = _buildOid(id_ad, 1)526 527ub_country_name_numeric_length = univ.Integer(3)528 529ub_country_name_alpha_length = univ.Integer(2)530 531 532class PhysicalDeliveryCountryName(univ.Choice):533    pass534 535 536PhysicalDeliveryCountryName.componentType = namedtype.NamedTypes(537    namedtype.NamedType('x121-dcc-code', char.NumericString().subtype(538        subtypeSpec=constraint.ValueSizeConstraint(ub_country_name_numeric_length, ub_country_name_numeric_length))),539    namedtype.NamedType('iso-3166-alpha2-code', char.PrintableString().subtype(540        subtypeSpec=constraint.ValueSizeConstraint(ub_country_name_alpha_length, ub_country_name_alpha_length)))541)542 543id_emailAddress = _buildOid(pkcs_9, 1)544 545common_name = univ.Integer(1)546 547 548class X520Pseudonym(univ.Choice):549    pass550 551 552X520Pseudonym.componentType = namedtype.NamedTypes(553    namedtype.NamedType('teletexString',554                        char.TeletexString().subtype(subtypeSpec=constraint.ValueSizeConstraint(1, ub_pseudonym))),555    namedtype.NamedType('printableString',556                        char.PrintableString().subtype(subtypeSpec=constraint.ValueSizeConstraint(1, ub_pseudonym))),557    namedtype.NamedType('universalString',558                        char.UniversalString().subtype(subtypeSpec=constraint.ValueSizeConstraint(1, ub_pseudonym))),559    namedtype.NamedType('utf8String',560                        char.UTF8String().subtype(subtypeSpec=constraint.ValueSizeConstraint(1, ub_pseudonym))),561    namedtype.NamedType('bmpString',562                        char.BMPString().subtype(subtypeSpec=constraint.ValueSizeConstraint(1, ub_pseudonym)))563)564 565ub_domain_name_length = univ.Integer(16)566 567 568class AdministrationDomainName(univ.Choice):569    pass570 571 572AdministrationDomainName.tagSet = univ.Choice.tagSet.tagExplicitly(573    tag.Tag(tag.tagClassApplication, tag.tagFormatConstructed, 2))574AdministrationDomainName.componentType = namedtype.NamedTypes(575    namedtype.NamedType('numeric', char.NumericString().subtype(576        subtypeSpec=constraint.ValueSizeConstraint(0, ub_domain_name_length))),577    namedtype.NamedType('printable', char.PrintableString().subtype(578        subtypeSpec=constraint.ValueSizeConstraint(0, ub_domain_name_length)))579)580 581 582class PresentationAddress(univ.Sequence):583    pass584 585 586PresentationAddress.componentType = namedtype.NamedTypes(587    namedtype.OptionalNamedType('pSelector', univ.OctetString().subtype(588        explicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 0))),589    namedtype.OptionalNamedType('sSelector', univ.OctetString().subtype(590        explicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 1))),591    namedtype.OptionalNamedType('tSelector', univ.OctetString().subtype(592        explicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 2))),593    namedtype.NamedType('nAddresses', univ.SetOf(componentType=univ.OctetString()).subtype(594        explicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 3)))595)596 597 598class ExtendedNetworkAddress(univ.Choice):599    pass600 601 602ExtendedNetworkAddress.componentType = namedtype.NamedTypes(603    namedtype.NamedType(604        'e163-4-address', univ.Sequence(605            componentType=namedtype.NamedTypes(606                namedtype.NamedType('number', char.NumericString().subtype(subtypeSpec=constraint.ValueSizeConstraint(1, ub_e163_4_number_length)).subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 0))),607                namedtype.OptionalNamedType('sub-address', char.NumericString().subtype(subtypeSpec=constraint.ValueSizeConstraint(1, ub_e163_4_sub_address_length)).subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 1)))608            )609        )610    ),611    namedtype.NamedType('psap-address', PresentationAddress().subtype(612        implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatConstructed, 0)))613)614 615 616class TeletexOrganizationName(char.TeletexString):617    pass618 619 620TeletexOrganizationName.subtypeSpec = constraint.ValueSizeConstraint(1, ub_organization_name_length)621 622ub_terminal_id_length = univ.Integer(24)623 624 625class TerminalIdentifier(char.PrintableString):626    pass627 628 629TerminalIdentifier.subtypeSpec = constraint.ValueSizeConstraint(1, ub_terminal_id_length)630 631id_ad_caIssuers = _buildOid(id_ad, 2)632 633id_at_countryName = _buildOid(id_at, 6)634 635 636class StreetAddress(PDSParameter):637    pass638 639 640postal_code = univ.Integer(9)641 642id_at_givenName = _buildOid(id_at, 42)643 644ub_title = univ.Integer(64)645 646 647class ExtensionAttributes(univ.SetOf):648    pass649 650 651ExtensionAttributes.componentType = ExtensionAttribute()652ExtensionAttributes.sizeSpec = constraint.ValueSizeConstraint(1, ub_extension_attributes)653 654ub_emailaddress_length = univ.Integer(255)655 656id_ad_caRepository = _buildOid(id_ad, 5)657 658 659class ExtensionORAddressComponents(PDSParameter):660    pass661 662 663ub_organizational_unit_name = univ.Integer(64)664 665 666class X520OrganizationalUnitName(univ.Choice):667    pass668 669 670X520OrganizationalUnitName.componentType = namedtype.NamedTypes(671    namedtype.NamedType('teletexString', char.TeletexString().subtype(672        subtypeSpec=constraint.ValueSizeConstraint(1, ub_organizational_unit_name))),673    namedtype.NamedType('printableString', char.PrintableString().subtype(674        subtypeSpec=constraint.ValueSizeConstraint(1, ub_organizational_unit_name))),675    namedtype.NamedType('universalString', char.UniversalString().subtype(676        subtypeSpec=constraint.ValueSizeConstraint(1, ub_organizational_unit_name))),677    namedtype.NamedType('utf8String', char.UTF8String().subtype(678        subtypeSpec=constraint.ValueSizeConstraint(1, ub_organizational_unit_name))),679    namedtype.NamedType('bmpString', char.BMPString().subtype(680        subtypeSpec=constraint.ValueSizeConstraint(1, ub_organizational_unit_name)))681)682 683 684class LocalPostalAttributes(PDSParameter):685    pass686 687 688teletex_organizational_unit_names = univ.Integer(5)689 690 691class X520Title(univ.Choice):692    pass693 694 695X520Title.componentType = namedtype.NamedTypes(696    namedtype.NamedType('teletexString',697                        char.TeletexString().subtype(subtypeSpec=constraint.ValueSizeConstraint(1, ub_title))),698    namedtype.NamedType('printableString',699                        char.PrintableString().subtype(subtypeSpec=constraint.ValueSizeConstraint(1, ub_title))),700    namedtype.NamedType('universalString',701                        char.UniversalString().subtype(subtypeSpec=constraint.ValueSizeConstraint(1, ub_title))),702    namedtype.NamedType('utf8String',703                        char.UTF8String().subtype(subtypeSpec=constraint.ValueSizeConstraint(1, ub_title))),704    namedtype.NamedType('bmpString', char.BMPString().subtype(subtypeSpec=constraint.ValueSizeConstraint(1, ub_title)))705)706 707id_at_localityName = _buildOid(id_at, 7)708 709id_at_initials = _buildOid(id_at, 43)710 711ub_state_name = univ.Integer(128)712 713 714class X520StateOrProvinceName(univ.Choice):715    pass716 717 718X520StateOrProvinceName.componentType = namedtype.NamedTypes(719    namedtype.NamedType('teletexString',720                        char.TeletexString().subtype(subtypeSpec=constraint.ValueSizeConstraint(1, ub_state_name))),721    namedtype.NamedType('printableString',722                        char.PrintableString().subtype(subtypeSpec=constraint.ValueSizeConstraint(1, ub_state_name))),723    namedtype.NamedType('universalString',724                        char.UniversalString().subtype(subtypeSpec=constraint.ValueSizeConstraint(1, ub_state_name))),725    namedtype.NamedType('utf8String',726                        char.UTF8String().subtype(subtypeSpec=constraint.ValueSizeConstraint(1, ub_state_name))),727    namedtype.NamedType('bmpString',728                        char.BMPString().subtype(subtypeSpec=constraint.ValueSizeConstraint(1, ub_state_name)))729)730 731physical_delivery_organization_name = univ.Integer(14)732 733id_at_surname = _buildOid(id_at, 4)734 735 736class X520countryName(char.PrintableString):737    pass738 739 740X520countryName.subtypeSpec = constraint.ValueSizeConstraint(2, 2)741 742physical_delivery_office_number = univ.Integer(11)743 744id_qt_unotice = _buildOid(id_qt, 2)745 746 747class X520SerialNumber(char.PrintableString):748    pass749 750 751X520SerialNumber.subtypeSpec = constraint.ValueSizeConstraint(1, ub_serial_number)752 753 754class Attribute(univ.Sequence):755    componentType = namedtype.NamedTypes(756        namedtype.NamedType('type', AttributeType()),757        namedtype.NamedType('values',758                            univ.SetOf(componentType=AttributeValue()),759                            openType=opentype.OpenType('type', certificateAttributesMap))760    )761 762ub_common_name = univ.Integer(64)763 764id_pe = _buildOid(id_pkix, 1)765 766 767class ExtensionPhysicalDeliveryAddressComponents(PDSParameter):768    pass769 770 771class EmailAddress(char.IA5String):772    pass773 774 775EmailAddress.subtypeSpec = constraint.ValueSizeConstraint(1, ub_emailaddress_length)776 777id_at_organizationName = _buildOid(id_at, 10)778 779post_office_box_address = univ.Integer(18)780 781 782class BuiltInDomainDefinedAttribute(univ.Sequence):783    pass784 785 786BuiltInDomainDefinedAttribute.componentType = namedtype.NamedTypes(787    namedtype.NamedType('type', char.PrintableString().subtype(788        subtypeSpec=constraint.ValueSizeConstraint(1, ub_domain_defined_attribute_type_length))),789    namedtype.NamedType('value', char.PrintableString().subtype(790        subtypeSpec=constraint.ValueSizeConstraint(1, ub_domain_defined_attribute_value_length)))791)792 793 794class BuiltInDomainDefinedAttributes(univ.SequenceOf):795    pass796 797 798BuiltInDomainDefinedAttributes.componentType = BuiltInDomainDefinedAttribute()799BuiltInDomainDefinedAttributes.sizeSpec = constraint.ValueSizeConstraint(1, ub_domain_defined_attributes)800 801id_at_pseudonym = _buildOid(id_at, 65)802 803id_domainComponent = _buildOid(0, 9, 2342, 19200300, 100, 1, 25)804 805 806class X520CommonName(univ.Choice):807    pass808 809 810X520CommonName.componentType = namedtype.NamedTypes(811    namedtype.NamedType('teletexString',812                        char.TeletexString().subtype(subtypeSpec=constraint.ValueSizeConstraint(1, ub_common_name))),813    namedtype.NamedType('printableString',814                        char.PrintableString().subtype(subtypeSpec=constraint.ValueSizeConstraint(1, ub_common_name))),815    namedtype.NamedType('universalString',816                        char.UniversalString().subtype(subtypeSpec=constraint.ValueSizeConstraint(1, ub_common_name))),817    namedtype.NamedType('utf8String',818                        char.UTF8String().subtype(subtypeSpec=constraint.ValueSizeConstraint(1, ub_common_name))),819    namedtype.NamedType('bmpString',820                        char.BMPString().subtype(subtypeSpec=constraint.ValueSizeConstraint(1, ub_common_name)))821)822 823extension_OR_address_components = univ.Integer(12)824 825ub_organizational_units = univ.Integer(4)826 827teletex_personal_name = univ.Integer(4)828 829ub_numeric_user_id_length = univ.Integer(32)830 831ub_common_name_length = univ.Integer(64)832 833 834class TeletexCommonName(char.TeletexString):835    pass836 837 838TeletexCommonName.subtypeSpec = constraint.ValueSizeConstraint(1, ub_common_name_length)839 840 841class PhysicalDeliveryOrganizationName(PDSParameter):842    pass843 844 845extension_physical_delivery_address_components = univ.Integer(15)846 847 848class NumericUserIdentifier(char.NumericString):849    pass850 851 852NumericUserIdentifier.subtypeSpec = constraint.ValueSizeConstraint(1, ub_numeric_user_id_length)853 854 855class CountryName(univ.Choice):856    pass857 858 859CountryName.tagSet = univ.Choice.tagSet.tagExplicitly(tag.Tag(tag.tagClassApplication, tag.tagFormatConstructed, 1))860CountryName.componentType = namedtype.NamedTypes(861    namedtype.NamedType('x121-dcc-code', char.NumericString().subtype(862        subtypeSpec=constraint.ValueSizeConstraint(ub_country_name_numeric_length, ub_country_name_numeric_length))),863    namedtype.NamedType('iso-3166-alpha2-code', char.PrintableString().subtype(864        subtypeSpec=constraint.ValueSizeConstraint(ub_country_name_alpha_length, ub_country_name_alpha_length)))865)866 867 868class OrganizationName(char.PrintableString):869    pass870 871 872OrganizationName.subtypeSpec = constraint.ValueSizeConstraint(1, ub_organization_name_length)873 874 875class OrganizationalUnitNames(univ.SequenceOf):876    pass877 878 879OrganizationalUnitNames.componentType = OrganizationalUnitName()880OrganizationalUnitNames.sizeSpec = constraint.ValueSizeConstraint(1, ub_organizational_units)881 882 883class PrivateDomainName(univ.Choice):884    pass885 886 887PrivateDomainName.componentType = namedtype.NamedTypes(888    namedtype.NamedType('numeric', char.NumericString().subtype(889        subtypeSpec=constraint.ValueSizeConstraint(1, ub_domain_name_length))),890    namedtype.NamedType('printable', char.PrintableString().subtype(891        subtypeSpec=constraint.ValueSizeConstraint(1, ub_domain_name_length)))892)893 894 895class BuiltInStandardAttributes(univ.Sequence):896    pass897 898 899BuiltInStandardAttributes.componentType = namedtype.NamedTypes(900    namedtype.OptionalNamedType('country-name', CountryName()),901    namedtype.OptionalNamedType('administration-domain-name', AdministrationDomainName()),902    namedtype.OptionalNamedType('network-address', NetworkAddress().subtype(903        implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 0))),904    namedtype.OptionalNamedType('terminal-identifier', TerminalIdentifier().subtype(905        implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 1))),906    namedtype.OptionalNamedType('private-domain-name', PrivateDomainName().subtype(907        explicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatConstructed, 2))),908    namedtype.OptionalNamedType('organization-name', OrganizationName().subtype(909        implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 3))),910    namedtype.OptionalNamedType('numeric-user-identifier', NumericUserIdentifier().subtype(911        implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 4))),912    namedtype.OptionalNamedType('personal-name', PersonalName().subtype(913        implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatConstructed, 5))),914    namedtype.OptionalNamedType('organizational-unit-names', OrganizationalUnitNames().subtype(915        implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 6)))916)917 918 919class ORAddress(univ.Sequence):920    pass921 922 923ORAddress.componentType = namedtype.NamedTypes(924    namedtype.NamedType('built-in-standard-attributes', BuiltInStandardAttributes()),925    namedtype.OptionalNamedType('built-in-domain-defined-attributes', BuiltInDomainDefinedAttributes()),926    namedtype.OptionalNamedType('extension-attributes', ExtensionAttributes())927)928 929 930class DistinguishedName(RDNSequence):931    pass932 933 934id_ad_timeStamping = _buildOid(id_ad, 3)935 936 937class PhysicalDeliveryOfficeNumber(PDSParameter):938    pass939 940 941teletex_domain_defined_attributes = univ.Integer(6)942 943 944class UniquePostalName(PDSParameter):945    pass946 947 948physical_delivery_country_name = univ.Integer(8)949 950ub_pds_name_length = univ.Integer(16)951 952 953class PDSName(char.PrintableString):954    pass955 956 957PDSName.subtypeSpec = constraint.ValueSizeConstraint(1, ub_pds_name_length)958 959 960class TeletexPersonalName(univ.Set):961    pass962 963 964TeletexPersonalName.componentType = namedtype.NamedTypes(965    namedtype.NamedType('surname', char.TeletexString().subtype(966        subtypeSpec=constraint.ValueSizeConstraint(1, ub_surname_length)).subtype(967        implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 0))),968    namedtype.OptionalNamedType('given-name', char.TeletexString().subtype(969        subtypeSpec=constraint.ValueSizeConstraint(1, ub_given_name_length)).subtype(970        implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 1))),971    namedtype.OptionalNamedType('initials', char.TeletexString().subtype(972        subtypeSpec=constraint.ValueSizeConstraint(1, ub_initials_length)).subtype(973        implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 2))),974    namedtype.OptionalNamedType('generation-qualifier', char.TeletexString().subtype(975        subtypeSpec=constraint.ValueSizeConstraint(1, ub_generation_qualifier_length)).subtype(976        implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 3)))977)978 979street_address = univ.Integer(17)980 981 982class PostOfficeBoxAddress(PDSParameter):983    pass984 985 986local_postal_attributes = univ.Integer(21)987 988 989class DirectoryString(univ.Choice):990    pass991 992 993DirectoryString.componentType = namedtype.NamedTypes(994    namedtype.NamedType('teletexString',995                        char.TeletexString().subtype(subtypeSpec=constraint.ValueSizeConstraint(1, MAX))),996    namedtype.NamedType('printableString',997                        char.PrintableString().subtype(subtypeSpec=constraint.ValueSizeConstraint(1, MAX))),998    namedtype.NamedType('universalString',999                        char.UniversalString().subtype(subtypeSpec=constraint.ValueSizeConstraint(1, MAX))),1000    namedtype.NamedType('utf8String', char.UTF8String().subtype(subtypeSpec=constraint.ValueSizeConstraint(1, MAX))),1001    namedtype.NamedType('bmpString', char.BMPString().subtype(subtypeSpec=constraint.ValueSizeConstraint(1, MAX)))1002)1003 1004teletex_common_name = univ.Integer(2)1005 1006 1007class CommonName(char.PrintableString):1008    pass1009 1010 1011CommonName.subtypeSpec = constraint.ValueSizeConstraint(1, ub_common_name_length)1012 1013 1014class Certificate(univ.Sequence):1015    pass1016 1017 1018Certificate.componentType = namedtype.NamedTypes(1019    namedtype.NamedType('tbsCertificate', TBSCertificate()),1020    namedtype.NamedType('signatureAlgorithm', AlgorithmIdentifier()),1021    namedtype.NamedType('signature', univ.BitString())1022)1023 1024 1025class TeletexOrganizationalUnitName(char.TeletexString):1026    pass1027 1028 1029TeletexOrganizationalUnitName.subtypeSpec = constraint.ValueSizeConstraint(1, ub_organizational_unit_name_length)1030 1031id_at_name = _buildOid(id_at, 41)1032 1033 1034class TeletexOrganizationalUnitNames(univ.SequenceOf):1035    pass1036 1037 1038TeletexOrganizationalUnitNames.componentType = TeletexOrganizationalUnitName()1039TeletexOrganizationalUnitNames.sizeSpec = constraint.ValueSizeConstraint(1, ub_organizational_units)1040 1041id_ce = _buildOid(2, 5, 29)1042 1043id_ce_issuerAltName = _buildOid(id_ce, 18)1044 1045 1046class SkipCerts(univ.Integer):1047    pass1048 1049 1050SkipCerts.subtypeSpec = constraint.ValueRangeConstraint(0, MAX)1051 1052 1053class CRLReason(univ.Enumerated):1054    pass1055 1056 1057CRLReason.namedValues = namedval.NamedValues(1058    ('unspecified', 0),1059    ('keyCompromise', 1),1060    ('cACompromise', 2),1061    ('affiliationChanged', 3),1062    ('superseded', 4),1063    ('cessationOfOperation', 5),1064    ('certificateHold', 6),1065    ('removeFromCRL', 8),1066    ('privilegeWithdrawn', 9),1067    ('aACompromise', 10)1068)1069 1070 1071class PrivateKeyUsagePeriod(univ.Sequence):1072    pass1073 1074 1075PrivateKeyUsagePeriod.componentType = namedtype.NamedTypes(1076    namedtype.OptionalNamedType('notBefore', useful.GeneralizedTime().subtype(1077        implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 0))),1078    namedtype.OptionalNamedType('notAfter', useful.GeneralizedTime().subtype(1079        implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 1)))1080)1081 1082 1083anotherNameMap = {1084 1085}1086 1087 1088class AnotherName(univ.Sequence):1089    componentType = namedtype.NamedTypes(1090        namedtype.NamedType('type-id', univ.ObjectIdentifier()),1091        namedtype.NamedType(1092            'value',1093            univ.Any().subtype(explicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 0)),1094            openType=opentype.OpenType('type-id', anotherNameMap)1095        )1096    )1097 1098 1099class EDIPartyName(univ.Sequence):1100    pass1101 1102 1103EDIPartyName.componentType = namedtype.NamedTypes(1104    namedtype.OptionalNamedType('nameAssigner', DirectoryString().subtype(1105        implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatConstructed, 0))),1106    namedtype.NamedType('partyName', DirectoryString().subtype(1107        implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatConstructed, 1)))1108)1109 1110 1111class GeneralName(univ.Choice):1112    pass1113 1114 1115GeneralName.componentType = namedtype.NamedTypes(1116    namedtype.NamedType('otherName',1117                        AnotherName().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatConstructed, 0))),1118    namedtype.NamedType('rfc822Name',1119                        char.IA5String().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 1))),1120    namedtype.NamedType('dNSName',1121                        char.IA5String().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 2))),1122    namedtype.NamedType('x400Address',1123                        ORAddress().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 3))),1124    namedtype.NamedType('directoryName',1125                        Name().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatConstructed, 4))),1126    namedtype.NamedType('ediPartyName',1127                        EDIPartyName().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatConstructed, 5))),1128    namedtype.NamedType('uniformResourceIdentifier',1129                        char.IA5String().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 6))),1130    namedtype.NamedType('iPAddress',1131                        univ.OctetString().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 7))),1132    namedtype.NamedType('registeredID', univ.ObjectIdentifier().subtype(1133        implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 8)))1134)1135 1136 1137class BaseDistance(univ.Integer):1138    pass1139 1140 1141BaseDistance.subtypeSpec = constraint.ValueRangeConstraint(0, MAX)1142 1143 1144class GeneralSubtree(univ.Sequence):1145    pass1146 1147 1148GeneralSubtree.componentType = namedtype.NamedTypes(1149    namedtype.NamedType('base', GeneralName()),1150    namedtype.DefaultedNamedType('minimum', BaseDistance().subtype(1151        implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 0)).subtype(value=0)),1152    namedtype.OptionalNamedType('maximum', BaseDistance().subtype(1153        implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 1)))1154)1155 1156 1157class GeneralNames(univ.SequenceOf):1158    pass1159 1160 1161GeneralNames.componentType = GeneralName()1162GeneralNames.sizeSpec = constraint.ValueSizeConstraint(1, MAX)1163 1164 1165class DistributionPointName(univ.Choice):1166    pass1167 1168 1169DistributionPointName.componentType = namedtype.NamedTypes(1170    namedtype.NamedType('fullName',1171                        GeneralNames().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 0))),1172    namedtype.NamedType('nameRelativeToCRLIssuer', RelativeDistinguishedName().subtype(1173        implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 1)))1174)1175 1176 1177class ReasonFlags(univ.BitString):1178    pass1179 1180 1181ReasonFlags.namedValues = namedval.NamedValues(1182    ('unused', 0),1183    ('keyCompromise', 1),1184    ('cACompromise', 2),1185    ('affiliationChanged', 3),1186    ('superseded', 4),1187    ('cessationOfOperation', 5),1188    ('certificateHold', 6),1189    ('privilegeWithdrawn', 7),1190    ('aACompromise', 8)1191)1192 1193 1194class IssuingDistributionPoint(univ.Sequence):1195    pass1196 1197 1198IssuingDistributionPoint.componentType = namedtype.NamedTypes(1199    namedtype.OptionalNamedType('distributionPoint', DistributionPointName().subtype(1200        implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatConstructed, 0))),

Showing the first 1,200 of 1659 lines. Download the file for the rest.

codekingpro/portable-devtools · Team Ai