codekingpro/portable-devtools
114k
1#2# This file is part of pyasn1-modules software.3#4# Created by Russ Housley with assistance from asn1ate v.0.6.0.5# Modified by Russ Housley to add a map for use with opentypes.6#7# Copyright (c) 2019, Vigil Security, LLC8# License: http://snmplabs.com/pyasn1/license.html9#10# Update to Enhanced Security Services for S/MIME11#12# ASN.1 source from:13# https://www.rfc-editor.org/rfc/rfc5035.txt14#15 16from pyasn1.codec.der.encoder import encode as der_encode17 18from pyasn1.type import namedtype19from pyasn1.type import univ20 21from pyasn1_modules import rfc263422from pyasn1_modules import rfc405523from pyasn1_modules import rfc565224from pyasn1_modules import rfc528025 26ContentType = rfc5652.ContentType27 28IssuerAndSerialNumber = rfc5652.IssuerAndSerialNumber29 30SubjectKeyIdentifier = rfc5652.SubjectKeyIdentifier31 32AlgorithmIdentifier = rfc5280.AlgorithmIdentifier33 34PolicyInformation = rfc5280.PolicyInformation35 36GeneralNames = rfc5280.GeneralNames37 38CertificateSerialNumber = rfc5280.CertificateSerialNumber39 40 41# Signing Certificate Attribute V1 and V242 43id_aa_signingCertificate = rfc2634.id_aa_signingCertificate44 45id_aa_signingCertificateV2 = univ.ObjectIdentifier('1.2.840.113549.1.9.16.2.47')46 47Hash = rfc2634.Hash48 49IssuerSerial = rfc2634.IssuerSerial50 51ESSCertID = rfc2634.ESSCertID52 53SigningCertificate = rfc2634.SigningCertificate54 55 56sha256AlgId = AlgorithmIdentifier()57sha256AlgId['algorithm'] = rfc4055.id_sha25658# A non-schema object for sha256AlgId['parameters'] as absent59sha256AlgId['parameters'] = der_encode(univ.OctetString(''))60 61 62class ESSCertIDv2(univ.Sequence):63 pass64 65ESSCertIDv2.componentType = namedtype.NamedTypes(66 namedtype.DefaultedNamedType('hashAlgorithm', sha256AlgId),67 namedtype.NamedType('certHash', Hash()),68 namedtype.OptionalNamedType('issuerSerial', IssuerSerial())69)70 71 72class SigningCertificateV2(univ.Sequence):73 pass74 75SigningCertificateV2.componentType = namedtype.NamedTypes(76 namedtype.NamedType('certs', univ.SequenceOf(77 componentType=ESSCertIDv2())),78 namedtype.OptionalNamedType('policies', univ.SequenceOf(79 componentType=PolicyInformation()))80)81 82 83# Mail List Expansion History Attribute84 85id_aa_mlExpandHistory = rfc2634.id_aa_mlExpandHistory86 87ub_ml_expansion_history = rfc2634.ub_ml_expansion_history88 89EntityIdentifier = rfc2634.EntityIdentifier90 91MLReceiptPolicy = rfc2634.MLReceiptPolicy92 93MLData = rfc2634.MLData94 95MLExpansionHistory = rfc2634.MLExpansionHistory96 97 98# ESS Security Label Attribute99 100id_aa_securityLabel = rfc2634.id_aa_securityLabel101 102ub_privacy_mark_length = rfc2634.ub_privacy_mark_length103 104ub_security_categories = rfc2634.ub_security_categories105 106ub_integer_options = rfc2634.ub_integer_options107 108ESSPrivacyMark = rfc2634.ESSPrivacyMark109 110SecurityClassification = rfc2634.SecurityClassification111 112SecurityPolicyIdentifier = rfc2634.SecurityPolicyIdentifier113 114SecurityCategory = rfc2634.SecurityCategory115 116SecurityCategories = rfc2634.SecurityCategories117 118ESSSecurityLabel = rfc2634.ESSSecurityLabel119 120 121# Equivalent Labels Attribute122 123id_aa_equivalentLabels = rfc2634.id_aa_equivalentLabels124 125EquivalentLabels = rfc2634.EquivalentLabels126 127 128# Content Identifier Attribute129 130id_aa_contentIdentifier = rfc2634.id_aa_contentIdentifier131 132ContentIdentifier = rfc2634.ContentIdentifier133 134 135# Content Reference Attribute136 137id_aa_contentReference = rfc2634.id_aa_contentReference138 139ContentReference = rfc2634.ContentReference140 141 142# Message Signature Digest Attribute143 144id_aa_msgSigDigest = rfc2634.id_aa_msgSigDigest145 146MsgSigDigest = rfc2634.MsgSigDigest147 148 149# Content Hints Attribute150 151id_aa_contentHint = rfc2634.id_aa_contentHint152 153ContentHints = rfc2634.ContentHints154 155 156# Receipt Request Attribute157 158AllOrFirstTier = rfc2634.AllOrFirstTier159 160ReceiptsFrom = rfc2634.ReceiptsFrom161 162id_aa_receiptRequest = rfc2634.id_aa_receiptRequest163 164ub_receiptsTo = rfc2634.ub_receiptsTo165 166ReceiptRequest = rfc2634.ReceiptRequest167 168 169# Receipt Content Type170 171ESSVersion = rfc2634.ESSVersion172 173id_ct_receipt = rfc2634.id_ct_receipt174 175Receipt = rfc2634.Receipt176 177ub_receiptsTo = rfc2634.ub_receiptsTo178 179ReceiptRequest = rfc2634.ReceiptRequest180 181 182# Map of Attribute Type to the Attribute structure is added to the183# ones that are in rfc5652.py184 185_cmsAttributesMapUpdate = {186 id_aa_signingCertificateV2: SigningCertificateV2(),187}188 189rfc5652.cmsAttributesMap.update(_cmsAttributesMapUpdate)190 191 192# Map of Content Type OIDs to Content Types is added to the193# ones that are in rfc5652.py194 195_cmsContentTypesMapUpdate = {196 id_ct_receipt: Receipt(),197}198 199rfc5652.cmsContentTypesMap.update(_cmsContentTypesMapUpdate)200 