Ë
    zñ�jÑ+  ã                   ó‚  — U d dl mZmZmZmZ d dlmZ d dlm	Z	m
Z
 d dlmZ  e
j                  «       Zeed<    e
j"                  «       Zeed<    e
j&                  «       Zeed<    e
j*                  «       Zeed<    e
j.                  «       Zeed	<    e
j2                  «       Zeed
<    e
j6                  «       Zeed<    e
j:                  «       Zeed<    e
j>                  «       Z eed<   de!fd„Z" G d„ d«      Z#de#de!de!fd„Z$defde#de!dee!   dede!f
d„Z%de#de!de!ddfd„Z&	 dde#de!dee!   dee!ef   fd„Z'de#ddfd„Z(y) é    )ÚOptionalÚTupleÚUnionÚ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                  ó�   — t        j                  dt        «      } t        j                  | «       t        j
                  | «      dd S )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    úb/var/www/api.ozpay.ru/ozpay/venv/lib/python3.12/site-packages/nacl/bindings/crypto_secretstream.pyr   r   4   s<   € ô �W‰WØÜ6ó€Fô ×4Ñ4°VÔ<Ü�:‰:�fÓ™aÐ Ð ó    c                   ó    — e Zd ZdZg d¢Zdd„Zy)Ú+crypto_secretstream_xchacha20poly1305_statezN
    An object wrapping the crypto_secretstream_xchacha20poly1305 state.

    )ÚstatebufÚrawbufÚtagbufNc                 óŽ   — t         t        t        t        f   }t	        j
                  dt        «      | _        d| _        d| _	        y)z Initialize a clean state object.r   N)
r   ÚbytesÚ	bytearrayÚ
memoryviewr   r   r   r   r    r!   )ÚselfÚ
ByteStrings     r   Ú__init__z4crypto_secretstream_xchacha20poly1305_state.__init__J   s9   € äœ5¤)¬ZÐ7Ñ8ˆ
Ü$'§G¡GØÜ<ó%
ˆŒð
 -1ˆŒØ,0ˆ�r   )r   N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__Ú	__slots__r(   © r   r   r   r   B   s   „ ñò
 1€Iô	1r   r   ÚstateÚkeyc                 óæ  — t        t        | t        «      dt        j                  ¬«       t        t        |t
        «      dt        j                  ¬«       t        t        |«      t        k(  dt        j                  ¬«       t        j                  dt        «      }t        j                  | j                  ||«      }t        |dk(  dt        j                  ¬«       t        j                   |«      dd 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©ÚraisingúKey must be a bytes sequenceúInvalid key lengthzunsigned char []r   úUnexpected failureN)r
   Ú
isinstancer   ÚexcÚ	TypeErrorr#   Úlenr   Ú
ValueErrorr   r   r   r	   Ú/crypto_secretstream_xchacha20poly1305_init_pushr   ÚRuntimeErrorr   )r/   r0   Ú	headerbufÚrcs       r   r=   r=   V   sÀ   € ô Ü�5ÔEÓFØLÜ—‘õô
 Ü�3œÓØ&Ü—‘õô
 ÜˆC‹ÔBÑBØÜ—‘õô —‘ØÜ9ó€Iô
 
×	<Ñ	<Ø�‰˜	 3ó
€Bô ˆ2�‰7Ð(´#×2BÑ2BÕCä�:‰:�iÓ ¡Ð#Ð#r   NÚmÚadÚtagc           
      óV  — t        t        | t        «      dt        j                  ¬«       t        t        |t
        «      dt        j                  ¬«       t        t        |«      t        k  dt        j                  ¬«       t        |du xs t        |t
        «      dt        j                  ¬«       t        |«      t        z   }| j                  �t        | j                  «      |k  rt        j                  d|«      | _
        |€t        j                  }d}nt        |«      }t        j                  | j                   | j                  t        j                  |t        |«      |||«      }t        |dk(  d	t        j"                  ¬«       t        j$                  | j                  |«      dd 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

    r2   r3   zMessage is not byteszMessage is too longNú%Additional data must be bytes or Noner   r   r7   )r
   r8   r   r9   r:   r#   r;   r   r<   r   r    r   r   ÚNULLr	   Ú*crypto_secretstream_xchacha20poly1305_pushr   r>   r   )r/   rA   rB   rC   ÚclenÚadlenr@   s          r   rG   rG   ‚   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                 ó|  — t        t        | t        «      dt        j                  ¬«       t        t        |t
        «      dt        j                  ¬«       t        t        |«      t        k(  dt        j                  ¬«       t        t        |t
        «      dt        j                  ¬«       t        t        |«      t        k(  dt        j                  ¬«       | j                  €t        j                  d«      | _
        t        j                  | j                  ||«      }t        |d	k(  d
t        j                   ¬«       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

    r2   r3   zHeader must be a bytes sequencezInvalid header lengthr5   r6   Nzunsigned char *r   r7   )r
   r8   r   r9   r:   r#   r;   r   r<   r   r!   r   r   r	   Ú/crypto_secretstream_xchacha20poly1305_init_pullr   r>   )r/   rJ   r0   r@   s       r   rL   rL   Å   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  — t        t        | t        «      dt        j                  ¬«       t        | j
                  dudt        j                  ¬«       t        t        |t        «      dt        j                  ¬«       t        t        |«      t        k\  dt        j                  ¬«       t        t        |«      t        t        z   k  dt        j                  ¬«       t        |du xs t        |t        «      dt        j                  ¬«       t        |«      t        z
  }| j                  �t        | j                  «      |k  rt        j                  d	|«      | _        |€t        j                  }d
}nt        |«      }t        j                   | j"                  | j                  t        j                  | j
                  |t        |«      ||«      }t        |d
k(  dt        j$                  ¬«       t        j&                  | j                  |«      dd t)        t+        t        | j
                  «      d
   «      fS )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)

    r2   r3   NzOState must be initialized using crypto_secretstream_xchacha20poly1305_init_pullzCiphertext is not byteszCiphertext is too shortzCiphertext is too longrE   r   r   r7   )r
   r8   r   r9   r:   r!   r<   r#   r;   r   r   r    r   r   rF   r	   Ú*crypto_secretstream_xchacha20poly1305_pullr   r>   r   Úintr   )r/   rM   rB   ÚmlenrI   r@   s         r   rO   rO   ú   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Ñ(Ó)ðð r   c                 ó–   — t        t        | t        «      dt        j                  ¬«       t        j                  | 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

    r2   r3   N)r
   r8   r   r9   r:   r	   Ú+crypto_secretstream_xchacha20poly1305_rekeyr   )r/   s    r   rS   rS   R  s5   € ô Ü�5ÔEÓFØLÜ—‘õô
 ×3Ñ3°E·N±NÕCr   )N))Útypingr   r   r   r   Únaclr   r9   Únacl._sodiumr   r	   Únacl.exceptionsr
   Ú,crypto_secretstream_xchacha20poly1305_abytesr   rP   Ú__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_finalr   r#   r   r   r=   rG   rL   rO   rS   r.   r   r   ú<module>rb      s  ð÷ 0Ô /å "ß !Ý "ð 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ð@-àð@-ð 	�‰ð@-ð 
ð	@-ð
 ó@-ðF2DØ6ð2Dàð2Dð 
ð2Dð 
ó	2Dðp ñUØ6ðUàðUð 	�‰ðUð ˆ5�#ˆ:Ñó	UðpDØ6ðDà	ôDr   