%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /lib/python3/dist-packages/gpg/__pycache__/
Upload File :
Create Path :
Current File : //lib/python3/dist-packages/gpg/__pycache__/core.cpython-312.pyc

�

�w�b�����ddlmZmZmZddlZddlZddlZddlZddlm	Z	ddl
mZmZddlm
Z
ddlm
Z
ddlmZ[[[	Gd	�d
e�ZGd�de�ZGd
�de�Zd�Zd�Zd�Zd�Zd�Zdd�Ze�d�Zd�Zdd�Zd�Zd�Zy)�)�absolute_import�print_function�unicode_literalsN�)�gpgme)�
errorcheck�
GPGMEError)�	constants)�errors)�utilc���eZdZdZd�Z�fd�Zd�Zd�Zd�Ze	d��Z
e	d��Zd	�Z	e
�Zdd
�Zej"d�Zd�Z�fd
�Z�xZS)�GpgmeWrapperz>Base wrapper class

    Not to be instantiated directly.

    c� �d|_||_y�N)�_callback_excinfo�wrapped)�selfrs  �*/usr/lib/python3/dist-packages/gpg/core.py�__init__zGpgmeWrapper.__init__3s��!%������c�\��djtt|��|j�S)Nz	<{}/{!r}>)�format�superr�__repr__r)r�	__class__s �rrzGpgmeWrapper.__repr__7s+����!�!��,��.�0�$�,�,�@�	@rc�P�djt|jj�g}|jD�cgc]}t	||�s�|��}}|r/|jdjdj
|���djdj
|��Scc}w)Nz{}.{}z({})� z<{}>)r�__name__r�_boolean_properties�getattr�append�join)r�acc�f�flagss    r�__str__zGpgmeWrapper.__str__;s~���~�~�h����(?�(?�@�A�� �4�4�I�q���a�8H��I��I���J�J�v�}�}�S�X�X�e�_�5�6��}�}�S�X�X�c�]�+�+��	Js�B#�B#c�>�tt|j��Sr)�hash�reprr�rs r�__hash__zGpgmeWrapper.__hash__Cs���D����&�'�'rc�^�|�yt|j�t|j�k(S�NF)r)r)r�others  r�__eq__zGpgmeWrapper.__eq__Fs'���=������%��e�m�m�)<�<�<rc��t��)z]The name of the c type wrapped by this class

        Must be set by child classes.

        ��NotImplementedErrorr*s r�_ctypezGpgmeWrapper._ctypeL�
��"�#�#rc��t��)zgThe common prefix of c functions wrapped by this class

        Must be set by child classes.

        r1r*s r�_cprefixzGpgmeWrapper._cprefixUr4rc��t��)z�Must be implemented by child classes.

        This function must return a trueish value for all c functions
        returning gpgme_error_t.r1�r�names  r�_errorcheckzGpgmeWrapper._errorcheck^s
��
"�#�#rc�d���ttdj|j|���ttdj|j|����fd�}�fd�}t	||dj|���}t|j||�|r||t|��y||�S)Nz{}get_{}z{}set_{}c�T��|jsyt�|j��Sr-�r�bool)�slf�get_funcs �r�getz1GpgmeWrapper.__wrap_boolean_property.<locals>.getls!����;�;�������-�.�.rc�X��|jsy�|jt|��yrr=)r?�value�set_funcs  �r�set_z2GpgmeWrapper.__wrap_boolean_property.<locals>.set_qs����;�;���S�[�[�$�u�+�.rz{} flag)�doc)r rrr6�property�setattrrr>)	r�key�do_setrCrArE�pr@rDs	       @@r�__wrap_boolean_propertyz$GpgmeWrapper.__wrap_boolean_propertyhs�����5�*�"3�"3�D�M�M�3�"G�H���5�*�"3�"3�D�M�M�3�"G�H��	/�
	/�

