§
    ¥”j£  ã                   ó€  — d dl Z d dlmZ d dl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 dd	lmZmZ dd
lmZ g d¢Z G d„ d¦  «        Z G d„ de¦  «        Z G d„ de¦  «        Z G d„ de¦  «        Z G d„ de¦  «        Z G d„ de¦  «        Z G d„ de j        ¦  «        Z G d„ de j        ¦  «        ZdS )é    N)Údatetime)ÚIterableÚOptional)ÚalgosÚcmsÚcoreÚtspÚx509)Úpdf)Úhashes)Úget_pyca_cryptography_hashé   )Úas_signing_certificate_v2Úsimple_cms_attribute)ÚTimeStamper)ÚAdobeRevinfoProviderÚCMSAlgorithmProtectionProviderÚCMSAttributeProviderÚSignedAttributeProviderSpecÚSigningCertificateV2ProviderÚSigningTimeProviderÚTSTProviderÚUnsignedAttributeProviderSpecc                   óL   — e Zd ZU dZeed<   	 dd„Zddeej	                 fd„Z
dS )	r   zB
    Base class to provide asynchronous CMS attribute values.
    Úattribute_typeFc              ƒ   ó   K  — t           ‚)a  
        Build the attribute value asynchronously.

        :param dry_run:
            ``True`` if the signer is operating in dry-run (size estimation)
            mode.
        :return:
            An attribute value appropriate for the attribute type.
        ©ÚNotImplementedError©ÚselfÚdry_runs     úf/var/www/finuniver-perm.ru/html/portfolio/venv/lib/python3.11/site-packages/pyhanko/sign/attributes.pyÚbuild_attr_valuez%CMSAttributeProvider.build_attr_value'   s   è è € õ "Ð!ó    Úreturnc              ƒ   óp   K  — |                       |¬¦  «        ƒ d {V —†}|�t          | j        |¦  «        S d S )N)r!   )r#   r   r   )r    r!   Úvalues      r"   Úget_attributez"CMSAttributeProvider.get_attribute3   sL   è è € Ø×+Ò+°GÐ+Ñ<Ô<Ð<Ð<Ð<Ð<Ð<Ð<ˆØÐÝ'¨Ô(;¸UÑCÔCÐCà�4r$   N©F)Ú__name__Ú
__module__Ú__qualname__Ú__doc__ÚstrÚ__annotations__r#   r   r   ÚCMSAttributer(   © r$   r"   r   r      so   € € € € € € ðð ð ÐÐÑðð

"ð 
"ð 
"ð 
"ðð °H¸SÔ=MÔ4Nð ð ð ð ð ð r$   r   c                   óP   — e Zd ZU dZdZeed<   dej        fd„Z	d
de
j        fd„Zd	S )r   z•
    Provide a value for the signing-certificate-v2 attribute.

    :param signing_cert:
        Certificate containing the signer's public key.
    Úsigning_certificate_v2r   Úsigning_certc                 ó   — || _         d S ©N)r4   )r    r4   s     r"   Ú__init__z%SigningCertificateV2Provider.__init__E   s   € Ø(ˆÔÐÐr$   Fr%   c              ƒ   ó.   K  — t          | j        ¦  «        S r6   )r   r4   r   s     r"   r#   z-SigningCertificateV2Provider.build_attr_valueH   s   è è € Ý(¨Ô):Ñ;Ô;Ð;r$   Nr)   )r*   r+   r,   r-   r   r.   r/   r
   ÚCertificater7   r	   ÚSigningCertificateV2r#   r1   r$   r"   r   r   ;   ss   € € € € € € ðð ð 3€N�CÐ2Ð2Ñ2ð) TÔ%5ð )ð )ð )ð )ð<ð <°sÔ7Oð <ð <ð <ð <ð <ð <r$   r   c                   óF   — e Zd ZU dZdZeed<   defd„Zd
