ó
    &ÝNjÑ+  ã                   ó’  • % S SK JrJrJrJr  S SKJr  S SKJ	r	J
r
  S SKJr  \
R                  " 5       r\\S'   \
R"                  " 5       r\\S'   \
R&                  " 5       r\\S'   \
R*                  " 5       r\\S'   \
R.                  " 5       r\\S	'   \
R2                  " 5       r\\S
'   \
R6                  " 5       r\\S'   \
R:                  " 5       r\\S'   \
R>                  " 5       r \\S'   S\!4S jr" " S S5      r#S\#S\!S\!4S jr$S\4S\#S\!S\\!   S\S\!4
S jjr%S\#S\!S\!SS4S jr& SS\#S\!S\\!   S\\!\4   4S jjr'S\#SS4S jr(g) é    )Ú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                  ó–   • [         R                  " S[        5      n [        R                  " U 5        [         R
                  " U 5      SS $ )zX
Generate a key for use with
:func:`.crypto_secretstream_xchacha20poly1305_init_push`.

úunsigned char[]N)r   Únewr   r	   Ú,crypto_secretstream_xchacha20poly1305_keygenÚbuffer)Úkeybufs    Ú^/home/mande/repo/quber/.venv/lib/python3.13/site-packages/nacl/bindings/crypto_secretstream.pyr   r   4   s<   € ô �WŠWØÜ6ó€Fô ×4Ò4°VÔ<Ü�:Š:�fÓ™aÐ Ð ó    c                   ó*   • \ rS rSrSr/ SQrSS jrSrg)Ú+crypto_secretstream_xchacha20poly1305_stateéB   zF
An object wrapping the crypto_secretstream_xchacha20poly1305 state.

)ÚstatebufÚrawbufÚtagbufNc                 ó�   • [         [        [        [        4   n[        R
                  " S[        5      U l        SU l        SU l	        g)z Initialize a clean state object.r   N)
r   ÚbytesÚ	bytearrayÚ
memoryviewr   r   r   r    r!   r"   )ÚselfÚ
ByteStrings     r   Ú__init__Ú4crypto_secretstream_xchacha20poly1305_state.__init__J   s9   € äœ5¤)¬ZÐ7Ñ8ˆ
Ü$'§G¢GØÜ<ó%
ˆŒð
 -1ˆŒØ,0ˆ�r   )r!   r    r"   )r   N)Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__Ú	__slots__r)   Ú__static_attributes__© r   r   r   r   B   s   † ñò
 1€I÷	1r   r   ÚstateÚkeyc                 óÒ  • [        [        U [        5      S[        R                  S9  [        [        U[
        5      S[        R                  S9  [        [        U5      [        :H  S[        R                  S9  [        R                  " S[        5      n[        R                  " U R                  X!5      n[        US:H  S[        R                  S9  [        R                   " U5      SS $ )	a8  
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   )r3   r4   Ú	headerbufÚrcs       r   rA   rA   V   s¾   € ô Ü�5ÔEÓFØLÜ—‘òô
 Ü�3œÓØ&Ü—‘òô
 ÜˆC‹ÔBÑBØÜ—‘òô —’ØÜ9ó€Iô
 
×	<Ò	<Ø�‰˜	ó
€Bô ˆ2�‰7Ð(´#×2BÑ2BÒCä�:Š:�iÓ ¡Ð#Ð#r   NÚmÚadÚtagc           
      óN  • [        [        U [        5      S[        R                  S9  [        [        U[
        5      S[        R                  S9  [        [        U5      [        :*  S[        R                  S9  [        USL =(       d    [        U[
        5      S[        R                  S9  [        U5      [        -   nU R                  b  [        U R                  5      U:  a  [        R                  " SU5      U l
        Uc  [        R                  nSnO[        U5      n[        R                  " U R                   U R                  [        R                  U[        U5      UUU5      n[        US:H  S	[        R"                  S9  [        R$                  " U R                  U5      S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

r6   r7   zMessage is not byteszMessage is too longNú%Additional data must be bytes or Noner   r   r;   )r
   r<   r   r=   r>   r$   r?   r   r@   r   r!   r   r   ÚNULLr	   Ú*crypto_secretstream_xchacha20poly1305_pushr    rB   r   )r3   rE   rF   rG   ÚclenÚadlenrD   s          r   rK   rK   ‚   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                 ó\  • [        [        U [        5      S[        R                  S9  [        [        U[
        5      S[        R                  S9  [        [        U5      [        :H  S[        R                  S9  [        [        U[
        5      S[        R                  S9  [        [        U5      [        :H  S[        R                  S9  U R                  c  [        R                  " S5      U l
        [        R                  " U R                  X5      n[        US	:H  S
[        R                   S9  g)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

r6   r7   zHeader must be a bytes sequencezInvalid header lengthr9   r:   Nzunsigned char *r   r;   )r
   r<   r   r=   r>   r$   r?   r   r@   r   r"   r   r   r	   Ú/crypto_secretstream_xchacha20poly1305_init_pullr    rB   )r3   rN   r4   rD   s       r   rP   rP   Å   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           
      óX  • [        [        U [        5      S[        R                  S9  [        U R
                  SLS[        R                  S9  [        [        U[        5      S[        R                  S9  [        [        U5      [        :¬  S[        R                  S9  [        [        U5      [        [        -   :*  S[        R                  S9  [        USL =(       d    [        U[        5      S[        R                  S9  [        U5      [        -
  nU R                  b  [        U R                  5      U:  a  [        R                  " S	U5      U l        Uc  [        R                  nS
nO[        U5      n[        R                   " U R"                  U R                  [        R                  U R
                  U[        U5      UU5      n[        US
:H  S[        R$                  S9  [        R&                  " U R                  U5      SS [)        [+        [        U R
                  5      S
   5      4$ )a  
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)

r6   r7   NzOState must be initialized using crypto_secretstream_xchacha20poly1305_init_pullzCiphertext is not byteszCiphertext is too shortzCiphertext is too longrI   r   r   r;   )r
   r<   r   r=   r>   r"   r@   r$   r?   r   r   r!   r   r   rJ   r	   Ú*crypto_secretstream_xchacha20poly1305_pullr    rB   r   Úintr   )r3   rQ   rF   ÚmlenrM   rD   s         r   rS   rS   ú   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                 ó’   • [        [        U [        5      S[        R                  S9  [
        R                  " U R                  5        g)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

r6   r7   N)r
   r<   r   r=   r>   r	   Ú+crypto_secretstream_xchacha20poly1305_rekeyr    )r3   s    r   rW   rW   R  s5   € ô Ü�5ÔEÓFØLÜ—‘òô
 ×3Ò3°E·N±NÕCr   )N))Útypingr   r   r   r   Únaclr   r=   Únacl._sodiumr   r	   Únacl.exceptionsr
   Ú,crypto_secretstream_xchacha20poly1305_abytesr   rT   Ú__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   rA   rK   rP   rS   rW   r2   r   r   Ú<module>rf      s  ð÷ 0Ô /å "ß !Ý "ð ×4Ò4Ó6ð -¨có ð ×9Ò9Ó;ð 2°3ó ð ×6Ò6Ó8ð /°ó ð ×>Ò>Ó@ð 7¸ó ð ×8Ò8Ó:ð 1°#ó ð ×9Ò9Ó;ð 2°3ó ð ×6Ò6Ó8ð /°ó ð ×7Ò7Ó9ð 0°ó ð ×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   