Файловый менеджер - Редактировать - /opt/imh-python/lib/python3.9/site-packages/Cryptodome/Cipher/__pycache__/_mode_ocb.cpython-39.pyc
Ðазад
a c�h~M � @ s� d Z ddlZddlmZ ddlmZmZ ddlmZm Z ddl mZ ddlm Z ddlmZ dd lmZmZmZmZmZmZmZmZ ed d�ZG dd � d e�Zdd� ZdS )ap Offset Codebook (OCB) mode. OCB is Authenticated Encryption with Associated Data (AEAD) cipher mode designed by Prof. Phillip Rogaway and specified in `RFC7253`_. The algorithm provides both authenticity and privacy, it is very efficient, it uses only one key and it can be used in online mode (so that encryption or decryption can start before the end of the message is available). This module implements the third and last variant of OCB (OCB3) and it only works in combination with a 128-bit block symmetric cipher, like AES. OCB is patented in US but `free licenses`_ exist for software implementations meant for non-military purposes. Example: >>> from Cryptodome.Cipher import AES >>> from Cryptodome.Random import get_random_bytes >>> >>> key = get_random_bytes(32) >>> cipher = AES.new(key, AES.MODE_OCB) >>> plaintext = b"Attack at dawn" >>> ciphertext, mac = cipher.encrypt_and_digest(plaintext) >>> # Deliver cipher.nonce, ciphertext and mac ... >>> cipher = AES.new(key, AES.MODE_OCB, nonce=nonce) >>> try: >>> plaintext = cipher.decrypt_and_verify(ciphertext, mac) >>> except ValueError: >>> print "Invalid message" >>> else: >>> print plaintext :undocumented: __package__ .. _RFC7253: http://www.rfc-editor.org/info/rfc7253 .. _free licenses: http://web.cs.ucdavis.edu/~rogaway/ocb/license.htm � N)� unhexlify)�bord�_copy_bytes)� long_to_bytes� bytes_to_long)�strxor)�BLAKE2s)�get_random_bytes)�load_pycryptodome_raw_lib�VoidPointer�create_string_buffer�get_raw_buffer�SmartPointer�c_size_t�c_uint8_ptr� is_bufferzCryptodome.Cipher._raw_ocba� int OCB_start_operation(void *cipher, const uint8_t *offset_0, size_t offset_0_len, void **pState); int OCB_encrypt(void *state, const uint8_t *in, uint8_t *out, size_t data_len); int OCB_decrypt(void *state, const uint8_t *in, uint8_t *out, size_t data_len); int OCB_update(void *state, const uint8_t *in, size_t data_len); int OCB_digest(void *state, uint8_t *tag, size_t tag_len); int OCB_stop_operation(void *state); c @ s� e Zd ZdZdd� Zdd� Zdd� Zdd � Zd d� Zdd d�Z d dd�Z dd� Zdd� Zdd� Z dd� Zdd� Zdd� Zdd� ZdS )!�OcbModez=Offset Codebook (OCB) mode. :undocumented: __init__ c C s� |j dkrtd��d| _ td d |�| _t|�tdd�vr@td��t|�sPtd��|| _d| krjdkstn td��d | _ d| _ d| _| j| j | j| j| jg| _t|�}|�d �}t�d | jd>