de	j
        fd„Zd	S )r   z¦
    Provide a value for the signing-time attribute (i.e. an otherwise
    unauthenticated timestamp).

    :param timestamp:
        Datetime object to include.
    Úsigning_timer   Ú	timestampc                 ó   — || _         d S r6   )r=   )r    r=   s     r"   r7   zSigningTimeProvider.__init__W   s   € Ø"ˆŒˆˆr$   Fr%   c              ƒ   ó`   K  — t          j        dt          j        | j        ¦  «        i¦  «        S )NÚutc_time)r   ÚTimer   ÚUTCTimer=   r   s     r"   r#   z$SigningTimeProvider.build_attr_valueZ   s'   è è € ÝŒx˜¥T¤\°$´.Ñ%AÔ%AÐBÑCÔCÐCr$   Nr)   )r*   r+   r,   r-   r   r.   r/   r   r7   r   rA   r#   r1   r$   r"   r   r   L   sw   € € € € € € ðð ð )€N�CÐ(Ð(Ñ(ð# (ð #ð #ð #ð #ðDð D°s´xð Dð Dð Dð Dð Dð Dr$   r   c                   ó^   — e Zd ZU dZdZeed<   dej        fd„Z		 d
de
ej                 fd„Zd	S )r   z£
    Yield Adobe-style revocation information for inclusion into a CMS
    object.

    :param value:
        A (pre-formatted) RevocationInfoArchival object.
    Úadobe_revocation_info_archivalr   r'   c                 ó   — || _         d S r6   ©r'   )r    r'   s     r"   r7   zAdobeRevinfoProvider.__init__o   s   € ØˆŒ
ˆ
ˆ
r$   Fr%   c              ƒ   ó   K  — | j         S r6   rF   r   s     r"   r#   z%AdobeRevinfoProvider.build_attr_valuer   s   è è € ð ŒzÐr$   Nr)   )r*   r+   r,   r-   r   r.   r/   Úasn1_pdfÚRevocationInfoArchivalr7   r   r#   r1   r$   r"   r   r   d   s~   € € € € € € ðð ð ;€N�CÐ:Ð:Ñ:ð˜hÔ=ð ð ð ð ð ðð à	�(Ô1Ô	2ðð ð ð ð ð r$   r   c                   óR   — e Zd ZU dZeed<   dedej        fd„Z	 d
de	j
        fd„Zd	S )r   Úcms_algorithm_protectionr   Údigest_algoÚsignature_algoc                 ó"   — || _         || _        d S r6   )rL   rM   )r    rL   rM   s      r"   r7   z'CMSAlgorithmProtectionProvider.__init__{   s   € ð 'ˆÔØ,ˆÔÐÐr$   Fr%   c              ƒ   óè   K  — d| j         i}| j         dk    r/| j        }|d         j        dk    rdt          j        d¦  «        dœ}t          j        t          j        |¦  «        | j        dœ¦  «        S )NÚ	algorithmÚshake256Úed448Úshake256_leni   )rP   Ú
parameters)Údigest_algorithmÚsignature_algorithm)	rL   rM   Únativer   ÚIntegerr   ÚCMSAlgorithmProtectionr   ÚDigestAlgorithm)r    r!   Údigest_algorithm_argsÚmechs       r"   r#   z/CMSAlgorithmProtectionProvider.build_attr_value�   s˜   è è € ð "-¨dÔ.>Ð ?ÐØÔ˜zÒ)Ð)àÔ&ˆDØ�KÔ Ô'¨7Ò2Ð2à!/Ý"&¤,¨sÑ"3Ô"3ð)ð )Ð%õ Ô)å$)Ô$9Ø)ñ%ô %ð (,Ô':ð	ð ñ
ô 
ð 	
r$   Nr)   )r*   r+   r,   r   r.   r/   r   ÚSignedDigestAlgorithmr7   r   rY   r#   r1   r$   r"   r   r   x   sv   € € € € € € Ø4€N�CÐ4Ð4Ñ4ð-Øð-Ø05Ô0Kð-ð -ð -ð -ð ð
ð 
à	Ô	#ð
ð 
ð 
ð 
ð 
ð 
r$   r   c            	       óD   — e Zd Z	 	 ddedededefd„Zddej        fd	„Z	d
S )r   Úsignature_time_stamp_tokenFrU   Ú
data_to_tsÚtimestamperÚ	attr_typec                 óL   — || _         || _        || _        || _        || _        d S r6   )r   rU   ra   ÚdataÚ	prehashed)r    rU   r`   ra   rb   re   s         r"   r7   zTSTProvider.__init__˜   s.   € ð (ˆÔØ 0ˆÔØ&ˆÔØˆŒ	Ø"ˆŒˆˆr$   r%   c              ƒ   óT  K  — | j         }| j        r| j        }nQt          |¦  «        }t	          j        |¦  «        }|                     | j        ¦  «         |                     ¦   «         }|r| j         	                    |¦  «        }n| j         
                    ||¦  «        }|ƒ d {V —†S r6   )rU   re   rd   r   r   ÚHashÚupdateÚfinalizera   Úasync_dummy_responseÚasync_timestamp)r    r!   rU   ÚdigestÚmd_specÚmdÚts_coros          r"   r#   zTSTProvider.build_attr_value¦   s­   è è € ØÔ0ÐØŒ>ð 	#Ø”YˆFˆFå0Ð1AÑBÔBˆGÝ”˜WÑ%Ô%ˆBØ�IŠI�d”iÑ Ô Ð Ø—[’[‘]”]ˆFØð 	QØÔ&×;Ò;Ð<LÑMÔMˆGˆGàÔ&×6Ò6°vÐ?OÑPÔPˆGØˆ}ˆ}ˆ}ˆ}ˆ}ˆ}Ðr$   N)r_   Fr)   )
