
    i)                     |    S r S/rSSKJr  SSKJrJrJrJrJ	r	J
r
JrJr  SSKJr  \" SS5      r " S S\5      rS	 rg
)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_byteszCrypto.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                   2    \ rS rSrSrS rSS jrSS jrSrg)	r   7   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           	         [        5       U l        [        R                  UR	                  5       [        U5      [        [        U5      5      [        U5      U R                  R                  5       5      nU(       a  [        SU-  5      e[        U R                  R	                  5       [        R                  5      U l        UR                  5         [        U5      U l         [        SSU5      U l         U R                  U l         SS/U l        g)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encryptdecrypt)r   _stateraw_cfb_libCFB_start_operationgetr   r
   len
address_of
ValueErrorr	   CFB_stop_operationrelease
block_sizer   ivIV_next)selfblock_cipherr   segment_sizeresults        R/var/www/html/trading/venv/lib/python3.13/site-packages/Crypto/Cipher/_mode_cfb.py__init__CfbMode.__init__J   s    ( "m001A1A1C1<R19#b'1B19,1G151G1G1I	K
 H6QRR #4;;??#4#.#A#AC
 	b'@dD"-	& ''+
    Nc           
          SU R                   ;  a  [        S5      eS/U l         Uc  [        [        U5      5      nOLUn[	        U5      (       d  [        S5      e[        U5      [        U5      :w  a  [        S[        U5      -  5      e[        R                  U R                  R                  5       [        U5      [        U5      [        [        U5      5      5      nU(       a  [        SU-  5      eUc  [        U5      $ g)aE  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``.
r   z*encrypt() cannot be called after decrypt()N4output must be a bytearray or a writeable memoryview9output must have the same length as the input  (%d bytes)z%Error %d while encrypting in CFB mode)r   	TypeErrorr   r   r   r   r   CFB_encryptr   r   r   r
   r   )r    	plaintextoutput
ciphertextr#   s        r$   r   CfbMode.encrypt|   s    B DJJ&HII[
>-c)n=JJ&v.. VWW9~V,  "025i."A B B (():)4Y)?)4Z)@)1#i.)AC DvMNN>!*--r'   c           
          SU R                   ;  a  [        S5      eS/U l         Uc  [        [        U5      5      nOLUn[	        U5      (       d  [        S5      e[        U5      [        U5      :w  a  [        S[        U5      -  5      e[        R                  U R                  R                  5       [        U5      [        U5      [        [        U5      5      5      nU(       a  [        SU-  5      eUc  [        U5      $ g)aG  Decrypt data with the key and the parameters set at initialization.

A cipher object is stateful: once you have decrypted a message
you cannot decrypt (or encrypt) another message with the same
object.

The data to decrypt can be broken up in two or
more pieces and `decrypt` can be called multiple times.

That is, the statement:

    >>> c.decrypt(a) + c.decrypt(b)

is equivalent to:

     >>> c.decrypt(a+b)

This function does not remove any padding from the plaintext.

:Parameters:
  ciphertext : bytes/bytearray/memoryview
    The piece of data to decrypt.
    It can be of any length.
:Keywords:
  output : bytearray/memoryview
    The location where the plaintext must be written to.
    If ``None``, the plaintext is returned.
:Return:
  If ``output`` is ``None``, the plaintext is returned as ``bytes``.
  Otherwise, ``None``.
r   z*decrypt() cannot be called after encrypt()Nr)   r*   z%Error %d while decrypting in CFB mode)r   r+   r   r   r   r   r   CFB_decryptr   r   r   r
   r   )r    r/   r.   r-   r#   s        r$   r   CfbMode.decrypt   s    B DJJ&HII[
>,S_=II&v.. VWW:#f+-  "025i."A B B (():)4Z)@)4Y)?)1#j/)BD DvMNN>!),,r'   )r   r   r   r   r   )N)	__name__
__module____qualname____firstlineno____doc__r%   r   r   __static_attributes__ r'   r$   r   r   7   s    $0,d;z;r'   c                    U R                  U5      nUR                  SS5      nUR                  SS5      nSX44:X  a  [        U R                  5      nUb  Ub  [	        S5      eOUn[        U5      U R                  :w  a  [        SU R                  -  5      e[        UR                  SS5      S5      u  pVUS	:X  d  US	:w  a  [        S
5      eU(       a  [	        S[        U5      -  5      e[        X#U5      $ )aH  Instantiate a cipher object that performs CFB encryption/decryption.

:Parameters:
  factory : module
    The underlying block cipher, a module from ``Crypto.Cipher``.

:Keywords:
  iv : bytes/bytearray/memoryview
    The IV to use for CFB.

  IV : bytes/bytearray/memoryview
    Alias for ``iv``.

  segment_size : integer
    The number of bit the plaintext and ciphertext are segmented in.
    If not present, the default is 8.

Any other keyword will be passed to the underlying block cipher.
See the relevant documentation for details (at least ``key`` will need
to be present).
r   Nr   )NNz*You must either use 'iv' or 'IV', not bothz.Incorrect IV length (it must be %d bytes long)r"      r   z6'segment_size' must be positive and multiple of 8 bitszUnknown parameters for CFB: %s)
_create_base_cipherpopr   r   r+   r   r   divmodstrr   )factorykwargscipher_stater   r   segment_size_bytesrems          r$   _create_cfb_cipherrF      s    . ..v6L	D$	B	D$	Bxg001	~>HII  
2w'$$$I""# $ 	$ %VZZ%BAFQ#(QRR83v;FGG<%788r'   N)r8   __all__Crypto.Util.py3compatr   Crypto.Util._raw_apir   r   r   r   r	   r
   r   r   Crypto.Randomr   r   objectr   rF   r:   r'   r$   <module>rL      sQ   . + -7 7 7
 +'(@ B< $}f }@.9r'   