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, LLC 8# License: http://snmplabs.com/pyasn1/license.html 9# 10# Update to Enhanced Security Services for S/MIME 11# 12# ASN.1 source from: 13# https://www.rfc-editor.org/rfc/rfc5035.txt 14# 15 16from pyasn1.codec.der.encoder import encode as der_encode 17 18from pyasn1.type import namedtype 19from pyasn1.type import univ 20 21from pyasn1_modules import rfc2634 22from pyasn1_modules import rfc4055 23from pyasn1_modules import rfc5652 24from pyasn1_modules import rfc5280 25 26ContentType = rfc5652.ContentType 27 28IssuerAndSerialNumber = rfc5652.IssuerAndSerialNumber 29 30SubjectKeyIdentifier = rfc5652.SubjectKeyIdentifier 31 32AlgorithmIdentifier = rfc5280.AlgorithmIdentifier 33 34PolicyInformation = rfc5280.PolicyInformation 35 36GeneralNames = rfc5280.GeneralNames 37 38CertificateSerialNumber = rfc5280.CertificateSerialNumber 39 40 41# Signing Certificate Attribute V1 and V2 42 43id_aa_signingCertificate = rfc2634.id_aa_signingCertificate 44 45id_aa_signingCertificateV2 = univ.ObjectIdentifier('1.2.840.113549.1.9.16.2.47') 46 47Hash = rfc2634.Hash 48 49IssuerSerial = rfc2634.IssuerSerial 50 51ESSCertID = rfc2634.ESSCertID 52 53SigningCertificate = rfc2634.SigningCertificate 54 55 56sha256AlgId = AlgorithmIdentifier() 57sha256AlgId['algorithm'] = rfc4055.id_sha256 58# A non-schema object for sha256AlgId['parameters'] as absent 59sha256AlgId['parameters'] = der_encode(univ.OctetString('')) 60 61 62class ESSCertIDv2(univ.Sequence): 63 pass 64 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 pass 74 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 Attribute 84 85id_aa_mlExpandHistory = rfc2634.id_aa_mlExpandHistory 86 87ub_ml_expansion_history = rfc2634.ub_ml_expansion_history 88 89EntityIdentifier = rfc2634.EntityIdentifier 90 91MLReceiptPolicy = rfc2634.MLReceiptPolicy 92 93MLData = rfc2634.MLData 94 95MLExpansionHistory = rfc2634.MLExpansionHistory 96 97 98# ESS Security Label Attribute 99 100id_aa_securityLabel = rfc2634.id_aa_securityLabel 101 102ub_privacy_mark_length = rfc2634.ub_privacy_mark_length 103 104ub_security_categories = rfc2634.ub_security_categories 105 106ub_integer_options = rfc2634.ub_integer_options 107 108ESSPrivacyMark = rfc2634.ESSPrivacyMark 109 110SecurityClassification = rfc2634.SecurityClassification 111 112SecurityPolicyIdentifier = rfc2634.SecurityPolicyIdentifier 113 114SecurityCategory = rfc2634.SecurityCategory 115 116SecurityCategories = rfc2634.SecurityCategories 117 118ESSSecurityLabel = rfc2634.ESSSecurityLabel 119 120 121# Equivalent Labels Attribute 122 123id_aa_equivalentLabels = rfc2634.id_aa_equivalentLabels 124 125EquivalentLabels = rfc2634.EquivalentLabels 126 127 128# Content Identifier Attribute 129 130id_aa_contentIdentifier = rfc2634.id_aa_contentIdentifier 131 132ContentIdentifier = rfc2634.ContentIdentifier 133 134 135# Content Reference Attribute 136 137id_aa_contentReference = rfc2634.id_aa_contentReference 138 139ContentReference = rfc2634.ContentReference 140 141 142# Message Signature Digest Attribute 143 144id_aa_msgSigDigest = rfc2634.id_aa_msgSigDigest 145 146MsgSigDigest = rfc2634.MsgSigDigest 147 148 149# Content Hints Attribute 150 151id_aa_contentHint = rfc2634.id_aa_contentHint 152 153ContentHints = rfc2634.ContentHints 154 155 156# Receipt Request Attribute 157 158AllOrFirstTier = rfc2634.AllOrFirstTier 159 160ReceiptsFrom = rfc2634.ReceiptsFrom 161 162id_aa_receiptRequest = rfc2634.id_aa_receiptRequest 163 164ub_receiptsTo = rfc2634.ub_receiptsTo 165 166ReceiptRequest = rfc2634.ReceiptRequest 167 168 169# Receipt Content Type 170 171ESSVersion = rfc2634.ESSVersion 172 173id_ct_receipt = rfc2634.id_ct_receipt 174 175Receipt = rfc2634.Receipt 176 177ub_receiptsTo = rfc2634.ub_receiptsTo 178 179ReceiptRequest = rfc2634.ReceiptRequest 180 181 182# Map of Attribute Type to the Attribute structure is added to the 183# ones that are in rfc5652.py 184 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 the 193# ones that are in rfc5652.py 194 195_cmsContentTypesMapUpdate = { 196 id_ct_receipt: Receipt(), 197} 198 199rfc5652.cmsContentTypesMap.update(_cmsContentTypesMapUpdate) 200