HEX
Server: Apache
System: Linux server2.voipitup.com.au 4.18.0-553.104.1.lve.el8.x86_64 #1 SMP Tue Feb 10 20:07:30 UTC 2026 x86_64
User: posscale (1027)
PHP: 8.2.29
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //lib64/python3.6/site-packages/M2Crypto/__pycache__/RSA.cpython-36.opt-1.pyc
3

6�\�8�@sddlmZddlZddlmZmZmZmZejrZddl	m
Z
mZmZm
Z
mZmZmZmZGdd�de�Zeje�ejZejZejZejZGdd�de�ZGd	d
�d
e�Zdd�Zejfd
d�Zefdd�Zej fdd�Z!ej fdd�Z"ej fdd�Z#dd�Z$dd�Z%dd�Z&dS)�)�absolute_importN)�BIO�Err�m2�util)�Any�AnyStr�Callable�Dict�List�IO�Optional�Tuplec@seZdZdS)�RSAErrorN)�__name__�
__module__�__qualname__�rr�/usr/lib64/python3.6/RSA.pyrsrc@s�eZdZdZejZd1dd�Zdd�Zdd�Z	d	d
�Z
dd�Zd
d�Zdd�Z
dd�Zdd�Zdejfdd�Zdejfdd�ZeZdejfdd�Zdd�Zdd�Zd d!�Zd"d#�Zd$d%�Zd2d(d)�Zd3d*d+�Zd4d,d-�Zd5d.d/�Zd0S)6�RSAz
    RSA Key Pair.
    rcCs||_||_dS)zG
        :param rsa: binary representation of OpenSSL RSA type
        N)�rsa�_pyfree)�selfrrrrr�__init__ szRSA.__init__cCst|dd�r|j|j�dS)Nrr)�getattr�m2_rsa_freer)rrrr�__del__)szRSA.__del__cCsttj|j�d>�S)N�)�intrZrsa_sizer)rrrr�__len__.szRSA.__len__cCs0|dkrtj|j�S|dkr(tj|j�St�dS)N�e�n)r�	rsa_get_er�	rsa_get_n�AttributeError)r�namerrr�__getattr__2s
zRSA.__getattr__cCstj|j�tj|j�fS)N)rr"rr#)rrrr�pub;szRSA.pubcCstj|j||�S)N)rZrsa_public_encryptr)r�data�paddingrrr�public_encrypt@szRSA.public_encryptcCstj|j||�S)N)rZrsa_public_decryptr)rr(r)rrr�public_decryptEszRSA.public_decryptcCstj|j||�S)N)rZrsa_private_encryptr)rr(r)rrr�private_encryptJszRSA.private_encryptcCstj|j||�S)N)rZrsa_private_decryptr)rr(r)rrr�private_decryptOszRSA.private_decryptZaes_128_cbccCs^|dkrtj|j|j�|�Stt|d�}|dkr>td|��n|�}tj|j|j�||�SdS)aC
        Save the key pair to an M2Crypto.BIO.BIO object in PEM format.

        :param bio: M2Crypto.BIO.BIO object to save key to.

        :param cipher: Symmetric cipher to protect the key. The default
                       cipher is 'aes_128_cbc'. If cipher is None, then
                       the key is saved in the clear.

        :param callback: A Python callable object that is invoked
                         to acquire a passphrase with which to protect
                         the key.  The default is
                         util.passphrase_callback.
        Nznot such cipher %s)rZrsa_write_key_no_cipherr�_ptrrrZ
rsa_write_key)r�bio�cipher�callbackZciphrrr�save_key_bioTszRSA.save_key_biocCs&tj|d��}|j|||�SQRXdS)a%
        Save the key pair to a file in PEM format.

        :param file: Name of file to save key to.

        :param cipher: Symmetric cipher to protect the key. The default
                       cipher is 'aes_128_cbc'. If cipher is None, then
                       the key is saved in the clear.

        :param callback: A Python callable object that is invoked
                         to acquire a passphrase with which to protect
                         the key.  The default is
                         util.passphrase_callback.
        �wbN)r�openfiler2)r�filer0r1r/rrr�save_keyoszRSA.save_keycCstj�}|j|||�|j�S)zB
        Returns the key(pair) as a string in PEM format.
        )r�MemoryBufferr2�read)rr0r1r/rrr�as_pem�sz