�S�$�I�$4�$4�S�$9�:�������Q�'����t�E�{�#��t�9�rz$gpgme_([^(]*)\(([^,]*), (.*\) -> .*)c������|ddk(s�j�y|�jvr�j|�S�j|z�tt����j��r��fd��n�fd��t�d�}|r�jjd|�}nd}|�_t�j|����fd�}||_|S)	z7On-the-fly generation of wrapper methods and propertiesr�_Nc���|jsy�|jg|���}|jrtj|�t	|��Sr)rrr�gpg_raise_callback_exceptionr)r?�args�result�funcr9s   ��r�	_funcwrapz+GpgmeWrapper.__getattr__.<locals>._funcwrap�sD����{�{���c�k�k�1�D�1���(�(��6�6�s�;�!�&�$�/�/rc���|jsy�|jg|���}|jrtj|�|Sr)rrrrP)r?rQrRrSs   �rrTz+GpgmeWrapper.__getattr__.<locals>._funcwrap�s<����{�{���c�k�k�1�D�1���(�(��6�6�s�;��
r�__doc__z\2.\1(\3c�����g|���Sr�)rQrTrs ��r�wrapperz)GpgmeWrapper.__getattr__.<locals>.wrapper�s����T�)�D�)�)r)r6r�$_GpgmeWrapper__wrap_boolean_propertyr rr:�_munge_docstring�subrVrHr)rrI�doc_origrFrYrTrSr9s`    @@@r�__getattr__zGpgmeWrapper.__getattr__�s�����q�6�S�=�D�M�M�1���$�*�*�*��/�/��4�4��}�}�s�"���u�d�#�����D�!�
0�
��4��+����'�'�+�+�K��B�C��C��	��	�����Y�/�	*�����rc�r��||jvr|j|d|�ytt|�||�y)z#On-the-fly generation of propertiesTN)rrZrr�__setattr__)rrIrCrs   �rr`zGpgmeWrapper.__setattr__�s4����$�*�*�*��(�(��d�E�:��,��1�#�u�=r)FN)r�
__module__�__qualname__rVrrr&r+r/rGr3r6r:�setrrZ�re�compiler[r^r`�
__classcell__�rs@rrr,s������@�,�(�=��$��$��$��$�$�,��%���,"�r�z�z�"I�J��/�b>�>rrc	����eZdZdZdddgej
ejddf�fd�	Zd�Zd�Z	gddddddddf	d�Z
d8d	�Zdejfd
�Z
ddgfd�Zd�Zd9d
�Zd9d�Zd9d�Zddej&j(j*dfd�Z									d:d�Z							d;d�Zd�Zd�Zd<d�Zd�Z			d=d�Zd>d�Zed��Zej@d��Zed��Z!e!j@d��Z!ed��Z"e"j@d��Z"ed��Z#e#j@d ��Z#d!Z$d"Z%d#�Z&hd$�Z'd%�Z(d&�Z)d'�Z*d(�Z+d)�Z,d?d*�Z-d+�Z.d,�Z/d9d-�Z0d.�Z1d9d/�Z2d0�Z3d9d1�Z4d2�Z5ed3��Z6d4�Z7d@d5�Z8d6�Z9d7�Z:�xZ;S)A�ContextaContext for cryptographic operations

    All cryptographic operations in GPGME are performed within a
    context, which contains the internal state of the operation as
    well as configuration parameters.  By using several contexts you
    can run several cryptographic operations in parallel, with
    different configuration.

    Access to a context must be synchronized.

    FNc	�h��|rd|_nctj�}	ttj|	��tj
|	�}tj|	�d|_tt|�'|�||_
||_||_||_
||_||_||_y)aConstruct a context object

        Keyword arguments:
        armor		-- enable ASCII armoring (default False)
        textmode	-- enable canonical text mode (default False)
        offline		-- do not contact external key sources (default False)
        signers		-- list of keys used for signing (default [])
        pinentry_mode	-- pinentry mode (default PINENTRY_MODE_DEFAULT)
        protocol	-- protocol to use (default PROTOCOL_OpenPGP)
        home_dir        -- state directory (default is the engine default)

        FTN)�ownr�new_gpgme_ctx_t_pr�	gpgme_new�gpgme_ctx_t_p_value�delete_gpgme_ctx_t_prrir�armor�textmode�offline�signers�
pinentry_mode�protocol�home_dir)rrprqrrrsrtrurrv�tmprs          �rrzContext.__init__�s����*��D�H��)�)�+�C��u���s�+�,��/�/��4�G��&�&�s�+��D�H�
�g�t�%�g�.���
� ��
�������*��� ��
� ��
rc�l�|s|�y|jdtj�|j�S)zxRead helper

        Helper function to retrieve the results of an operation, or
        None if SINK is given.
        Nr)�seek�os�SEEK_SET�read)r�sink�datas   r�__read__zContext.__read__�s,���4�<���	�	�!�R�[�[�!��y�y�{�rc�$�dj|�S)Nz�Context(armor={0.armor}, textmode={0.textmode}, offline={0.offline}, signers={0.signers}, pinentry_mode={0.pinentry_mode}, protocol={0.protocol}, home_dir={0.home_dir}))rr*s rrzContext.__repr__�s����V�D�\�		"rTc�b��|r|n	t�}d}||tjzz}||tjzz}||tjzz}||	tj
zz}||
tjzz}��E|j}
t|dd�}tj|_d�fd�	}|j|�	|r|j||||�n|j||||���
|_t7j8|�	|j�}|j(rJ�|r|j!�nd}|r|j0rJ�|j#||�||fS#tj$�r	}|j�}|r|j!�nd}|j#||�||f}|j%�tj&k(r8|j(r,tj*|j(|j,|���|j%�tj.k(rH|j!�}|j0r,tj2|j0|j,|���||_|�d}~wwxYw#��
|_t7j8|�wwxYw)a%Encrypt data

        Encrypt the given plaintext for the given recipients.  If the
        list of recipients is empty, the data is encrypted
        symmetrically with a passphrase.

        The passphrase can be given as parameter, using a callback
        registered at the context, or out-of-band via pinentry.

        Keyword arguments:
        recipients	-- list of keys to encrypt to
        sign		-- sign plaintext (default True)
        sink		-- write result to sink instead of returning it
        passphrase	-- for symmetric encryption
        always_trust	-- always trust the keys (default False)
        add_encrypt_to	-- encrypt to configured additional keys (default False)
        prepare		-- (ui) prepare for encryption (default False)
        expect_sign	-- (ui) prepare for signing (default False)
        compress	-- compress plaintext (default True)

        Returns:
        ciphertext	-- the encrypted data (or None if sink is given)
        result		-- additional information about the encryption
        sign_result	-- additional information about the signature(s)

        Raises:
        InvalidRecipients -- if encryption using a particular key failed
        InvalidSigners	-- if signing using a particular key failed
        GPGMEError	-- as signaled by the underlying library

        rN�_passphrase_cbc����SrrX��hint�desc�prev_bad�hook�
passphrases    �r�
passphrase_cbz&Context.encrypt.<locals>.passphrase_cb5�	���!�!r��error�resultsr)�Datar
�ENCRYPT_ALWAYS_TRUST�ENCRYPT_NO_ENCRYPT_TO�ENCRYPT_PREPARE�ENCRYPT_EXPECT_SIGN�ENCRYPT_NO_COMPRESSrtr �PINENTRY_MODE_LOOPBACK�set_passphrase_cb�op_encrypt_sign�
op_encryptrr	�op_encrypt_result�op_sign_resultr�getcode�UNUSABLE_PUBKEY�invalid_recipients�InvalidRecipientsr��UNUSABLE_SECKEY�invalid_signers�InvalidSignersr�r�gpg_set_passphrase_cb)r�	plaintext�
recipients�signr}r��always_trust�add_encrypt_to�prepare�expect_sign�compress�
ciphertextr%�old_pinentry_mode�old_passphrase_cbr��erR�
sig_resultr�s     `              r�encryptzContext.encrypt�s����T"�T�t�v�
���
��	� >� >�>�>��
�n�$�	�(G�(G�G�G��
��9�4�4�4�4��
��y�<�<�<�<��
�h�,�)�"?�"?�?�?���!� $� 2� 2�� '��.>�� E��!*�!A�!A�D��
"�
�"�"�=�1�	E���$�$�Z��	�:�N����
�E�9�j�I�.�%�%6��"��+�+�D�2C�D��'�'�)���,�,�,�,�.2�T�(�(�*��
��Z�%?�%?�?�?��}�}�T�:�.��
�B�B��?� � �	��+�+�-�F�26��,�,�.�D�J��}�}�T�:�6��
�K�G��y�y�{�f�4�4�4��,�,� �2�2��1�1��g�g� '�)�)��y�y�{�f�4�4�4�!�0�0�2�
��-�-� �/�/�"�2�2��g�g� '�)�)� �A�I��G��)	��,�%�%6��"��+�+�D�2C�D�&�s%�
+E,�,J	�DJ�J	�	J�"J.c�.��d}d}|r|n	t�}��E|j}	t|dd�}
tj|_d�fd�	}|j|�	t
|t�r|}n$|�tjdt��d}n|}d}|r|j||�n|j||���	|_t'j(|
�	|j�}
|r|j!�}nd}|j#||�|
|f}|
j*r!tj,|
j*|���|r�|r%t/t1d	�|j2��|_|��g}|D]�}d}|j4D]`}|j2D]K}|j6tj8zd
k(r�$|j:r|j<|j<k(rd}n|s�`n|r�w|j?|���|rtj@|||���|S#tj$rF}|j�}
|r|j!�}nd}|j#||�|
|f|_|�d}~wwxYw#��	|_t'j(|
�wwxYw)a=Decrypt data

        Decrypt the given ciphertext and verify any signatures.  If
        VERIFY is an iterable of keys, the ciphertext must be signed
        by all those keys, otherwise a MissingSignatures error is
        raised.  Note: if VERIFY is an empty iterable, that is treated
        the same as passing verify=True (that is, verify signatures
        and return data about any valid signatures found, but no
        signatures are required and no MissingSignatures error will be
        raised).

        The filter_signatures argument can be used to force this
        function to return signatures that are not fully trusted - for
        example because they were made by unknown keys.

        If the ciphertext is symmetrically encrypted using a
        passphrase, that passphrase can be given as parameter, using a
        callback registered at the context, or out-of-band via
        pinentry.

        Keyword arguments:
        sink            -- write result to sink instead of returning it
        passphrase      -- for symmetric decryption
        verify          -- check signatures (boolean or iterable of keys,
                           see above) (default True)
        filter_signatures  -- if this function should filter out signatures
                           that are not completely OK (default True)

        Returns:
        plaintext       -- the decrypted data (or None if sink is given)
        result          -- additional information about the decryption
        verify_result   -- additional information about the valid
                           signature(s) found

        Raises:
        UnsupportedAlgorithm -- if an unsupported algorithm was used
        MissingSignatures    -- if expected signatures are missing or bad
        GPGMEError           -- as signaled by the underlying library

        FNr�c����SrrXr�s    �rr�z&Context.decrypt.<locals>.passphrase_cb�r�rzTctx.decrypt called with verify=None, should be bool or iterable (treating as False).��categoryT�r�c�<�|jtjk(Sr��statusr�NO_ERROR)�ss r�<lambda>z!Context.decrypt.<locals>.<lambda>�s�����V�_�_�A\�rrr)!r�rtr r
