%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /lib/python3/dist-packages/nacl/bindings/__pycache__/
Upload File :
Create Path :
Current File : //lib/python3/dist-packages/nacl/bindings/__pycache__/crypto_secretstream.cpython-312.pyc

�

�f�+���UddlmZmZmZmZddlmZddlm	Z	m
Z
ddlmZe
j�Zeed<e
j"�Zeed<e
j&�Zeed<e
j*�Zeed<e
j.�Zeed	<e
j2�Zeed
<e
j6�Zeed<e
j:�Zeed<e
j>�Z eed
<de!fd�Z"Gd�d�Z#de#de!de!fd�Z$defde#de!dee!dede!f
d�Z%de#de!de!ddfd�Z&	dde#de!dee!dee!effd�Z'de#ddfd�Z(y) �)�
ByteString�Optional�Tuple�cast)�
exceptions)�ffi�lib)�ensure�,crypto_secretstream_xchacha20poly1305_ABYTES�1crypto_secretstream_xchacha20poly1305_HEADERBYTES�.crypto_secretstream_xchacha20poly1305_KEYBYTES�6crypto_secretstream_xchacha20poly1305_MESSAGEBYTES_MAX�0crypto_secretstream_xchacha20poly1305_STATEBYTES�1crypto_secretstream_xchacha20poly1305_TAG_MESSAGE�.crypto_secretstream_xchacha20poly1305_TAG_PUSH�/crypto_secretstream_xchacha20poly1305_TAG_REKEY�/crypto_secretstream_xchacha20poly1305_TAG_FINAL�returnc��tjdt�}tj|�tj
|�ddS)zd
    Generate a key for use with
    :func:`.crypto_secretstream_xchacha20poly1305_init_push`.

    �unsigned char[]N)r�newr
r	�,crypto_secretstream_xchacha20poly1305_keygen�buffer)�keybufs �C/usr/lib/python3/dist-packages/nacl/bindings/crypto_secretstream.pyrr4s<���W�W��6��F��4�4�V�<��:�:�f��a� � �c� �eZdZdZgd�Zdd�Zy)�+crypto_secretstream_xchacha20poly1305_statezN
    An object wrapping the crypto_secretstream_xchacha20poly1305 state.

    )�statebuf�rawbuf�tagbufNc�^�tjdt�|_d|_d|_y)z Initialize a clean state object.rN)rrrrr r!)�selfs r�__init__z4crypto_secretstream_xchacha20poly1305_state.__init__Js(��$'�G�G��<�%
��
�
-1���,0��r)rN)�__name__�
__module__�__qualname__�__doc__�	__slots__r$�rrrrBs���
1�I�1rr�state�keyc���tt|t�dtj��tt|t
�dtj��tt
|�tk(dtj��tjdt�}tj|j||�}t|dk(dtj��tj |�ddS)	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��raising�Key must be a bytes sequence�Invalid key lengthzunsigned char []r�Unexpected failureN)r
�
isinstancer�exc�	TypeError�bytes�lenr
�
ValueErrorrrrr	�/crypto_secretstream_xchacha20poly1305_init_pushr�RuntimeErrorr)r+r,�	headerbuf�rcs    rr:r:Us�����5�E�F�L��
�
��
��3���&��
�
��
��C��B�B����������9��I�


�	<�	<�
���	�3�
�B��2��7�(�#�2B�2B�C��:�:�i� ��#�#rN�m�ad�tagc
�V�tt|t�dtj��tt|t
�dtj��tt
|�tkdtj��t|duxst|t
�dtj��t
|�tz}|j�t
|j�|krtjd|�|_
|�tj}d}nt
|�}tj|j |jtj|t
|�|||�}t|dk(d	tj"��tj$|j|�ddS)
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

    r.r/zMessage is not byteszMessage is too longN�%Additional data must be bytes or Nonerrr3)r
