a
    ˜ëj6  ã                   @   s´   d dl mZ d dlmZ dZdZG dd„ deƒZG dd„ deƒZeeed	œd
d„Z	eeed	œdd„Z
eeed	œdd„Zeeed	œdd„Zeeeedœdd„Zeeeedœdd„ZdS )é    )Ú	CryptBase)ÚDependencyErrorz/cryptography>=3.1 is required for AES algorithm)Zlocal_crypt_fallbackz0.0.0c                   @   sD   e Zd Zeddœdd„Zeedœdd„Zdd	œeeed
œdd„ZdS )ÚCryptRC4N©ÚkeyÚreturnc                 C   sh   t tdƒƒ| _d}tdƒD ]H}|| j|  ||t|ƒ   d }| j| | j|  | j|< | j|< qd S )Né   r   )Ú	bytearrayÚrangeÚsÚlen)Úselfr   ÚjÚi© r   ú_/mnt/bigstor/www/usecases/.venv/lib/python3.9/site-packages/pypdf/_crypt_providers/_fallback.pyÚ__init__&   s
    "zCryptRC4.__init__©Údatar   c                 C   s    t | jƒ}dd„ tt|ƒƒD ƒ}d\}}tt|ƒƒD ]b}|d d }|||  d }|| ||  ||< ||< ||| ||  d  }|| |A ||< q4t|ƒS )Nc                 S   s   g | ]}d ‘qS )r   r   )Ú.0Ú_r   r   r   Ú
<listcomp>/   ó    z$CryptRC4.encrypt.<locals>.<listcomp>)r   r   é   r   )r	   r   r
   r   Úbytes)r   r   r   Úoutr   r   ÚkÚxr   r   r   Úencrypt-   s    
zCryptRC4.encryptT©Ústrict©r   r    r   c                C   s
   |   |¡S ©N)r   ©r   r   r    r   r   r   Údecrypt9   s    zCryptRC4.decrypt©Ú__name__Ú
__module__Ú__qualname__r   r   r   Úboolr$   r   r   r   r   r   %   s   r   c                   @   sD   e Zd Zeddœdd„Zeedœdd„Zdd	œeeed
œdd„ZdS )ÚCryptAESNr   c                 C   s   d S r"   r   )r   r   r   r   r   r   >   s    zCryptAES.__init__r   c                 C   s   t tƒ‚d S r"   ©r   Ú_DEPENDENCY_ERROR_STR)r   r   r   r   r   r   A   s    zCryptAES.encryptTr   r!   c                C   s   t tƒ‚d S r"   r+   r#   r   r   r   r$   D   s    zCryptAES.decryptr%   r   r   r   r   r*   =   s   r*   )r   r   r   c                 C   s   t | ƒ |¡S r"   )r   r   ©r   r   r   r   r   Úrc4_encryptH   s    r.   c                 C   s   t | ƒ |¡S r"   )r   r$   r-   r   r   r   Úrc4_decryptL   s    r/   c                 C   s   t tƒ‚d S r"   r+   r-   r   r   r   Úaes_ecb_encryptP   s    r0   c                 C   s   t tƒ‚d S r"   r+   r-   r   r   r   Úaes_ecb_decryptT   s    r1   )r   Úivr   r   c                 C   s   t tƒ‚d S r"   r+   ©r   r2   r   r   r   r   Úaes_cbc_encryptX   s    r4   c                 C   s   t tƒ‚d S r"   r+   r3   r   r   r   Úaes_cbc_decrypt\   s    r5   N)Zpypdf._crypt_providers._baser   Zpypdf.errorsr   r,   Zcrypt_providerr   r*   r   r.   r/   r0   r1   r4   r5   r   r   r   r   Ú<module>   s   