o
    XzjÀ  ã                   @   s   d Z ddlZG dd„ dƒZdS )z1
This module holds the AESModeCTR wrapper class.
é    Nc                   @   s(   e Zd ZdZdd„ Zdd„ Zdd„ ZdS )	Ú
AESModeCTRz>Wrapper around pyaes.AESModeOfOperationCTR mode with custom IVc                 C   sJ   t |tƒsJ ‚t |¡| _t |tƒsJ ‚t|ƒdksJ ‚t|ƒ| jj_dS )zÊ
        Initializes the AES CTR mode with the given key/iv pair.

        :param key: the key to be used as bytes.
        :param iv: the bytes initialization vector. Must have a length of 16.
        é   N)Ú
isinstanceÚbytesÚpyaesÚAESModeOfOperationCTRÚ_aesÚlenÚlistÚ_counter)ÚselfÚkeyÚiv© r   úQ/var/www/kodo/tsheker/venv/lib/python3.10/site-packages/telethon/crypto/aesctr.pyÚ__init__   s
   zAESModeCTR.__init__c                 C   ó   | j  |¡S )z¢
        Encrypts the given plain text through AES CTR.

        :param data: the plain text to be encrypted.
        :return: the encrypted cipher text.
        )r   Úencrypt©r   Údatar   r   r   r      ó   zAESModeCTR.encryptc                 C   r   )z¢
        Decrypts the given cipher text through AES CTR

        :param data: the cipher text to be decrypted.
        :return: the decrypted plain text.
        )r   Údecryptr   r   r   r   r   #   r   zAESModeCTR.decryptN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r   r   r   r   r   r      s
    	r   )r   r   r   r   r   r   r   Ú<module>   s    