%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /opt/alt/python37/lib64/python3.7/site-packages/Crypto/Cipher/__pycache__/
Upload File :
Create Path :
Current File : //opt/alt/python37/lib64/python3.7/site-packages/Crypto/Cipher/__pycache__/blockalgo.cpython-37.pyc

B

Bd\R41�@spdZddlZejddkr0ejddkr0ddlTddlTdZdZdZdZdZ	d	Z
d
Zddd�ZGd
d�d�Z
dS)z4Module with definitions common to all block ciphers.�N��)�*�����cCs6|�|�}t|�|kr.|r&td|��||}|p4|S)zFFind a parameter in tuple and dictionary arguments a function receivesz!Parameter '%s' is specified twice)�get�len�
ValueError)�name�index�args�kwargs�defaultZparam�r�J/opt/alt/python37/lib64/python3.7/site-packages/Crypto/Cipher/blockalgo.py�
_getParameter|s
rc@s(eZdZdZdd�Zdd�Zdd�ZdS)	�	BlockAlgoz)Class modelling an abstract block cipher.cOs�tdd||td�|_|j|_|jtkrH|j|f|�|�|_|jj|_�n^d|_d|_	tdd||�|_|jsrt
d��|j|ttd�|j|jd	d
�}t
|j�|jkr�|�|j|jdd�td�|jd�d|jd�|_n�t
|j�|jdk�rf|j|_|�|jtd�|jd�d|jd�|_|jdd�|jd
d�k�rTt
d��|jdd�|_nt
d|j|jdf��|j|t|j|jd�|jd	d
�|_dS)N�moder)rFZivrzMODE_OPENPGP requires an IV��)Zsegment_size���r���z%Failed integrity check for OPENPGP IVz4Length of IV must be %d or %d bytes for MODE_OPENPGP)r�MODE_ECBr�
block_size�MODE_OPENPGP�new�_cipherZIV�_done_first_block�_done_last_blockr�MODE_CFB�br�encrypt�
_encrypted_IV�decrypt)�self�factory�keyrrZ	IV_cipherrrr�__init__�s>
	zBlockAlgo.__init__cCs�|jtkr�|jt|�|j|j}|dkrn|jr>td|j��d|_|td�|}|j�|�dt|��}n|j�|�}|j	s�|j
|}d|_	|S|j�|�S)aXEncrypt data with the key and the parameters set at initialization.
        
        The cipher object is stateful; encryption of a long block
        of data can be broken up in two or more calls to `encrypt()`.
        That is, the statement:
            
            >>> c.encrypt(a) + c.encrypt(b)

        is always equivalent to:

             >>> c.encrypt(a+b)

        That also means that you cannot reuse an object for encrypting
        or decrypting other data with the same key.

        This function does not perform any padding.
       
         - For `MODE_ECB`, `MODE_CBC`, and `MODE_OFB`, *plaintext* length
           (in bytes) must be a multiple of *block_size*.

         - For `MODE_CFB`, *plaintext* length (in bytes) must be a multiple
           of *segment_size*/8.

         - For `MODE_CTR`, *plaintext* can be of any length.

         - For `MODE_OPENPGP`, *plaintext* must be a multiple of *block_size*,
           unless it is the last chunk of the message.

        :Parameters:
          plaintext : byte string
            The piece of data to encrypt.
        :Return:
            the encrypted data, as a byte string. It is as long as
            *plaintext* with one exception: when encrypting the first message
            chunk with `MODE_OPENPGP`, the encypted IV is prepended to the
            returned ciphertext.
        rzFOnly the last chunk is allowed to have length not multiple of %d bytesTrN)rrrrr!rr#rr$r r%)r'Z	plaintext�padding_length�padded�resrrrr$�s'

zBlockAlgo.encryptcCs�|jtkr~|jt|�|j|j}|dkrn|jr>td|j��d|_|td�|}|j�|�dt|��}n|j�|�}|S|j�|�S)a�Decrypt data with the key and the parameters set at initialization.
        
        The cipher object is stateful; decryption of a long block
        of data can be broken up in two or more calls to `decrypt()`.
        That is, the statement:
            
            >>> c.decrypt(a) + c.decrypt(b)

        is always equivalent to:

             >>> c.decrypt(a+b)

        That also means that you cannot reuse an object for encrypting
        or decrypting other data with the same key.

        This function does not perform any padding.
       
         - For `MODE_ECB`, `MODE_CBC`, and `MODE_OFB`, *ciphertext* length
           (in bytes) must be a multiple of *block_size*.

         - For `MODE_CFB`, *ciphertext* length (in bytes) must be a multiple
           of *segment_size*/8.

         - For `MODE_CTR`, *ciphertext* can be of any length.

         - For `MODE_OPENPGP`, *plaintext* must be a multiple of *block_size*,
           unless it is the last chunk of the message.

        :Parameters:
          ciphertext : byte string
            The piece of data to decrypt.
        :Return: the decrypted data (byte string, as long as *ciphertext*).
        rzFOnly the last chunk is allowed to have length not multiple of %d bytesTrN)	rrrrr!rr#rr&)r'Z
ciphertextr+r,r-rrrr&�s"
zBlockAlgo.decryptN)�__name__�
__module__�__qualname__�__doc__r*r$r&rrrrr�s3;r)N)r1�sys�version_infoZCrypto.Util.py21compatZCrypto.Util.py3compatrZMODE_CBCr"ZMODE_PGPZMODE_OFBZMODE_CTRrrrrrrr�<module>s

	

Zerion Mini Shell 1.0