U
    ¯ªhÀ  ã                   @   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t‚t |¡| _t |tƒs(t‚t|ƒdks8t‚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ÚAssertionErrorÚpyaesZAESModeOfOperationCTRÚ_aesÚlenÚlistÚ_counter)ÚselfÚkeyZiv© r   ú:/tmp/pip-unpacked-wheel-c81u5j2r/telethon/crypto/aesctr.pyÚ__init__   s
    zAESModeCTR.__init__c                 C   s   | 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      s    zAESModeCTR.encryptc                 C   s   | j  |¡S )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   #   s    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   