r4rr5r6r7r8rr9rr rr�NULLr	�*crypto_secretstream_xchacha20poly1305_pushrr;r)r+r>r?r@�clen�adlenr=s       rrDrD�sF��2��5�E�F�L��
�
��
�:�a���!7����O�
��A��H�H������
�
�d�
�+�j��U�+�/��
�
���q�6�@�@�D��|�|��s�5�<�<�0�4�7��w�w�0�$�7���	�z�
�X�X�����B���	�	7�	7�
���
������	��A��
�
��	
�B��2��7�(�#�2B�2B�C��:�:�e�l�l�D�)�!�,�,r�headerc�|�tt|t�dtj��tt|t
�dtj��tt
|�tk(dtj��tt|t
�dtj��tt
|�tk(dtj��|j�tjd�|_
tj|j||�}t|d	k(d
tj ��y)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

    r.r/zHeader must be a bytes sequencezInvalid header lengthr1r2Nzunsigned char *rr3)r
r4rr5r6r7r8rr9r
r!rrr	�/crypto_secretstream_xchacha20poly1305_init_pullrr;)r+rGr,r=s    rrIrI�s���$��5�E�F�L��
�
��
��6�5�!�)��
�
��
��F��H�H������
��3���&��
�
��
��C��B�B������
�|�|���w�w�0�1���	�	<�	<�
�����
�B��2��7�(�#�2B�2B�Cr�cc
�l�tt|t�dtj��t|j
dudtj��tt|t�dtj��tt|�tk\dtj��tt|�ttzkdtj��t|duxst|t�dtj��t|�tz
}|j�t|j�|krtjd	|�|_|�tj}d
}nt|�}tj |j"|jtj|j
|t|�||�}t|d
k(dtj$��tj&|j|�ddt)t+t|j
�d
�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)

    r.r/NzOState must be initialized using crypto_secretstream_xchacha20poly1305_init_pullzCiphertext is not byteszCiphertext is too shortzCiphertext is too longrBrrr3)r
r4rr5r6r!r9r7r8rrr rrrCr	�*crypto_secretstream_xchacha20poly1305_pullrr;r�intr)r+rJr?�mlenrFr=s      rrLrL�s���*��5�E�F�L��
�
��
�
���D� �
>����
���1�e��!��
�
��
��A��>�>�!�����
��A��B�:�
;�	
�
	!������
�d�
�+�j��U�+�/��
�
���q�6�@�@�D��|�|��s�5�<�<�0�4�7��w�w�0�$�7���	�z�
�X�X�����B���	�	7�	7�
���
������
���	��A��
�
�	
�B��2��7�(�#�2B�2B�C�	�
�
�5�<�<��&�q�)��D�����%�a�(�)��rc��tt|t�dtj��tj|j�y)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

    r.r/N)r
r4rr5r6r	�+crypto_secretstream_xchacha20poly1305_rekeyr)r+s rrPrPQs5����5�E�F�L��
�
��
�3�3�E�N�N�Cr)N))�typingrrrr�naclrr5�nacl._sodiumrr	�nacl.exceptionsr
�,crypto_secretstream_xchacha20poly1305_abytesrrM�__annotations__�1crypto_secretstream_xchacha20poly1305_headerbytesr�.crypto_secretstream_xchacha20poly1305_keybytesr
�6crypto_secretstream_xchacha20poly1305_messagebytes_maxr�0crypto_secretstream_xchacha20poly1305_statebytesr�1crypto_secretstream_xchacha20poly1305_tag_messager�.crypto_secretstream_xchacha20poly1305_tag_pushr�/crypto_secretstream_xchacha20poly1305_tag_rekeyr�/crypto_secretstream_xchacha20poly1305_tag_finalrr7rrr:rDrIrLrPr*rr�<module>r_s��5�4�"�!�"�5�C�4�4�6�-�c��:�C�9�9�;�2�3��7�C�6�6�8�/���?�C�>�>�@�7���9�C�8�8�:�1�#��:�C�9�9�;�2�3��7�C�6�6�8�/���8�C�7�7�9�0���8�C�7�7�9�0���
!�e�!�1�1�&)$�6�)$�=B�)$�
�)$�^�@�	@-�6�@-��@-�	���@-�

�	@-�
�@-�F2D�6�2D��2D�
�2D�
�	2D�p�U�6�U��U�	���U��5�#�:��	U�pD�6�D�	�Dr

Zerion Mini Shell 1.0