HEX
Server: Apache
System: Linux scp1.abinfocom.com 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64
User: confeduphaar (1010)
PHP: 8.1.33
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //lib/python3/dist-packages/nacl/bindings/__pycache__/crypto_secretstream.cpython-38.pyc
U

�֫[�(�@s�ddlmZmZmZddlmZddlmZm	Z	ddl
mZe	��Z
e	��Ze	��Ze	��Ze	��Ze	��Ze	��Ze	��Ze	��Zdd�ZGdd�de�Z d	d
�Z!defdd
�Z"dd�Z#ddd�Z$dd�Z%dS)�)�absolute_import�division�print_function)�
exceptions)�ffi�lib)�ensurecCs(t�dt�}t�|�t�|�dd�S)zd
    Generate a key for use with
    :func:`.crypto_secretstream_xchacha20poly1305_init_push`.

    �unsigned char[]N)r�new�.crypto_secretstream_xchacha20poly1305_KEYBYTESr�,crypto_secretstream_xchacha20poly1305_keygen�buffer)Zkeybuf�r�C/usr/lib/python3/dist-packages/nacl/bindings/crypto_secretstream.pyr,s�
rc@s"eZdZdZdddgZdd�ZdS)�+crypto_secretstream_xchacha20poly1305_statezN
    An object wrapping the crypto_secretstream_xchacha20poly1305 state.

    �statebuf�rawbuf�tagbufcCst�dt�|_d|_d|_dS)z! Initialize a clean state object.r	N)rr
�0crypto_secretstream_xchacha20poly1305_STATEBYTESrrr)�selfrrr�__init__As�z4crypto_secretstream_xchacha20poly1305_state.__init__N)�__name__�
__module__�__qualname__�__doc__�	__slots__rrrrrr:s
rcCs�tt|t�dtjd�tt|t�dtjd�tt|�tkdtjd�t	�
dt�}t�
|j||�}t|dkdtjd�t	�|�dd�S)	a\
    Initialize a crypto_secretstream_xchacha20poly1305 encryption buffer.

    :param state: a secretstream state object
    :type state: crypto_secretstream_xchacha20poly1305_state
    :param key: must be
                :data:`.crypto_secretstream_xchacha20poly1305_KEYBYTES` long
    :type key: bytes
    :return: header
    :rtype: bytes

    �BState must be a crypto_secretstream_xchacha20poly1305_state object�Zraising�Key must be a bytes sequence�Invalid key lengthzunsigned char []r�Unexpected failureN)r�
isinstancer�exc�	TypeError�bytes�lenr�
ValueErrorrr
�1crypto_secretstream_xchacha20poly1305_HEADERBYTESr�/crypto_secretstream_xchacha20poly1305_init_pushr�RuntimeErrorr
)�state�keyZ	headerbuf�rcrrrr(Ls4
��
���r(Nc
Cs�tt|t�dtjd�tt|t�dtjd�tt|�tkdtjd�t|dkpVt|t�dtjd�t|�t	}|j
dks�t|j
�|kr�t�d|�|_
|dkr�tj
}d}nt|�}t�|j|j
tj
|t|�|||�}t|dkd	tjd�t�|j
|�dd�S)
a�
    Add an encrypted message to the secret stream.

    :param state: a secretstream state object
    :type state: crypto_secretstream_xchacha20poly1305_state
    :param m: the message to encrypt, the maximum length of an individual
              message is
              :data:`.crypto_secretstream_xchacha20poly1305_MESSAGEBYTES_MAX`.
    :type m: bytes
    :param ad: additional data to include in the authentication tag
    :type ad: bytes or None
    :param tag: the message tag, usually
                :data:`.crypto_secretstream_xchacha20poly1305_TAG_MESSAGE` or
                :data:`.crypto_secretstream_xchacha20poly1305_TAG_FINAL`.
    :type tag: int
    :return: ciphertext
    :rtype: bytes

    rrzMessage is not byteszMessage is too longN�%Additional data must be bytes or Noner	rr )rr!rr"r#r$r%�6crypto_secretstream_xchacha20poly1305_MESSAGEBYTES_MAXr&�,crypto_secretstream_xchacha20poly1305_ABYTESrrr
