§
    ¥”jR!  ã                   ó`  — d Z ddlmZ ddlmZ ddlZddlmZ ddlmZ ddl	m
Z
 ddlmZ dd	lmZ dd
lmZ ddlmZ ddlmZmZ g d¢Z	 	 	 	 	 	 dde
dededee         dee         f
d„Z	 	 	 	 	 	 dde
dededee         dee         f
d„Z	 	 	 	 dde
dedej        dej        dee         f
d„ZdS ) z<
This module defines pyHanko's high-level API entry points.
é    )Údatetime)ÚOptionalN)Úcms)Úembed)ÚBasePdfFileWriter)ÚSigFieldSpec)ÚSigningError)ÚTimeStamperé   )ÚSigner)ÚPdfSignatureMetadataÚ	PdfSigner)Úasync_sign_pdfÚembed_payload_with_cmsÚsign_pdfFÚpdf_outÚsignature_metaÚsignerÚtimestamperÚnew_field_specc	                 ó‚   — |�|rt          d¦  «        ‚t          ||||¬¦  «        }	|	                     | ||||¬¦  «        S )a@  
    Thin convenience wrapper around
    :meth:`~pyhanko.sign.signers.pdf_signer.PdfSigner.sign_pdf`.

    :param pdf_out:
        An :class:`.IncrementalPdfFileWriter`.
    :param bytes_reserved:
        Bytes to reserve for the CMS object in the PDF file.
        If not specified, make an estimate based on a dummy signature.
    :param signature_meta:
        The specification of the signature to add.
    :param signer:
        :class:`~pyhanko.sign.signers.pdf_cms.Signer`
        object to use to produce the signature object.
    :param timestamper:
        :class:`.TimeStamper` object to use to produce any time stamp tokens
        that might be required.
    :param in_place:
        Sign the input in-place. If ``False``, write output to a
        :class:`.BytesIO` object.
    :param existing_fields_only:
        If ``True``, never create a new empty signature field to contain
        the signature.
        If ``False``, a new field may be created if no field matching
        :attr:`~pyhanko.sign.signers.pdf_signer.PdfSignatureMetadata.field_name`
        exists.
    :param new_field_spec:
        If a new field is to be created, this parameter allows the caller
        to specify the field's properties in the form of a
        :class:`.SigFieldSpec`. This parameter is only meaningful if
        ``existing_fields_only`` is ``False``.
    :param output:
        Write the output to the specified output stream.
        If ``None``, write to a new :class:`.BytesIO` object.
        Default is ``None``.
    :return:
        The output stream containing the signed output.
    NúSSpecifying a signature field spec is not meaningful when existing_fields_only=True.©r   r   ©Úexisting_fields_onlyÚbytes_reservedÚin_placeÚoutput)r	   r   r   ©
r   r   r   r   r   r   r   r   r   Ú
pdf_signers
             úm/var/www/finuniver-perm.ru/html/portfolio/venv/lib/python3.11/site-packages/pyhanko/sign/signers/functions.pyr   r      sx   € ðd Ð!Ð&:Ð!Ýð)ñ
ô 
ð 	
õ
 ØØØØ%ð	ñ ô €Jð ×ÒØØ1Ø%ØØð ñ ô ð ó    c	              ƒ   ó’   K  — |�|rt          d¦  «        ‚t          ||||¬¦  «        }	|	                     | ||||¬¦  «        ƒ d{V —†S )aF  
    Thin convenience wrapper around
    :meth:`~pyhanko.sign.signers.pdf_signer.PdfSigner.async_sign_pdf`.

    :param pdf_out:
        An :class:`.IncrementalPdfFileWriter`.
    :param bytes_reserved:
        Bytes to reserve for the CMS object in the PDF file.
        If not specified, make an estimate based on a dummy signature.
    :param signature_meta:
        The specification of the signature to add.
    :param signer:
        :class:`~pyhanko.sign.signers.pdf_cms.Signer`
        object to use to produce the signature object.
    :param timestamper:
        :class:`.TimeStamper` object to use to produce any time stamp tokens
        that might be required.
    :param in_place:
        Sign the input in-place. If ``False``, write output to a
        :class:`.BytesIO` object.
    :param existing_fields_only:
        If ``True``, never create a new empty signature field to contain
        the signature.
        If ``False``, a new field may be created if no field matching
        :attr:`~pyhanko.sign.signers.pdf_signer.PdfSignatureMetadata.field_name`
        exists.
    :param new_field_spec:
        If a new field is to be created, this parameter allows the caller
        to specify the field's properties in the form of a
        :class:`.SigFieldSpec`. This parameter is only meaningful if
        ``existing_fields_only`` is ``False``.
    :param output:
        Write the output to the specified output stream.
        If ``None``, write to a new :class:`.BytesIO` object.
        Default is ``None``.
    :return:
        The output stream containing the signed output.
    Nr   r   r   )r	   r   r   r   s
             r!   r   r   ]   sš   è è € ðd Ð!Ð&:Ð!Ýð)ñ
ô 
ð 	
õ
 ØØØØ%ð	ñ ô €Jð ×*Ò*ØØ1Ø%ØØð +ñ ô ð ð ð ð ð ð ð r"   ú.sigÚ
pdf_writerÚfile_spec_stringÚpayloadÚcms_objÚ	file_namec           
      óz  — t          j        t          j        ¦   «         ¬¦  «        }t          j                             | |                     ¦   «         ddt	          j        ||¬¦  «        ¬¦  «        }	| 	                    dd¦  «        d         |z   }
d	x}}|�6| 	                    dd¦  «        d         |z   }t	          j
        ||	¬
¦  «        g}t	          j        d|||t	          j
        |
|	¬
¦  «        g|dœ|pi ¤Ž}t	          j        | |¦  «         t	          j        d|
||	dœ|pi ¤Ž}t	          j        | |¦  «         d	S )a  
    Embed some data as an embedded file stream into a PDF, and associate it
    with a CMS object.

    The resulting CMS object will also be turned into an embedded file, and
    associated with the original payload through a related file relationship.

    This can be used to bundle (non-PDF) detached signatures with PDF
    attachments, for example.

    .. versionadded:: 0.7.0

    :param pdf_writer:
        The PDF writer to use.
    :param file_spec_string:
        See :attr:`~pyhanko.pdf_utils.embed.FileSpec.file_spec_string` in
        :class:`~pyhanko.pdf_utils.embed.FileSpec`.
    :param payload:
        Payload object.
    :param cms_obj:
        CMS object pertaining to the payload.
    :param extension:
        File extension to use for the CMS attachment.
    :param file_name:
        See :attr:`~pyhanko.pdf_utils.embed.FileSpec.file_name` in
        :class:`~pyhanko.pdf_utils.embed.FileSpec`.
    :param file_spec_kwargs:
        Extra arguments to pass to the
        :class:`~pyhanko.pdf_utils.embed.FileSpec` constructor
        for the main attachment specification.
    :param cms_file_spec_kwargs:
        Extra arguments to pass to the
        :class:`~pyhanko.pdf_utils.embed.FileSpec` constructor
        for the CMS attachment specification.
    )ÚtzFzapplication/pkcs7-mime)Úcreation_dateÚmodification_date)r%   ÚdataÚcompressÚ	mime_typeÚparamsú.r   r   N)Úembedded_data)r&   r)   r3   Úf_related_filesÚuf_related_files)r&   r)   r3   © )r   ÚnowÚtzlocalÚget_localzoner   ÚEmbeddedFileObjectÚfrom_file_dataÚdumpÚEmbeddedFileParamsÚrsplitÚRelatedFileSpecÚFileSpecÚ
embed_file)r%   r&   r'   r(   Ú	extensionr)   Úfile_spec_kwargsÚcms_file_spec_kwargsr7   Ú
cms_ef_objÚ
cms_data_fÚcms_data_ufr5   ÚspecÚcms_specs                  r!   r   r   ¤   s�  € õ^ Œ,�'Ô/Ñ1Ô1Ð
2Ñ
2Ô
2€CÝÔ)×8Ò8ØØ�\Š\‰^Œ^ØØ*ÝÔ'Ø°ð
ñ 
ô 
ð 9ñ ô €Jð "×(Ò(¨¨aÑ0Ô0°Ô3°iÑ?€Jð &*Ð)€KÐ"ØÐØ×&Ò& s¨AÑ.Ô.¨qÔ1°IÑ=ˆåÔ! +¸ZÐHÑHÔHð
Ðõ Œ>ð 	Ø)ØØåÔ! *¸JÐGÑGÔGð
ð *ð	ð 	ð Ð!˜rð	ð 	€Dõ 
Ô�Z Ñ&Ô&Ð&õ Œ~ð Ø#ØØ ðð ð  Ð% 2ð	ð €Hõ 
Ô�Z Ñ*Ô*Ð*Ð*Ð*r"   )NNFNFN)r$   NNN)Ú__doc__r   Útypingr   r8   Ú
asn1cryptor   Úpyhanko.pdf_utilsr   Úpyhanko.pdf_utils.writerr   Úpyhanko.sign.fieldsr   Úpyhanko.sign.generalr	   Úpyhanko.sign.timestampsr
   Úpdf_cmsr   r    r   r   Ú__all__r   r   Ústrr:   ÚContentInfor   r6   r"   r!   ú<module>rV      s3  ððð ð Ð Ð Ð Ð Ð Ø Ð Ð Ð Ð Ð à €€€Ø Ð Ð Ð Ð Ð Ø #Ð #Ð #Ð #Ð #Ð #Ø 6Ð 6Ð 6Ð 6Ð 6Ð 6Ø ,Ð ,Ð ,Ð ,Ð ,Ð ,Ø -Ð -Ð -Ð -Ð -Ð -Ø /Ð /Ð /Ð /Ð /Ð /à Ð Ð Ð Ð Ð Ø 7Ð 7Ð 7Ð 7Ð 7Ð 7Ð 7Ð 7à
BÐ
BÐ
B€ð *.Ø-1ØØØØðDð DØðDà(ðDð ðDð ˜+Ô&ð	Dð
 ˜\Ô*ðDð Dð Dð DðV *.Ø-1ØØØØðDð DØðDà(ðDð ðDð ˜+Ô&ð	Dð
 ˜\Ô*ðDð Dð Dð DðX Ø#ØØðY+ð Y+Ø!ðY+àðY+ð Ô%ðY+ð Œ_ð	Y+ð ˜Œ}ðY+ð Y+ð Y+ð Y+ð Y+ð Y+r"   