r�r��
isinstancer>�warnings�warn�DeprecationWarning�op_decrypt_verify�
op_decryptrr	�op_decrypt_result�op_verify_resultrr�rr��unsupported_algorithm�UnsupportedAlgorithm�list�filter�
signatures�subkeys�summary�SIGSUM_VALID�can_sign�fprr!�MissingSignatures)rr�r}r��verify�filter_signatures�do_sig_verification�
required_keysr�r�r�r�r�rR�
verify_resultr��missingrI�ok�subkey�sigs   `                 r�decryptzContext.decrypt`s����R$���
� �D�d�f�	��!� $� 2� 2�� '��.>�� E��!*�!A�!A�D��
"�
�"�"�=�1�	E��&�$�'�&,�#����
�
�j�/�1�',�#�!'�
�&*�#�"��&�&�z�9�=����
�I�6��%�%6��"��+�+�D�2C�D��'�'�)��� �1�1�3�M� �M��=�=��y�1�6�=�I���'�'��-�-�f�.J�.J�6=�?�
?�� �+/��7\�^k�^v�^v�0w�+x�
�(��(���(�,�C��B�"%�+�+�"��#0�#;�#;�"�C�"�{�{�Y�-C�-C�C�q�H� (�%���6�:�:����3H�%)��!�"��!�"�����s�+�,�� �2�2�=�'�;B�D�D����c� � �	��+�+�-�F�"� $� 5� 5� 7�
� $�
����t�Y�7���O�A�I��G��	���%�%6��"��+�+�D�2C�D�&�s&�AH�I/�)AI*�*I/�/I2�2"Jc���|r|n	t�}	|j|||�|j�}|jrJ�|j	||�|fS#tj$r�}|j	||�|j�f}|j
�tjk(r>|djr/tj|dj|j|���||_|�d}~wwxYw)aSign data

        Sign the given data with either the configured default local
        key, or the 'signers' keys of this context.

        Keyword arguments:
        mode		-- signature mode (default: normal, see below)
        sink		-- write result to sink instead of returning it

        Returns:
        either
          signed_data	-- encoded data and signature (normal mode)
          signature	-- only the signature data (detached mode)
          cleartext	-- data and signature as text (cleartext mode)
            (or None if sink is given)
        result		-- additional information about the signature(s)

        Raises:
        InvalidSigners	-- if signing using a particular key failed
        GPGMEError	-- as signaled by the underlying library

        rr�N)r��op_signrr	rr�r�r�r�r�r�r�)rr~r}�mode�
signeddatar�r�rRs        rr�zContext.sign�s���."�T�t�v�
�	��L�L��z�4�0��$�$�&���)�)�)�)��}�}�T�:�.��6�6��� � �		��}�}�T�:�6��8K�8K�8M�N�G��y�y�{�f�4�4�4��1�:�-�-� �/�/���
�2�2��g�g� '�)�)� �A�I��G��		�s�A�C7�(B
C2�2C7c�.�|rd}n|r|n	t�}	|r|j||d�n|j|d|�|j	||�|j�f}td�|djD��rtj|d|���t�}|D]�}	d}
|	jD]e}|djD]M}|jtjzdk(r�$|js�1|j |j k(s�Kd}
n|
s�en|
r�||j#|	���|rtj$|d||���|S#tj$r.}|j	||�|j�f|_|�d}~wwxYw)a�Verify signatures

        Verify signatures over data.  If VERIFY is an iterable of
        keys, the ciphertext must be signed by all those keys,
        otherwise an error is raised.

        Keyword arguments:
        signature	-- detached signature data
        sink		-- write result to sink instead of returning it

        Returns:
        data		-- the plain data
            (or None if sink is given, or we verified a detached signature)
        result		-- additional information about the signature(s)

        Raises:
        BadSignatures	-- if a bad signature is encountered
        MissingSignatures -- if expected signatures are missing or bad
        GPGMEError	-- as signaled by the underlying library

        Nc3�VK�|]!}|jtjk7���#y�wrr�)�.0r�s  r�	<genexpr>z!Context.verify.<locals>.<genexpr>-s����J�q�q�x�x�6�?�?�*�J�s�')rr�FrT)r��	op_verifyrr	rr�r��anyr��
BadSignaturesr�r�r�r
r�r�r�r!r�)
r�signed_data�	signaturer}r�r~r�r�r�rIr�r�r�s
             rr�zContext.verifys���,��D��4�T�V�D�	�����y�+�t�<����{�D�$�7��=�=��t�,�d�.C�.C�.E�F���J�G�A�J�4I�4I�J�J��&�&�w�q�z�7�C�C��&���	$�C��B��+�+�
��"�1�:�0�0��C��{�{�Y�%;�%;�;�q�@� ����6�:�:����+@�!������
�����s�#�	$���*�*���
�G�W�6�
6����7� � �	����t�T�2�D�4I�4I�4K�L�A�I��G��	�s�)E�F�&)F�Fc�P�	|j|�|j�}|jdk(rtj}ntj
}|tj
k(r}|S|}|S#t$r�}|tjk(r1|jdk(rtj}nqtj}n`|tk(rt|d�durtj}n8|tk(rt|d�durtj}ntj}Yd}~��d}~wwxYw)a�Import data

        Imports the given data into the Context.

        Returns:
                -- an object describing the results of imported or updated
                   keys

        Raises:
        TypeError      -- Very rarely.
        GPGMEError     -- as signaled by the underlying library:

                          Import status errors, when they occur, will usually
                          be of NODATA.  NO_PUBKEY indicates something
                          managed to run the function without any
                          arguments, while an argument of None triggers
                          the first NODATA of errors.GPGME in the
                          exception.
        rzNo data�decodeT�encodeN)�	op_import�op_import_result�
consideredr
�STATUS_IMPORT_PROBLEM�STATUS_KEY_CONSIDERED�	Exceptionrr	�code_str�
STATUS_NODATA�STATUS_FILE_ERROR�	TypeError�hasattr�STATUS_NO_PUBKEY�STATUS_ERROR)rr~rRr�r��
import_results      r�
key_importzContext.key_importDs���(	0��N�N�4� ��*�*�,�F�� � �A�%�"�8�8��"�8�8���Y�4�4�4�"�M���#�M����%�	0��F�%�%�%��:�:��*�&�4�4�F�&�8�8�F��i��G�D�(�$;�t�$C�"�3�3���i��G�D�(�$;�t�$C�"�4�4��"�/�/����	0�s�AA.�.	D%�7B$D � D%c���t�}d}	|j|||�|jdtj�|j�}t|�dkDr|}|Sd}|S#t$r}|�d}~wwxYw)aQExport keys.

        Exports public keys matching the pattern specified.  If no
        pattern is specified then exports all available keys.

        Keyword arguments:
        pattern	-- return keys matching pattern (default: all keys)

        Returns:
                -- A key block containing one or more OpenPGP keys in
                   either ASCII armoured or binary format as determined
                   by the Context().  If there are no matching keys it
                   returns None.

        Raises:
        GPGMEError     -- as signaled by the underlying library.
        rN)r��	op_exportryrzr{r|r	�len�r�patternr~r��	pk_resultr�rRs       r�
key_exportzContext.key_exportss��$�v����	��N�N�7�D�$�/��I�I�a����%��	�	��I��y�>�A���F��
��F��
���	��G��	�s�AA'�'	A7�0A2�2A7c��t�}tj}	|j|||�|j	dt
j�|j�}t|�dkDr|}|Sd}|S#t$r}|�d}~wwxYw)ayExport keys.

        Exports public keys matching the pattern specified in a
        minimised format.  If no pattern is specified then exports all
        available keys.

        Keyword arguments:
        pattern	-- return keys matching pattern (default: all keys)

        Returns:
                -- A key block containing one or more minimised OpenPGP
                   keys in either ASCII armoured or binary format as
                   determined by the Context().  If there are no matching
                   keys it returns None.

        Raises:
        GPGMEError     -- as signaled by the underlying library.
        rN)