�NULLr�*crypto_secretstream_xchacha20poly1305_pushrr)r
)r*�m�ad�tagZclen�adlenr,rrrr1usF�
���r1cCs�tt|t�dtjd�tt|t�dtjd�tt|�tkdtjd�tt|t�dtjd�tt|�t	kdtjd�|j
dkr�t�d�|_
t
�|j||�}t|d	kd
tjd�dS)a�
    Initialize a crypto_secretstream_xchacha20poly1305 decryption buffer.

    :param state: a secretstream state object
    :type state: crypto_secretstream_xchacha20poly1305_state
    :param header: must be
                :data:`.crypto_secretstream_xchacha20poly1305_HEADERBYTES` long
    :type header: bytes
    :param key: must be
                :data:`.crypto_secretstream_xchacha20poly1305_KEYBYTES` long
    :type key: bytes

    rrzHeader must be a bytes sequencezInvalid header lengthrrNzunsigned char *rr )rr!rr"r#r$r%r'r&rrrr
r�/crypto_secretstream_xchacha20poly1305_init_pullrr))r*�headerr+r,rrrr6�sB��
��
�
�r6c
Cs>tt|t�dtjd�t|jdk	dtjd�tt|t�dtjd�tt|�t	kdtjd�tt|�t
t	kdtjd�t|dkp�t|t�dtjd�t|�t	}|jdks�t|j�|kr�t�
d	|�|_|dkr�tj}d
}nt|�}t�|j|jtj|j|t|�||�}t|d
kdtjd�t�|j|�dd�t|jd
�fS)aM
    Read a decrypted message from the secret stream.

    :param state: a secretstream state object
    :type state: crypto_secretstream_xchacha20poly1305_state
    :param c: the ciphertext to decrypt, the maximum length of an individual
              ciphertext is
              :data:`.crypto_secretstream_xchacha20poly1305_MESSAGEBYTES_MAX` +
              :data:`.crypto_secretstream_xchacha20poly1305_ABYTES`.
    :type c: bytes
    :param ad: additional data to include in the authentication tag
    :type ad: bytes or None
    :return: (message, tag)
    :rtype: (bytes, int)

    rrNzOState must be initialized using crypto_secretstream_xchacha20poly1305_init_pullzCiphertext is not byteszCiphertext is too shortzCiphertext is too longr-r	rr )rr!rr"r#rr&r$r%r/r.rrr
r0r�*crypto_secretstream_xchacha20poly1305_pullrr)r
�int)r*�cr3Zmlenr5r,rrrr8�sj���
������r8cCs&tt|t�dtjd�t�|j�dS)a�
    Explicitly change the encryption key in the stream.

    Normally the stream is re-keyed as needed or an explicit ``tag`` of
    :data:`.crypto_secretstream_xchacha20poly1305_TAG_REKEY` is added to a
    message to ensure forward secrecy, but this method can be used instead
    if the re-keying is controlled without adding the tag.

    :param state: a secretstream state object
    :type state: crypto_secretstream_xchacha20poly1305_state

    rrN)rr!rr"r#r�+crypto_secretstream_xchacha20poly1305_rekeyr)r*rrrr;1s
�r;)N)&Z
__future__rrrZnaclrr"Znacl._sodiumrrZnacl.exceptionsrZ,crypto_secretstream_xchacha20poly1305_abytesr/Z1crypto_secretstream_xchacha20poly1305_headerbytesr'Z.crypto_secretstream_xchacha20poly1305_keybytesrZ6crypto_secretstream_xchacha20poly1305_messagebytes_maxr.Z0crypto_secretstream_xchacha20poly1305_statebytesrZ1crypto_secretstream_xchacha20poly1305_tag_messageZ1crypto_secretstream_xchacha20poly1305_TAG_MESSAGEZ.crypto_secretstream_xchacha20poly1305_tag_pushZ.crypto_secretstream_xchacha20poly1305_TAG_PUSHZ/crypto_secretstream_xchacha20poly1305_tag_rekeyZ/crypto_secretstream_xchacha20poly1305_TAG_REKEYZ/crypto_secretstream_xchacha20poly1305_tag_finalZ/crypto_secretstream_xchacha20poly1305_TAG_FINALr�objectrr(r1r6r8r;rrrr�<module>s<���������,�
@0
L