RSA.as_pemcCstj|j|j��S)z�
        Save the key pair to an M2Crypto.BIO.BIO object in DER format.

        :param bio: M2Crypto.BIO.BIO object to save key to.
        )rZrsa_write_key_derrr.)rr/rrr�save_key_der_bio�szRSA.save_key_der_bioc	Cs"tj|d��}|j|�SQRXdS)zj
        Save the key pair to a file in DER format.

        :param file: Filename to save key to
        r3N)rr4r:)rr5r/rrr�save_key_der�szRSA.save_key_dercCstj|j|j��S)z�
        Save the public key to an M2Crypto.BIO.BIO object in PEM format.

        :param bio: M2Crypto.BIO.BIO object to save key to.
        )r�rsa_write_pub_keyrr.)rr/rrr�save_pub_key_bio�szRSA.save_pub_key_bioc
Cs*tj|d��}tj|j|j��SQRXdS)zq
        Save the public key to a file in PEM format.

        :param file: Name of file to save key to.
        r3N)rr4rr<rr.)rr5r/rrr�save_pub_key�szRSA.save_pub_keycCstj|j�S)a�
        Validate RSA keys.

        It checks that p and q are in fact prime, and that n = p*q.

        :return: returns 1 if rsa is a valid RSA key, and 0 otherwise.
                 -1 is returned if an error occurs while checking the key.
                 If the key is invalid or an error occurred, the reason
                 code can be obtained using ERR_get_error(3).
        )rZ
rsa_check_keyr)rrrr�	check_key�sz
RSA.check_key�sha1�cCsBtt|d�}|dkr td|��tj|j||�|�}|j|tj�S)a�
        Signs a digest with the private key using RSASSA-PSS

        :param digest: A digest created by using the digest method

        :param salt_length: The length of the salt to use

        :param algo: The hash algorithm to use
                     Legal values like 'sha1','sha224', 'sha256',
                     'ripemd160', and 'md5'.

        :return: a string which is the signature
        Nznot such hash algorithm %s)rrrZrsa_padding_add_pkcs1_pssrr,�
no_padding)r�digest�algo�salt_length�hash�	signaturerrr�sign_rsassa_pss�s
zRSA.sign_rsassa_psscCsDtt|d�}|dkr td|��|j|tj�}tj|j|||�|�S)a�
        Verifies the signature RSASSA-PSS

        :param data: Data that has been signed

        :param signature: The signature signed with RSASSA-PSS

        :param salt_length: The length of the salt that was used

        :param algo: The hash algorithm to use
                     Legal values are for example 'sha1','sha224',
                     'sha256', 'ripemd160', and 'md5'.

        :return: 1 or 0, depending on whether the signature was
                 verified or not.
        Nznot such hash algorithm %s)rrrr+rBZrsa_verify_pkcs1_pssr)rr(rGrDrErFZplain_signaturerrr�verify_rsassa_pss�s
zRSA.verify_rsassa_psscCs2ttd|d�}|dkr"td|��tj|j||�S)aT
        Signs a digest with the private key

        :param digest: A digest created by using the digest method

        :param algo: The method that created the digest.
                     Legal values like 'sha1','sha224', 'sha256',
                     'ripemd160', and 'md5'.

        :return: a string which is the signature
        �NID_Nzunknown algorithm)rr�
ValueErrorZrsa_signr)rrCrD�digest_typerrr�sign�s

zRSA.signcCs4ttd|d�}|dkr"td|��tj|j|||�S)a�
        Verifies the signature with the public key

        :param data: Data that has been signed

        :param signature: The signature signed with the private key

        :param algo: The method use to create digest from the data
                     before it was signed.  Legal values like
                     'sha1','sha224', 'sha256', 'ripemd160', and 'md5'.

        :return: 1 or 0, depending on whether the signature was
                 verified or not.
        rJNzunknown algorithm)rrrKZ
rsa_verifyr)rr(rGrDrLrrr�verifys
z
RSA.verifyN)r)r@rA)r@rA)r@)r@)rrr�__doc__rZrsa_freerrrrr&r'r*r+r,r-r�passphrase_callbackr2r6Zsave_pemr9r:r;r=r>r?rHrIrMrNrrrrrs4
				
	



rc@s@eZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dS)�RSA_pubz0
    Object interface to an RSA public key.
    cCs |dkrtd��n