r�r�GPGME_EXPORT_MODE_MINIMALr�ryrzr{r|r	r�r�s       r�key_export_minimalzContext.key_export_minimal�s���&�v���.�.��	��N�N�7�D�$�/��I�I�a����%��	�	��I��y�>�A���F��
��F��
���	��G��	���AA5�5	B�>B�Bc��t�}tj}	|j|||�|j	dt
j�|j�}t|�dkDr|}|Sd}|S#t$r}|�d}~wwxYw)a�Export secret keys.

        Exports secret keys matching the pattern specified.  If no
        pattern is specified then exports or attempts to export all
        available secret keys.

        IMPORTANT: Each secret key to be exported will prompt for its
        passphrase via an invocation of pinentry and gpg-agent.  If the
        passphrase is not entered or does not match then no data will be
        exported.  This is the same result as when specifying a pattern
        that is not matched by the available keys.

        Keyword arguments:
        pattern	-- return keys matching pattern (default: all keys)

        Returns:
                -- On success a key block containing one or more OpenPGP
                   secret keys in either ASCII armoured or binary format
                   as determined by the Context().
                -- On failure while not raising an exception, returns None.

        Raises:
        GPGMEError     -- as signaled by the underlying library.
        rN)
r�r�GPGME_EXPORT_MODE_SECRETr�ryrzr{r|r	r�)rr�r~r��	sk_resultr�rRs       r�key_export_secretzContext.key_export_secret�s���2�v���-�-��	��N�N�7�D�$�/��I�I�a����%��	�	��I��y�>�A���F��
��F��
���	��G��	�rc#�&K�|s$|j|�|j||�n.t|t�st|��}|j	|d�|j�}|r|��|j�}|r�|j
�y�w)aList keys

        Keyword arguments:
        pattern	-- return keys matching pattern (default: all keys)
        secret	-- return only secret keys (default: False)
        mode    -- keylist mode (default: list local keys)
        source  -- read keys from source instead from the keyring
                       (all other options are ignored in this case)

        Returns:
                -- an iterator returning key objects

        Raises:
        GPGMEError	-- as signaled by the underlying library
        )�filerN)�set_keylist_mode�op_keylist_startr�r��op_keylist_from_data_start�op_keylist_next�op_keylist_end)rr��secretr��sourcerIs      r�keylistzContext.keylist�s�����(��!�!�$�'��!�!�'�6�2�
�f�d�+��6�*���+�+�F�A�6��"�"�$����I��&�&�(�C��	
����s�A=B�Bc	��	�tj�	�rE|j}t|dd�}tj
|_d�	fd�	}
|j
|
�	|j||d|d|rtjjnd|rtjjndz|rtjjndz|rtjjndz�	�tjjndz|rdntjjz|
rtjjndz�tj�	�r|_t!j"|�|j%�S#tj�	�r|_t!j"|�wwxYw)a	Create a primary key

        Create a primary key for the user id USERID.

        ALGORITHM may be used to specify the public key encryption
        algorithm for the new key.  By default, a reasonable default
        is chosen.  You may use "future-default" to select an
        algorithm that will be the default in a future implementation
        of the engine.  ALGORITHM may be a string like "rsa", or
        "rsa2048" to explicitly request an algorithm and a key size.

        EXPIRES_IN specifies the expiration time of the key in number
        of seconds since the keys creation.  By default, a reasonable
        expiration time is chosen.  If you want to create a key that
        does not expire, use the keyword argument EXPIRES.

        SIGN, ENCRYPT, CERTIFY, and AUTHENTICATE can be used to
        request the capabilities of the new key.  If you don't request
        any, a reasonable set of capabilities is selected, and in case
        of OpenPGP, a subkey with a reasonable set of capabilities is
        created.

        If PASSPHRASE is None (the default), then the key will not be
        protected with a passphrase.  If PASSPHRASE is a string, it
        will be used to protect the key.  If PASSPHRASE is True, the
        passphrase must be supplied using a passphrase callback or
        out-of-band with a pinentry.

        Keyword arguments:
        algorithm    -- public key algorithm, see above (default: reasonable)
        expires_in   -- expiration time in seconds (default: reasonable)
        expires      -- whether or not the key should expire (default: True)
        sign         -- request the signing capability (see above)
        encrypt      -- request the encryption capability (see above)
        certify      -- request the certification capability (see above)
        authenticate -- request the authentication capability (see above)
        passphrase   -- protect the key with a passphrase (default: no
                        passphrase)
        force        -- force key creation even if a key with the same userid
                        exists (default: False)

        Returns:
                     -- an object describing the result of the key creation

        Raises:
        GPGMEError   -- as signaled by the underlying library

        r�Nc����SrrXr�s    �rr�z)Context.create_key.<locals>.passphrase_cbFr�rrr)r�is_a_stringrtr r
