⚝
One Hat Cyber Team
⚝
Your IP:
3.145.106.159
Server IP:
97.74.87.16
Server:
Linux 16.87.74.97.host.secureserver.net 5.14.0-503.38.1.el9_5.x86_64 #1 SMP PREEMPT_DYNAMIC Fri Apr 18 08:52:10 EDT 2025 x86_64
Server Software:
Apache
PHP Version:
8.2.28
Buat File
|
Buat Folder
Eksekusi
Dir :
~
/
lib64
/
python3.9
/
site-packages
/
gpg
/
__pycache__
/
View File Name :
core.cpython-39.opt-1.pyc
a �����x�_������������������������@���s��d�dl�mZmZmZ�d�dlZd�dlZd�dlZd�dlZddlm Z �ddl mZmZ�ddlm Z �ddlm Z �ddlmZ�[[[G�d d ��d e�ZG�dd��de�ZG�d d��de�Zdd��Zdd��Zdd��Zdd��Zdd��Zd%dd�Ze���dd��Zdd��Zd&dd �Zd!d"��Zd#d$��ZdS�)'�����)�absolute_import�print_function�unicode_literalsN����)�gpgme)� errorcheck� GPGMEError)� constants)�errors)�utilc�����������������������s����e�Zd�ZdZdd��Z��fdd�Zdd��Zdd ��Zd d��Ze dd ���Z e dd���Zdd��Ze ��Zddd�Ze�d�Zdd��Z��fdd�Z���ZS�)�GpgmeWrapperz>Base wrapper class Not to be instantiated directly. c�����������������C���s���d�|�_�||�_d�S��N)�_callback_excinfo�wrapped)�selfr�����r����./usr/lib64/python3.9/site-packages/gpg/core.py�__init__3���s����zGpgmeWrapper.__init__c��������������������s���d��tt|�����|�j�S�)Nz <{}/{!r}>)�format�superr����__repr__r����r����� __class__r���r���r���7���s�����zGpgmeWrapper.__repr__c��������������������sP���d��t��jj�g}��fdd���jD��}|r@|�d��d�|����d��d�|��S�)Nz{}.{}c��������������������s���g�|�]}t���|�r|�qS�r���)�getattr��.0�fr���r���r���� <listcomp>=��������z(GpgmeWrapper.__str__.<locals>.<listcomp>z({})� z<{}>)r����__name__r����_boolean_properties�append�join)r���Zacc�flagsr���r���r����__str__;���s ����zGpgmeWrapper.__str__c�����������������C���s���t�t|�j��S�r ���)�hash�reprr���r���r���r���r����__hash__C���s����zGpgmeWrapper.__hash__c�����������������C���s$���|d�u�rdS�t�|�j�t�|j�kS�d�S�)NF)r(���r���)r����otherr���r���r����__eq__F���s����zGpgmeWrapper.__eq__c�����������������C���s ���t����dS�)z]The name of the c type wrapped by this class Must be set by child classes. N��NotImplementedErrorr���r���r���r����_ctypeL���s����zGpgmeWrapper._ctypec�����������������C���s ���t����dS�)zgThe common prefix of c functions wrapped by this class Must be set by child classes. Nr,���r���r���r���r����_cprefixU���s����zGpgmeWrapper._cprefixc�����������������C���s ���t����dS�)z�Must be implemented by child classes. This function must return a trueish value for all c functions returning gpgme_error_t.Nr,����r����namer���r���r����_errorcheck^���s����zGpgmeWrapper._errorcheckFNc��������������������s����t�td�|�j|����t�td�|�j|�����fdd�}�fdd�}t||d�|�d�}t|�j||��|rv||�t|���n||��S�d�S�) Nz{}get_{}z{}set_{}c��������������������s���t���|�j��S�r ���)�boolr���)�slf)�get_funcr���r����getl���s����z1GpgmeWrapper.__wrap_boolean_property.<locals>.getc��������������������s�����|�j�t|���d�S�r ���)r���r3���)r4����value)�set_funcr���r����set_o���s����z2GpgmeWrapper.__wrap_boolean_property.<locals>.set_z{} flag)�doc)r���r���r���r/����property�setattrr���r3���)r����keyZdo_setr7���r6���r9����pr���)r5���r8���r���Z__wrap_boolean_propertyh���s����z$GpgmeWrapper.__wrap_boolean_propertyz$gpgme_([^(]*)\(([^,]*), (.*\) -> .*)c��������������������s����|d�dks�j�du�rdS�|�jv�r.��|�S��j�|��tt�������r\��fdd���n�fdd���t�d�}|r��j�d|�}nd}|��_t �j |�������fd d �}||_|S�)z7On-the-fly generation of wrapper methods and propertiesr����_Nc��������������������s,�����|�j�g|�R���}|�jr"t�|���t|��S�r ���)r���r���r����gpg_raise_callback_exceptionr����r4����args�result)�funcr1���r���r���� _funcwrap����s���� z+GpgmeWrapper.__getattr__.<locals>._funcwrapc��������������������s&�����|�j�g|�R���}|�jr"t�|���|S�r ���)r���r���r���r@���rA���)rD���r���r���rE�������s���� �__doc__z\2.\1(\3c���������������������s������g|��R���S�r ���r���)rB���)rE���r���r���r����wrapper����s����z)GpgmeWrapper.__getattr__.<locals>.wrapper)r/���r"����$_GpgmeWrapper__wrap_boolean_propertyr���r���r2����_munge_docstring�subrF���r<���r���)r���r=���Zdoc_origr:���rG���r���)rE���rD���r1���r���r����__getattr__|���s$���� zGpgmeWrapper.__getattr__c��������������������s0���||�j�v�r|��|d|��ntt|���||��dS�)z#On-the-fly generation of propertiesTN)r"���rH���r���r����__setattr__)r���r=���r7���r���r���r���rL�������s���� zGpgmeWrapper.__setattr__)FN)r!���� __module__�__qualname__rF���r���r���r&���r)���r+���r;���r.���r/���r2����setr"���rH����re�compilerI���rK���rL���� __classcell__r���r���r���r���r���,���s ��� -r���c���������������� �������s:��e�Zd�ZdZdddg�ejejddf��fdd� Zdd��Zdd ��Z g�d ddddddd f dd�Z ded d�Zdejfdd�Z ddg�fdd�Zdd��Zdfdd�Zdgdd�Zdhdd�Zddejjjdfdd�Zdidd�Zdjd d!�Zd"d#��Zd$d%��Zdkd&d'�Zd(d)��Zdld*d+�Zdmd,d-�Zed.d/���Zej d0d/���Zed1d2���Z!e!j d3d2���Z!ed4d5���Z"e"j d6d5���Z"ed7d8���Z#e#j d9d8���Z#d:Z$d;Z%d<d=��Z&h�d>�Z'd?d@��Z(dAdB��Z)dCdD��Z*dEdF��Z+dGdH��Z,dndIdJ�Z-dKdL��Z.dMdN��Z/dodOdP�Z0dQdR��Z1dpdSdT�Z2dUdV��Z3dqdWdX�Z4dYdZ��Z5ed[d\���Z6d]d^��Z7drd_d`�Z8dadb��Z9dcdd��Z:���Z;S�)s�Contexta��Context 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 ����������� ���������sz���|rd|�_�n0t���} tt�| ���t�| �}t�| ��d|�_�tt|��� |��||�_ ||�_||�_||�_ ||�_||�_||�_dS�)a��Construct 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���Znew_gpgme_ctx_t_pr���� gpgme_newZgpgme_ctx_t_p_valueZdelete_gpgme_ctx_t_pr���rS���r����armor�textmode�offline�signers� pinentry_mode�protocol�home_dir) r���rV���rW���rX���rY���rZ���r[���r���r\����tmpr���r���r���r�������s���� zContext.__init__c�����������������C���s&���|s|du�rdS�|��dtj��|���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�datar���r���r����__read__����s����zContext.__read__c�����������������C���s ���d��|��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}))r���r���r���r���r���r�������s�����zContext.__repr__Tc�������������� ������s��|r|nt���}d}||tj�O�}||�tj�O�}||tj�O�}|| tj�O�}|| �tj�O�}��dur�|�j} t|�dd�}tj |�_d��fdd� }|�� |���zz*|r�|��||||��n|��||||��W�n��t j�y��}�z�|����}|r�|����nd}|��||�||f}|���t jk�r.|j�r.t j|j|j|d��|���t jk�rb|����}|j�rbt j|j|j|d��||_|�W�Y�d}~n d}~0�0�W���du�r�| |�_|�r�|�j |dd�����n*��du�r�| |�_|�r�|�j |dd�����0�|����}|�r�|����nd}|��||�||fS�) 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 r���N�_passphrase_cbc��������������������s�����S�r ���r�����hintZdescZprev_bad�hook�� passphraser���r���� passphrase_cb-��s����z&Context.encrypt.<locals>.passphrase_cb��error�resultsr���)N)�Datar ���ZENCRYPT_ALWAYS_TRUSTZENCRYPT_NO_ENCRYPT_TOZENCRYPT_PREPAREZENCRYPT_EXPECT_SIGNZENCRYPT_NO_COMPRESSrZ���r����PINENTRY_MODE_LOOPBACK�set_passphrase_cbZop_encrypt_signZ op_encryptr ���r���Zop_encrypt_result�op_sign_resultrd����getcodeZUNUSABLE_PUBKEYZinvalid_recipientsZInvalidRecipientsrm����UNUSABLE_SECKEY�invalid_signers�InvalidSignersrn���)r���� plaintextZ recipients�signrb���rj���Zalways_trustZadd_encrypt_toZprepareZexpect_sign�compress� ciphertextr%����old_pinentry_mode�old_passphrase_cbrk����erC���Z sig_resultrn���r���ri���r����encrypt����sb����* �� � zContext.encryptc�������������� ������sb��d}d}|r|nt���}��durP|�j}t|�dd�} tj|�_d��fdd� } |��| ��z�zVt|t�rd|}n$|du�r�tj dt d��d}n|}d}|r�|��||��n|��||��W�nZ�t j�y�}�z>|����}|r�|����} nd} |��||�|| f|_|�W�Y�d}~n d}~0�0�W���du�rZ||�_| �rZ|�j| d d�����n*��du�rX||�_| �rX|�j| d d�����0�|����}|�rr|����} nd} |��||�|| f}|j�r�t j|j|d ��|�r^ttdd��| j��| _|du�r^g�}|D�]x}d}|jD�]V}| jD�]<}|jtj@�d k�r��q�|j�r|j|jk�rd}��q$�q�|�r���q4�q�|�s�|�|���q�|�r^t j| ||d ��|S�)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). 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) 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 FNre���c��������������������s�����S�r ���r���rf���ri���r���r���rk������s����z&Context.decrypt.<locals>.passphrase_cbzTctx.decrypt called with verify=None, should be bool or iterable (treating as False).��categoryTr����rn���c�����������������S���s���|�j�tjkS�r �����statusr ���ZNO_ERROR)�sr���r���r����<lambda>���r���z!Context.decrypt.<locals>.<lambda>r���)N)ro���rZ���r���r ���rp���rq���� isinstancer3����warnings�warn�DeprecationWarningZop_decrypt_verifyZ op_decryptr ���r���Zop_decrypt_result�op_verify_resultrd���rn���Zunsupported_algorithmZUnsupportedAlgorithm�list�filter� signatures�subkeys�summary�SIGSUM_VALID�can_sign�fprr#����MissingSignatures)r���rz���rb���rj����verifyZdo_sig_verification� required_keysrw���r{���r|���rk���r}���rC���Z verify_resultrn����missingr=����ok�subkey�sigr���ri���r����decryptY��s�����# � � � �zContext.decryptc�������������� ���C���s����|r|nt���}z|��|||��W�nt�tjy��}�zZ|��||�|����f}|���tjkrv|d�jrvtj |d�j|j |d��||_|�W�Y�d}~n d}~0�0�|����}|��||�|fS�)a��Sign 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 r���rl���N)ro���Zop_signr ���r���rd���rr���rs���rt���ru���rv���rm���rn���)r���rc���rb����modeZ signeddatar}���rn���rC���r���r���r���rx������s ���� �zContext.signc����������� ��� ���C���sR��|r d}n|r|nt���}z&|r.|��||d��n|��|d|��W�n@�tjy~�}�z&|��||�|����f|_|�W�Y�d}~n d}~0�0�|��||�|����f}tdd��|d�jD���r�tj |d�|d��t ��}|D�]j} d} | jD�]L}|d�jD�]2}|jt j@�dkr�q�|jr�|j|jkr�d} ��qq�| r���q$q�| s�|�| ��q�|�rNtj|d�||d��|S�) 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 Nc�����������������s���s���|�]}|j�tjkV��qd�S�r ���r����)r���r����r���r���r���� <genexpr>!��r���z!Context.verify.<locals>.<genexpr>r���r����Fr���T)ro���Z op_verifyr ���r���rd���r����rn����anyr����Z BadSignaturesr����r����r����r ���r����r����r����r#���r����) r���Zsigned_dataZ signaturerb���r����rc���r}���rn���r����r=���r����r����r����r���r���r���r�������s@���� �zContext.verifyc�������������� ���C���s����z.|���|��|����}|jdkr&tj}ntj}W�n��ty��}�zr|tjkrb|j dkrZtj }q�tj}nB|tkr�t |d�du�r�tj}n$|tkr�t |d�du�r�tj}ntj}W�Y�d}~n d}~0�0�|tjkr�|}n|}|S�)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. r���zNo data�decodeT�encodeN)Z op_importZop_import_resultZ consideredr ���ZSTATUS_IMPORT_PROBLEMZSTATUS_KEY_CONSIDERED� Exceptionr ���r���Zcode_strZ STATUS_NODATAZSTATUS_FILE_ERROR� TypeError�hasattrZSTATUS_NO_PUBKEYZSTATUS_ERROR)r���rc���rC���r����r}���Z import_resultr���r���r���� key_import8��s(���� zContext.key_importc�������������� ���C���sv���t���}d}z(|��|||��|�dtj��|���}W�n(�tyZ�}�z|�W�Y�d}~n d}~0�0�t|�dkrn|}nd}|S�)aQ��Export 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. r���N)ro���� op_exportr^���r_���r`���ra���r����len�r����patternrc���r����Z pk_resultr}���rC���r���r���r���� key_exportg��s����zContext.key_exportc�������������� ���C���sx���t���}tj}z(|��|||��|�dtj��|���}W�n(�ty\�}�z|�W�Y�d}~n d}~0�0�t |�dkrp|}nd}|S�)ay��Export 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. r���N) ro���r���ZGPGME_EXPORT_MODE_MINIMALr����r^���r_���r`���ra���r���r����r����r���r���r����key_export_minimal���s����zContext.key_export_minimalc�������������� ���C���sx���t���}tj}z(|��|||��|�dtj��|���}W�n(�ty\�}�z|�W�Y�d}~n d}~0�0�t |�dkrp|}nd}|S�)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. r���N) ro���r���ZGPGME_EXPORT_MODE_SECRETr����r^���r_���r`���ra���r���r����)r���r����rc���r����Z sk_resultr}���rC���r���r���r����key_export_secret���s����zContext.key_export_secretc�����������������c���sd���|s|���|��|��||��n t|t�s0t|d�}|��|d��|����}|rX|V��|����}qD|�����dS�)a��List 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 )�filer���N)Zset_keylist_mode�op_keylist_startr����ro���Zop_keylist_from_data_start�op_keylist_next�op_keylist_end)r���r�����secretr�����sourcer=���r���r���r����keylist���s���� zContext.keylistr���c�������������� ������s ��t�����r<|�j}t|�dd�}tj|�_d��fdd� } |��| ��z�|��||d|d|rXtjj nd|rftjj ndB�|rvtjjndB�|r�tjjndB���du�r�tjj ndB�|r�dntjjB�| r�tjjndB���W�t�����r�||�_|r�|�j|dd�����n,t������r||�_|�r|�j|dd�����0�|����S�)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 re���Nc��������������������s�����S�r ���r���rf���ri���r���r���rk���:��s����z)Context.create_key.<locals>.passphrase_cbr���r���)N)r����is_a_stringrZ���r���r ���rp���rq���Zop_createkey�create�SIGN�ENCRZCERT�AUTH�NOPASSWD�NOEXPIREZFORCE�op_genkey_result)r���Zuserid� algorithm� expires_in�expiresrx���r~���Zcertify�authenticaterj����forcer{���r|���rk���r���ri���r���� create_key���sH����; ������� �zContext.create_keyc �������������� ������s����t�����r<|�j} t|�dd�} tj|�_d��fdd� }|��|��z�|��||d||rVtjj nd|rdtjj ndB�|rttjjndB���du�r�tjjndB�|r�dntjj B���W�t�����r�| |�_| r�|�j| dd�����n(t�����r�| |�_| r�|�j| dd�����0�|����S�)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 re���Nc��������������������s�����S�r ���r���rf���ri���r���r���rk������s����z,Context.create_subkey.<locals>.passphrase_cbr���r���)N)r���r����rZ���r���r ���rp���rq���Zop_createsubkeyr����r����r����r����r����r����r����)r���r=���r����r����r����rx���r~���r����rj���r{���r|���rk���r���ri���r���� create_subkeyU��s>����6 ����� � zContext.create_subkeyc�����������������C���s���|���||d��dS�)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 r���N)Z op_adduid�r���r=����uidr���r���r����key_add_uid���s���� zContext.key_add_uidc�����������������C���s���|���||d��dS�)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 r���N)Z op_revuidr����r���r���r����key_revoke_uid���s���� zContext.key_revoke_uidc�����������������C���sb���d}|du�s.t��|�rn|tjjO�}d�|�}|s>|tjjO�}|rN|tjjO�}|��||||��dS�)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 r���N� ) r���r����r ���ZkeysignZLFSEPr$���r�����LOCALZ op_keysign)r���r=���Zuidsr�����localr%���r���r���r����key_sign���s���� zContext.key_signc�����������������C���s���|���||��dS�)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)Zop_tofu_policy)r���r=���Zpolicyr���r���r����key_tofu_policy���s���� zContext.key_tofu_policyc����������� ��� ���C���s����t��|�st|t�r|}nd�dd��|D���}t���}t�|�j||rRt � |��|fnd|rft � |��|fnd|rzt � |��|fnd|�}|�jr�t�|���t |��t�|�}t�|��|dkr�t|�S�dS�)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 r ���c�����������������s���s���|�]}t��|�V��qd�S�r ���)r���Zpercent_escaper���r���r���r���r������r���z*Context.assuan_transact.<locals>.<genexpr>Nr���)r���r����r�����bytesr$���r����new_gpgme_error_t_pZgpgme_op_assuan_transact_extr����weakref�refr���r@���r����gpgme_error_t_p_value�delete_gpgme_error_t_pr���) r���ZcommandZdata_cbZ inquire_cbZ status_cb�cmdZerrptr�errr����r���r���r����assuan_transact���s,�������� zContext.assuan_transactc�����������������C���sr���|du�rt�d��|du�rt��}|r4t�|��||f}nt�|��|f}t�|�j||||�}|�jrft�|���t |��dS�)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) � ValueErrorro���r����r����r���Zgpgme_op_interactr���r���r@���r���)r���r=���rD���rb���r%���� fnc_valueZ opaquedatarC���r���r���r����interact'��s����� zContext.interactc��������������������s�����fdd�t�������D��S�)zKeys used for signingc��������������������s���g�|�]}����|��qS�r���)Zsigners_enum�r����ir���r���r���r���K��r���z#Context.signers.<locals>.<listcomp>)�rangeZ signers_countr���r���r���r���rY���H��s����zContext.signersc�����������������C���s@���|�j�}|�����z|D�]}|��|��qW�n���||�_���Y�n0�d�S�r ���)rY���Z signers_clearZsigners_add)r���rY����oldr=���r���r���r���rY���M��s����c�����������������C���s���|�����S�)z Pinentry mode)Zget_pinentry_moder���r���r���r���rZ���X��s����zContext.pinentry_modec�����������������C���s���|���|��d�S�r ���)Zset_pinentry_mode�r���r7���r���r���r���rZ���]��s����c�����������������C���s���|�����S�)zProtocol to use)Zget_protocolr���r���r���r���r[���a��s����zContext.protocolc�����������������C���s���t�t�|���|��|��d�S�r ���)r���r����gpgme_engine_check_versionZset_protocolr����r���r���r���r[���f��s����c�����������������C���s���|�j�jS�)zEngine's home directory)�engine_infor\���r���r���r���r���r\���k��s����zContext.home_dirc�����������������C���s���|�j�|�j|d��d�S�)N)r\���)�set_engine_infor[���r����r���r���r���r\���p��s����Zgpgme_ctx_tZgpgme_c�����������������C���s���|��d�r|�d��p|dv�S�)�?This function should list all functions returning gpgme_error_tZ gpgme_op_Z_result>���Zgpgme_set_keylist_modeZgpgme_set_senderZgpgme_ctx_set_engine_infoZgpgme_set_sub_protocolZgpgme_get_sig_keyrU���Zgpgme_signers_add�gpgme_set_locale� gpgme_get_keyZgpgme_cancelZgpgme_set_pinentry_modeZgpgme_sig_notation_addZgpgme_set_protocolZgpgme_cancel_asyncZgpgme_set_ctx_flag)� startswith�endswithr0���r���r���r���r2���w��s ���� ��zContext._errorcheck>���rV���rX���rW���c�����������������C���sH���t�sd�S�|�����|�����|�����|�jrD|�jrDt�jrDt��|�j��d�|�_d�S�r ���)r����_free_passcb�_free_progresscb�_free_statuscbrT���r���Z gpgme_releaser���r���r���r����__del__���s����zContext.__del__c�����������������C���s���|�S�r ���r���r���r���r���r���� __enter__���s����zContext.__enter__c�����������������C���s���|������d�S�r ����r�����r����typer7����tbr���r���r����__exit__���s����zContext.__exit__c�����������������o���s8���|�j�|i�|���|����}|r,|V��|����}q|�����d�S�r ���)r����r����r����)r���rB����kwargsr=���r���r���r����op_keylist_all���s���� zContext.op_keylist_allc�������������� ���C���s����t����}z tt��|�j|���t��|�}W�n<�tjyd�}�z"d}|���tj krP|�W�Y�d}~n d}~0�0�t�� |��|r�dd��|_|S�dS�)z~Returns the next key in the list created by a call to op_keylist_start(). The object returned is of type Key.Nc�����������������S���s ���t��|��S�r ����r���Zgpgme_key_unrefr���r���r���r���r�������r���z)Context.op_keylist_next.<locals>.<lambda>)r����new_gpgme_key_t_pr���Zgpgme_op_keylist_nextr����gpgme_key_t_p_valuer ���r���rs����EOF�delete_gpgme_key_t_pr����)r����ptrr=����excpr���r���r���r�������s���� zContext.op_keylist_nextc�������������� ���C���s����t����}ztt��|�j|||���W�nB�tjyd�}�z(|���tjkrLt� |��|�W�Y�d}~n d}~0�0�t�� |�}t��|��dd��|_|S�)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�����������������S���s ���t��|��S�r ���r����r���r���r���r���r�������r���z!Context.get_key.<locals>.<lambda>) r���r����r���r����r���r ���r���rs���r����ZKeyNotFoundr����r����r����)r���r����r����r����r}���r=���r���r���r����get_key���s���� zContext.get_keyc�����������������o���s8���|�j�|i�|���|����}|r,|V��|����}q|�����d�S�r ���)Zop_trustlist_start�op_trustlist_nextZop_trustlist_end)r���rB���r�����trustr���r���r����op_trustlist_all���s���� zContext.op_trustlist_allc�������������� ���C���sr���t����}z tt��|�j|���t��|�}W�n:�tjyb�}�z d}|���tj krN��W�Y�d}~n d}~0�0�t�� |��|S�)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���Znew_gpgme_trust_item_t_pr���Zgpgme_op_trustlist_nextr���Zgpgme_trust_item_t_p_valuer ���r���rs���r����Zdelete_gpgme_trust_item_t_p)r���r����r����r����r���r���r���r�������s���� zContext.op_trustlist_nextc�����������������C���sF���|du�rd}n(|du�r&t��|��|f}nt��|��||f}t�|�|��dS�)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)r����r����r����gpg_set_passphrase_cb�r���rD���rh����hookdatar���r���r���rq������s����zContext.set_passphrase_cbc�����������������C���s���t�jr|��d���d�S�r ���)r���r����rq���r���r���r���r���r������s����zContext._free_passcbc�����������������C���sF���|du�rd}n(|du�r&t��|��|f}nt��|��||f}t�|�|��dS�)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)r����r����r����gpg_set_progress_cbr����r���r���r����set_progress_cb��s����zContext.set_progress_cbc�����������������C���s���t�jr|��d���d�S�r ���)r���r����r����r���r���r���r���r������s����zContext._free_progresscbc�����������������C���sF���|du�rd}n(|du�r&t��|��|f}nt��|��||f}t�|�|��dS�)aP��Sets 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)r����r����r����gpg_set_status_cbr����r���r���r���� set_status_cb��s����zContext.set_status_cbc�����������������C���s���t�jr|��d���d�S�r ���)r���r����r���r���r���r���r���r����2��s����zContext._free_statuscbc��������������������s$���|�j�����fdd�|����D��}|d�S�)z,Configuration of the engine currently in usec��������������������s���g�|�]}|j���kr|�qS�r���)r[���r�����r>���r���r���r���:��r���z'Context.engine_info.<locals>.<listcomp>r���)r[����get_engine_info)r���Zinfosr���r��r���r����6��s����zContext.engine_infoc�����������������C���s���t��|�j�S�)z�Get engine configuration Returns information about all configured and installed engines. Returns: infos -- a list of engine infos )r���Zgpgme_ctx_get_engine_infor���r���r���r���r���r��>��s���� zContext.get_engine_infoc�����������������C���s���|���|||��dS�)a6��Change 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)Zctx_set_engine_info)r����proto� file_namer\���r���r���r���r����J��s����zContext.set_engine_infoc�����������������C���s8���t����}t��|�j||��t��|�}t��|��t|��dS�)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)r���r����� gpgme_waitr���r����r����r���)r����hangr����r����r���r���r����waitW��s ���� zContext.waitc�����������������C���s ���t�jdtd��|�j||||d�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���)rb���r����)r����r����r����r����)r���r=���rD���r�����outr���r���r����op_editd��s�����zContext.op_edit)NNT)N)N)N) Nr���TFFFFNF)Nr���TFFFN)NFF)NNN)Nr���N)F)N)N)N)NN)<r!���rM���rN���rF���r ���ZPINENTRY_MODE_DEFAULTZPROTOCOL_OpenPGPr���rd���r���r~���r����ZSIG_MODE_NORMALrx���r����r����r����r����r����r����r����r����r����r����r����r����r����r����r����r����r;���rY����setterrZ���r[���r\���r.���r/���r2���r"���r����r����r����r����r����r����r����r����rq���r����r����r����r���r����r����r��r����r��r ��rR���r���r���r���r���rS�������s���� �& � c v+>/ " # *� '���������� ]�������� S )���� 2 ! rS���c�����������������������s����e�Zd�ZdZdZdZdd��Zd'��fdd � Zd d��Zdd ��Z dd��Z dd��Zdd��Zd(dd�Z d)dd�Zd*dd�Zdd��Zdd��Zdd��Zd d!��Zd"d#��Zd+d%d&�Z���ZS�),ro���aJ��Data 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. Zgpgme_data_tZgpgme_data_c�����������������C���s���|dvS�)r����> ����gpgme_data_readZgpgme_data_release_and_get_memZgpgme_data_get_encoding�gpgme_data_release�gpgme_data_writeZgpgme_data_seekZgpgme_data_set_flagZgpgme_data_identifyZgpgme_data_get_file_namer���r0���r���r���r���r2������s����zData._errorcheckNTc��������������������s����t�t|���d��d|�_|dur*|�j|���nr|dur@|��||��n\|durh|durh|durh|��|||��n4|dur�t�|�r�|�� ||��q�|�� |��n|�����dS�)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)r���ro���r���Zdata_cbs�new_from_cbs�new_from_mem�new_from_filepartr���r����� new_from_file�new_from_fd�new)r����stringr�����offset�lengthZcbs�copyr���r���r���r������s����/ z Data.__init__c�����������������C���sF���t�sd�S�|�jd�ur:t�jr:t��|�j��|�jr4t��|���d�|�_|�����d�S�r ���)r���r���r��r���r@���� _free_datacbsr���r���r���r���r�������s���� zData.__del__c�����������������C���s���|�S�r ���r���r���r���r���r���r�������s����zData.__enter__c�����������������C���s���|������d�S�r ���r����r����r���r���r���r�������s����z Data.__exit__c�����������������C���s ���d�|�_�d�S�r ���)Z _data_cbsr���r���r���r���r�����s����zData._free_datacbsc�����������������C���s0���t����}tt��|���t��|�|�_t��|��d�S�r ���)r����new_gpgme_data_t_pr���Zgpgme_data_new�gpgme_data_t_p_valuer����delete_gpgme_data_t_p)r���r]���r���r���r���r�����s����zData.newc�����������������C���s:���t����}tt��||t|�|���t��|�|�_t��|��d�S�r ���)r���r��r���Zgpgme_data_new_from_memr����r��r���r��)r���r��r��r]���r���r���r���r�����s�����zData.new_from_memc�������������� ���C���s����t����}ztt��|||���W�nF�tjyd�}�z,|���tjkrL|sLtd��n|�W�Y�d�}~n d�}~0�0�t�� |�|�_ t��|��d�S�)Nz#delayed reads are not yet supported)r���r��r���Zgpgme_data_new_from_filer ���r���rs���Z INV_VALUEr����r��r���r��)r����filenamer��r]���r}���r���r���r���r�����s���� zData.new_from_filec�����������������C���sd���t����}|d�ur(t�|��|||||f}nt�|��||||f}t��|�||��t��|�|�_t��|��d�S�r ���)r���r��r����r����Zgpg_data_new_from_cbsr��r���r��)r���Zread_cbZwrite_cbZseek_cbZ release_cbrh���r]���r����r���r���r���r����s������zData.new_from_cbsc�����������������C���s����t����}d}d}t�|�r |}n6t��|���|j�}|du�rVtdtt |��t|�f���t t��|||||���t��|�|�_ t��|��dS�)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. Nz"Failed to open file from %s arg %s)r���r��r���r�����fdopen�filenor����r�����strr����r���Zgpgme_data_new_from_filepartr��r���r��)r���r����r��r��r]���r���fpr���r���r���r����s&���� ����zData.new_from_filepartc�����������������C���s6���t����}tt��||������t��|�|�_t��|��dS�)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)r���r��r���Zgpgme_data_new_from_fdr��r��r���r��)r���r����r]���r���r���r���r��2��s����zData.new_from_fdc�����������������C���s���|���|��dS�)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���r���r����r���r���r����new_from_stream=��s����zData.new_from_streamc�����������������C���s���|���|��dS�)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!��r���r���r����new_from_estreamC��s����zData.new_from_estreamc�����������������C���s4���t��|�j|�}|dk�r0|�jr(t��|���nt����|S�)zkWrite buffer given as string or bytes. If a string is given, it is implicitly encoded using UTF-8.r���)r���r ��r���r���r@���r���ZfromSyserror)r����bufferZwrittenr���r���r����writeI��s����z Data.write���c�����������������C���s����|dkrdS�|dkrLzt��|�j|�}W�n ���|�jr@t��|���n��Y�n0�|S�g�}zt��|�jd�}W�n ���|�jr|t��|���n��Y�n0�t|�dkr�q�|�|��qPd�|�S�dS�)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�����i���r���N)r���r��r���r���r@���r����r#���r$���)r����sizerC����chunksr���r���r���ra���U��s*����z Data.read)NNNNNT)T)T)N)r&��)r!���rM���rN���rF���r.���r/���r2���r���r����r����r����r��r��r��r��r��r��r��r"��r#��r%��ra���rR���r���r���r���r���ro���u��s2����������@ ro���c�����������������C���s ���t��|��S�)z�Return short algorithm string Return a public key algorithm string (e.g. "rsa2048") for a given SUBKEY. Returns: algo - a string )r���Zgpgme_pubkey_algo_string)r����r���r���r����pubkey_algo_stringy��s���� r*��c�����������������C���s ���t��|��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���Zgpgme_pubkey_algo_name�Zalgor���r���r����pubkey_algo_name���s���� r,��c�����������������C���s ���t��|��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���Zgpgme_hash_algo_namer+��r���r���r����hash_algo_name���s���� r-��c�����������������C���s ���t��|��S�)ztGet protocol description Get the string describing protocol PROTO. Returns: proto - a string )r���Zgpgme_get_protocol_name�r��r���r���r����get_protocol_name���s���� r/��c�����������������C���s ���t��|��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���Zgpgme_addrspec_from_uid)r����r���r���r����addrspec_from_uid���s���� r0��c�����������������C���s ���t��|��S�r ���)r���Zgpgme_check_version)�versionr���r���r���� check_version���s����r2��c�����������������C���s0���zt�t�|����W�dS��tjy*���Y�dS�0�d�S�)NTF)r���r���r����r ���r���r.��r���r���r����engine_check_version���s ����r3��c������������������C���sL���t����}�ztt��|����t��|��}W�n�tjy<���d�}Y�n0�t��|���|S�r ���)r���Znew_gpgme_engine_info_t_pr���Zgpgme_get_engine_infoZgpgme_engine_info_t_p_valuer ���r���Zdelete_gpgme_engine_info_t_p)r�����infor���r���r���r�����s���� r��c�����������������C���s���t�t�|�||���dS�)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)r���r���Zgpgme_set_engine_info)r��r��r\���r���r���r���r�������s����r����c�����������������C���s���t�t�d|�|���dS�)z(Sets the default locale used by contextsN)r���r���r����)r����r7���r���r���r���� set_locale���s����r5��c�����������������C���sL���t����}t��d||��}t��|�}t��|��|du�r<t|��nt|�}||fS�)aF��Wait 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)r���r����r��r����r����r���rS���)r��r�����contextr����r���r���r���r�����s���� r��)N)N)Z __future__r���r���r���rP���r_���r����r����r'��r���r ���r���r���r ���r����objectr���rS���ro���r*��r,��r-��r/��r0��r2��r3��r��r����r5��r��r���r���r���r����<module>���sJ�������������M��