||j|<dS)Nr r!z0use factory function new_pub_key() to set (e, n))r r!)r�__dict__)rr%�valuerrr�__setattr__%s
zRSA_pub.__setattr__cGstd��dS)Nz!RSA_pub object has no private key)r)r�argvrrrr,,szRSA_pub.private_encryptcGstd��dS)Nz!RSA_pub object has no private key)r)rrUrrrr-0szRSA_pub.private_decryptcOs
|j|�S)z*
        Save public key to file.
        )r>)rr5�args�kwrrrr64szRSA_pub.save_keycOs
|j|�S)z)
        Save public key to BIO.
        )r=)rr/rVrWrrrr2;szRSA_pub.save_key_biocCstj|j�S)N)rZrsa_check_pub_keyr)rrrrr?FszRSA_pub.check_keyN)
rrrrOrTr,r-r6r2r?rrrrrQsrQcCsttj���dS)N)rrZget_error_messagerrrr�	rsa_errorKsrXcCs&ddddg}|j||�|j�dS)z)
    Default callback for gen_key().
    �.�+�*�
N)�write�flush)�pr!�outZchrrr�keygen_callbackPsracCsttj|||�d�S)a�
    Generate an RSA key pair.

    :param bits: Key length, in bits.

    :param e: The RSA public exponent.

    :param callback: A Python callable object that is invoked
                     during key generation; its usual purpose is to
                     provide visual feedback. The default callback is
                     keygen_callback.

    :return: M2Crypto.RSA.RSA object.
    �)rrZrsa_generate_key)�bitsr r1rrr�gen_keyZsrdc
Cs tj|��}t||�SQRXdS)aa
    Load an RSA key pair from file.

    :param file: Name of file containing RSA public key in PEM format.

    :param callback: A Python callable object that is invoked
                     to acquire a passphrase with which to unlock the
                     key.  The default is util.passphrase_callback.

    :return: M2Crypto.RSA.RSA object.
    N)rr4�load_key_bio)r5r1r/rrr�load_keyms
rfcCs(tj|j�|�}|dkrt�t|d�S)a�
    Load an RSA key pair from an M2Crypto.BIO.BIO object.

    :param bio: M2Crypto.BIO.BIO object containing RSA key pair in PEM
                format.

    :param callback: A Python callable object that is invoked
                     to acquire a passphrase with which to unlock the
                     key.  The default is util.passphrase_callback.

    :return: M2Crypto.RSA.RSA object.
    Nrb)rZrsa_read_keyr.rXr)r/r1rrrrre~srecCstj|�}t||�S)a^
    Load an RSA key pair from a string.

    :param string: String containing RSA key pair in PEM format.

    :param callback: A Python callable object that is invoked
                     to acquire a passphrase with which to unlock the
                     key. The default is util.passphrase_callback.

    :return: M2Crypto.RSA.RSA object.
    )rr7re)�stringr1r/rrr�load_key_string�s
rhc	Cstj|��
}t|�SQRXdS)z�
    Load an RSA public key from file.

    :param file: Name of file containing RSA public key in PEM format.

    :return: M2Crypto.RSA.RSA_pub object.
    N)rr4�load_pub_key_bio)r5r/rrr�load_pub_key�s	rjcCs&tj|j��}|dkrt�t|d�S)z�
    Load an RSA public key from an M2Crypto.BIO.BIO object.

    :param bio: M2Crypto.BIO.BIO object containing RSA public key in PEM
                format.

    :return: M2Crypto.RSA.RSA_pub object.
    Nrb)rZrsa_read_pub_keyr.rXrQ)r/rrrrri�s
ricCs(|\}}tj�}tj|||�t|d�S)a�
    Instantiate an RSA_pub object from an (e, n) tuple.

    :param e: The RSA public exponent; it is a string in OpenSSL's MPINT
              format - 4-byte big-endian bit-count followed by the
              appropriate number of bits.

    :param n: The RSA composite of primes; it is a string in OpenSSL's
              MPINT format - 4-byte big-endian bit-count followed by the
              appropriate number of bits.

    :return: M2Crypto.RSA.RSA_pub object.
    rb)rZrsa_newZ
rsa_set_enrQ)Ze_nr r!rrrr�new_pub_key�srk)'Z
__future__r�sysZM2CryptorrrrZpy27plusZtypingrrr	r
rrr
r�	ExceptionrZrsa_initrBZ
pkcs1_paddingZsslv23_paddingZpkcs1_oaep_padding�objectrrQrX�stdoutrardrPrfrerhrjrirkrrrr�<module>s.(
,