403Webshell
Server IP : 192.158.238.246  /  Your IP : 18.118.104.28
Web Server : LiteSpeed
System : Linux uniform.iwebfusion.net 4.18.0-553.27.1.lve.1.el8.x86_64 #1 SMP Wed Nov 20 15:58:00 UTC 2024 x86_64
User : jenniferflocom ( 1321)
PHP Version : 8.1.32
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /opt/alt/python37/lib64/python3.7/site-packages/Crypto/Cipher/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /opt/alt/python37/lib64/python3.7/site-packages/Crypto/Cipher/__pycache__/PKCS1_OAEP.cpython-37.pyc
B

o~�^y$�@sndZdZddgZddlZddlZddlTddlZddlmZddl	m
Z
Gd	d�d�Zdded
�fdd�Z
dS)a{RSA encryption protocol according to PKCS#1 OAEP

See RFC3447__ or the `original RSA Labs specification`__ .

This scheme is more properly called ``RSAES-OAEP``.

As an example, a sender may encrypt a message in this way:

        >>> from Crypto.Cipher import PKCS1_OAEP
        >>> from Crypto.PublicKey import RSA
        >>>
        >>> message = 'To be encrypted'
        >>> key = RSA.importKey(open('pubkey.der').read())
        >>> cipher = PKCS1_OAEP.new(key)
        >>> ciphertext = cipher.encrypt(message)

At the receiver side, decryption can be done using the private part of
the RSA key:

        >>> key = RSA.importKey(open('privkey.der').read())
        >>> cipher = PKCS1_OAP.new(key)
        >>> message = cipher.decrypt(ciphertext)

:undocumented: __revision__, __package__

.. __: http://www.ietf.org/rfc/rfc3447.txt
.. __: http://www.rsa.com/rsalabs/node.asp?id=2125.
z$Id$�new�PKCS1OAEP_Cipher�N)�*)�ceil_div)�strxorc@s8eZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�ZdS)
rzBThis cipher can perform PKCS#1 v1.5 OAEP encryption or decryption.cs@|�_|r|�_n
tjj�_|r(|�_n�fdd��_|�_dS)a�Initialize this PKCS#1 OAEP cipher object.
        
        :Parameters:
         key : an RSA key object
          If a private half is given, both encryption and decryption are possible.
          If a public half is given, only encryption is possible.
         hashAlgo : hash object
                The hash function to use. This can be a module under `Crypto.Hash`
                or an existing hash object created from any of such modules. If not specified,
                `Crypto.Hash.SHA` (that is, SHA-1) is used.
         mgfunc : callable
                A mask generation function that accepts two parameters: a string to
                use as seed, and the lenth of the mask to generate, in bytes.
                If not specified, the standard MGF1 is used (a safe choice).
         label : string
                A label to apply to this particular encryption. If not specified,
                an empty string is used. Specifying a label does not improve
                security.
 
        :attention: Modify the mask generation function only if you know what you are doing.
                    Sender and receiver must use the same one.
        cstjj�||�j�S)N)�CryptoZ	SignatureZ	PKCS1_PSSZMGF1�_hashObj)�x�y)�self��K/opt/alt/python37/lib64/python3.7/site-packages/Crypto/Cipher/PKCS1_OAEP.py�<lambda>e�z+PKCS1OAEP_Cipher.__init__.<locals>.<lambda>N)�_keyrrZHashZSHA�_mgf�_label)r�key�hashAlgo�mgfunc�labelr)rr