r*   r+   r,   r.   Úbytesr   r7   r   ÚContentInfor#   r1   r$   r"   r   r   —   s}   € € € € € ð 6Øð#ð #àð#ð ð#ð !ð	#ð
 ð#ð #ð #ð #ðð °s´ð ð ð ð ð ð r$   r   c                   ó2   — e Zd ZdZdededee         fd„ZdS )r   z¥
    .. versionadded:: 0.14.0

    Interface for setting up signed attributes, independently of the
    :class:`~pyhanko.sign.signers.pdf_cms.Signer` hierarchy.
    Údata_digestrU   r%   c                 ó   — t           ‚)zÑ
        Lazily set up signed attribute providers.

        :param data_digest:
            The digest of the data to be signed.
        :param digest_algorithm:
            The digest algorithm used.
        r   )r    rs   rU   s      r"   Úsigned_attr_providersz1SignedAttributeProviderSpec.signed_attr_providers¾   s
   € õ "Ð!r$   N)	r*   r+   r,   r-   rp   r.   r   r   ru   r1   r$   r"   r   r   ¶   sP   € € € € € ðð ð"Ø ð"Ø47ð"à	Ð&Ô	'ð"ð "ð "ð "ð "ð "r$   r   c            	       ó@   — e Zd ZdZdedej        dedee	         fd„Z
dS )r   z§
    .. versionadded:: 0.14.0

    Interface for setting up unsigned attributes, independently of the
    :class:`~pyhanko.sign.signers.pdf_cms.Signer` hierarchy.
    Ú	signatureÚsigned_attrsrU   r%   c                 ó   — t           ‚)a>  
        Lazily set up unsigned attribute providers.

        :param signature:
            The signature computed over the signed attributes.
        :param signed_attrs:
            Signed attributes over which the signature was taken.
        :param digest_algorithm:
            The digest algorithm used.
        r   )r    rw   rx   rU   s       r"   Úunsigned_attr_providersz5UnsignedAttributeProviderSpec.unsigned_attr_providersÔ   s
   € õ  "Ð!r$   N)r*   r+   r,   r-   rp   r   ÚCMSAttributesr.   r   r   rz   r1   r$   r"   r   r   Ì   sa   € € € € € ðð ð"àð"ð Ô'ð"ð ð	"ð
 
Ð&Ô	'ð"ð "ð "ð "ð "ð "r$   r   ) Úabcr   Útypingr   r   Ú
asn1cryptor   r   r   r	   r
   r   rH   Úcryptography.hazmat.primitivesr   Úpyhanko_certvalidator.utilr   Úgeneralr   r   Ú
timestampsr   Ú__all__r   r   r   r   r   r   ÚABCr   r   r1   r$   r"   ú<module>r…      sN  ðØ 
€
€
€
Ø Ð Ð Ð Ð Ð Ø %Ð %Ð %Ð %Ð %Ð %Ð %Ð %à 2Ð 2Ð 2Ð 2Ð 2Ð 2Ð 2Ð 2Ð 2Ð 2Ð 2Ð 2Ð 2Ð 2Ø &Ð &Ð &Ð &Ð &Ð &Ø 1Ð 1Ð 1Ð 1Ð 1Ð 1Ø AÐ AÐ AÐ AÐ AÐ Aðð ð ð ð ð ð ð ð $Ð #Ð #Ð #Ð #Ð #ð	ð 	ð 	€ðð ð ð ð ñ ô ð ð><ð <ð <ð <ð <Ð#7ñ <ô <ð <ð"Dð Dð Dð Dð DÐ.ñ Dô Dð Dð0ð ð ð ð Ð/ñ ô ð ð(
ð 
ð 
ð 
ð 
Ð%9ñ 
ô 
ð 
ð>ð ð ð ð Ð&ñ ô ð ð>"ð "ð "ð "ð " #¤'ñ "ô "ð "ð,"ð "ð "ð "ð " C¤Gñ "ô "ð "ð "ð "r$   