r�r��op_createkey�create�SIGN�ENCR�CERT�AUTH�NOPASSWD�NOEXPIRE�FORCErr��op_genkey_result)r�userid�	algorithm�
expires_in�expiresr�r��certify�authenticater��forcer�r�r�s         `    r�
create_keyzContext.create_keys����v���J�'� $� 2� 2�� '��.>�� E��!*�!A�!A�D��
"�
�"�"�=�1�	E���������+/�)�"�"�'�'�Q�+2�)�"�"�'�'��;�+2�)�"�"�'�'��;�,8�)�"�"�'�'�Q�@�0:�/A�)�"�"�+�+�q�	J�
�!�I�$4�$4�$=�$=�?�-2�)�"�"�(�(�q�
:�

<����
�+�%6��"��+�+�D�2C�D��$�$�&�&��	���
�+�%6��"��+�+�D�2C�D�,�s
�C,F�5Gc	���tj��rE|j}	t|dd�}
tj
|_d�fd�	}|j
|�	|j||d||rtjjnd|rtjjndz|rtjjndz��tjjndz|rdntjjz�tj��r	|_tj|
�|j!�S#tj��r	|_tj|
�wwxYw)a@Create a subkey

        Create a subkey for the given KEY.  As subkeys are a concept
        of OpenPGP, calling this is only valid for the OpenPGP
        protocol.

        ALGORITHM may be used to specify the public key encryption
        algorithm for the new subkey.  By default, a reasonable
        default is chosen.  You may use "future-default" to select an
        algorithm that will be the default in a future implementation
        of the engine.  ALGORITHM may be a string like "rsa", or
        "rsa2048" to explicitly request an algorithm and a key size.

        EXPIRES_IN specifies the expiration time of the subkey in
        number of seconds since the subkeys creation.  By default, a
        reasonable expiration time is chosen.  If you want to create a
        subkey that does not expire, use the keyword argument EXPIRES.

        SIGN, ENCRYPT, and AUTHENTICATE can be used to request the
        capabilities of the new subkey.  If you don't request any, an
        encryption subkey is generated.

        If PASSPHRASE is None (the default), then the subkey will not
        be protected with a passphrase.  If PASSPHRASE is a string, it
        will be used to protect the subkey.  If PASSPHRASE is True,
        the passphrase must be supplied using a passphrase callback or
        out-of-band with a pinentry.

        Keyword arguments:
        algorithm    -- public key algorithm, see above (default: reasonable)
        expires_in   -- expiration time in seconds (default: reasonable)
        expires      -- whether or not the subkey should expire (default: True)
        sign         -- request the signing capability (see above)
        encrypt      -- request the encryption capability (see above)
        authenticate -- request the authentication capability (see above)
        passphrase   -- protect the subkey with a passphrase (default: no
                        passphrase)

        Returns:
                     -- an object describing the result of the subkey creation

        Raises:
        GPGMEError   -- as signaled by the underlying library

        r�Nc����SrrXr�s    �rr�z,Context.create_subkey.<locals>.passphrase_cb�r�rrr)rrrtr r
r�r��op_createsubkeyrrrrrrrr�r)rrIrr r!r�r�r#r�r�r�r�s        `   r�
create_subkeyzContext.create_subkey`sX���l���J�'� $� 2� 2�� '��.>�� E��!*�!A�!A�D��
"�
�"�"�=�1�	E�� � �����+/�)�"�"�'�'�Q�+2�)�"�"�'�'��;�+7�)�"�"�'�'�Q�@�0:�/A�)�"�"�+�+�q�J��!�I�$4�$4�$=�$=�	?�	
A����
�+�%6��"��+�+�D�2C�D��$�$�&�&��	���
�+�%6��"��+�+�D�2C�D�,�s
�B-E�5Fc�*�|j||d�y)z�Add a UID

        Add the uid UID to the given KEY.  Calling this function is
        only valid for the OpenPGP protocol.

        Raises:
        GPGMEError   -- as signaled by the underlying library

        rN)�	op_adduid�rrI�uids   r�key_add_uidzContext.key_add_uid����	
���s�C��#rc�*�|j||d�y)z�Revoke a UID

        Revoke the uid UID from the given KEY.  Calling this function
        is only valid for the OpenPGP protocol.

        Raises:
        GPGMEError   -- as signaled by the underlying library

        rN)�	op_revuidr,s   r�key_revoke_uidzContext.key_revoke_uid�r/rc�8�d}|�tj|�rn.|tjjz}dj|�}|s|tjjz}|r|tjjz}|j||||�y)a�Sign a key

        Sign a key with the current set of signing keys.  Calling this
        function is only valid for the OpenPGP protocol.

        If UIDS is None (the default), then all UIDs are signed.  If
        it is a string, then only the matching UID is signed.  If it
        is a list of strings, then all matching UIDs are signed.  Note
        that a case-sensitive exact string comparison is done.

        EXPIRES_IN specifies the expiration time of the signature in
        seconds.  If EXPIRES_IN is False, the signature does not
        expire.

        Keyword arguments:
        uids         -- user ids to sign, see above (default: sign all)
        expires_in   -- validity period of the signature in seconds
                                               (default: do not expire)
        local        -- create a local, non-exportable signature
                                               (default: False)

        Raises:
        GPGMEError   -- as signaled by the underlying library

        rN�
)	rrr
�keysign�LFSEPr"r�LOCAL�
op_keysign)rrI�uidsr �localr%s      r�key_signzContext.key_sign�s���4���<�4�+�+�D�1���Y�&�&�,�,�,�E��9�9�T�?�D���Y�&�&�/�/�/�E���Y�&�&�,�,�,�E�����T�:�u�5rc�(�|j||�y)z�Set a keys' TOFU policy

        Set the TOFU policy associated with KEY to POLICY.  Calling
        this function is only valid for the OpenPGP protocol.

        Raises:
        GPGMEError   -- as signaled by the underlying library

        N)�op_tofu_policy)rrI�policys   r�key_tofu_policyzContext.key_tofu_policy�s��	
���C��(rc	�X�tj|�st|t�r|}ndj	d�|D��}tj�}tj|j||rtj|�|fnd|rtj|�|fnd|rtj|�|fnd|�}|jrtj|�t|�tj|�}tj|�|dk7rt!|�SdS)a�Issue a raw assuan command

        This function can be used to issue a raw assuan command to the
        engine.

        If command is a string or bytes, it will be used as-is.  If it
        is an iterable of strings, it will be properly escaped and
        joined into an well-formed assuan command.

        Keyword arguments:
        data_cb		-- a callback receiving data lines
        inquire_cb	-- a callback providing more information
        status_cb	-- a callback receiving status lines

        Returns:
        result		-- the result of command as GPGMEError

        Raises:
        GPGMEError	-- as signaled by the underlying library

        rc3�FK�|]}tj|����y�wr)r�percent_escape)r�r$s  rr�z*Context.assuan_transact.<locals>.<genexpr>s����C�a�4�.�.�q�1�C�s�!Nr)rrr��bytesr"r�new_gpgme_error_t_p�gpgme_op_assuan_transact_extr�weakref�refrrPr�gpgme_error_t_p_value�delete_gpgme_error_t_pr	)	r�command�data_cb�
inquire_cb�	status_cb�cmd�errptr�errr�s	         r�assuan_transactzContext.assuan_transact�s���6���G�$�
�7�E�(B��C��(�(�C�7�C�C�C��*�*�,���0�0��L�L�#��!(���D� 1�7�;� ��$+�;�;�t�#4�j�"A�#��'.�k�k�$�&7��%C�"�F�	,���!�!��.�.�t�4��3���,�,�V�4��
�$�$�V�,�%+�q�[�z�&�!�:�d�:rc�8�|�td��|�
t�}|rtj|�||f}ntj|�|f}t	j
|j||||�}|jrt	j|�t|�y)a�Interact with the engine

        This method can be used to edit keys and cards interactively.
        KEY is the key to edit, FUNC is called repeatedly with two
        unicode arguments, 'keyword' and 'args'.  See the GPGME manual
        for details.

        Keyword arguments:
        sink		-- if given, additional output is written here
        flags		-- use constants.INTERACT_CARD to edit a card

        Raises:
        GPGMEError	-- as signaled by the underlying library

        NzFirst argument cannot be None)
�
ValueErrorr�rFrGr�gpgme_op_interactrrrPr)rrIrSr}r%�	fnc_value�
opaquedatarRs        r�interactzContext.interact1s��� �;��<�=�=��<��6�D��!�+�+�d�+�T�9�=�J�!�+�+�d�+�T�2�J��(�(����s�E�:�)-�/���!�!��.�.�t�4��6�rc��|jsyt|j��D�cgc]}|j|���c}Scc}w)zKeys used for signingN)r�range�
signers_count�signers_enum)r�is  rrszContext.signersRs;���|�|��.3�D�4F�4F�4H�.I�J���!�!�!�$�J�J��Js�Ac��|j}|j�	|D]}|j|��y#||_�xYwr)rs�
signers_clear�signers_add)rrs�oldrIs    rrszContext.signersYsJ���l�l������	��
&��� � ��%�
&��	��D�L��s	�7�
Ac�"�|j�S)z
Pinentry mode)�get_pinentry_moder*s rrtzContext.pinentry_modeds���%�%�'�'rc�&�|j|�yr)�set_pinentry_mode�rrCs  rrtzContext.pinentry_modeis�����u�%rc�"�|j�S)zProtocol to use)�get_protocolr*s rruzContext.protocolms��� � �"�"rc�b�ttj|��|j|�yr)rr�gpgme_engine_check_version�set_protocolres  rruzContext.protocolrs#���5�3�3�E�:�;����%� rc�H�|jsy|jjS)zEngine's home directoryN)r�engine_inforvr*s rrvzContext.home_dirws ���|�|�����(�(�(rc�>�|j|j|��y)N)rv)�set_engine_inforures  rrvzContext.home_dir~s�����T�]�]�U��;r�gpgme_ctx_t�gpgme_c�X�|jd�xr|jd�xs|dvS)�?This function should list all functions returning gpgme_error_t�	gpgme_op_�_result>rm�gpgme_cancel�
gpgme_get_key�gpgme_set_locale�gpgme_set_sender�gpgme_get_sig_key�gpgme_signers_add�gpgme_cancel_async�gpgme_set_ctx_flag�gpgme_set_protocol�gpgme_set_keylist_mode�gpgme_set_sub_protocol�gpgme_sig_notation_add�gpgme_set_pinentry_mode�gpgme_ctx_set_engine_info)�
startswith�endswithr8s  rr:zContext._errorcheck�s=������-�*����y�)�3*�	�.2�7�/�		r>rprrrqc��tsy|j�|j�|j�|jrE|j
r8tjr'tj|j
�d|_yyyyr)r�_free_passcb�_free_progresscb�_free_statuscbrkr�
gpgme_releaser*s r�__del__zContext.__del__�sc�����������������8�8�����)<�)<�������-��D�L�*=��8rc��|SrrXr*s r�	__enter__zContext.__enter__�����rc��yr-rX�r�typerC�tbs    r�__exit__zContext.__exit__����rc/�K�|j|i|��|j�}|r|��|j�}|r�|j�y�wr)r
rr
)rrQ�kwargsrIs    r�op_keylist_allzContext.op_keylist_all�sR��������t�.�v�.��"�"�$����I��&�&�(�C��	
�����
�;A�Ac�v�tj�}	ttj|j|��tj
|�}tj|�|r
d�|_|Sy#tj$r/}d}|j�tjk7r|�Yd}~�_d}~wwxYw)z~Returns the next key in the list created
        by a call to op_keylist_start().  The object returned
        is of type Key.Nc�,�tj|�Sr�r�gpgme_key_unrefr*s rr�z)Context.op_keylist_next.<locals>.<lambda>�s��u�'<�'<�T�'B�r)r�new_gpgme_key_t_pr�gpgme_op_keylist_nextr�gpgme_key_t_p_valuerr	r��EOF�delete_gpgme_key_t_pr�)r�ptrrI�excps    rrzContext.op_keylist_next�s����%�%�'��	��u�2�2�4�<�<��E�F��+�+�C�0�C�
	�"�"�3�'��B�C�K��J���� � �	��C��|�|�~����+��
�,��	�s�>A6�6B8�	%B3�3B8c��tj�}	ttj|j|||��tj|�}tj|�|sJ�d�|_|S#t
j$r=}|j�t
jk(rtj|��|�d}~wwxYw)a&Get a key given a fingerprint

        Keyword arguments:
        secret		-- to request a secret key

        Returns:
                        -- the matching key

        Raises:
        KeyError	-- if the key was not found
        GPGMEError	-- as signaled by the underlying library

        Nc�,�tj|�Srr�r*s rr�z!Context.get_key.<locals>.<lambda>�s��5�#8�#8��#>�r)
rr�rrvrrr	r�r��KeyNotFoundr�r�r�)rr�rr�r�rIs      r�get_keyzContext.get_key�s����%�%�'��	��u�*�*�4�<�<��c�6�J�K��'�'��,��
�"�"�3�'��
�s�>����
��� � �	��y�y�{�f�j�j�(��(�(��-�-��G��	�s�+A9�9C	�8C�C	c/�K�|j|i|��|j�}|r|��|j�}|r�|j�y�wr)�op_trustlist_start�op_trustlist_next�op_trustlist_end)rrQr��trusts    r�op_trustlist_allzContext.op_trustlist_all�sR���������0��0��&�&�(����K��*�*�,�E��	
����r�c�^�tj�}	ttj|j|��tj
|�}tj|�|S#tj$r.}d}|j�tjk7r�Yd}~�Sd}~wwxYw)z�Returns the next trust item in the list created
        by a call to op_trustlist_start().  The object returned
        is of type TrustItem.N)r�new_gpgme_trust_item_t_pr�gpgme_op_trustlist_nextr�gpgme_trust_item_t_p_valuerr	r�r��delete_gpgme_trust_item_t_p)rr�r�r�s    rr�zContext.op_trustlist_next�s����,�,�.��	��u�4�4�T�\�\�3�G�H��4�4�S�9�E�
	�)�)�#�.����� � �	��E��|�|�~����+��,��	�s�>A+�+B,�>$B'�'B,c��|�d}n2|�tj|�|f}ntj|�||f}tj||�y)a*Sets the passphrase callback to the function specified by func.

        When the system needs a passphrase, it will call func with three args:
        hint, a string describing the key it needs the passphrase for;
        desc, a string describing the passphrase it needs;
        prev_bad, a boolean equal True if this is a call made after
        unsuccessful previous attempt.

        If hook has a value other than None it will be passed into the func
        as a forth argument.

        Please see the GPGME manual for more information.
        N)rFrGrr��rrSr��hookdatas    rr�zContext.set_passphrase_cb�sK���<��H��|�#�K�K��-�t�4��#�K�K��-�t�T�:��
�#�#�D�(�3rc�H�tjr|jd�yyr)rr�r�r*s rr�zContext._free_passcbs���&�&��"�"�4�(�'rc��|�d}n2|�tj|�|f}ntj|�||f}tj||�y)a�Sets the progress meter callback to the function specified by FUNC.
        If FUNC is None, the callback will be cleared.

        This function will be called to provide an interactive update
        of the system's progress.  The function will be called with
        three arguments, type, total, and current.  If HOOK is not
        None, it will be supplied as fourth argument.

        Please see the GPGME manual for more information.

        N)rFrGr�gpg_set_progress_cbr�s    r�set_progress_cbzContext.set_progress_cbsK���<��H��|�#�K�K��-�t�4��#�K�K��-�t�T�:��
�!�!�$��1rc�H�tjr|jd�yyr)rr�r�r*s rr�zContext._free_progresscb(s���$�$�� � ��&�%rc��|�d}n2|�tj|�|f}ntj|�||f}tj||�y)aPSets the status callback to the function specified by FUNC.  If
        FUNC is None, the callback will be cleared.

        The function will be called with two arguments, keyword and
        args.  If HOOK is not None, it will be supplied as third
        argument.

        Please see the GPGME manual for more information.

        N)rFrGr�gpg_set_status_cbr�s    r�
set_status_cbzContext.set_status_cb,sK���<��H��|�#�K�K��-�t�4��#�K�K��-�t�T�:��
����h�/rc�H�tjr|jd�yyr)rr�r�r*s rr�zContext._free_statuscb@s���"�"����t�$�#rc��|j}|j�D�cgc]}|j|k(s�|��}}t|�dk(sJ�|dScc}w)z,Configuration of the engine currently in userr)ru�get_engine_infor�)rrKr\�infoss    rrlzContext.engine_infoDsR��
�M�M�� �0�0�2�F�q�a�j�j�A�o��F��F��5�z�Q�����Q�x���Gs
�A�Ac�@�tj|j�S)z�Get engine configuration

        Returns information about all configured and installed
        engines.

        Returns:
        infos		-- a list of engine infos

        )r�gpgme_ctx_get_engine_inforr*s rr�zContext.get_engine_infoLs���.�.�t�|�|�<�<rc�*�|j|||�y)a6Change engine configuration

        Changes the configuration of the crypto engine implementing
        the protocol 'proto' for the context.

        Keyword arguments:
        file_name	-- engine program file name (unchanged if None)
        home_dir	-- configuration directory (unchanged if None)

        N)�ctx_set_engine_info)r�proto�	file_namervs    rrnzContext.set_engine_infoXs��	
� � ��	�8�<rc���tj�}tj|j||�tj|�}tj
|�t
|�y)z�Wait for asynchronous call to finish. Wait forever if hang is True.
        Raises an exception on errors.

        Please read the GPGME manual for more information.

        N)rrD�
gpgme_waitrrHrIr)r�hangr�r�s    r�waitzContext.waitesN���'�'�)��
������s�D�1��,�,�S�1��
�$�$�S�)��6�rc�b�tjdt��|j||||��S)a�Start key editing using supplied callback function

        Note: This interface is deprecated and will be removed with
        GPGME 1.8.  Please use .interact instead.  Furthermore, we
        implement this using gpgme_op_interact, so callbacks will get
        called with string keywords instead of numeric status
        messages.  Code that is using constants.STATUS_X or
        constants.status.X will continue to work, whereas code using
        magic numbers will break as a result.

        z"Call to deprecated method op_edit.r�)r}rU)r�r�r�rW)rrIrSrU�outs     r�op_editzContext.op_editrs.��	�
�
�0�;M�	O��}�}�S�$�S�I�}�F�Fr)NNTTr)	NrTFFFFNF)NrTFFFN)NFF)NNN)NrN)F)NN)<rrarbrVr
�PINENTRY_MODE_DEFAULT�PROTOCOL_OpenPGPrrrr�r��SIG_MODE_NORMALr�r�r�r�rrrr�r7r%r)r.r2r;r?rQrWrGrs�setterrtrurvr3r6r:rr�r�r�r�rr�r�r�r�r�r�r�r�r�rlr�rnr�r�rfrgs@rriri�st���
�����(�>�>�#�4�4���$!�L	�"�����"�$��!��`C�Dy�v#��)B�)B�)7�V-1�t�B�<�|-�^ �D!�F'�T���&�&�+�+�1�1��	#�N"���� � � %�"��X'�x!%�!"�"� �#�#(�!%�P'�d
$�
$�'6�R
)�!%�#'�"&�	0;�d�B�K��K�
�^�^�����(��(����&��&��#��#��_�_�!��!��)��)��_�_�<��<��F��H��";��
 �����"�: �
�4�.)�2�*'�0�(%�����
=�=��Grric���eZdZdZdZdZd�Z						d�fd�	Zd�Zd�Z	d�Z
d	�Zd
�Zdd�Z
dd�Zdd
�Zd�Zd�Zd�Zd�Zd�Zdd�Z�xZS)r�aJData buffer

    A lot of data has to be exchanged between the user and the crypto
    engine, like plaintext messages, ciphertext, signatures and
    information about the keys.  The technical details about
    exchanging the data information are completely abstracted by
    GPGME.  The user provides and receives the data via `gpgme_data_t'
    objects, regardless of the communication protocol between GPGME
    and the crypto engine in use.

    This Data class is the implementation of the GpgmeData objects.

    Please see the information about __init__ for instantiation.

    �gpgme_data_t�gpgme_data_c�
�|dvS)rr>	�gpgme_data_read�gpgme_data_seek�gpgme_data_write�gpgme_data_release�gpgme_data_identify�gpgme_data_set_flag�gpgme_data_get_encoding�gpgme_data_get_file_name�gpgme_data_release_and_get_memrXr8s  rr:zData._errorcheck�s���

�

�
	
rc�T��tt|�d�d|_|�|j|�y|�|j||�y|�|�|�|j
|||�y|�:tj|�r|j||�y|j|�y|j�y)a�Initialize a new gpgme_data_t object.

        If no args are specified, make it an empty object.

        If string alone is specified, initialize it with the data
        contained there.

        If file, offset, and length are all specified, file must
        be either a filename or a file-like object, and the object
        will be initialized by reading the specified chunk from the file.

        If cbs is specified, it MUST be a tuple of the form:

        (read_cb, write_cb, seek_cb, release_cb[, hook])

        where the first four items are functions implementing reading,
        writing, seeking the data, and releasing any resources once
        the data object is deallocated.  The functions must match the
        following prototypes:

            def read(amount, hook=None):
                return <a b"bytes" object>

            def write(data, hook=None):
                return <the number of bytes written>

            def seek(offset, whence, hook=None):
                return <the new file position>

            def release(hook=None):
                <return value and exceptions are ignored>

        The functions may be bound methods.  In that case, you can
        simply use the 'self' reference instead of using a hook.

        If file is specified without any other arguments, then
        it must be a filename, and the object will be initialized from
        that file.

        N)rr�r�data_cbs�new_from_cbs�new_from_mem�new_from_filepartrr�
new_from_file�new_from_fd�new)r�stringr�offset�length�cbs�copyrs       �rrz
Data.__init__�s����^	�d�D�"�4�(���
��?��D���s�#�
�
����f�d�+�
�
�&�"4��9K��"�"�4���8�
�
�����%��"�"�4��.�� � ��&��H�H�Jrc��tsy|j�WtjrGtj|j�|jrtj|�d|_|j�yr)rrr�rrP�
_free_datacbsr*s rr�zData.__del__�sV�����<�<�#��(@�(@��$�$�T�\�\�2��%�%��2�2�4�8��D�L����rc��|SrrXr*s rr�zData.__enter__�r�rc��yr-rXr�s    rr�z
Data.__exit__�r�rc��d|_yr)�	_data_cbsr*s rr�zData._free_datacbs�s	����rc���tj�}ttj|��tj|�|_tj|�yr)r�new_gpgme_data_t_pr�gpgme_data_new�gpgme_data_t_p_valuer�delete_gpgme_data_t_p)rrws  rr�zData.newsC���&�&�(���5�'�'��,�-��1�1�#�6���
�#�#�C�(rc	���tj�}ttj||t	|�|��tj
|�|_tj|�yr)rr�r�gpgme_data_new_from_memr�r�rr�)rr�r�rws    rr�zData.new_from_memsQ���&�&�(����)�)�#�v�s�6�{�D�I�	K��1�1�#�6���
�#�#�C�(rc�b�tj�}	ttj|||��tj|�|_
tj|�y#tj
$r5}|j
�tjk(r
|std��|�d}~wwxYw)Nz#delayed reads are not yet supported)rr�r�gpgme_data_new_from_filerr	r��	INV_VALUErSr�rr�)r�filenamer�rwr�s     rr�zData.new_from_file
s����&�&�(��	��u�5�5�c�8�T�J�K��1�1�#�6���
�#�#�C�(��
� � �	��y�y�{�f�.�.�.�t� �!F�G�G����		�s� A&�&B.�90B)�)B.c�(�tj�}|�tj|�|||||f}ntj|�||||f}tj|||�tj
|�|_tj|�yr)rr�rFrG�gpg_data_new_from_cbsr�rr�)r�read_cb�write_cb�seek_cb�
release_cbr�rwr�s        rr�zData.new_from_cbss����&�&�(�������D�)�7�H�g�"�D�*�H� ���D�)�7�H�g�"�$�H�
�#�#�D�(�C�8��1�1�#�6���
�#�#�C�(rc	��tj�}d}d}tj|�r|}n\tj|j�|j�}|�,tdtt|���dt|�����ttj|||||��tj|�|_
tj|�y)z�This wraps the GPGME gpgme_data_new_from_filepart() function.
        The argument "file" may be:

        * a string specifying a file name, or
        * a file-like object supporting the fileno() and the mode attribute.

        NzFailed to open file from z arg )rr�rr�fdopen�filenor�rS�strr�r�gpgme_data_new_from_filepartr�rr�)rrr�r�rwr��fps       rr�zData.new_from_filepart%s����&�&�(����
�����D�!��H����d�k�k�m�T�Y�Y�7�B��z� ����J�J �!$�T��",�-�-�	��.�.�s�H�b�&�/5�
7�	8��1�1�#�6���
�#�#�C�(rc���tj�}ttj||j	���tj
|�|_tj|�y)z�This wraps the GPGME gpgme_data_new_from_fd() function.  The
        argument "file" must be a file-like object, supporting the
        fileno() method.

        N)rr�r�gpgme_data_new_from_fdrr�rr�)rrrws   rr�zData.new_from_fd@sM���&�&�(���5�/�/��T�[�[�]�C�D��1�1�#�6���
�#�#�C�(rc�&�|j|�y)z�This wrap around gpgme_data_new_from_stream is an alias for
        new_from_fd() method since in python there's no difference
        between file stream and file descriptor.N)r��rrs  r�new_from_streamzData.new_from_streamKs��	
����rc�&�|j|�y)z�This wrap around gpgme_data_new_from_estream is an alias for
        new_from_fd() method since in python there's no difference
        between file stream and file descriptor, but using fd broke.N)r
rs  r�new_from_estreamzData.new_from_estreamQs��	
���T�"rc��tj|j|�}|dkr7|jrtj|�|Stj��|S)zkWrite buffer given as string or bytes.

        If a string is given, it is implicitly encoded using UTF-8.r)rr�rrrPr	�fromSyserror)r�buffer�writtens   r�writez
Data.writeWsU���(�(����v�>���Q�;��%�%��2�2�4�8���!�-�-�/�/��rc��|dk(ry|dkDr#	tj|j|�}|Sg}		tj|jd�}t�dk(rn|j
|��Bdj|�S#|jrtj|�YS�xYw#|jrtj|�n�Y��xYw)z�Read at most size bytes, returned as bytes.

        If the size argument is negative or omitted, read until EOF is reached.

        Returns the data read, or the empty string if there was no data
        to read before EOF was reached.r�ir)rr�rrrPr�r!r")r�sizerR�chunkss    rr|z	Data.readcs����1�9���!�8�
��.�.�t�|�|�T�B���M��F���"�2�2�4�<�<��F�F��v�;�!�#���
�
�f�%���8�8�F�#�#��'
��)�)��6�6�t�<��M�����-�-��:�:�4�@��A�s� B� B/�#B,�+B,�/%C)NNNNNT)Tr)���)rrarbrVr3r6r:rr�r�r�r�r�r�r�r�r�r�r
rrr|rfrgs@rr�r��sy���� �F��H�
�(������
>�@
����)�)�
)�
)�)�6	)��#�
�!$rr�c�,�tj|�S)z�Return short algorithm string

    Return a public key algorithm string (e.g. "rsa2048") for a given
    SUBKEY.

    Returns:
    algo      - a string

    )r�gpgme_pubkey_algo_string)r�s r�pubkey_algo_stringr�s���)�)�&�1�1rc�,�tj|�S)z�Return name of public key algorithm

    Return the name of the public key algorithm for a given numeric
    algorithm id ALGO (cf. RFC4880).

    Returns:
    algo      - a string

    )r�gpgme_pubkey_algo_name��algos r�pubkey_algo_namer!�s���'�'��-�-rc�,�tj|�S)z�Return name of hash algorithm

    Return the name of the hash algorithm for a given numeric
    algorithm id ALGO (cf. RFC4880).

    Returns:
    algo      - a string

    )r�gpgme_hash_algo_namers r�hash_algo_namer$�s���%�%�d�+�+rc�,�tj|�S)ztGet protocol description

    Get the string describing protocol PROTO.

    Returns:
    proto     - a string

    )r�gpgme_get_protocol_name�r�s r�get_protocol_namer(�s���(�(��/�/rc�,�tj|�S)z�Return the address spec

    Return the addr-spec (cf. RFC2822 section 4.3) from a user id UID.

    Returns:
    addr_spec - a string

    )r�gpgme_addrspec_from_uid)r-s r�addrspec_from_uidr+�s���(�(��-�-rc�,�tj|�Sr)r�gpgme_check_version)�versions r�
check_versionr/�s���$�$�W�-�-rc�t�	ttj|��y#tj$rYywxYw)NTF)rrrirr	r's r�engine_check_versionr1�s5����5�3�3�E�:�;���������s�!�7�7c��tj�}	ttj|��tj|�}tj|�|S#t
j$rd}Y�.wxYwr)r�new_gpgme_engine_info_t_pr�gpgme_get_engine_info�gpgme_engine_info_t_p_valuerr	�delete_gpgme_engine_info_t_p)r��infos  rr�r��si��
�
)�
)�
+�C���5�.�.�s�3�4��0�0��5��
�&�&�s�+��K���������s�3A � A8�7A8c�D�ttj|||��y)a#Changes the default configuration of the crypto engine implementing
    the protocol 'proto'. 'file_name' is the file name of
    the executable program implementing this protocol. 'home_dir' is the
    directory name of the configuration directory (engine's default is
    used if omitted).N)rr�gpgme_set_engine_info)r�r�rvs   rrnrn�s���u�*�*�5�)�X�F�Grc�D�ttjd||��y)z(Sets the default locale used by contextsN)rrrw)r�rCs  r�
set_localer;�s���u�%�%�d�H�e�<�=rc���tj�}tjd||�}tj|�}tj|�|�t|�||fSt
|�}||fS)aFWait for asynchronous call on any Context  to finish.
    Wait forever if hang is True.

    For finished anynch calls it returns a tuple (status, context):
        status  - status return by asnynchronous call.
        context - context which caused this call to return.

    Please read the GPGME manual of more information.N)rrDr�rHrIrri)r�r��contextr�s    rr�r��su���
#�
#�
%�C����t�S�$�/�G�
�
(�
(��
-�F�	� � ��%����6��
�G����'�"���G��rr)�
__future__rrrrdrzr�rFrrrrr	r
r�objectrrir�rr!r$r(r+r/r1r�rnr;r�rXrr�<module>r@s���I�H�	�	����*�����^�%5�&�J>�6�J>�ZGG�l�GG�T&A$�<�A$�H
2�
.�
,�	0�	.�.�����H�>�
r

Zerion Mini Shell 1.0