�__init__Ds
zPKCS1OAEP_Cipher.__init__cCs
|j��S)z?Return True/1 if this cipher object can be used for encryption.)r�can_encrypt)rrrr
riszPKCS1OAEP_Cipher.can_encryptcCs
|j��S)z?Return True/1 if this cipher object can be used for decryption.)r�can_decrypt)rrrr
rmszPKCS1OAEP_Cipher.can_decryptcCs|jj}tjj�|jj�}t|d�}|jj	}t
|�}||d|d}|dkrXtd��|j�|j
���}td�|}	||	td�|}
||�}|�|||d�}t|
|�}
|�|
|�}t||�}td�||
}|j�|d�d}td�|t
|�|}|S)a�Produce the PKCS#1 OAEP encryption of a message.
    
        This function is named ``RSAES-OAEP-ENCRYPT``, and is specified in
        section 7.1.1 of RFC3447.
    
        :Parameters:
         message : string
                The message to encrypt, also known as plaintext. It can be of
                variable length, but not longer than the RSA modulus (in bytes)
                minus 2, minus twice the hash output size.
   
        :Return: A string, the ciphertext in which the message is encrypted.
            It is as long as the RSA modulus (in bytes).
        :Raise ValueError:
            If the RSA key length is not sufficiently long to deal with the given
            message.
        ��rzPlaintext is too long.�)rZ	_randfuncr�Util�number�size�nrr�digest_size�len�
ValueErrorrr�digest�bchrrr�encrypt)r�messageZrandFunc�modBits�k�hLenZmLenZps_len�lHashZps�dbZros�dbMask�maskedDB�seedMask�
maskedSeed�em�m�crrr
r&qs(


zPKCS1OAEP_Cipher.encryptcCsLtjj�|jj�}t|d�}|jj}t	|�|ks<||dkrDt
d��|j�|�}td�|t	|�|}|j�
|j���}|d}|d|d�}	||dd�}
|�|
|�}t|	|�}|�|||d�}
t|
|
�}d}||d��td��}|d|�}||k�r
d}|dk�rd}t|�dk�r*d}|�s8t
d��|||dd�S)aDecrypt a PKCS#1 OAEP ciphertext.
    
        This function is named ``RSAES-OAEP-DECRYPT``, and is specified in
        section 7.1.2 of RFC3447.
    
        :Parameters:
         ct : string
                The ciphertext that contains the message to recover.
   
        :Return: A string, the original message.
        :Raise ValueError:
            If the ciphertext length is incorrect, or if the decryption does not
            succeed.
        :Raise TypeError:
            If the RSA key has no private half.
        rrz!Ciphertext with incorrect length.rrNzIncorrect decryption.)rrrrrr rrr!r"r#�decryptr%rrr$rr�findZbord)rZctr(r)r*r2r1r+r
r0r.r/Zseedr-r,ZvalidZoneZlHash1rrr
r4�s6




zPKCS1OAEP_Cipher.decryptN)	�__name__�
__module__�__qualname__�__doc__rrrr&r4rrrr
rAs%8�cCst||||�S)aMReturn a cipher object `PKCS1OAEP_Cipher` that can be used to perform PKCS#1 OAEP encryption or decryption.

    :Parameters:
     key : RSA key object
      The key to use to encrypt or decrypt the message. This is a `Crypto.PublicKey.RSA` object.
      Decryption is only possible if *key* is a private RSA key.
     hashAlgo : hash object
      The hash function to use. This can be a module under `Crypto.Hash`
      or an existing hash object created from any of such modules. If not specified,
      `Crypto.Hash.SHA` (that is, SHA-1) is used.
     mgfunc : callable
      A mask generation function that accepts two parameters: a string to
      use as seed, and the lenth of the mask to generate, in bytes.
      If not specified, the standard MGF1 is used (a safe choice).
     label : string
      A label to apply to this particular encryption. If not specified,
      an empty string is used. Specifying a label does not improve
      security.
 
    :attention: Modify the mask generation function only if you know what you are doing.
      Sender and receiver must use the same one.
    )r)rrrrrrr
r�s)r9�__revision__�__all__ZCrypto.Signature.PKCS1_PSSrZCrypto.Hash.SHAZCrypto.Util.py3compatZCrypto.Util.numberrZCrypto.Util.strxorrr�brrrrr
�<module>2s'

Youez - 2016 - github.com/yon3zu
LinuXploit