� J�gp���dZddlZddlmZddlmZddlmZmZddlm Z ddl m Z Gd �d ��Z d �Zd �Zd Zed��ZdS)z� Module dedicated to document signature generation. The contents of this module are internal to fpdf2, and not part of the public API. They may change at any time without prior warning or any deprecation period, in non-backward-compatible ways. �N)�timezone)�patch�)�build_obj_dict�Name)�create_dictionary_string)� buffer_substc��eZdZdd�Zdd�ZdS)� SignatureNc���td��|_td��|_td��|_||_ ||_ ||_ ||_ t|_ dtzdz|_ dS)N�Sigz Adobe.PPKLitezadbe.pkcs7.detached�<�>) r�type�filter� sub_filter� contact_info�location�m�reason� _SIGNATURE_BYTERANGE_PLACEHOLDER� byte_range�_SIGNATURE_CONTENTS_PLACEHOLDER�contents)�selfrrrrs �Y/home/asafur/pinokio/api/open-webui.git/app/env/lib/python3.11/site-packages/fpdf/sign.py�__init__zSignature.__init__st����K�K�� ��?�+�+�� ��4�5�5���(���p� �� �?������� �$�:����=�=��C�� � � �c�x��t�fd�t���D��||���}t|��S)Nc�2��i|]}|t�|����S�)�getattr)�.0�keyrs �r� <dictcomp>z'Signature.serialize.<locals>.<dictcomp>$s%��� :� :� :��S�'�$��$�$� :� :� :r)�_security_handler�_obj_id)r�dir�pdf_dict)rr&r'�obj_dicts` r� serializezSignature.serialize"sJ���!� :� :� :� :��D� � � :� :� :�/�� � � �� ��!�!�!r)NNNN)NN)�__name__� __module__� __qualname__rr+r!rrr r s@������ D� D� D� D�"�"�"�"�"�"rr c ���t�d��}|�|��}|t|��z} d|dz | dzt|��| z dz f} t |t d| z��}t j|��} | �|d| d���| �|| dd���G�fd�d��} td | ��|j ��} | d||||d | � ��� ��}t|���d��}t|��t|��ksJ�|� ||d��S) z� Perform PDF signing based on the content of the buffer, performing substitutions on it. The signing operation does not alter the buffer size �latin1rrz[%010d %010d %010d %010d]N�c�*��eZdZe�fd���ZdS)�#sign_content.<locals>.mock_datetimec�B����tj��S)N)� astimezoner�utc)�tz� sign_times �r�nowz'sign_content.<locals>.mock_datetime.nowFs����'�'�� �5�5� 5rN)r,r-r.� staticmethodr9)r8s�r� mock_datetimer3Es8������� � 6� 6� 6� 6� �� 6� 6� 6rr;zendesive.signer.datetimeT)�dataur$�cert� othercerts�hashalgo�attrs� signed_value)r�encode�find�lenr r�hashlib�new�updater�sign�digest�_pkcs11_aligned�replace)�signer�bufferr$r=� extra_certsr?r8�sig_placeholder� start_index� end_index� content_range� content_hashr;rHrs ` r� sign_contentrT+s����6�<�<�X�F�F�O��+�+�o�.�.�K��c�/�2�2�2�I�� �a���Q���F� � �i�8O�RS�8S�T�M� ��(�#�m�3���F��;�x�(�(�L�����1��q�!1�1�2�3�3�3�����}�Q�/�1�1�2�3�3�3�6�6�6�6�6�6�6�6�6�6� <�5�+�]� ;� ;�F�K� H� H�D��t�� � ����!�(�(�*�*����H��x�(�(�/�/��9�9�H� �� � �3�x�=�=� 0� 0� 0� 0� �>�>�/�8�Q� 7� 7�7rc�p�d�d�|D����}|ddt|��z zzS)N�c3�K�|]}|d�V�� dS)�02xNr!)r#�is r� <genexpr>z"_pkcs11_aligned.<locals>.<genexpr>\s&����,�,�!�a�:�:�,�,�,�,�,�,r�0i@)�joinrD)�datas rrJrJ[s=�� �7�7�,�,�t�,�,�,� ,� ,�D� �#��#�d�)�)�+�,� ,�,rz-[0000000000 0000000000 0000000000 0000000000])r)�__doc__rE�datetimer� unittest.mockr�syntaxrrrr)�utilr r rTrJrrr!rr�<module>rcs���������������������(�(�(�(�(�(�(�(�8�8�8�8�8�8�������"�"�"�"�"�"�"�"�2-8�-8�-8�`-�-�-� $S� �"1�/�$�"7�"7���r
Memory