| Server IP : 217.160.0.135 / Your IP : 216.73.217.25 Web Server : Apache System : Linux www 6.18.52-i1-ampere #1203 SMP Mon Sep 14 18:29:59 CEST 2026 aarch64 User : sws1074145052 ( 1074145052) PHP Version : 8.3.32 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /lib/python3/dist-packages/Cryptodome/Cipher/__pycache__/ |
Upload File : |
�
8�tcE* � � � d Z dgZddlmZ ddlmZmZmZmZm Z m
Z
mZmZ ddl
mZ edd� � Z G d� de� � Zd � Zd
S )z
Counter Feedback (CFB) mode.
�CfbMode� )�_copy_bytes)�load_pycryptodome_raw_lib�VoidPointer�create_string_buffer�get_raw_buffer�SmartPointer�c_size_t�c_uint8_ptr�is_writeable_buffer)�get_random_byteszCryptodome.Cipher._raw_cfba
int CFB_start_operation(void *cipher,
const uint8_t iv[],
size_t iv_len,
size_t segment_len, /* In bytes */
void **pResult);
int CFB_encrypt(void *cfbState,
const uint8_t *in,
uint8_t *out,
size_t data_len);
int CFB_decrypt(void *cfbState,
const uint8_t *in,
uint8_t *out,
size_t data_len);
int CFB_stop_operation(void *state);c �( � e Zd ZdZd� Zdd�Zdd�ZdS )r a� *Cipher FeedBack (CFB)*.
This mode is similar to CFB, but it transforms
the underlying block cipher into a stream cipher.
Plaintext and ciphertext are processed in *segments*
of **s** bits. The mode is therefore sometimes
labelled **s**-bit CFB.
An Initialization Vector (*IV*) is required.
See `NIST SP800-38A`_ , Section 6.3.
.. _`NIST SP800-38A` : http://csrc.nist.gov/publications/nistpubs/800-38a/sp800-38a.pdf
:undocumented: __init__
c �v � t � � | _ t � |� � � t |� � t
t |� � � � t
|� � | j � � � � � }|rt d|z � � �t | j � � � t j � � | _ |� � � t |� � | _
t dd|� � | _ | j | _ | j | j g| _ dS )a� Create a new block cipher, configured in CFB mode.
:Parameters:
block_cipher : C pointer
A smart pointer to the low-level block cipher instance.
iv : bytes/bytearray/memoryview
The initialization vector to use for encryption or decryption.
It is as long as the cipher block.
**The IV must be unpredictable**. Ideally it is picked randomly.
Reusing the *IV* for encryptions performed with the same key
compromises confidentiality.
segment_size : integer
The number of bytes the plaintext and ciphertext are segmented in.
z)Error %d while instantiating the CFB modeN)r �_state�raw_cfb_lib�CFB_start_operation�getr r
�len�
address_of�
ValueErrorr �CFB_stop_operation�release�
block_sizer �iv�IV�encrypt�decrypt�_next)�self�block_cipherr �segment_size�results �=/usr/lib/python3/dist-packages/Cryptodome/Cipher/_mode_cfb.py�__init__zCfbMode.__init__J s � �( "�m�m����0�0��1A�1A�1C�1C�1<�R���19�#�b�'�'�1B�1B�19�,�1G�1G�15��1G�1G�1I�1I� K� K��
� S��H�6�Q�R�R�R� #�4�;�?�?�#4�#4�#.�#A�C� C���
�������b�'�'���@��d�D�"�-�-��� &� �'�����|�T�\�3��
�
�
� Nc
�p � | j | j vrt d� � �| j g| _ |�t t |� � � � }n_|}t |� � st d� � �t |� � t |� � k rt
dt |� � z � � �t � | j �
� � t |� � t |� � t t |� � � � � � }|rt
d|z � � �|�t |� � S dS )a� Encrypt data with the key and the parameters set at initialization.
A cipher object is stateful: once you have encrypted a message
you cannot encrypt (or decrypt) another message using the same
object.
The data to encrypt can be broken up in two or
more pieces and `encrypt` can be called multiple times.
That is, the statement:
>>> c.encrypt(a) + c.encrypt(b)
is equivalent to:
>>> c.encrypt(a+b)
This function does not add any padding to the plaintext.
:Parameters:
plaintext : bytes/bytearray/memoryview
The piece of data to encrypt.
It can be of any length.
:Keywords:
output : bytearray/memoryview
The location where the ciphertext must be written to.
If ``None``, the ciphertext is returned.
:Return:
If ``output`` is ``None``, the ciphertext is returned as ``bytes``.
Otherwise, ``None``.
z*encrypt() cannot be called after decrypt()N�4output must be a bytearray or a writeable memoryview�9output must have the same length as the input (%d bytes)z%Error %d while encrypting in CFB mode)r r � TypeErrorr r r r r �CFB_encryptr r r r
r )r � plaintext�output�
ciphertextr"