File manager - Edit - /home/newsbmcs.com/public_html/static/img/logo/pyasn1_modules.tar
Back
rfc6486.py 0000644 00000003574 15030212136 0006222 0 ustar 00 # # This file is part of pyasn1-modules software. # # Created by Russ Housley with assistance from asn1ate v.0.6.0. # # Copyright (c) 2019, Vigil Security, LLC # License: http://snmplabs.com/pyasn1/license.html # # RPKI Manifests # # ASN.1 source from: # https://www.rfc-editor.org/rfc/rfc6486.txt # from pyasn1.type import char from pyasn1.type import constraint from pyasn1.type import namedtype from pyasn1.type import tag from pyasn1.type import useful from pyasn1.type import univ from pyasn1_modules import rfc5652 MAX = float('inf') id_smime = univ.ObjectIdentifier('1.2.840.113549.1.9.16') id_ct = id_smime + (1, ) id_ct_rpkiManifest = id_ct + (26, ) class FileAndHash(univ.Sequence): componentType = namedtype.NamedTypes( namedtype.NamedType('file', char.IA5String()), namedtype.NamedType('hash', univ.BitString()) ) class Manifest(univ.Sequence): componentType = namedtype.NamedTypes( namedtype.DefaultedNamedType('version', univ.Integer().subtype(explicitTag=tag.Tag( tag.tagClassContext, tag.tagFormatSimple, 0)).subtype(value=0)), namedtype.NamedType('manifestNumber', univ.Integer().subtype( subtypeSpec=constraint.ValueRangeConstraint(0, MAX))), namedtype.NamedType('thisUpdate', useful.GeneralizedTime()), namedtype.NamedType('nextUpdate', useful.GeneralizedTime()), namedtype.NamedType('fileHashAlg', univ.ObjectIdentifier()), namedtype.NamedType('fileList', univ.SequenceOf(componentType=FileAndHash()).subtype( subtypeSpec=constraint.ValueSizeConstraint(0, MAX))) ) # Map of Content Type OIDs to Content Types added to the # ones that are in rfc5652.py _cmsContentTypesMapUpdate = { id_ct_rpkiManifest: Manifest(), } rfc5652.cmsContentTypesMap.update(_cmsContentTypesMapUpdate) rfc3537.py 0000644 00000001434 15030212136 0006205 0 ustar 00 # # This file is part of pyasn1-modules software. # # Created by Russ Housley. # # Copyright (c) 2019, Vigil Security, LLC # License: http://snmplabs.com/pyasn1/license.html # # SEED Encryption Algorithm in CMS # # ASN.1 source from: # https://www.rfc-editor.org/rfc/rfc4010.txt # from pyasn1.type import constraint from pyasn1.type import univ from pyasn1_modules import rfc5280 id_alg_HMACwith3DESwrap = univ.ObjectIdentifier('1.2.840.113549.1.9.16.3.11') id_alg_HMACwithAESwrap = univ.ObjectIdentifier('1.2.840.113549.1.9.16.3.12') # Update the Algorithm Identifier map in rfc5280.py. _algorithmIdentifierMapUpdate = { id_alg_HMACwith3DESwrap: univ.Null(""), id_alg_HMACwithAESwrap: univ.Null(""), } rfc5280.algorithmIdentifierMap.update(_algorithmIdentifierMapUpdate) pem.py 0000644 00000003435 15030212136 0005675 0 ustar 00 # # This file is part of pyasn1-modules software. # # Copyright (c) 2005-2020, Ilya Etingof <etingof@gmail.com> # License: http://snmplabs.com/pyasn1/license.html # import base64 stSpam, stHam, stDump = 0, 1, 2 # The markers parameters is in form ('start1', 'stop1'), ('start2', 'stop2')... # Return is (marker-index, substrate) def readPemBlocksFromFile(fileObj, *markers): startMarkers = dict(map(lambda x: (x[1], x[0]), enumerate(map(lambda y: y[0], markers)))) stopMarkers = dict(map(lambda x: (x[1], x[0]), enumerate(map(lambda y: y[1], markers)))) idx = -1 substrate = '' certLines = [] state = stSpam while True: certLine = fileObj.readline() if not certLine: break certLine = certLine.strip() if state == stSpam: if certLine in startMarkers: certLines = [] idx = startMarkers[certLine] state = stHam continue if state == stHam: if certLine in stopMarkers and stopMarkers[certLine] == idx: state = stDump else: certLines.append(certLine) if state == stDump: substrate = ''.encode().join([base64.b64decode(x.encode()) for x in certLines]) break return idx, substrate # Backward compatibility routine def readPemFromFile(fileObj, startMarker='-----BEGIN CERTIFICATE-----', endMarker='-----END CERTIFICATE-----'): idx, substrate = readPemBlocksFromFile(fileObj, (startMarker, endMarker)) return substrate def readBase64fromText(text): return base64.b64decode(text.encode()) def readBase64FromFile(fileObj): return readBase64fromText(fileObj.read()) rfc2634.py 0000644 00000022321 15030212136 0006200 0 ustar 00 # # This file is part of pyasn1-modules software. # # Created by Russ Housley with assistance from asn1ate v.0.6.0. # Modified by Russ Housley to add a map for use with opentypes. # # Copyright (c) 2019, Vigil Security, LLC # License: http://snmplabs.com/pyasn1/license.html # # Enhanced Security Services for S/MIME # # ASN.1 source from: # https://www.rfc-editor.org/rfc/rfc2634.txt # from pyasn1.type import char from pyasn1.type import constraint from pyasn1.type import namedval from pyasn1.type import namedtype from pyasn1.type import tag from pyasn1.type import univ from pyasn1.type import useful from pyasn1_modules import rfc5652 from pyasn1_modules import rfc5280 MAX = float('inf') ContentType = rfc5652.ContentType IssuerAndSerialNumber = rfc5652.IssuerAndSerialNumber SubjectKeyIdentifier = rfc5652.SubjectKeyIdentifier PolicyInformation = rfc5280.PolicyInformation GeneralNames = rfc5280.GeneralNames CertificateSerialNumber = rfc5280.CertificateSerialNumber # Signing Certificate Attribute # Warning: It is better to use SigningCertificateV2 from RFC 5035 id_aa_signingCertificate = univ.ObjectIdentifier('1.2.840.113549.1.9.16.2.12') class Hash(univ.OctetString): pass # SHA-1 hash of entire certificate; RFC 5035 supports other hash algorithms class IssuerSerial(univ.Sequence): pass IssuerSerial.componentType = namedtype.NamedTypes( namedtype.NamedType('issuer', GeneralNames()), namedtype.NamedType('serialNumber', CertificateSerialNumber()) ) class ESSCertID(univ.Sequence): pass ESSCertID.componentType = namedtype.NamedTypes( namedtype.NamedType('certHash', Hash()), namedtype.OptionalNamedType('issuerSerial', IssuerSerial()) ) class SigningCertificate(univ.Sequence): pass SigningCertificate.componentType = namedtype.NamedTypes( namedtype.NamedType('certs', univ.SequenceOf( componentType=ESSCertID())), namedtype.OptionalNamedType('policies', univ.SequenceOf( componentType=PolicyInformation())) ) # Mail List Expansion History Attribute id_aa_mlExpandHistory = univ.ObjectIdentifier('1.2.840.113549.1.9.16.2.3') ub_ml_expansion_history = univ.Integer(64) class EntityIdentifier(univ.Choice): pass EntityIdentifier.componentType = namedtype.NamedTypes( namedtype.NamedType('issuerAndSerialNumber', IssuerAndSerialNumber()), namedtype.NamedType('subjectKeyIdentifier', SubjectKeyIdentifier()) ) class MLReceiptPolicy(univ.Choice): pass MLReceiptPolicy.componentType = namedtype.NamedTypes( namedtype.NamedType('none', univ.Null().subtype(implicitTag=tag.Tag( tag.tagClassContext, tag.tagFormatSimple, 0))), namedtype.NamedType('insteadOf', univ.SequenceOf( componentType=GeneralNames()).subtype( sizeSpec=constraint.ValueSizeConstraint(1, MAX)).subtype( implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 1))), namedtype.NamedType('inAdditionTo', univ.SequenceOf( componentType=GeneralNames()).subtype( sizeSpec=constraint.ValueSizeConstraint(1, MAX)).subtype( implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 2))) ) class MLData(univ.Sequence): pass MLData.componentType = namedtype.NamedTypes( namedtype.NamedType('mailListIdentifier', EntityIdentifier()), namedtype.NamedType('expansionTime', useful.GeneralizedTime()), namedtype.OptionalNamedType('mlReceiptPolicy', MLReceiptPolicy()) ) class MLExpansionHistory(univ.SequenceOf): pass MLExpansionHistory.componentType = MLData() MLExpansionHistory.sizeSpec = constraint.ValueSizeConstraint(1, ub_ml_expansion_history) # ESS Security Label Attribute id_aa_securityLabel = univ.ObjectIdentifier('1.2.840.113549.1.9.16.2.2') ub_privacy_mark_length = univ.Integer(128) ub_security_categories = univ.Integer(64) ub_integer_options = univ.Integer(256) class ESSPrivacyMark(univ.Choice): pass ESSPrivacyMark.componentType = namedtype.NamedTypes( namedtype.NamedType('pString', char.PrintableString().subtype( subtypeSpec=constraint.ValueSizeConstraint(1, ub_privacy_mark_length))), namedtype.NamedType('utf8String', char.UTF8String().subtype( subtypeSpec=constraint.ValueSizeConstraint(1, MAX))) ) class SecurityClassification(univ.Integer): pass SecurityClassification.subtypeSpec=constraint.ValueRangeConstraint(0, ub_integer_options) SecurityClassification.namedValues = namedval.NamedValues( ('unmarked', 0), ('unclassified', 1), ('restricted', 2), ('confidential', 3), ('secret', 4), ('top-secret', 5) ) class SecurityPolicyIdentifier(univ.ObjectIdentifier): pass class SecurityCategory(univ.Sequence): pass SecurityCategory.componentType = namedtype.NamedTypes( namedtype.NamedType('type', univ.ObjectIdentifier().subtype( implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 0))), namedtype.NamedType('value', univ.Any().subtype(implicitTag=tag.Tag( tag.tagClassContext, tag.tagFormatSimple, 1))) ) class SecurityCategories(univ.SetOf): pass SecurityCategories.componentType = SecurityCategory() SecurityCategories.sizeSpec = constraint.ValueSizeConstraint(1, ub_security_categories) class ESSSecurityLabel(univ.Set): pass ESSSecurityLabel.componentType = namedtype.NamedTypes( namedtype.NamedType('security-policy-identifier', SecurityPolicyIdentifier()), namedtype.OptionalNamedType('security-classification', SecurityClassification()), namedtype.OptionalNamedType('privacy-mark', ESSPrivacyMark()), namedtype.OptionalNamedType('security-categories', SecurityCategories()) ) # Equivalent Labels Attribute id_aa_equivalentLabels = univ.ObjectIdentifier('1.2.840.113549.1.9.16.2.9') class EquivalentLabels(univ.SequenceOf): pass EquivalentLabels.componentType = ESSSecurityLabel() # Content Identifier Attribute id_aa_contentIdentifier = univ.ObjectIdentifier('1.2.840.113549.1.9.16.2.7') class ContentIdentifier(univ.OctetString): pass # Content Reference Attribute id_aa_contentReference = univ.ObjectIdentifier('1.2.840.113549.1.9.16.2.10') class ContentReference(univ.Sequence): pass ContentReference.componentType = namedtype.NamedTypes( namedtype.NamedType('contentType', ContentType()), namedtype.NamedType('signedContentIdentifier', ContentIdentifier()), namedtype.NamedType('originatorSignatureValue', univ.OctetString()) ) # Message Signature Digest Attribute id_aa_msgSigDigest = univ.ObjectIdentifier('1.2.840.113549.1.9.16.2.5') class MsgSigDigest(univ.OctetString): pass # Content Hints Attribute id_aa_contentHint = univ.ObjectIdentifier('1.2.840.113549.1.9.16.2.4') class ContentHints(univ.Sequence): pass ContentHints.componentType = namedtype.NamedTypes( namedtype.OptionalNamedType('contentDescription', char.UTF8String().subtype(subtypeSpec=constraint.ValueSizeConstraint(1, MAX))), namedtype.NamedType('contentType', ContentType()) ) # Receipt Request Attribute class AllOrFirstTier(univ.Integer): pass AllOrFirstTier.namedValues = namedval.NamedValues( ('allReceipts', 0), ('firstTierRecipients', 1) ) class ReceiptsFrom(univ.Choice): pass ReceiptsFrom.componentType = namedtype.NamedTypes( namedtype.NamedType('allOrFirstTier', AllOrFirstTier().subtype( implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 0))), namedtype.NamedType('receiptList', univ.SequenceOf( componentType=GeneralNames()).subtype(implicitTag=tag.Tag( tag.tagClassContext, tag.tagFormatSimple, 1))) ) id_aa_receiptRequest = univ.ObjectIdentifier('1.2.840.113549.1.9.16.2.1') ub_receiptsTo = univ.Integer(16) class ReceiptRequest(univ.Sequence): pass ReceiptRequest.componentType = namedtype.NamedTypes( namedtype.NamedType('signedContentIdentifier', ContentIdentifier()), namedtype.NamedType('receiptsFrom', ReceiptsFrom()), namedtype.NamedType('receiptsTo', univ.SequenceOf(componentType=GeneralNames()).subtype(sizeSpec=constraint.ValueSizeConstraint(1, ub_receiptsTo))) ) # Receipt Content Type class ESSVersion(univ.Integer): pass ESSVersion.namedValues = namedval.NamedValues( ('v1', 1) ) id_ct_receipt = univ.ObjectIdentifier('1.2.840.113549.1.9.16.1.1') class Receipt(univ.Sequence): pass Receipt.componentType = namedtype.NamedTypes( namedtype.NamedType('version', ESSVersion()), namedtype.NamedType('contentType', ContentType()), namedtype.NamedType('signedContentIdentifier', ContentIdentifier()), namedtype.NamedType('originatorSignatureValue', univ.OctetString()) ) # Map of Attribute Type to the Attribute structure is added to the # ones that are in rfc5652.py _cmsAttributesMapUpdate = { id_aa_signingCertificate: SigningCertificate(), id_aa_mlExpandHistory: MLExpansionHistory(), id_aa_securityLabel: ESSSecurityLabel(), id_aa_equivalentLabels: EquivalentLabels(), id_aa_contentIdentifier: ContentIdentifier(), id_aa_contentReference: ContentReference(), id_aa_msgSigDigest: MsgSigDigest(), id_aa_contentHint: ContentHints(), id_aa_receiptRequest: ReceiptRequest(), } rfc5652.cmsAttributesMap.update(_cmsAttributesMapUpdate) # Map of Content Type OIDs to Content Types is added to the # ones that are in rfc5652.py _cmsContentTypesMapUpdate = { id_ct_receipt: Receipt(), } rfc5652.cmsContentTypesMap.update(_cmsContentTypesMapUpdate) rfc1902.py 0000644 00000007171 15030212136 0006203 0 ustar 00 # # This file is part of pyasn1-modules software. # # Copyright (c) 2005-2020, Ilya Etingof <etingof@gmail.com> # License: http://snmplabs.com/pyasn1/license.html # # SNMPv2c message syntax # # ASN.1 source from: # http://www.ietf.org/rfc/rfc1902.txt # from pyasn1.type import constraint from pyasn1.type import namedtype from pyasn1.type import tag from pyasn1.type import univ class Integer(univ.Integer): subtypeSpec = univ.Integer.subtypeSpec + constraint.ValueRangeConstraint( -2147483648, 2147483647 ) class Integer32(univ.Integer): subtypeSpec = univ.Integer.subtypeSpec + constraint.ValueRangeConstraint( -2147483648, 2147483647 ) class OctetString(univ.OctetString): subtypeSpec = univ.Integer.subtypeSpec + constraint.ValueSizeConstraint( 0, 65535 ) class IpAddress(univ.OctetString): tagSet = univ.OctetString.tagSet.tagImplicitly( tag.Tag(tag.tagClassApplication, tag.tagFormatSimple, 0x00) ) subtypeSpec = univ.OctetString.subtypeSpec + constraint.ValueSizeConstraint( 4, 4 ) class Counter32(univ.Integer): tagSet = univ.Integer.tagSet.tagImplicitly( tag.Tag(tag.tagClassApplication, tag.tagFormatSimple, 0x01) ) subtypeSpec = univ.Integer.subtypeSpec + constraint.ValueRangeConstraint( 0, 4294967295 ) class Gauge32(univ.Integer): tagSet = univ.Integer.tagSet.tagImplicitly( tag.Tag(tag.tagClassApplication, tag.tagFormatSimple, 0x02) ) subtypeSpec = univ.Integer.subtypeSpec + constraint.ValueRangeConstraint( 0, 4294967295 ) class Unsigned32(univ.Integer): tagSet = univ.Integer.tagSet.tagImplicitly( tag.Tag(tag.tagClassApplication, tag.tagFormatSimple, 0x02) ) subtypeSpec = univ.Integer.subtypeSpec + constraint.ValueRangeConstraint( 0, 4294967295 ) class TimeTicks(univ.Integer): tagSet = univ.Integer.tagSet.tagImplicitly( tag.Tag(tag.tagClassApplication, tag.tagFormatSimple, 0x03) ) subtypeSpec = univ.Integer.subtypeSpec + constraint.ValueRangeConstraint( 0, 4294967295 ) class Opaque(univ.OctetString): tagSet = univ.OctetString.tagSet.tagImplicitly( tag.Tag(tag.tagClassApplication, tag.tagFormatSimple, 0x04) ) class Counter64(univ.Integer): tagSet = univ.Integer.tagSet.tagImplicitly( tag.Tag(tag.tagClassApplication, tag.tagFormatSimple, 0x06) ) subtypeSpec = univ.Integer.subtypeSpec + constraint.ValueRangeConstraint( 0, 18446744073709551615 ) class Bits(univ.OctetString): pass class ObjectName(univ.ObjectIdentifier): pass class SimpleSyntax(univ.Choice): componentType = namedtype.NamedTypes( namedtype.NamedType('integer-value', Integer()), namedtype.NamedType('string-value', OctetString()), namedtype.NamedType('objectID-value', univ.ObjectIdentifier()) ) class ApplicationSyntax(univ.Choice): componentType = namedtype.NamedTypes( namedtype.NamedType('ipAddress-value', IpAddress()), namedtype.NamedType('counter-value', Counter32()), namedtype.NamedType('timeticks-value', TimeTicks()), namedtype.NamedType('arbitrary-value', Opaque()), namedtype.NamedType('big-counter-value', Counter64()), # This conflicts with Counter32 # namedtype.NamedType('unsigned-integer-value', Unsigned32()), namedtype.NamedType('gauge32-value', Gauge32()) ) # BITS misplaced? class ObjectSyntax(univ.Choice): componentType = namedtype.NamedTypes( namedtype.NamedType('simple', SimpleSyntax()), namedtype.NamedType('application-wide', ApplicationSyntax()) ) rfc5697.py 0000644 00000003246 15030212136 0006221 0 ustar 00 # This file is being contributed to pyasn1-modules software. # # Created by Russ Housley. # # Copyright (c) 2019, Vigil Security, LLC # License: http://snmplabs.com/pyasn1/license.html # # Other Certificates Extension # # ASN.1 source from: # https://www.rfc-editor.org/rfc/rfc5697.txt from pyasn1.type import namedtype from pyasn1.type import univ from pyasn1_modules import rfc5280 from pyasn1_modules import rfc4055 # Imports from RFC 5280 AlgorithmIdentifier = rfc5280.AlgorithmIdentifier CertificateSerialNumber = rfc5280.CertificateSerialNumber GeneralNames = rfc5280.GeneralNames # Imports from RFC 4055 id_sha1 = rfc4055.id_sha1 # Imports from RFC 5055 # These are defined here because a module for RFC 5055 does not exist yet class SCVPIssuerSerial(univ.Sequence): componentType = namedtype.NamedTypes( namedtype.NamedType('issuer', GeneralNames()), namedtype.NamedType('serialNumber', CertificateSerialNumber()) ) sha1_alg_id = AlgorithmIdentifier() sha1_alg_id['algorithm'] = id_sha1 class SCVPCertID(univ.Sequence): componentType = namedtype.NamedTypes( namedtype.NamedType('certHash', univ.OctetString()), namedtype.NamedType('issuerSerial', SCVPIssuerSerial()), namedtype.DefaultedNamedType('hashAlgorithm', sha1_alg_id) ) # Other Certificates Extension id_pe_otherCerts = univ.ObjectIdentifier((1, 3, 6, 1, 5, 5, 7, 1, 19,)) class OtherCertificates(univ.SequenceOf): componentType = SCVPCertID() # Update of certificate extension map in rfc5280.py _certificateExtensionsMapUpdate = { id_pe_otherCerts: OtherCertificates(), } rfc5280.certificateExtensionsMap.update(_certificateExtensionsMapUpdate) rfc5084.py 0000644 00000005447 15030212136 0006214 0 ustar 00 # This file is being contributed to pyasn1-modules software. # # Created by Russ Housley with assistance from the asn1ate tool, with manual # changes to AES_CCM_ICVlen.subtypeSpec and added comments # # Copyright (c) 2018-2019, Vigil Security, LLC # License: http://snmplabs.com/pyasn1/license.html # # AES-CCM and AES-GCM Algorithms fo use with the Authenticated-Enveloped-Data # protecting content type for the Cryptographic Message Syntax (CMS) # # ASN.1 source from: # https://www.rfc-editor.org/rfc/rfc5084.txt from pyasn1.type import constraint from pyasn1.type import namedtype from pyasn1.type import univ from pyasn1_modules import rfc5280 def _OID(*components): output = [] for x in tuple(components): if isinstance(x, univ.ObjectIdentifier): output.extend(list(x)) else: output.append(int(x)) return univ.ObjectIdentifier(output) class AES_CCM_ICVlen(univ.Integer): pass class AES_GCM_ICVlen(univ.Integer): pass AES_CCM_ICVlen.subtypeSpec = constraint.SingleValueConstraint(4, 6, 8, 10, 12, 14, 16) AES_GCM_ICVlen.subtypeSpec = constraint.ValueRangeConstraint(12, 16) class CCMParameters(univ.Sequence): pass CCMParameters.componentType = namedtype.NamedTypes( namedtype.NamedType('aes-nonce', univ.OctetString().subtype(subtypeSpec=constraint.ValueSizeConstraint(7, 13))), # The aes-nonce parameter contains 15-L octets, where L is the size of the length field. L=8 is RECOMMENDED. # Within the scope of any content-authenticated-encryption key, the nonce value MUST be unique. namedtype.DefaultedNamedType('aes-ICVlen', AES_CCM_ICVlen().subtype(value=12)) ) class GCMParameters(univ.Sequence): pass GCMParameters.componentType = namedtype.NamedTypes( namedtype.NamedType('aes-nonce', univ.OctetString()), # The aes-nonce may have any number of bits between 8 and 2^64, but it MUST be a multiple of 8 bits. # Within the scope of any content-authenticated-encryption key, the nonce value MUST be unique. # A nonce value of 12 octets can be processed more efficiently, so that length is RECOMMENDED. namedtype.DefaultedNamedType('aes-ICVlen', AES_GCM_ICVlen().subtype(value=12)) ) aes = _OID(2, 16, 840, 1, 101, 3, 4, 1) id_aes128_CCM = _OID(aes, 7) id_aes128_GCM = _OID(aes, 6) id_aes192_CCM = _OID(aes, 27) id_aes192_GCM = _OID(aes, 26) id_aes256_CCM = _OID(aes, 47) id_aes256_GCM = _OID(aes, 46) # Map of Algorithm Identifier OIDs to Parameters is added to the # ones in rfc5280.py _algorithmIdentifierMapUpdate = { id_aes128_CCM: CCMParameters(), id_aes128_GCM: GCMParameters(), id_aes192_CCM: CCMParameters(), id_aes192_GCM: GCMParameters(), id_aes256_CCM: CCMParameters(), id_aes256_GCM: GCMParameters(), } rfc5280.algorithmIdentifierMap.update(_algorithmIdentifierMapUpdate) rfc6019.py 0000644 00000002076 15030212136 0006206 0 ustar 00 # This file is being contributed to pyasn1-modules software. # # Created by Russ Housley. # Modified by Russ Housley to add a map for use with opentypes. # # Copyright (c) 2019, Vigil Security, LLC # License: http://snmplabs.com/pyasn1/license.html # # BinaryTime: An Alternate Format for Representing Date and Time # # ASN.1 source from: # https://www.rfc-editor.org/rfc/rfc6019.txt from pyasn1.type import constraint from pyasn1.type import univ from pyasn1_modules import rfc5652 MAX = float('inf') # BinaryTime: Represent date and time as an integer class BinaryTime(univ.Integer): pass BinaryTime.subtypeSpec = constraint.ValueRangeConstraint(0, MAX) # CMS Attribute for representing signing time in BinaryTime id_aa_binarySigningTime = univ.ObjectIdentifier('1.2.840.113549.1.9.16.2.46') class BinarySigningTime(BinaryTime): pass # Map of Attribute Type OIDs to Attributes ia added to the # ones that are in rfc5652.py _cmsAttributesMapUpdate = { id_aa_binarySigningTime: BinarySigningTime(), } rfc5652.cmsAttributesMap.update(_cmsAttributesMapUpdate) rfc7773.py 0000644 00000002443 15030212136 0006214 0 ustar 00 # # This file is part of pyasn1-modules software. # # Created by Russ Housley with some assistance from asn1ate v.0.6.0. # # Copyright (c) 2019, Vigil Security, LLC # License: http://snmplabs.com/pyasn1/license.html # # Authentication Context Certificate Extension # # ASN.1 source from: # https://www.rfc-editor.org/rfc/rfc7773.txt # from pyasn1.type import char from pyasn1.type import constraint from pyasn1.type import namedtype from pyasn1.type import univ from pyasn1_modules import rfc5280 MAX = float('inf') # Authentication Context Extension e_legnamnden = univ.ObjectIdentifier('1.2.752.201') id_eleg_ce = e_legnamnden + (5, ) id_ce_authContext = id_eleg_ce + (1, ) class AuthenticationContext(univ.Sequence): componentType = namedtype.NamedTypes( namedtype.NamedType('contextType', char.UTF8String()), namedtype.OptionalNamedType('contextInfo', char.UTF8String()) ) class AuthenticationContexts(univ.SequenceOf): componentType = AuthenticationContext() subtypeSpec=constraint.ValueSizeConstraint(1, MAX) # Map of Certificate Extension OIDs to Extensions added to the # ones that are in rfc5280.py _certificateExtensionsMapUpdate = { id_ce_authContext: AuthenticationContexts(), } rfc5280.certificateExtensionsMap.update(_certificateExtensionsMapUpdate) rfc4476.py 0000644 00000003650 15030212136 0006212 0 ustar 00 # # This file is part of pyasn1-modules software. # # Created by Russ Housley with assistance from asn1ate v.0.6.0. # # Copyright (c) 2019, Vigil Security, LLC # License: http://snmplabs.com/pyasn1/license.html # # Attribute Certificate Policies Extension # # ASN.1 source from: # https://www.rfc-editor.org/rfc/rfc4476.txt # from pyasn1.type import char from pyasn1.type import constraint from pyasn1.type import namedtype from pyasn1.type import univ from pyasn1_modules import rfc5280 MAX = float('inf') # Imports from RFC 5280 PolicyQualifierId = rfc5280.PolicyQualifierId PolicyQualifierInfo = rfc5280.PolicyQualifierInfo UserNotice = rfc5280.UserNotice id_pkix = rfc5280.id_pkix # Object Identifiers id_pe = id_pkix + (1,) id_pe_acPolicies = id_pe + (15,) id_qt = id_pkix + (2,) id_qt_acps = id_qt + (4,) id_qt_acunotice = id_qt + (5,) # Attribute Certificate Policies Extension class ACUserNotice(UserNotice): pass class ACPSuri(char.IA5String): pass class AcPolicyId(univ.ObjectIdentifier): pass class PolicyInformation(univ.Sequence): componentType = namedtype.NamedTypes( namedtype.NamedType('policyIdentifier', AcPolicyId()), namedtype.OptionalNamedType('policyQualifiers', univ.SequenceOf(componentType=PolicyQualifierInfo()).subtype( subtypeSpec=constraint.ValueSizeConstraint(1, MAX))) ) class AcPoliciesSyntax(univ.SequenceOf): componentType = PolicyInformation() subtypeSpec = constraint.ValueSizeConstraint(1, MAX) # Update the policy qualifier map in rfc5280.py _policyQualifierInfoMapUpdate = { id_qt_acps: ACPSuri(), id_qt_acunotice: UserNotice(), } rfc5280.policyQualifierInfoMap.update(_policyQualifierInfoMapUpdate) # Update the certificate extension map in rfc5280.py _certificateExtensionsMapUpdate = { id_pe_acPolicies: AcPoliciesSyntax(), } rfc5280.certificateExtensionsMap.update(_certificateExtensionsMapUpdate) rfc7030.py 0000644 00000002641 15030212136 0006176 0 ustar 00 # # This file is part of pyasn1-modules software. # # Created by Russ Housley with assistance from asn1ate v.0.6.0. # # Copyright (c) 2019, Vigil Security, LLC # License: http://snmplabs.com/pyasn1/license.html # # Enrollment over Secure Transport (EST) # # ASN.1 source from: # https://www.rfc-editor.org/rfc/rfc7030.txt # from pyasn1.type import constraint from pyasn1.type import namedtype from pyasn1.type import univ from pyasn1_modules import rfc5652 MAX = float('inf') # Imports from RFC 5652 Attribute = rfc5652.Attribute # Asymmetric Decrypt Key Identifier Attribute id_aa_asymmDecryptKeyID = univ.ObjectIdentifier('1.2.840.113549.1.9.16.2.54') class AsymmetricDecryptKeyIdentifier(univ.OctetString): pass aa_asymmDecryptKeyID = Attribute() aa_asymmDecryptKeyID['attrType'] = id_aa_asymmDecryptKeyID aa_asymmDecryptKeyID['attrValues'][0] = AsymmetricDecryptKeyIdentifier() # CSR Attributes class AttrOrOID(univ.Choice): pass AttrOrOID.componentType = namedtype.NamedTypes( namedtype.NamedType('oid', univ.ObjectIdentifier()), namedtype.NamedType('attribute', Attribute()) ) class CsrAttrs(univ.SequenceOf): pass CsrAttrs.componentType = AttrOrOID() CsrAttrs.subtypeSpec=constraint.ValueSizeConstraint(0, MAX) # Update CMS Attribute Map _cmsAttributesMapUpdate = { id_aa_asymmDecryptKeyID: AsymmetricDecryptKeyIdentifier(), } rfc5652.cmsAttributesMap.update(_cmsAttributesMapUpdate) rfc4073.py 0000644 00000003144 15030212136 0006201 0 ustar 00 # # This file is part of pyasn1-modules software. # # Created by Russ Housley with some assistance from asn1ate v.0.6.0. # Modified by Russ Housley to add a map for use with opentypes. # # Copyright (c) 2019, Vigil Security, LLC # License: http://snmplabs.com/pyasn1/license.html # # Protecting Multiple Contents with the CMS # # ASN.1 source from: # https://www.rfc-editor.org/rfc/rfc4073.txt # from pyasn1.type import constraint from pyasn1.type import namedtype from pyasn1.type import univ from pyasn1_modules import rfc5652 MAX = float('inf') # Content Collection Content Type and Object Identifier id_ct_contentCollection = univ.ObjectIdentifier('1.2.840.113549.1.9.16.1.19') class ContentCollection(univ.SequenceOf): pass ContentCollection.componentType = rfc5652.ContentInfo() ContentCollection.sizeSpec = constraint.ValueSizeConstraint(1, MAX) # Content With Attributes Content Type and Object Identifier id_ct_contentWithAttrs = univ.ObjectIdentifier('1.2.840.113549.1.9.16.1.20') class ContentWithAttributes(univ.Sequence): pass ContentWithAttributes.componentType = namedtype.NamedTypes( namedtype.NamedType('content', rfc5652.ContentInfo()), namedtype.NamedType('attrs', univ.SequenceOf( componentType=rfc5652.Attribute()).subtype( sizeSpec=constraint.ValueSizeConstraint(1, MAX))) ) # Map of Content Type OIDs to Content Types is added to the # ones that are in rfc5652.py _cmsContentTypesMapUpdate = { id_ct_contentCollection: ContentCollection(), id_ct_contentWithAttrs: ContentWithAttributes(), } rfc5652.cmsContentTypesMap.update(_cmsContentTypesMapUpdate) rfc6010.py 0000644 00000004453 15030212136 0006176 0 ustar 00 # # This file is part of pyasn1-modules software. # # Created by Russ Housley with assistance from asn1ate v.0.6.0. # Modified by Russ Housley to add maps for use with opentypes. # # Copyright (c) 2019, Vigil Security, LLC # License: http://snmplabs.com/pyasn1/license.html # # Certificate Extension for CMS Content Constraints (CCC) # # ASN.1 source from: # https://www.rfc-editor.org/rfc/rfc6010.txt # from pyasn1.type import constraint from pyasn1.type import namedtype from pyasn1.type import namedval from pyasn1.type import univ from pyasn1_modules import rfc5280 MAX = float('inf') AttributeType = rfc5280.AttributeType AttributeValue = rfc5280.AttributeValue id_ct_anyContentType = univ.ObjectIdentifier('1.2.840.113549.1.9.16.1.0') class AttrConstraint(univ.Sequence): pass AttrConstraint.componentType = namedtype.NamedTypes( namedtype.NamedType('attrType', AttributeType()), namedtype.NamedType('attrValues', univ.SetOf( componentType=AttributeValue()).subtype(subtypeSpec=constraint.ValueSizeConstraint(1, MAX))) ) class AttrConstraintList(univ.SequenceOf): pass AttrConstraintList.componentType = AttrConstraint() AttrConstraintList.subtypeSpec=constraint.ValueSizeConstraint(1, MAX) class ContentTypeGeneration(univ.Enumerated): pass ContentTypeGeneration.namedValues = namedval.NamedValues( ('canSource', 0), ('cannotSource', 1) ) class ContentTypeConstraint(univ.Sequence): pass ContentTypeConstraint.componentType = namedtype.NamedTypes( namedtype.NamedType('contentType', univ.ObjectIdentifier()), namedtype.DefaultedNamedType('canSource', ContentTypeGeneration().subtype(value='canSource')), namedtype.OptionalNamedType('attrConstraints', AttrConstraintList()) ) # CMS Content Constraints (CCC) Extension and Object Identifier id_pe_cmsContentConstraints = univ.ObjectIdentifier('1.3.6.1.5.5.7.1.18') class CMSContentConstraints(univ.SequenceOf): pass CMSContentConstraints.componentType = ContentTypeConstraint() CMSContentConstraints.subtypeSpec=constraint.ValueSizeConstraint(1, MAX) # Map of Certificate Extension OIDs to Extensions # To be added to the ones that are in rfc5280.py _certificateExtensionsMap = { id_pe_cmsContentConstraints: CMSContentConstraints(), } rfc5280.certificateExtensionsMap.update(_certificateExtensionsMap) rfc3447.py 0000644 00000003105 15030212136 0006202 0 ustar 00 # # This file is part of pyasn1-modules software. # # Copyright (c) 2005-2020, Ilya Etingof <etingof@gmail.com> # License: http://snmplabs.com/pyasn1/license.html # # PKCS#1 syntax # # ASN.1 source from: # ftp://ftp.rsasecurity.com/pub/pkcs/pkcs-1/pkcs-1v2-1.asn # # Sample captures could be obtained with "openssl genrsa" command # from pyasn1.type import constraint from pyasn1.type import namedval from pyasn1_modules.rfc2437 import * class OtherPrimeInfo(univ.Sequence): componentType = namedtype.NamedTypes( namedtype.NamedType('prime', univ.Integer()), namedtype.NamedType('exponent', univ.Integer()), namedtype.NamedType('coefficient', univ.Integer()) ) class OtherPrimeInfos(univ.SequenceOf): componentType = OtherPrimeInfo() sizeSpec = univ.SequenceOf.sizeSpec + constraint.ValueSizeConstraint(1, MAX) class RSAPrivateKey(univ.Sequence): componentType = namedtype.NamedTypes( namedtype.NamedType('version', univ.Integer(namedValues=namedval.NamedValues(('two-prime', 0), ('multi', 1)))), namedtype.NamedType('modulus', univ.Integer()), namedtype.NamedType('publicExponent', univ.Integer()), namedtype.NamedType('privateExponent', univ.Integer()), namedtype.NamedType('prime1', univ.Integer()), namedtype.NamedType('prime2', univ.Integer()), namedtype.NamedType('exponent1', univ.Integer()), namedtype.NamedType('exponent2', univ.Integer()), namedtype.NamedType('coefficient', univ.Integer()), namedtype.OptionalNamedType('otherPrimeInfos', OtherPrimeInfos()) ) rfc7229.py 0000644 00000001347 15030212136 0006212 0 ustar 00 # # This file is part of pyasn1-modules software. # # Created by Russ Housley. # # Copyright (c) 2019, Vigil Security, LLC # License: http://snmplabs.com/pyasn1/license.html # # Object Identifiers for Test Certificate Policies # # ASN.1 source from: # https://www.rfc-editor.org/rfc/rfc7229.txt # from pyasn1.type import univ id_pkix = univ.ObjectIdentifier('1.3.6.1.5.5.7') id_TEST = id_pkix + (13, ) id_TEST_certPolicyOne = id_TEST + (1, ) id_TEST_certPolicyTwo = id_TEST + (2, ) id_TEST_certPolicyThree = id_TEST + (3, ) id_TEST_certPolicyFour = id_TEST + (4, ) id_TEST_certPolicyFive = id_TEST + (5, ) id_TEST_certPolicySix = id_TEST + (6, ) id_TEST_certPolicySeven = id_TEST + (7, ) id_TEST_certPolicyEight = id_TEST + (8, ) rfc3820.py 0000644 00000002706 15030212136 0006203 0 ustar 00 # # This file is part of pyasn1-modules software. # # Created by Russ Housley with assistance from asn1ate v.0.6.0. # # Copyright (c) 2019, Vigil Security, LLC # License: http://snmplabs.com/pyasn1/license.html # # Diffie-Hellman Key Agreement # # ASN.1 source from: # https://www.rfc-editor.org/rfc/rfc3820.txt # from pyasn1.type import namedtype from pyasn1.type import univ from pyasn1_modules import rfc5280 class ProxyCertPathLengthConstraint(univ.Integer): pass class ProxyPolicy(univ.Sequence): componentType = namedtype.NamedTypes( namedtype.NamedType('policyLanguage', univ.ObjectIdentifier()), namedtype.OptionalNamedType('policy', univ.OctetString()) ) class ProxyCertInfoExtension(univ.Sequence): componentType = namedtype.NamedTypes( namedtype.OptionalNamedType('pCPathLenConstraint', ProxyCertPathLengthConstraint()), namedtype.NamedType('proxyPolicy', ProxyPolicy()) ) id_pkix = univ.ObjectIdentifier((1, 3, 6, 1, 5, 5, 7, )) id_pe = id_pkix + (1, ) id_pe_proxyCertInfo = id_pe + (14, ) id_ppl = id_pkix + (21, ) id_ppl_anyLanguage = id_ppl + (0, ) id_ppl_inheritAll = id_ppl + (1, ) id_ppl_independent = id_ppl + (2, ) # Map of Certificate Extension OIDs to Extensions added to the # ones that are in rfc5280.py _certificateExtensionsMapUpdate = { id_pe_proxyCertInfo: ProxyCertInfoExtension(), } rfc5280.certificateExtensionsMap.update(_certificateExtensionsMapUpdate) rfc8494.py 0000644 00000004473 15030212136 0006222 0 ustar 00 # This file is being contributed to pyasn1-modules software. # # Created by Russ Housley with assistance from asn1ate v.0.6.0. # # Copyright (c) 2019, Vigil Security, LLC # License: http://snmplabs.com/pyasn1/license.html # # Multicast Email (MULE) over Allied Communications Publication 142 # # ASN.1 source from: # https://www.rfc-editor.org/rfc/rfc8494.txt from pyasn1.type import namedtype from pyasn1.type import namedval from pyasn1.type import tag from pyasn1.type import univ id_mmhs_CDT = univ.ObjectIdentifier('1.3.26.0.4406.0.4.2') class AlgorithmID_ShortForm(univ.Integer): pass AlgorithmID_ShortForm.namedValues = namedval.NamedValues( ('zlibCompress', 0) ) class ContentType_ShortForm(univ.Integer): pass ContentType_ShortForm.namedValues = namedval.NamedValues( ('unidentified', 0), ('external', 1), ('p1', 2), ('p3', 3), ('p7', 4), ('mule', 25) ) class CompressedContentInfo(univ.Sequence): pass CompressedContentInfo.componentType = namedtype.NamedTypes( namedtype.NamedType('unnamed', univ.Choice(componentType=namedtype.NamedTypes( namedtype.NamedType('contentType-ShortForm', ContentType_ShortForm().subtype(explicitTag=tag.Tag( tag.tagClassContext, tag.tagFormatSimple, 0))), namedtype.NamedType('contentType-OID', univ.ObjectIdentifier().subtype(explicitTag=tag.Tag( tag.tagClassContext, tag.tagFormatSimple, 1))) ))), namedtype.NamedType('compressedContent', univ.OctetString().subtype(explicitTag=tag.Tag( tag.tagClassContext, tag.tagFormatSimple, 0))) ) class CompressionAlgorithmIdentifier(univ.Choice): pass CompressionAlgorithmIdentifier.componentType = namedtype.NamedTypes( namedtype.NamedType('algorithmID-ShortForm', AlgorithmID_ShortForm().subtype(explicitTag=tag.Tag( tag.tagClassContext, tag.tagFormatSimple, 0))), namedtype.NamedType('algorithmID-OID', univ.ObjectIdentifier().subtype(explicitTag=tag.Tag( tag.tagClassContext, tag.tagFormatSimple, 1))) ) class CompressedData(univ.Sequence): pass CompressedData.componentType = namedtype.NamedTypes( namedtype.NamedType('compressionAlgorithm', CompressionAlgorithmIdentifier()), namedtype.NamedType('compressedContentInfo', CompressedContentInfo()) ) rfc5636.py 0000644 00000004424 15030212136 0006211 0 ustar 00 # This file is being contributed to pyasn1-modules software. # # Created by Russ Housley. # # Copyright (c) 2019, Vigil Security, LLC # License: http://snmplabs.com/pyasn1/license.html # # Traceable Anonymous Certificate # # ASN.1 source from: # https://www.rfc-editor.org/rfc/rfc5480.txt from pyasn1.type import namedtype from pyasn1.type import univ from pyasn1.type import useful from pyasn1_modules import rfc5652 # Imports from RFC 5652 ContentInfo = rfc5652.ContentInfo EncapsulatedContentInfo = rfc5652.EncapsulatedContentInfo id_data = rfc5652.id_data # Object Identifiers id_KISA = univ.ObjectIdentifier((1, 2, 410, 200004,)) id_npki = id_KISA + (10,) id_attribute = id_npki + (1,) id_kisa_tac = id_attribute + (1,) id_kisa_tac_token = id_kisa_tac + (1,) id_kisa_tac_tokenandblindbash = id_kisa_tac + (2,) id_kisa_tac_tokenandpartially = id_kisa_tac + (3,) # Structures for Traceable Anonymous Certificate (TAC) class UserKey(univ.OctetString): pass class Timeout(useful.GeneralizedTime): pass class BlinedCertificateHash(univ.OctetString): pass class PartiallySignedCertificateHash(univ.OctetString): pass class Token(ContentInfo): pass class TokenandBlindHash(ContentInfo): pass class TokenandPartiallySignedCertificateHash(ContentInfo): pass # Added to the module in RFC 5636 for the CMS Content Type Map class TACToken(univ.Sequence): componentType = namedtype.NamedTypes( namedtype.NamedType('userKey', UserKey()), namedtype.NamedType('timeout', Timeout()) ) class TACTokenandBlindHash(univ.Sequence): componentType = namedtype.NamedTypes( namedtype.NamedType('token', Token()), namedtype.NamedType('blinded', BlinedCertificateHash()) ) class TACTokenandPartiallySignedCertificateHash(univ.Sequence): componentType = namedtype.NamedTypes( namedtype.NamedType('token', Token()), namedtype.NamedType('partially', PartiallySignedCertificateHash()) ) # Add to the CMS Content Type Map in rfc5752.py _cmsContentTypesMapUpdate = { id_kisa_tac_token: TACToken(), id_kisa_tac_tokenandblindbash: TACTokenandBlindHash(), id_kisa_tac_tokenandpartially: TACTokenandPartiallySignedCertificateHash(), } rfc5652.cmsContentTypesMap.update(_cmsContentTypesMapUpdate) rfc8410.py 0000644 00000001713 15030212136 0006200 0 ustar 00 # This file is being contributed to pyasn1-modules software. # # Created by Russ Housley. # # Copyright (c) 2019, Vigil Security, LLC # License: http://snmplabs.com/pyasn1/license.html # # Algorithm Identifiers for Ed25519, Ed448, X25519, and X448 # # ASN.1 source from: # https://www.rfc-editor.org/rfc/rfc8410.txt from pyasn1.type import univ from pyasn1_modules import rfc3565 from pyasn1_modules import rfc4055 from pyasn1_modules import rfc5280 class SignatureAlgorithmIdentifier(rfc5280.AlgorithmIdentifier): pass class KeyEncryptionAlgorithmIdentifier(rfc5280.AlgorithmIdentifier): pass class CurvePrivateKey(univ.OctetString): pass id_X25519 = univ.ObjectIdentifier('1.3.101.110') id_X448 = univ.ObjectIdentifier('1.3.101.111') id_Ed25519 = univ.ObjectIdentifier('1.3.101.112') id_Ed448 = univ.ObjectIdentifier('1.3.101.113') id_sha512 = rfc4055.id_sha512 id_aes128_wrap = rfc3565.id_aes128_wrap id_aes256_wrap = rfc3565.id_aes256_wrap rfc2985.py 0000644 00000034027 15030212136 0006217 0 ustar 00 # # This file is part of pyasn1-modules software. # # Created by Russ Housley with assistance from asn1ate v.0.6.0. # # Copyright (c) 2019, Vigil Security, LLC # License: http://snmplabs.com/pyasn1/license.html # # PKCS#9: Selected Attribute Types (Version 2.0) # # ASN.1 source from: # https://www.rfc-editor.org/rfc/rfc2985.txt # from pyasn1.type import char from pyasn1.type import constraint from pyasn1.type import namedtype from pyasn1.type import namedval from pyasn1.type import opentype from pyasn1.type import tag from pyasn1.type import univ from pyasn1.type import useful from pyasn1_modules import rfc7292 from pyasn1_modules import rfc5958 from pyasn1_modules import rfc5652 from pyasn1_modules import rfc5280 def _OID(*components): output = [] for x in tuple(components): if isinstance(x, univ.ObjectIdentifier): output.extend(list(x)) else: output.append(int(x)) return univ.ObjectIdentifier(output) MAX = float('inf') # Imports from RFC 5280 AlgorithmIdentifier = rfc5280.AlgorithmIdentifier Attribute = rfc5280.Attribute EmailAddress = rfc5280.EmailAddress Extensions = rfc5280.Extensions Time = rfc5280.Time X520countryName = rfc5280.X520countryName X520SerialNumber = rfc5280.X520SerialNumber # Imports from RFC 5652 ContentInfo = rfc5652.ContentInfo ContentType = rfc5652.ContentType Countersignature = rfc5652.Countersignature MessageDigest = rfc5652.MessageDigest SignerInfo = rfc5652.SignerInfo SigningTime = rfc5652.SigningTime # Imports from RFC 5958 EncryptedPrivateKeyInfo = rfc5958.EncryptedPrivateKeyInfo # Imports from RFC 7292 PFX = rfc7292.PFX # TODO: # Need a place to import PKCS15Token; it does not yet appear in an RFC # SingleAttribute is the same as Attribute in RFC 5280, except that the # attrValues SET must have one and only one member class AttributeType(univ.ObjectIdentifier): pass class AttributeValue(univ.Any): pass class AttributeValues(univ.SetOf): pass AttributeValues.componentType = AttributeValue() class SingleAttributeValues(univ.SetOf): pass SingleAttributeValues.componentType = AttributeValue() class SingleAttribute(univ.Sequence): pass SingleAttribute.componentType = namedtype.NamedTypes( namedtype.NamedType('type', AttributeType()), namedtype.NamedType('values', AttributeValues().subtype(sizeSpec=constraint.ValueSizeConstraint(1, 1)), openType=opentype.OpenType('type', rfc5280.certificateAttributesMap) ) ) # CMSAttribute is the same as Attribute in RFC 5652, and CMSSingleAttribute # is the companion where the attrValues SET must have one and only one member CMSAttribute = rfc5652.Attribute class CMSSingleAttribute(univ.Sequence): pass CMSSingleAttribute.componentType = namedtype.NamedTypes( namedtype.NamedType('attrType', AttributeType()), namedtype.NamedType('attrValues', AttributeValues().subtype(sizeSpec=constraint.ValueSizeConstraint(1, 1)), openType=opentype.OpenType('attrType', rfc5652.cmsAttributesMap) ) ) # DirectoryString is the same as RFC 5280, except the length is limited to 255 class DirectoryString(univ.Choice): pass DirectoryString.componentType = namedtype.NamedTypes( namedtype.NamedType('teletexString', char.TeletexString().subtype( subtypeSpec=constraint.ValueSizeConstraint(1, 255))), namedtype.NamedType('printableString', char.PrintableString().subtype( subtypeSpec=constraint.ValueSizeConstraint(1, 255))), namedtype.NamedType('universalString', char.UniversalString().subtype( subtypeSpec=constraint.ValueSizeConstraint(1, 255))), namedtype.NamedType('utf8String', char.UTF8String().subtype( subtypeSpec=constraint.ValueSizeConstraint(1, 255))), namedtype.NamedType('bmpString', char.BMPString().subtype( subtypeSpec=constraint.ValueSizeConstraint(1, 255))) ) # PKCS9String is DirectoryString with an additional choice of IA5String, # and the SIZE is limited to 255 class PKCS9String(univ.Choice): pass PKCS9String.componentType = namedtype.NamedTypes( namedtype.NamedType('ia5String', char.IA5String().subtype( subtypeSpec=constraint.ValueSizeConstraint(1, 255))), namedtype.NamedType('directoryString', DirectoryString()) ) # Upper Bounds pkcs_9_ub_pkcs9String = univ.Integer(255) pkcs_9_ub_challengePassword = univ.Integer(pkcs_9_ub_pkcs9String) pkcs_9_ub_emailAddress = univ.Integer(pkcs_9_ub_pkcs9String) pkcs_9_ub_friendlyName = univ.Integer(pkcs_9_ub_pkcs9String) pkcs_9_ub_match = univ.Integer(pkcs_9_ub_pkcs9String) pkcs_9_ub_signingDescription = univ.Integer(pkcs_9_ub_pkcs9String) pkcs_9_ub_unstructuredAddress = univ.Integer(pkcs_9_ub_pkcs9String) pkcs_9_ub_unstructuredName = univ.Integer(pkcs_9_ub_pkcs9String) ub_name = univ.Integer(32768) pkcs_9_ub_placeOfBirth = univ.Integer(ub_name) pkcs_9_ub_pseudonym = univ.Integer(ub_name) # Object Identifier Arcs ietf_at = _OID(1, 3, 6, 1, 5, 5, 7, 9) id_at = _OID(2, 5, 4) pkcs_9 = _OID(1, 2, 840, 113549, 1, 9) pkcs_9_mo = _OID(pkcs_9, 0) smime = _OID(pkcs_9, 16) certTypes = _OID(pkcs_9, 22) crlTypes = _OID(pkcs_9, 23) pkcs_9_oc = _OID(pkcs_9, 24) pkcs_9_at = _OID(pkcs_9, 25) pkcs_9_sx = _OID(pkcs_9, 26) pkcs_9_mr = _OID(pkcs_9, 27) # Object Identifiers for Syntaxes for use with LDAP-accessible directories pkcs_9_sx_pkcs9String = _OID(pkcs_9_sx, 1) pkcs_9_sx_signingTime = _OID(pkcs_9_sx, 2) # Object Identifiers for object classes pkcs_9_oc_pkcsEntity = _OID(pkcs_9_oc, 1) pkcs_9_oc_naturalPerson = _OID(pkcs_9_oc, 2) # Object Identifiers for matching rules pkcs_9_mr_caseIgnoreMatch = _OID(pkcs_9_mr, 1) pkcs_9_mr_signingTimeMatch = _OID(pkcs_9_mr, 2) # PKCS #7 PDU pkcs_9_at_pkcs7PDU = _OID(pkcs_9_at, 5) pKCS7PDU = Attribute() pKCS7PDU['type'] = pkcs_9_at_pkcs7PDU pKCS7PDU['values'][0] = ContentInfo() # PKCS #12 token pkcs_9_at_userPKCS12 = _OID(2, 16, 840, 1, 113730, 3, 1, 216) userPKCS12 = Attribute() userPKCS12['type'] = pkcs_9_at_userPKCS12 userPKCS12['values'][0] = PFX() # PKCS #15 token pkcs_9_at_pkcs15Token = _OID(pkcs_9_at, 1) # TODO: Once PKCS15Token can be imported, this can be included # # pKCS15Token = Attribute() # userPKCS12['type'] = pkcs_9_at_pkcs15Token # userPKCS12['values'][0] = PKCS15Token() # PKCS #8 encrypted private key information pkcs_9_at_encryptedPrivateKeyInfo = _OID(pkcs_9_at, 2) encryptedPrivateKeyInfo = Attribute() encryptedPrivateKeyInfo['type'] = pkcs_9_at_encryptedPrivateKeyInfo encryptedPrivateKeyInfo['values'][0] = EncryptedPrivateKeyInfo() # Electronic-mail address pkcs_9_at_emailAddress = rfc5280.id_emailAddress emailAddress = Attribute() emailAddress['type'] = pkcs_9_at_emailAddress emailAddress['values'][0] = EmailAddress() # Unstructured name pkcs_9_at_unstructuredName = _OID(pkcs_9, 2) unstructuredName = Attribute() unstructuredName['type'] = pkcs_9_at_unstructuredName unstructuredName['values'][0] = PKCS9String() # Unstructured address pkcs_9_at_unstructuredAddress = _OID(pkcs_9, 8) unstructuredAddress = Attribute() unstructuredAddress['type'] = pkcs_9_at_unstructuredAddress unstructuredAddress['values'][0] = DirectoryString() # Date of birth pkcs_9_at_dateOfBirth = _OID(ietf_at, 1) dateOfBirth = SingleAttribute() dateOfBirth['type'] = pkcs_9_at_dateOfBirth dateOfBirth['values'][0] = useful.GeneralizedTime() # Place of birth pkcs_9_at_placeOfBirth = _OID(ietf_at, 2) placeOfBirth = SingleAttribute() placeOfBirth['type'] = pkcs_9_at_placeOfBirth placeOfBirth['values'][0] = DirectoryString() # Gender class GenderString(char.PrintableString): pass GenderString.subtypeSpec = constraint.ValueSizeConstraint(1, 1) GenderString.subtypeSpec = constraint.SingleValueConstraint("M", "F", "m", "f") pkcs_9_at_gender = _OID(ietf_at, 3) gender = SingleAttribute() gender['type'] = pkcs_9_at_gender gender['values'][0] = GenderString() # Country of citizenship pkcs_9_at_countryOfCitizenship = _OID(ietf_at, 4) countryOfCitizenship = Attribute() countryOfCitizenship['type'] = pkcs_9_at_countryOfCitizenship countryOfCitizenship['values'][0] = X520countryName() # Country of residence pkcs_9_at_countryOfResidence = _OID(ietf_at, 5) countryOfResidence = Attribute() countryOfResidence['type'] = pkcs_9_at_countryOfResidence countryOfResidence['values'][0] = X520countryName() # Pseudonym id_at_pseudonym = _OID(2, 5, 4, 65) pseudonym = Attribute() pseudonym['type'] = id_at_pseudonym pseudonym['values'][0] = DirectoryString() # Serial number id_at_serialNumber = rfc5280.id_at_serialNumber serialNumber = Attribute() serialNumber['type'] = id_at_serialNumber serialNumber['values'][0] = X520SerialNumber() # Content type pkcs_9_at_contentType = rfc5652.id_contentType contentType = CMSSingleAttribute() contentType['attrType'] = pkcs_9_at_contentType contentType['attrValues'][0] = ContentType() # Message digest pkcs_9_at_messageDigest = rfc5652.id_messageDigest messageDigest = CMSSingleAttribute() messageDigest['attrType'] = pkcs_9_at_messageDigest messageDigest['attrValues'][0] = MessageDigest() # Signing time pkcs_9_at_signingTime = rfc5652.id_signingTime signingTime = CMSSingleAttribute() signingTime['attrType'] = pkcs_9_at_signingTime signingTime['attrValues'][0] = SigningTime() # Random nonce class RandomNonce(univ.OctetString): pass RandomNonce.subtypeSpec = constraint.ValueSizeConstraint(4, MAX) pkcs_9_at_randomNonce = _OID(pkcs_9_at, 3) randomNonce = CMSSingleAttribute() randomNonce['attrType'] = pkcs_9_at_randomNonce randomNonce['attrValues'][0] = RandomNonce() # Sequence number class SequenceNumber(univ.Integer): pass SequenceNumber.subtypeSpec = constraint.ValueRangeConstraint(1, MAX) pkcs_9_at_sequenceNumber = _OID(pkcs_9_at, 4) sequenceNumber = CMSSingleAttribute() sequenceNumber['attrType'] = pkcs_9_at_sequenceNumber sequenceNumber['attrValues'][0] = SequenceNumber() # Countersignature pkcs_9_at_counterSignature = rfc5652.id_countersignature counterSignature = CMSAttribute() counterSignature['attrType'] = pkcs_9_at_counterSignature counterSignature['attrValues'][0] = Countersignature() # Challenge password pkcs_9_at_challengePassword = _OID(pkcs_9, 7) challengePassword = SingleAttribute() challengePassword['type'] = pkcs_9_at_challengePassword challengePassword['values'][0] = DirectoryString() # Extension request class ExtensionRequest(Extensions): pass pkcs_9_at_extensionRequest = _OID(pkcs_9, 14) extensionRequest = SingleAttribute() extensionRequest['type'] = pkcs_9_at_extensionRequest extensionRequest['values'][0] = ExtensionRequest() # Extended-certificate attributes (deprecated) class AttributeSet(univ.SetOf): pass AttributeSet.componentType = Attribute() pkcs_9_at_extendedCertificateAttributes = _OID(pkcs_9, 9) extendedCertificateAttributes = SingleAttribute() extendedCertificateAttributes['type'] = pkcs_9_at_extendedCertificateAttributes extendedCertificateAttributes['values'][0] = AttributeSet() # Friendly name class FriendlyName(char.BMPString): pass FriendlyName.subtypeSpec = constraint.ValueSizeConstraint(1, pkcs_9_ub_friendlyName) pkcs_9_at_friendlyName = _OID(pkcs_9, 20) friendlyName = SingleAttribute() friendlyName['type'] = pkcs_9_at_friendlyName friendlyName['values'][0] = FriendlyName() # Local key identifier pkcs_9_at_localKeyId = _OID(pkcs_9, 21) localKeyId = SingleAttribute() localKeyId['type'] = pkcs_9_at_localKeyId localKeyId['values'][0] = univ.OctetString() # Signing description pkcs_9_at_signingDescription = _OID(pkcs_9, 13) signingDescription = CMSSingleAttribute() signingDescription['attrType'] = pkcs_9_at_signingDescription signingDescription['attrValues'][0] = DirectoryString() # S/MIME capabilities class SMIMECapability(AlgorithmIdentifier): pass class SMIMECapabilities(univ.SequenceOf): pass SMIMECapabilities.componentType = SMIMECapability() pkcs_9_at_smimeCapabilities = _OID(pkcs_9, 15) smimeCapabilities = CMSSingleAttribute() smimeCapabilities['attrType'] = pkcs_9_at_smimeCapabilities smimeCapabilities['attrValues'][0] = SMIMECapabilities() # Certificate Attribute Map _certificateAttributesMapUpdate = { # Attribute types for use with the "pkcsEntity" object class pkcs_9_at_pkcs7PDU: ContentInfo(), pkcs_9_at_userPKCS12: PFX(), # TODO: Once PKCS15Token can be imported, this can be included # pkcs_9_at_pkcs15Token: PKCS15Token(), pkcs_9_at_encryptedPrivateKeyInfo: EncryptedPrivateKeyInfo(), # Attribute types for use with the "naturalPerson" object class pkcs_9_at_emailAddress: EmailAddress(), pkcs_9_at_unstructuredName: PKCS9String(), pkcs_9_at_unstructuredAddress: DirectoryString(), pkcs_9_at_dateOfBirth: useful.GeneralizedTime(), pkcs_9_at_placeOfBirth: DirectoryString(), pkcs_9_at_gender: GenderString(), pkcs_9_at_countryOfCitizenship: X520countryName(), pkcs_9_at_countryOfResidence: X520countryName(), id_at_pseudonym: DirectoryString(), id_at_serialNumber: X520SerialNumber(), # Attribute types for use with PKCS #10 certificate requests pkcs_9_at_challengePassword: DirectoryString(), pkcs_9_at_extensionRequest: ExtensionRequest(), pkcs_9_at_extendedCertificateAttributes: AttributeSet(), } rfc5280.certificateAttributesMap.update(_certificateAttributesMapUpdate) # CMS Attribute Map # Note: pkcs_9_at_smimeCapabilities is not included in the map because # the definition in RFC 5751 is preferred, which produces the same # encoding, but it allows different parameters for SMIMECapability # and AlgorithmIdentifier. _cmsAttributesMapUpdate = { # Attribute types for use in PKCS #7 data (a.k.a. CMS) pkcs_9_at_contentType: ContentType(), pkcs_9_at_messageDigest: MessageDigest(), pkcs_9_at_signingTime: SigningTime(), pkcs_9_at_randomNonce: RandomNonce(), pkcs_9_at_sequenceNumber: SequenceNumber(), pkcs_9_at_counterSignature: Countersignature(), # Attributes for use in PKCS #12 "PFX" PDUs or PKCS #15 tokens pkcs_9_at_friendlyName: FriendlyName(), pkcs_9_at_localKeyId: univ.OctetString(), pkcs_9_at_signingDescription: DirectoryString(), # pkcs_9_at_smimeCapabilities: SMIMECapabilities(), } rfc5652.cmsAttributesMap.update(_cmsAttributesMapUpdate) rfc8017.py 0000644 00000010122 15030212136 0006175 0 ustar 00 # # This file is part of pyasn1-modules software. # # Created by Russ Housley. # # Copyright (c) 2019, Vigil Security, LLC # License: http://snmplabs.com/pyasn1/license.html # # PKCS #1: RSA Cryptography Specifications Version 2.2 # # ASN.1 source from: # https://www.rfc-editor.org/rfc/rfc8017.txt # from pyasn1.type import constraint from pyasn1.type import namedtype from pyasn1.type import namedval from pyasn1.type import univ from pyasn1_modules import rfc2437 from pyasn1_modules import rfc3447 from pyasn1_modules import rfc4055 from pyasn1_modules import rfc5280 MAX = float('inf') # Import Algorithm Identifier from RFC 5280 AlgorithmIdentifier = rfc5280.AlgorithmIdentifier class DigestAlgorithm(AlgorithmIdentifier): pass class HashAlgorithm(AlgorithmIdentifier): pass class MaskGenAlgorithm(AlgorithmIdentifier): pass class PSourceAlgorithm(AlgorithmIdentifier): pass # Object identifiers from NIST SHA2 hashAlgs = univ.ObjectIdentifier('2.16.840.1.101.3.4.2') id_sha256 = rfc4055.id_sha256 id_sha384 = rfc4055.id_sha384 id_sha512 = rfc4055.id_sha512 id_sha224 = rfc4055.id_sha224 id_sha512_224 = hashAlgs + (5, ) id_sha512_256 = hashAlgs + (6, ) # Basic object identifiers pkcs_1 = univ.ObjectIdentifier('1.2.840.113549.1.1') rsaEncryption = rfc2437.rsaEncryption id_RSAES_OAEP = rfc2437.id_RSAES_OAEP id_pSpecified = rfc2437.id_pSpecified id_RSASSA_PSS = rfc4055.id_RSASSA_PSS md2WithRSAEncryption = rfc2437.md2WithRSAEncryption md5WithRSAEncryption = rfc2437.md5WithRSAEncryption sha1WithRSAEncryption = rfc2437.sha1WithRSAEncryption sha224WithRSAEncryption = rfc4055.sha224WithRSAEncryption sha256WithRSAEncryption = rfc4055.sha256WithRSAEncryption sha384WithRSAEncryption = rfc4055.sha384WithRSAEncryption sha512WithRSAEncryption = rfc4055.sha512WithRSAEncryption sha512_224WithRSAEncryption = pkcs_1 + (15, ) sha512_256WithRSAEncryption = pkcs_1 + (16, ) id_sha1 = rfc2437.id_sha1 id_md2 = univ.ObjectIdentifier('1.2.840.113549.2.2') id_md5 = univ.ObjectIdentifier('1.2.840.113549.2.5') id_mgf1 = rfc2437.id_mgf1 # Default parameter values sha1 = rfc4055.sha1Identifier SHA1Parameters = univ.Null("") mgf1SHA1 = rfc4055.mgf1SHA1Identifier class EncodingParameters(univ.OctetString): subtypeSpec = constraint.ValueSizeConstraint(0, MAX) pSpecifiedEmpty = rfc4055.pSpecifiedEmptyIdentifier emptyString = EncodingParameters(value='') # Main structures class Version(univ.Integer): namedValues = namedval.NamedValues( ('two-prime', 0), ('multi', 1) ) class TrailerField(univ.Integer): namedValues = namedval.NamedValues( ('trailerFieldBC', 1) ) RSAPublicKey = rfc2437.RSAPublicKey OtherPrimeInfo = rfc3447.OtherPrimeInfo OtherPrimeInfos = rfc3447.OtherPrimeInfos RSAPrivateKey = rfc3447.RSAPrivateKey RSAES_OAEP_params = rfc4055.RSAES_OAEP_params rSAES_OAEP_Default_Identifier = rfc4055.rSAES_OAEP_Default_Identifier RSASSA_PSS_params = rfc4055.RSASSA_PSS_params rSASSA_PSS_Default_Identifier = rfc4055.rSASSA_PSS_Default_Identifier # Syntax for the EMSA-PKCS1-v1_5 hash identifier class DigestInfo(univ.Sequence): componentType = namedtype.NamedTypes( namedtype.NamedType('digestAlgorithm', DigestAlgorithm()), namedtype.NamedType('digest', univ.OctetString()) ) # Update the Algorithm Identifier map _algorithmIdentifierMapUpdate = { id_sha1: univ.Null(), id_sha224: univ.Null(), id_sha256: univ.Null(), id_sha384: univ.Null(), id_sha512: univ.Null(), id_sha512_224: univ.Null(), id_sha512_256: univ.Null(), id_mgf1: AlgorithmIdentifier(), id_pSpecified: univ.OctetString(), id_RSAES_OAEP: RSAES_OAEP_params(), id_RSASSA_PSS: RSASSA_PSS_params(), md2WithRSAEncryption: univ.Null(), md5WithRSAEncryption: univ.Null(), sha1WithRSAEncryption: univ.Null(), sha224WithRSAEncryption: univ.Null(), sha256WithRSAEncryption: univ.Null(), sha384WithRSAEncryption: univ.Null(), sha512WithRSAEncryption: univ.Null(), sha512_224WithRSAEncryption: univ.Null(), sha512_256WithRSAEncryption: univ.Null(), } rfc5280.algorithmIdentifierMap.update(_algorithmIdentifierMapUpdate) __pycache__/rfc6486.cpython-310.pyc 0000644 00000003121 15030212136 0012545 0 ustar 00 o �h| � @ s� d dl mZ d dl mZ d dl mZ d dl mZ d dl mZ d dl mZ d dlmZ e d�Z e�d �Zed Z e d ZG dd � d ej�ZG dd� dej�Zee� iZej�e� dS )� )�char)� constraint)� namedtype)�tag)�useful)�univ)�rfc5652�infz1.2.840.113549.1.9.16)� )� c @ s0 e Zd Ze�e�de�� �e�de� � ��Z dS )�FileAndHash�file�hashN)�__name__� __module__�__qualname__r � NamedTypes� NamedTyper � IA5Stringr � BitString� componentType� r r �I/usr/local/CyberCP/lib/python3.10/site-packages/pyasn1_modules/rfc6486.pyr "