U
    <gw                     @   s   d dl Z d dlZd dlmZ d dlmZ d dlmZmZmZm	Z	m
Z
mZmZmZmZmZmZmZmZ d dlmZmZmZmZmZ d dlmZ d dlmZ d dlmZmZm Z  d d	l!m"Z"m#Z#m$Z$m%Z%m&Z&m'Z'm(Z(m)Z) d d
l*m+Z+ d dl,m-Z- d dl.m/Z/ d dl0m1Z1m2Z2 d dl3m4Z4m5Z5m6Z6m7Z7m8Z8m9Z9m:Z:m;Z;m<Z<m=Z= ddl>m?Z? ddl@mAZA ddlBmCZCmDZD ddlEmFZF ddlGmHZH ddlImJZJmKZKmLZLmMZMmNZNmOZOmPZP ddlQmRZRmSZSmTZTmUZU dddddddd d!d"d#d$d%gZVeWeXZYed&eNd'ZZej[eej\ej]df d(d)d%Z^e_d*d+d,Z`ejaej[d-d.d/Zbej[ejceejd eeje d0d1d$Zfd]ejgejaeheieeS ee ee_e_f d2d3dZjejke8d4d5d"Zld^ejkeei ee eem ee- ee/ eeS eHe	ehef d6	d7dZnd_ejaeeHee- ee/ d8d9d:d;Zoeddddd<ejkeeZ eei ee eem eeH eZd=d>dZpeddddd<ejkeei ee eem eeH eNd?d@dZpeNdddddfejkeei ee eem eeH eeS eZdAdBdZpejgee dCdDd!Zqd`ejge_eejk dFdGd Zrejgeei dCdHdZsejgee eidIdJdZtdaejkee eieeS dKdLdZueejv ejaeeee1 eee&e%e$f  f dMdNdOZweejv ejaee ej[dPdQd#Zxddddde?jydfeeieejzej{f ejkee ee ee eeH eeS eOdRdSdZ|edTdUdVZ}edUdWG dXdY dYe
e} Z~ee} e~e} dZd[d\ZdS )b    N)	dataclass)datetime)IOAny	AwaitableDictGenericIterableListOptionalTupleTypeTypeVarUnionoverload)algoscmscoretspx509)InvalidSignature)hashes)CancelableAsyncIteratorValidationContextfind_valid_path)DisallowedAlgorithmErrorExpiredErrorInvalidCertificateErrorPathBuildingErrorPathValidationErrorRevokedErrorStaleRevinfoErrorValidationError)TimeSlideFailure)ValidationPath)PKIXValidationParams)ACValidationResultasync_validate_ac)
CMSExtractionErrorCMSStructuralErrorMultivaluedAttributeErrorNonexistentAttributeErrorSignedDataCertscheck_ess_certidextract_certificate_infoextract_signer_infofind_unique_cms_attributeget_pyca_cryptography_hash   )misc)lift_iterable_async   )AdESFailureAdESIndeterminate   )errors)KeyUsageConstraints)CAdESSignerAttributeAssertionsCertifiedAttributesClaimedAttributesRevocationDetailsSignatureStatusStandardCMSSignatureStatusTimestampSignatureStatus)DEFAULT_ALGORITHM_USAGE_POLICYCMSAlgorithmUsagePolicyextract_message_digestvalidate_rawvalidate_sig_integrityasync_validate_cms_signaturecollect_timing_infovalidate_tst_signed_dataasync_validate_detached_cmscms_basic_validationcompute_signature_tst_digestextract_tst_dataextract_self_reported_tsextract_certs_for_validationcollect_signer_attr_statusvalidate_algorithm_protectionget_signing_cert_attr
StatusType)bound)signed_attrsreturnc                 C   s$   t | dd}|dkr t | dd}|S )a   
    Retrieve the ``signingCertificate`` or ``signingCertificateV2`` attribute
    (giving preference to the latter) from a signature's signed attributes.

    :param signed_attrs:
        Signed attributes.
    :return:
        The value of the attribute, if present, else ``None``.
    Tv2NF)_grab_signing_cert_attr)rU   attr r[   G/tmp/pip-unpacked-wheel-w101_d3s/pyhanko/sign/validation/generic_cms.pyrR   c   s    rW   c              
   C   s   |rdnd}|rt jnt j}zt| |}|| W S  tk
rL   Y d S  tk
r } ztj	}t
jd|d|W 5 d }~X Y nX d S )NZsigning_certificate_v2Zsigning_certificatez3Wrong cardinality for signing certificate attributeZades_subindication)r   SigningCertificateV2SigningCertificater0   loaddumpr+   r*   r7   NO_SIGNING_CERTIFICATE_FOUNDr9   SignatureValidationError)rU   rX   	attr_nameclsvalueeerrr[   r[   r\   rY   u   s    
rY   )certrU   c                 C   sN   t |}|d krd S |d d }t| |sJtj}tjd| jj d|dd S )Ncertsr   zWSigning certificate attribute does not match selected signer's certificate for subject"z".r]   )rR   r-   r7   rb   r9   rc   subjectZhuman_friendly)ri   rU   rZ   Zcertidrh   r[   r[   r\   _check_signing_certificate   s    
rl   )attrsclaimed_digest_algorithm_objclaimed_signature_algorithm_objclaimed_mac_algorithm_objc                 C   s   zt | d}W n2 tk
r&   d}Y n tk
r@   tdY nX |dk	r|d j}||jkrhtd|dk	r|d j}|dkrtdn||jkrtd|dk	r|d	 j}|dkrtd
n||jkrtddS )a  
    Internal API to validate the CMS algorithm protection attribute
    defined in :rfc:`6211`, if present.

    :param attrs:
        A CMS attribute list.
    :param claimed_digest_algorithm_obj:
        The claimed (i.e. unprotected) digest algorithm value.
    :param claimed_signature_algorithm_obj:
        The claimed (i.e. unprotected) signature algorithm value.
    :param claimed_mac_algorithm_obj:
        The claimed (i.e. unprotected) MAC algorithm value.
    :raises errors.CMSStructuralError:
        if multiple CMS protection attributes are present
    :raises errors.CMSAlgorithmProtectionError:
        if a mismatch is detected
    Zcms_algorithm_protectionNz4Multiple CMS algorithm protection attributes presentdigest_algorithmzCDigest algorithm does not match CMS algorithm protection attribute.signature_algorithmz<CMS algorithm protection attribute not valid for signed datazFSignature mechanism does not match CMS algorithm protection attribute.Zmac_algorithmzCCMS algorithm protection attribute not valid for authenticated dataz@MAC mechanism does not match CMS algorithm protection attribute.)r0   r+   r*   r)   nativer9   CMSAlgorithmProtectionError)rm   rn   ro   rp   Zcms_algid_protectionZauth_digest_algorithmZauth_sig_algorithmZauth_mac_algorithmr[   r[   r\   rQ      sN     





)signer_infori   expected_content_typeactual_digestalgorithm_usage_policy
time_indicrV   c              
   C   sf  | d }| d }|d j }|dk	r|j|||jd}	|	szd|d j  d}
|	jdk	rf|
d|	j d	7 }
tj|
|	jdkd
|j||d}|sd|d j  d}
|jdk	r|
d|j d	7 }
tj|
|jdkd
| d j }| d }|tj	krd}d}|}n| d 
 }| }d}zt|||dd W nl tk
r\ } ztj|jtjdW 5 d}~X Y n8 tjk
r } ztj|jtjdW 5 d}~X Y nX t|| zt|d}W n* ttfk
r   tjdtjdY nX |j }||krtjd| d| tjdt| }z t||||||||d d}W n tk
rF   d}Y nX |dk	rZ||kn|}||fS )ae  
    Validate the integrity of a signature for a particular signerInfo object
    inside a CMS signed data container.

    .. warning::
        This function does not do any trust checks, and is considered
        "dangerous" API because it is easy to misuse.

    :param signer_info:
        A :class:`cms.SignerInfo` object.
    :param cert:
        The signer's certificate.

        .. note::
            This function will not attempt to extract certificates from
            the signed data.
    :param expected_content_type:
        The expected value for the content type attribute (as a Python string,
        see :class:`cms.ContentType`).
    :param actual_digest:
        The actual digest to be matched to the message digest attribute.
    :param algorithm_usage_policy:
        Algorithm usage policy.
    :param time_indic:
        Time indication for the production of the signature.
    :return:
        A tuple of two booleans. The first indicates whether the provided
        digest matches the value in the signed attributes.
        The second indicates whether the signature of the digest is valid.
    rr   rq   	algorithmN)moment
public_keyzThe algorithm z, is not allowed by the current usage policy.z	 Reason: .)Z	permanent)r{   	signaturerU   TF)rn   ro   rp   r]   content_typezQContent type not found in signature, or multiple content-type attributes present.zContent type z did not match expected value )	prehashedalgorithm_policyry   )rs   Zsignature_algorithm_allowedr|   Zfailure_reasonr9   r   Znot_allowed_afterZdigest_algorithm_allowedr   VOIDZuntagra   rQ   r)   rc   failure_messager6   FORMAT_FAILURErt   r7   ZGENERICrl   r0   r+   r*   rD   rE   r   )ru   ri   rv   rw   rx   ry   rr   Zdigest_algorithm_objmd_algorithmZsig_algo_allowedmsgZdigest_algo_allowedr~   Zsigned_attrs_origZembedded_digestr   signed_datarU   rg   r   validintactr[   r[   r\   rF      s    '
  
 
 

	
 
 


)r   rV   c                 C   sV   zt | }|j}W n$ tk
r6   tjdtjdY nX t| }|d }t|| |S )a  
    Extract certificates from a CMS signed data object for validation purposes,
    identifying the signer's certificate in accordance with ETSI EN 319 102-1,
    5.2.3.4.

    :param signed_data:
        The CMS payload.
    :return:
        The extracted certificates.
    z,signer certificate not included in signaturer]   rU   )	r.   signer_certr(   r9   rc   r7   rb   r/   rl   )r   	cert_infori   ru   rU   r[   r[   r\   rO     s    

)	r   
raw_digestvalidation_contextstatus_kwargsvalidation_pathpkix_validation_paramsr   key_usage_settingsrV   c                   s4  t | }t| }	|	j}
|	j}d}|dk	r>|p6t|j}|j}|pFt }|dkrTt	}|d }|d j
}|d d j
}| d }|d j
}|dkrt|d }t|}t|}|| | }n|d tjk	rtjdtjd	zt||
||||d
\}}W n< tk
r6 } ztjd|j tjd	|W 5 d}~X Y nX d } } }}|rzj|j| |dk	rrt|g}n|j|
}t|
||||dI dH }|j }|j!}|j"p|j#}|j$}W n8 t%k
r } zt&j'd|d t(j)}W 5 d}~X Y nX |pi }|dkr
dn|j*|d< |j|||
||||||d	 |S )z
    Perform basic validation of CMS and PKCS#7 signatures in isolation
    (i.e. integrity and trust checks).

    Internal API.
    Nrr   rz   rq   encap_content_infor   contentzKCMS structural error: detached signatures should not have encapsulated datar]   )rv   rw   rx   ry   zCMS structural error: )r   pathsr   z&Processing error in validation processexc_infovalidation_time)	r   r   Zsigning_certr   Zpkcs7_signature_mechanismZtrust_problem_indicr   Zrevocation_detailserror_time_horizon)+r/   rO   r   other_certsrC   Zlift_policyr   Zbest_signature_timer   rB   rs   bytesr1   r   Hashupdatefinalizer   r   r9   rc   r6   r   rF   r)   r   certificate_registryregister_multipler4   Zpath_builderZasync_build_paths_lazyvalidate_cert_usageerror_subindicrevo_detailssuccess_result
error_pathr   
ValueErrorloggererrorr7   !CERTIFICATE_CHAIN_GENERAL_FAILUREr{   )r   r   r   r   r   r   r   r   ru   r   ri   r   ry   rr   Z	mechanismr   ecirv   rawZmd_specmdr   r   rg   ades_statuspathr   r   r   	op_resultr[   r[   r\   rK     s    









z,CertvalidatorOperationResult[ValidationPath])ri   r   r   r   r   rV   c                    s*   t d fdd}t| I dH S )zE
    Low-level certificate validation routine.
    Internal API.
    )rV   c                      s       t dI d H S )N)r   r   )validater   r[   ri   r   r   r   r   r[   r\   _check9  s    
z#validate_cert_usage.<locals>._checkN)r$   handle_certvalidator_errors)ri   r   r   r   r   r   r[   r   r\   r   -  s    
r   )r   r   r   r   )r   
status_clsr   r   r   r   rV   c                   s   d S Nr[   )r   r   r   r   r   r   r[   r[   r\   rG   F  s    	)r   r   r   r   r   rV   c                   s   d S r   r[   )r   r   r   r   r   r[   r[   r\   rG   R  s    )r   r   r   r   r   r   rV   c                    s.   | |}t| |||||dI dH }|f |S )a  
    Validate a CMS signature (i.e. a ``SignedData`` object).

    :param signed_data:
        The :class:`.asn1crypto.cms.SignedData` object to validate.
    :param status_cls:
        Status class to use for the validation result.
    :param raw_digest:
        Raw digest, computed from context.
    :param validation_context:
        Validation context to validate the signer's certificate.
    :param status_kwargs:
        Other keyword arguments to pass to the ``status_class`` when reporting
        validation results.
    :param key_usage_settings:
        A :class:`.KeyUsageConstraints` object specifying which key usages
        must or must not be present in the signer's certificate.
    :param algorithm_policy:
        The algorithm usage policy for the signature validation.

        .. warning::
            This is distinct from the algorithm usage policy used for
            certificate validation, but the latter will be used as a fallback
            if this parameter is not specified.

            It is nonetheless recommended to align both policies unless
            there is a clear reason to do otherwise.
    :return:
        A :class:`.SignatureStatus` object (or an instance of a proper subclass)
    )r   r   N)default_usage_constraintsrK   )r   r   r   r   r   r   r   Zeff_key_usage_settingsr[   r[   r\   rG   ]  s    '	)ru   rV   c              	   C   s:   z| d }t |d}|jW S  ttfk
r4   Y dS X dS )a  
    Extract self-reported timestamp (from the ``signingTime`` attribute)

    Internal API.

    :param signer_info:
        A ``SignerInfo`` value.
    :return:
        The value of the ``signingTime`` attribute as a ``datetime``, or
        ``None``.
    rU   Zsigning_timeN)r0   rs   r+   r*   )ru   sastr[   r[   r\   rN     s    
F)ru   signedrV   c              	   C   sX   z8|r| d }t |d}n| d }t |d}|d }|W S  ttfk
rR   Y dS X dS )a  
    Extract signed data associated with a timestamp token.

    Internal API.

    :param signer_info:
        A ``SignerInfo`` value.
    :param signed:
        If ``True``, look for a content timestamp (among the signed
        attributes), else look for a signature timestamp (among the unsigned
        attributes).
    :return:
        The ``SignedData`` value found, or ``None``.
    rU   Zcontent_time_stampZunsigned_attrsZsignature_time_stamp_tokenr   N)r0   r+   r*   )ru   r   r   ZtstZuatst_signed_datar[   r[   r\   rM     s    
c                 C   sf   t | }|dkrdS |d }|d jd }|d d j}| d j}t|}t|}|| | S )a.  
    Compute the digest of the signature according to the message imprint
    algorithm information in a signature timestamp token.

    Internal API.

    :param signer_info:
        A ``SignerInfo`` value.
    :return:
        The computed digest, or ``None`` if there is no signature timestamp.
    Nr   r   message_imprinthash_algorithmrz   r~   )rM   parsedrs   r1   r   r   r   r   )ru   Ztst_datar   miZtst_md_algorithmZsignature_bytesZtst_md_specr   r[   r[   r\   rL     s    


)ru   ts_validation_contextr   c                    s   i }t | }|dk	r||d< t| dd}|dk	rht| }|dk	sDtt|||I dH }tf |}||d< t| dd}	|	dk	rt|	||dI dH }
tf |
}||d< |S )	a  
    Collect and validate timing information in a ``SignerInfo`` value.
    This includes the ``signingTime`` attribute, content timestamp information
    and signature timestamp information.

    :param signer_info:
        A ``SignerInfo`` value.
    :param ts_validation_context:
        The timestamp validation context to validate against.
    :param raw_digest:
        The raw external message digest bytes (only relevant for the
        validation of the content timestamp token, if there is one)
    Nsigner_reported_dtF)r   Ztimestamp_validityT)expected_tst_imprintZcontent_timestamp_validity)rN   rM   rL   AssertionErrorrI   rA   )ru   r   r   r   r   r   Ztst_signature_digestZtst_validity_kwargsZtst_validityZcontent_tst_signed_dataZcontent_tst_validity_kwargsZcontent_tst_validityr[   r[   r\   rH     s6    

)r   r   r   r   c           
         s   d}| d d }t |tjr"|j}t |tjs>tjdtj	d|d j
}t }t| |d|i||dI dH }|d	 d
 j
}	||	krtd|	  d|  d d|d< |S )a  
    Validate the ``SignedData`` of a time stamp token.

    :param tst_signed_data:
        The ``SignedData`` value to validate; must encapsulate a ``TSTInfo``
        value.
    :param validation_context:
        The validation context to validate against.
    :param expected_tst_imprint:
        The expected message imprint value that should be contained in
        the encapsulated ``TSTInfo``.
    :param algorithm_policy:
        The algorithm usage policy for the signature validation.

        .. warning::
            This is distinct from the algorithm usage policy used for
            certificate validation, but the latter will be used as a fallback
            if this parameter is not specified.

            It is nonetheless recommended to align both policies unless
            there is a clear reason to do otherwise.
    :return:
        Keyword arguments for a :class:`.TimeStampSignatureStatus`.
    Nr   r   z'SignedData does not encapsulate TSTInfor]   Zgen_time	timestamp)r   r   r   r   r   Zhashed_messagezTimestamp token imprint is z, but expected r}   Fr   )
isinstancer   ZParsableOctetStringr   r   ZTSTInfor9   rc   r6   r   rs   rA   r   rK   r   warninghex)
r   r   r   r   Ztst_infoZtst_info_bytesr   Zku_settingsr   Ztst_imprintr[   r[   r\   rI     s2    
	)acsr   r   rV   c                    s|    fdd| D }g }g }t |D ]L}z||I d H  W q& tttfk
rp } z|| W 5 d }~X Y q&X q&||fS )Nc                    s   g | ]}t | d qS ))Zholder_cert)r'   ).0acr   r   r[   r\   
<listcomp>c  s   z+process_certified_attrs.<locals>.<listcomp>)asyncioZas_completedappendr   r   r   )r   r   r   jobsresultsr9   Zjobrg   r[   r   r\   process_certified_attrsY  s    
r   sd_attr_certificatesr   r   sd_signed_attrsc              
      s  zt |d}W nN tk
r&   d }Y n8 tk
r\ } ztjt|tjd|W 5 d }~X Y nX i }d }d }|d k	rN|d }	t	t
|	tjs|	nd}
|d }d}t
|tjsdd |D }t|t|k}|d k	rt|||}|I d H \}}|d k	rt|}nd }|pt
|d	 tj }|d k	r:|r:td
 t|
|||d|d< |d k	rt| ||I d H \}}|r~|| |r|| t||d< ||d< |S )NZsigner_attributes_v2r]   Zclaimed_attributesr[   Zcertified_attributes_v2Fc                 S   s   g | ]}|j d kr|jqS )Z	attr_cert)nameZchosen)r   rZ   r[   r[   r\   r     s   
z.collect_signer_attr_status.<locals>.<listcomp>Zsigned_assertionszCAdES signer attributes with externally certified assertions for which no validation method is available. This may affect signature semantics in unexpected ways.)Zclaimed_attrsZcertified_attrsac_validation_errsZunknown_attrs_presentZcades_signer_attrsZac_attrsr   )r0   r+   r*   r9   rc   strr6   r   r=   from_iterabler   r   ZVoidlenr   r<   Zfrom_resultsr   r   r;   extend)r   r   r   r   Zsigner_attrsrg   resultZcades_ac_resultsZcades_ac_errorsZclaimed_asn1ZclaimedZcertified_asn1Zunknown_cert_attrsZ	cades_acsZval_jobZ	certifiedZunknown_attrsZ
ac_resultsZ	ac_errorsr[   r[   r\   rP   u  s      

 

  

)
input_datar   signer_validation_contextr   ac_validation_contextr   r   rV   c	                    s  |dkr|}t |}	|	d d j}
tt|
}t| trF||  n@t| tj	tj
frl|t| d  nt|}tj|| ||d | }t|	||dI dH }t|}t||||||dI dH }t|}|dk	r|j|j |t|j|j||	d d	I dH  tf |S )
a  
    .. versionadded: 0.9.0

    .. versionchanged: 0.11.0
        Added ``ac_validation_context`` param.

    Validate a detached CMS signature.

    :param input_data:
        The input data to sign. This can be either a :class:`bytes` object,
        a file-like object or a :class:`cms.ContentInfo` /
        :class:`cms.EncapsulatedContentInfo` object.

        If a CMS content info object is passed in, the `content` field
        will be extracted.
    :param signed_data:
        The :class:`cms.SignedData` object containing the signature to verify.
    :param signer_validation_context:
        Validation context to use to verify the signer certificate's trust.
    :param ts_validation_context:
        Validation context to use to verify the TSA certificate's trust, if
        a timestamp token is present.
        By default, the same validation context as that of the signer is used.
    :param ac_validation_context:
        Validation context to use to validate attribute certificates.
        If not supplied, no AC validation will be performed.

        .. note::
            :rfc:`5755` requires attribute authority trust roots to be specified
            explicitly; hence why there's no default.
    :param algorithm_policy:
        The algorithm usage policy for the signature validation.

        .. warning::
            This is distinct from the algorithm usage policy used for
            certificate validation, but the latter will be used as a fallback
            if this parameter is not specified.

            It is nonetheless recommended to align both policies unless
            there is a clear reason to do otherwise.
    :param key_usage_settings:
        Key usage parameters for the signer.
    :param chunk_size:
        Chunk size to use when consuming input data.
    :param max_read:
        Maximal number of bytes to read from the input stream.
    :return:
        A description of the signature's status.
    Nrq   rz   r   )max_read)r   r   )r   r   r   r   r   rU   r   )r/   rs   r   r   r1   r   r   r   r   ContentInfoEncapsulatedContentInfo	bytearrayr3   Zchunked_digestr   rH   r@   r   rK   r.   r   r   r   rP   Zattribute_certsr   )r   r   r   r   r   r   r   
chunk_sizer   ru   rq   hZtemp_bufZdigest_bytesr   r   r[   r[   r\   rJ     sT    =


ResultTypeT)	covariant)frozenc                   @   s^   e Zd ZU dZee ed< dZee ed< dZ	ee
 ed< dZee ed< dZee ed< dS )CertvalidatorOperationResultzB
    Internal class to inspect error data from certvalidator.
    r   Nr   r   r   r   )__name__
__module____qualname____doc__r   r   __annotations__r   r>   r   r   r   r$   r   r7   r[   r[   r[   r\   r   H  s   
r   )cororV   c              
      s  d}d }}zt | I dH dW S  tk
rX } ztj|j|d tj}W 5 d}~X Y n\ tk
r } ztj|j|d tj}W 5 d}~X Y n$ t	k
r } z tj|j|d tj
}|j}W 5 d}~X Y n tk
r( } z:tj|j|d |j}|jdkr
tj}ntj}|j}W 5 d}~X Y n tk
r } zf|j}t|j |j}|jrbtj}n:|jrtj}td|j|jd}ntj}td|j|jd}W 5 d}~X Y n tk
r } ztjd|d tj}W 5 d}~X Y n tk
r< } z:|j}t|j |j}|js&|jr&tj}ntj}W 5 d}~X Y nx tk
rz } z |j}tj|j|d tj}W 5 d}~X Y n: t k
r } ztj|j|d tj}W 5 d}~X Y nX t d||||dS )	z
    Internal error handling function that maps certvalidator errors
    to AdES status indications.

    :param coro:
    :return:
    N)r   r   F)Z
ca_revokedrevocation_daterevocation_reasonTzFailed to build path)r   r   r   r   r   )!r   r   r   r   Zfailure_msgr7   ZCHAIN_CONSTRAINTS_FAILUREr#   ZNO_POEr!   Z	TRY_LATERZtime_cutoffr   Zoriginal_pathZbanned_sinceZCRYPTO_CONSTRAINTS_FAILUREZ!CRYPTO_CONSTRAINTS_FAILURE_NO_POEr    Zrevocation_dtZis_side_validationr   Z
is_ee_certZREVOKED_NO_POEr>   reasonZREVOKED_CA_NO_POEr   ZNO_CERTIFICATE_CHAIN_FOUNDr   Z
expired_dtZOUT_OF_BOUNDS_NO_POEr   r"   )r   Ztime_horizonr   r   rg   r   r[   r[   r\   r   U  s    
r   )NN)NNNNNN)N)F)N)r   loggingdataclassesr   r   typingr   r   r   r   r   r	   r
   r   r   r   r   r   r   Z
asn1cryptor   r   r   r   r   cryptography.exceptionsr   Zcryptography.hazmat.primitivesr   Zpyhanko_certvalidatorr   r   r   Zpyhanko_certvalidator.errorsr   r   r   r   r   r    r!   r"   Z pyhanko_certvalidator.ltv.errorsr#   Zpyhanko_certvalidator.pathr$   Z!pyhanko_certvalidator.policy_declr%   Zpyhanko_certvalidator.validater&   r'   Zpyhanko.sign.generalr(   r)   r*   r+   r,   r-   r.   r/   r0   r1   Z	pdf_utilsr3   Zpdf_utils.miscr4   Zades.reportr6   r7    r9   settingsr:   statusr;   r<   r=   r>   r?   r@   rA   utilsrB   rC   rD   rE   __all__	getLoggerr   r   rS   ZCMSAttributesr_   r^   rR   boolrY   Certificaterl   ZDigestAlgorithmZSignedDigestAlgorithmZHmacAlgorithmrQ   Z
SignerInfor   r   rF   Z
SignedDatarO   dictrK   r   rG   rN   rM   rL   rH   rI   ZAttributeCertificateV2r   rP   ZDEFAULT_CHUNK_SIZEr   r   rJ   r   r   r   r[   r[   r[   r\   <module>   s  <(
0$	
 K  
 *!      
  6  "9 ?hk