3 L]b@s6dZddlmZmZmZmZy ddlZWnek r@dZYnXddlm Z m Z m Z m Z m Z mZddlmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZddlm Z ddl!m"Z"dd l#m$Z$dd l%m&Z&m'Z'm(Z(m)Z)m*Z*m+Z+Gd d d eZ,Gd ddeZ-GdddeZ.GdddeZ/GdddeZ0GdddeZ1GdddeZ2GdddeZ3GdddeZ4GdddeZ5Gdd d eZ6Gd!d"d"eZ7Gd#d$d$eZ8Gd%d&d&eZ9Gd'd(d(eZ:Gd)d*d*eZ;Gd+d,d,eZGd1d2d2eZ?Gd3d4d4eZ@Gd5d6d6eZAGd7d8d8eZBGd9d:d:eZCGd;d<dd>eZEGd?d@d@eZFGdAdBdBeZGGdCdDdDeZHGdEdFdFeZIGdGdHdHeZJGdIdJdJeZKGdKdLdLeZLGdMdNdNeZMGdOdPdPeZNGdQdRdReZOGdSdTdTeZPGdUdVdVeZQGdWdXdXeZRGdYdZdZeZSGd[d\d\eZTGd]d^d^eZUGd_d`d`eZVGdadbdbeZWGdcddddeZXGdedfdfeZYGdgdhdheZZGdidjdjeZ[GdkdldleZ\GdmdndneZ]GdodpdpeZ^GdqdrdreZ_GdsdtdteZ`GdudvdveZaGdwdxdxeZbGdydzdzeZcGd{d|d|eZdGd}d~d~eZeGdddeZfGdddeZgGdddeZhGdddeZiGdddeZjGdddeZkGdddeZlGdddeZmGdddeZnGdddeZoGdddeZpGdddeZqGdddeZrGddde eZsGdddeZtGdddeZuGdddeZvGdddeZwGdddeZxGdddeZyGdddeZzGdddeZ{GdddeZ|GdddeZ}GdddeZ~GdddeZGdddeZGdddeZGdddeZGdddeZGdddeZGdddeZGdddeZGdd„deZGddĄdeZGddƄdeZGddȄdeZGddʄdeZeeoeeeeeeed˜ ea_eoeeeeeeed̜ec_e3e4e5enebe7d͜e8_dS)a ASN.1 type classes for cryptographic message syntax (CMS). Structures are also compatible with PKCS#7. Exports the following items: - AuthenticatedData() - AuthEnvelopedData() - CompressedData() - ContentInfo() - DigestedData() - EncryptedData() - EnvelopedData() - SignedAndEnvelopedData() - SignedData() Other type classes are defined that help compose the types listed above. Most CMS structures in the wild are formatted as ContentInfo encapsulating one of the other types. )unicode_literalsdivisionabsolute_importprint_functionN)_ForceNullParametersDigestAlgorithmEncryptionAlgorithm HmacAlgorithm KdfAlgorithmSignedDigestAlgorithm)Any BitStringChoice EnumeratedGeneralizedTimeIntegerObjectIdentifierOctetBitString OctetStringParsableOctetStringSequence SequenceOfSetOfUTCTime UTF8String)CertificateList) PublicKeyInfo) OCSPResponse) Attributes Certificate Extensions GeneralName GeneralNamesNamec@s"eZdZdefdefdefgZdS)ExtendedCertificateInfoversion certificate attributesN)__name__ __module__ __qualname__rr r_fieldsr-r-6/tmp/pip-install-wfra5znf/asn1crypto/asn1crypto/cms.pyr%?sr%c@s"eZdZdefdefdefgZdS)ExtendedCertificateZextended_certificate_infosignature_algorithm signatureN)r)r*r+r%r rr,r-r-r-r.r/Gsr/c@seZdZdddddddZdS) CMSVersionZv0v1v2Zv3Zv4Zv5)rrN)r)r*r+_mapr-r-r-r.r2Us r2c@seZdZdddddddZdS) CMSAttributeType content_typemessage_digest signing_timecounter_signaturesignature_time_stamp_tokencms_algorithm_protection)z1.2.840.113549.1.9.3z1.2.840.113549.1.9.4z1.2.840.113549.1.9.5z1.2.840.113549.1.9.6z1.2.840.113549.1.9.16.2.14z1.2.840.113549.1.9.52N)r)r*r+r9r-r-r-r.r:`s r:c@seZdZdefdefgZdS)TimeZutc_timeZgeneralized_timeN)r)r*r+rr _alternativesr-r-r-r.rAmsrAc @s$eZdZddddddddd d Zd S) ContentTypedata signed_dataenveloped_datasigned_and_enveloped_data digested_dataencrypted_dataauthenticated_datacompressed_dataauthenticated_enveloped_data) z1.2.840.113549.1.7.1z1.2.840.113549.1.7.2z1.2.840.113549.1.7.3z1.2.840.113549.1.7.4z1.2.840.113549.1.7.5z1.2.840.113549.1.7.6z1.2.840.113549.1.9.16.1.2z1.2.840.113549.1.9.16.1.9z1.2.840.113549.1.9.16.1.23N)r)r*r+r9r-r-r-r.rCtsrCc@s2eZdZdefdedddfdedddfgZdS) CMSAlgorithmProtectiondigest_algorithmr0rT)implicitoptional mac_algorithmr5N)r)r*r+rr r r,r-r-r-r.rMsrMc@seZdZeZdS)SetOfContentTypeN)r)r*r+rC _child_specr-r-r-r.rRsrRc@seZdZeZdS)SetOfOctetStringN)r)r*r+rrSr-r-r-r.rTsrTc@seZdZeZdS) SetOfTimeN)r)r*r+rArSr-r-r-r.rUsrUc@seZdZeZdS)SetOfAnyN)r)r*r+r rSr-r-r-r.rVsrVc@seZdZeZdS)SetOfCMSAlgorithmProtectionN)r)r*r+rMrSr-r-r-r.rWsrWc@s,eZdZdefdgZiZddZdeiZdS) CMSAttributetypevaluesNcCs|jj|djtS)NrY) _oid_specsgetnativerV)selfr-r-r. _values_specszCMSAttribute._values_spec)rZN)r)r*r+r:r,r[r__spec_callbacksr-r-r-r.rXs rXc@seZdZeZdS) CMSAttributesN)r)r*r+rXrSr-r-r-r.rasrac@s(eZdZdefdefdeddifgZdS) IssuerSerialissuerserialZ issuer_uidrPTN)r)r*r+r#rrr,r-r-r-r.rbsrbc@seZdZdddZdS)AttCertVersionr3r4)rrN)r)r*r+r9r-r-r-r.resrec@s(eZdZdeddifdeddifgZdS)AttCertSubjectbase_certificate_idexplicitrZ subject_namerN)r)r*r+rbr#rBr-r-r-r.rfs rfc@seZdZdefdefgZdS)AttCertValidityPeriodZnot_before_timeZnot_after_timeN)r)r*r+rr,r-r-r-r.risric @sXeZdZdeddifdefdefdefdefdefd e fd e d d ifd e d d ifg Z dS)AttributeCertificateInfoV1r&defaultr3subjectrcr1 serial_numberatt_cert_validity_periodr(issuer_unique_idrPT extensionsN) r)r*r+rerfr#r rrirrr!r,r-r-r-r.rjs  rjc@s"eZdZdefdefdefgZdS)AttributeCertificateV1ac_infor0r1N)r)r*r+rjr rr,r-r-r-r.rqsrqc@seZdZddddZdS)DigestedObjectTypeZ public_keyZpublic_key_certZother_objy_types)rrr5N)r)r*r+r9r-r-r-r.rssrsc@s.eZdZdefdeddifdefdefgZdS)ObjectDigestInfoZdigested_object_typeZother_object_type_idrPTrNZ object_digestN)r)r*r+rsrrrr,r-r-r-r.rts rtc@s:eZdZdedddfdedddfdedddfgZd S) HolderrgrT)rOrPZ entity_namerobject_digest_infor5N)r)r*r+rbr#rtr,r-r-r-r.rusruc@s8eZdZdeddifdedddfdedddfgZd S) V2FormZ issuer_namerPTrgr)rhrPrvrN)r)r*r+r#rbrtr,r-r-r-r.rws rwc@s"eZdZdefdeddifgZdS) AttCertIssuerZv1_formZv2_formrhrN)r)r*r+r#rwrBr-r-r-r.rxsrxc@s"eZdZdefdefdefgZdS) IetfAttrValueoctetsoidstringN)r)r*r+rrrrBr-r-r-r.ry sryc@seZdZeZdS)IetfAttrValuesN)r)r*r+ryrSr-r-r-r.r}sr}c@s$eZdZdedddfdefgZdS)IetfAttrSyntaxZpolicy_authorityrT)rOrPrZN)r)r*r+r#r}r,r-r-r-r.r~sr~c@seZdZeZdS)SetOfIetfAttrSyntaxN)r)r*r+r~rSr-r-r-r.r src@s(eZdZdefdefdeddifgZdS) SvceAuthInfoZserviceidentZ auth_inforPTN)r)r*r+r"rr,r-r-r-r.r$src@seZdZeZdS)SetOfSvceAuthInfoN)r)r*r+rrSr-r-r-r.r,src@s*eZdZdedddfdeddifgZdS) RoleSyntaxZrole_authorityrT)rOrPZ role_namerOrN)r)r*r+r#r"r,r-r-r-r.r0src@seZdZeZdS)SetOfRoleSyntaxN)r)r*r+rrSr-r-r-r.r7src@seZdZdddddddZdS) ClassListZunmarked unclassifiedZ restrictedZ confidentialZsecretZ top_secret)rrr5r6r7r8N)r)r*r+r9r-r-r-r.r;s rc@s(eZdZdeddifdeddifgZdS)SecurityCategoryrYrOrvaluerN)r)r*r+rr r,r-r-r-r.rFs rc@seZdZeZdS)SetOfSecurityCategoryN)r)r*r+rrSr-r-r-r.rMsrc@s8eZdZdeddifdedddfded d d fgZd S) Clearance policy_idrOrZ class_listrr)rOrkZsecurity_categoriesr5T)rOrPN)r)r*r+rrrr,r-r-r-r.rQs rc@seZdZeZdS)SetOfClearanceN)r)r*r+rrSr-r-r-r.rYsrc@s(eZdZdefdefdeddifgZdS)BigTimemajorZfractional_secondssignrPTN)r)r*r+rr,r-r-r-r.r]src@seZdZdefdefgZdS)LeapDataZ leap_timeactionN)r)r*r+rrr,r-r-r-r.resrc@seZdZeZdS) SetOfLeapDataN)r)r*r+rrSr-r-r-r.rlsrc@s4eZdZdefdefdefdefdeddifgZdS) TimingMetricsZntp_timeoffsetdelayZ expirationZ leap_eventrPTN)r)r*r+rrr,r-r-r-r.rps rc@seZdZeZdS)SetOfTimingMetricsN)r)r*r+rrSr-r-r-r.rzsrc@s8eZdZdedeifdedddfdedddfgZd S) TimingPolicyrspecZ max_offsetrT)rhrPZ max_delayrN)r)r*r+rrrr,r-r-r-r.r~s rc@seZdZeZdS)SetOfTimingPolicyN)r)r*r+rrSr-r-r-r.rsrc @s"eZdZddddddddd Zd S) AttCertAttributeTypeauthentication_infoaccess_identitycharging_identitygrouprole clearancetiming_metrics timing_policy)z1.3.6.1.5.5.7.10.1z1.3.6.1.5.5.7.10.2z1.3.6.1.5.5.7.10.3z1.3.6.1.5.5.7.10.4z2.5.4.72z2.5.4.55z1.3.6.1.4.1.601.10.4.1z1.3.6.1.4.1.601.10.4.2N)r)r*r+r9r-r-r-r.rsrc @s>eZdZdefdgZeeeeeee e dZ ddZ de iZ dS)AttCertAttributerYrZN)rrrrrrrrcCs|jj|djtS)NrY)r[r\r]rV)r^r-r-r.r_szAttCertAttribute._values_spec)rZN)r)r*r+rr,rrrrrrr[r_r`r-r-r-r.rsrc@seZdZeZdS)AttCertAttributesN)r)r*r+rrSr-r-r-r.rsrc @sReZdZdefdefdefdefdefdefde fde d d ifd e d d ifg Z d S) AttributeCertificateInfoV2r&Zholderrcr1rmrnr(rorPTrpN) r)r*r+rerurxr rrirrr!r,r-r-r-r.rs rc@s&eZdZdZdefdefdefgZdS)AttributeCertificateV2rrrr0r1N)r)r*r+Z_bad_tagrr rr,r-r-r-r.rsrc@seZdZdefdefgZdS)OtherCertificateFormatZother_cert_formatZ other_certN)r)r*r+rr r,r-r-r-r.rsrcsVeZdZdefdeddifdeddifdeddifd edd ifgZfd d Z Z S) CertificateChoicesr'Zextended_certificaterOrZ v1_attr_certrZ v2_attr_certr5otherr6csFtt|j||||jdkrBtjtj|djjdkrBd|_dS)aJ Ensures that the class and tag specified exist as an alternative. This custom version fixes parsing broken encodings there a V2 attribute # certificate is encoded as a V1 :param class_: The integer class_ from the encoded value header :param tag: The integer tag from the encoded value header :param contents: A byte string of the contents of the value - used when the object is explicitly tagged :raises: ValueError - when value is not a valid alternative r5rr4r6N) superrvalidateZ_choicereloadrdumpr])r^class_tagcontents) __class__r-r.rs zCertificateChoices.validate) r)r*r+r r/rqrrrBr __classcell__r-r-)rr.rs    rc@seZdZeZdS)CertificateSetN)r)r*r+rrSr-r-r-r.rsrc@s,eZdZdefdedddfgZdZiZdS) ContentInfor;contentrT)rhrPN)r;r)r)r*r+rCr r, _oid_pairr[r-r-r-r.rsrc@seZdZeZdS)SetOfContentInfoN)r)r*r+rrSr-r-r-r.rsrc@s,eZdZdefdedddfgZdZiZdS)EncapsulatedContentInfor;rrT)rhrPN)r;r)r)r*r+rCrr,rr[r-r-r-r.r src@seZdZdefdefgZdS)IssuerAndSerialNumberrcrmN)r)r*r+r$rr,r-r-r-r.rsrc@s"eZdZdefdeddifgZdS)SignerIdentifierissuer_and_serial_numbersubject_key_identifierrOrN)r)r*r+rrrBr-r-r-r.rsrc@seZdZeZdS)DigestAlgorithmsN)r)r*r+rrSr-r-r-r.r!src@seZdZeZdS)CertificateRevocationListsN)r)r*r+rrSr-r-r-r.r%src@s$eZdZdedddfdefgZdS) SCVPReqResrequestrT)rhrPresponseN)r)r*r+rr,r-r-r-r.r)src@seZdZdddZdS)OtherRevInfoFormatId ocsp_responsescvp)z1.3.6.1.5.5.7.16.2z1.3.6.1.5.5.7.16.4N)r)r*r+r9r-r-r-r.r0src@s*eZdZdefdefgZdZeedZ dS)OtherRevocationInfoFormatother_rev_info_formatother_rev_info)rrN)rr) r)r*r+rr r,rrrr[r-r-r-r.r7s  rc@s"eZdZdefdeddifgZdS)RevocationInfoChoicecrlrrOrN)r)r*r+rrrBr-r-r-r.rDsrc@seZdZeZdS)RevocationInfoChoicesN)r)r*r+rrSr-r-r-r.rKsrc @sJeZdZdefdefdefdedddfdefd efd ed ddfgZ d S) SignerInfor&ZsidrNZ signed_attrsrT)rOrPr0r1Zunsigned_attrsrN) r)r*r+r2rrrar rr,r-r-r-r.rOsrc@seZdZeZdS) SignerInfosN)r)r*r+rrSr-r-r-r.r[src @sPeZdZdefdefddedddfd ed ddfd efgZd d Z de iZ dS) SignedDatar&digest_algorithmsencap_content_infoN certificatesrT)rOrPcrlsr signer_infoscCs|djdkrtStS)Nr&r3)r]rr)r^r-r-r._encap_content_info_specisz#SignedData._encap_content_info_spec)rN) r)r*r+r2rrrrr,rr`r-r-r-r.r_s rc@s,eZdZdedddfdedddfgZdS)OriginatorInfocertsrT)rOrPrrN)r)r*r+rrr,r-r-r-r.r|src@s"eZdZdefdeddifgZdS)RecipientIdentifierrrrOrN)r)r*r+rrrBr-r-r-r.rsrc@s eZdZddddddddZd S) KeyEncryptionAlgorithmIdZrsaZ aes128_wrapZaes128_wrap_padZ aes192_wrapZaes192_wrap_padZ aes256_wrapZaes256_wrap_pad)z1.2.840.113549.1.1.1z2.16.840.1.101.3.4.1.5z2.16.840.1.101.3.4.1.8z2.16.840.1.101.3.4.1.25z2.16.840.1.101.3.4.1.28z2.16.840.1.101.3.4.1.45z2.16.840.1.101.3.4.1.48N)r)r*r+r9r-r-r-r.rsrc@s"eZdZdefdeddifgZdS)KeyEncryptionAlgorithm algorithm parametersrPTN)r)r*r+rr r,r-r-r-r.rsrc@s(eZdZdefdefdefdefgZdS)KeyTransRecipientInfor&ridkey_encryption_algorithm encrypted_keyN)r)r*r+r2rrrr,r-r-r-r.rsrc@s.eZdZdefdeddifdeddifgZdS)OriginatorIdentifierOrKeyrrrOrZoriginator_keyrN)r)r*r+rrrrBr-r-r-r.rs rc@seZdZdefdefgZdS)OtherKeyAttributeZ key_attr_idZkey_attrN)r)r*r+rr r,r-r-r-r.rsrc@s.eZdZdefdeddifdeddifgZdS)RecipientKeyIdentifierrdaterPTrN)r)r*r+rrrr,r-r-r-r.rs rc@s"eZdZdefdeddifgZdS)KeyAgreementRecipientIdentifierrZr_key_idrOrN)r)r*r+rrrBr-r-r-r.rsrc@seZdZdefdefgZdS)RecipientEncryptedKeyrrN)r)r*r+rrr,r-r-r-r.rsrc@seZdZeZdS)RecipientEncryptedKeysN)r)r*r+rrSr-r-r-r.rsrc@s<eZdZdefdeddifdedddfd efd efgZd S) KeyAgreeRecipientInfor&Z originatorrhrZukmrT)rhrPrZrecipient_encrypted_keysN) r)r*r+r2rrrrr,r-r-r-r.rs  rc@s.eZdZdefdeddifdeddifgZdS) KEKIdentifierZkey_identifierrrPTrN)r)r*r+rrrr,r-r-r-r.rs rc@s(eZdZdefdefdefdefgZdS)KEKRecipientInfor&ZkekidrrN)r)r*r+r2rrrr,r-r-r-r.rsrc@s0eZdZdefdedddfdefdefgZdS) PasswordRecipientInfor&Zkey_derivation_algorithmrT)rOrPrrN)r)r*r+r2r rrr,r-r-r-r.rsrc@seZdZdefdefgZdS)OtherRecipientInfoZori_typeZ ori_valueN)r)r*r+rr r,r-r-r-r.rsrc@sFeZdZdefdeddifdeddifdeddifd edd ifgZd S) RecipientInfoZktriZkarirOrZkekrir5Zpwrir6Zorir7N) r)r*r+rrrrrrBr-r-r-r.rs    rc@seZdZeZdS)RecipientInfosN)r)r*r+rrSr-r-r-r.rsrc@s*eZdZdefdefdedddfgZdS)EncryptedContentInfor;Zcontent_encryption_algorithmZencrypted_contentrT)rOrPN)r)r*r+rCr rr,r-r-r-r.rsrc @s>eZdZdefdedddfdefdefded ddfgZd S) EnvelopedDatar&originator_inforT)rOrPrecipient_infosencrypted_content_infounprotected_attrsrN) r)r*r+r2rrrrar,r-r-r-r.rs rc @sJeZdZdefdefdefdefdedddfd ed ddfd e fgZ d S) SignedAndEnvelopedDatar&rrrrrT)rOrPrrrN) r)r*r+r2rrrrrrr,r-r-r-r.rsrc@s4eZdZdefdefddefgZddZdeiZdS) DigestedDatar&rNrNdigestcCs|djdkrtStS)Nr&r3)r]rr)r^r-r-r.r.sz%DigestedData._encap_content_info_spec)rN) r)r*r+r2rrr,rr`r-r-r-r.r&s  rc@s*eZdZdefdefdedddfgZdS) EncryptedDatar&rrrT)rOrPN)r)r*r+r2rrar,r-r-r-r.rAsrc @sfeZdZdefdedddfdefdefded ddfd efd e d ddfd e fde dddfg Z dS)AuthenticatedDatar&rrT)rOrPrrQrNrr auth_attrsr5mac unauth_attrsr6N) r)r*r+r2rrr rrrarr,r-r-r-r.rIsrc @sReZdZdefdedddfdefdefded ddfd efd ed ddfgZ d S)AuthEnvelopedDatar&rrT)rOrPrZauth_encrypted_content_inforrrrr5N) r)r*r+r2rrrrarr,r-r-r-r.rYsrc@seZdZddiZdS)CompressionAlgorithmIdz1.2.840.113549.1.9.16.3.8zlibN)r)r*r+r9r-r-r-r.resrc@s"eZdZdefdeddifgZdS)CompressionAlgorithmrrrPTN)r)r*r+rr r,r-r-r-r.rksrc@s2eZdZdefdefdefgZdZeddZ dS)CompressedDatar&Zcompression_algorithmrNcCs6|jdkr0tdkrtdtj|ddj|_|jS)Nz The zlib module is not availablerr) _decompressedr SystemError decompressr])r^r-r-r. decompressed{s  zCompressedData.decompressed) r)r*r+r2rrr,rpropertyrr-r-r-r.rrs  r) rDrErFrGrHrIrJrKrL)rErFrGrHrIrJrKrL)r;r<r=r>r?r@)__doc__ __future__rrrrr ImportErrorZalgosrrr r r r corer rrrrrrrrrrrrrrrrkeysrZocsprx509rr r!r"r#r$r%r/r2r:rArCrMrRrTrUrVrWrXrarbrerfrirjrqrsrtrurwrxryr}r~rrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr[r-r-r-r.s   D           #