← Back
Editing: AES.cpython-311.pyc
� 8�tcQ% � �0 � d Z ddlZddlmZ ddlmZmZmZmZm Z ddl mZ ddlm Z dZ ede� � Z dZ ej � � r ed e� d d� � � � Zn# e$ r Y nw xY wd� Zd � Zd� ZdZdZdZdZdZdZdZdZdZdZ dZ!dZ"dZ#dS )a� Module's constants for the modes of operation supported with AES: :var MODE_ECB: :ref:`Electronic Code Book (ECB) <ecb_mode>` :var MODE_CBC: :ref:`Cipher-Block Chaining (CBC) <cbc_mode>` :var MODE_CFB: :ref:`Cipher FeedBack (CFB) <cfb_mode>` :var MODE_OFB: :ref:`Output FeedBack (OFB) <ofb_mode>` :var MODE_CTR: :ref:`CounTer Mode (CTR) <ctr_mode>` :var MODE_OPENPGP: :ref:`OpenPGP Mode <openpgp_mode>` :var MODE_CCM: :ref:`Counter with CBC-MAC (CCM) Mode <ccm_mode>` :var MODE_EAX: :ref:`EAX Mode <eax_mode>` :var MODE_GCM: :ref:`Galois Counter Mode (GCM) <gcm_mode>` :var MODE_SIV: :ref:`Syntethic Initialization Vector (SIV) <siv_mode>` :var MODE_OCB: :ref:`Offset Code Book (OCB) <ocb_mode>` � N)�_create_cipher)�load_pycryptodome_raw_lib�VoidPointer�SmartPointer�c_size_t�c_uint8_ptr)� _cpu_features)�get_random_bytesa int AES_start_operation(const uint8_t key[], size_t key_len, void **pResult); int AES_encrypt(const void *state, const uint8_t *in, uint8_t *out, size_t data_len); int AES_decrypt(const void *state, const uint8_t *in, uint8_t *out, size_t data_len); int AES_stop_operation(void *state); zCryptodome.Cipher._raw_aeszCryptodome.Cipher._raw_aesni�AES�AESNIc � � | � dd� � } | � d� � }n# t $ r t d� � �w xY wt |� � t vrt dt |� � z � � �|r t rt j }t j }nt j }t j }t � � } |t |� � t t |� � � � |� � � � � }|rt d|z � � �t! |� � � |� � S )z}This method instantiates and returns a handle to a low-level base cipher. It will absorb named parameters in the process.� use_aesniT�keyzMissing 'key' parameterz#Incorrect AES key length (%d bytes)z+Error %X while instantiating the AES cipher)�pop�KeyError� TypeError�len�key_size� ValueError�_raw_aesni_lib�AESNI_start_operation�AESNI_stop_operation�_raw_aes_lib�AES_start_operation�AES_stop_operationr r r � address_ofr �get)�dict_parametersr r �start_operation�stop_operation�cipher�results �7/usr/lib/python3/dist-packages/Cryptodome/Cipher/AES.py�_create_base_cipherr$ Q s> � � �#�#�K��6�6�I�3��!�!�%�(�(����� 3� 3� 3��1�2�2�2�3���� �3�x�x�x����>��S���I�J�J�J�� 9�^� 9�(�>��'�<���&�:��%�8�� �]�]�F� �_�[��-�-�%�c�#�h�h�/�/�#�.�.�0�0�2� 2�F� � #��F�!�"� #� #� #��� � ���n�5�5�5s �. �Ac �( � t | � � dk rt d� � �|�t d� � }n"t |� � dk rt d� � �t | dd� t � � � |� � }| dd� ||fS )zrDerive a tuple (r, s, nonce) for a Poly1305 MAC. If nonce is ``None``, a new 16-byte nonce is generated. � z(Poly1305 with AES requires a 32-byte keyN� z*Poly1305 with AES requires a 16-byte nonce)r r r �new�MODE_ECB�encrypt)r �nonce�ss r# �_derive_Poly1305_key_pairr- p s� � � �3�x�x�2�~�~��C�D�D�D��}� ��$�$��� �U���r� � ��E�F�F�F��C����H�h���'�'��.�.�A��r�s�s�8�Q���� c �Z � d|d<