§
    &xÅj7-  ã                   óx  — 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
j        ¦   «         Zeed
<    e
j        ¦   «         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(dS ) é    )Ú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    úRC:\Projects\Historical\venv\Lib\site-packages\nacl/bindings/crypto_secretstream.pyr   r   4   sG   € õ ŒWØÝ6ñô €Fõ Ô4°VÑ<Ô<Ð<ÝŒ:�fÑÔ˜a˜a˜aÔ Ð ó    c                   ó"   — e Zd ZdZg d¢Zdd„ZdS )Ú+crypto_secretstream_xchacha20poly1305_statezN
    An object wrapping the crypto_secretstream_xchacha20poly1305 state.

    )ÚstatebufÚrawbufÚtagbufr   Nc                 óž   — t           t          t          t          f         }t	          j        dt          ¦  «        | _        d| _        d| _	        dS )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   s@   € å�5¥)­ZÐ7Ô8ˆ
Ý$'¤GØÝ<ñ%
ô %
ˆŒð
 -1ˆŒØ,0ˆŒˆˆr   )r   N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__Ú	__slots__r(   © r   r   r   r   B   s?   € € € € € ðð ð
 1Ð0Ð0€Ið	1ð 	1ð 	1ð 	1ð 	1ð 	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ÔFØLÝ”ðñ ô ð õ
 Ý�3�ÑÔØ&Ý”ðñ ô ð õ
 ÝˆC‰ŒÕBÒBØÝ”ðñ ô ð õ ”ØÝ9ñô €Iõ
 
Ô	<ØŒ˜	 3ñ
ô 
€Bõ ˆ2�Š7Ð(µ#Ô2BÐCÑCÔCÐCåŒ:�iÑ Ô    Ô#Ð#r   NÚmÚadÚtagc           
      ód  — t          t          | t          ¦  «        dt          j        ¬¦  «         t          t          |t
          ¦  «        dt          j        ¬¦  «         t          t          |¦  «        t          k    dt          j        ¬¦  «         t          |du p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   ‚   s�  € õ2 Ý�5ÕEÑFÔFØLÝ”ðñ ô ð õ
 �:�a�ÑÔÐ!7ÅÄÐOÑOÔOÐOÝ
ÝˆA‰ŒÕHÒHØÝ”ðñ ô ð õ
 Ø
ˆdˆ
Ð+•j ¥UÑ+Ô+Ø/Ý”ðñ ô ð õ ˆq‰6Œ6Õ@Ñ@€DØ„|Ð�s 5¤<Ñ0Ô0°4Ò7Ð7Ý”wÐ0°$Ñ7Ô7ˆŒà	€zÝŒXˆØˆˆå�B‘”ˆå	Ô	7ØŒØŒÝŒØ	ÝˆA‰ŒØ
ØØñ	
ô 	
€Bõ ˆ2�Š7Ð(µ#Ô2BÐCÑCÔCÐCåŒ:�e”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        ¬¦  «         dS )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   Å   sI  € õ$ Ý�5ÕEÑFÔFØLÝ”ðñ ô ð õ
 Ý�6�5Ñ!Ô!Ø)Ý”ðñ ô ð õ
 ÝˆF‰ŒÕHÒHØÝ”ðñ ô ð õ
 Ý�3�ÑÔØ&Ý”ðñ ô ð õ
 ÝˆC‰ŒÕBÒBØÝ”ðñ ô ð ð „|ÐÝ”wÐ0Ñ1Ô1ˆŒå	Ô	<ØŒ˜ ñ
ô 
€Bõ ˆ2�Š7Ð(µ#Ô2BÐCÑCÔCÐCÐCÐCr   Úcc           
      ó‚  — 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 p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ÔFØLÝ”ðñ ô ð õ
 ØŒ˜DÐ ð>õ ”ðñ ô ð õ Ý�1•eÑÔØ!Ý”ðñ ô ð õ
 ÝˆA‰ŒÕ>Ò>Ø!Ý”ðñ ô ð õ
 ÝˆA‰ŒåBÝ:ñ;ò	
ð
 	!Ý”ðñ ô ð õ Ø
ˆdˆ
Ð+•j ¥UÑ+Ô+Ø/Ý”ðñ ô ð õ ˆq‰6Œ6Õ@Ñ@€DØ„|Ð�s 5¤<Ñ0Ô0°4Ò7Ð7Ý”wÐ0°$Ñ7Ô7ˆŒà	€zÝŒXˆØˆˆå�B‘”ˆå	Ô	7ØŒØŒÝŒØŒØ	ÝˆA‰ŒØ
Øñ	
ô 	
€Bõ ˆ2�Š7Ð(µ#Ô2BÐCÑCÔCÐCõ 	Œ
�5”< Ñ&Ô& q q qÔ)Ý�D•˜œÑ%Ô% aÔ(Ñ)Ô)ðð r   c                 ó–   — t          t          | t          ¦  «        dt          j        ¬¦  «         t          j        | j        ¦  «         dS )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  sL   € õ Ý�5ÕEÑFÔFØLÝ”ðñ ô ð õ
 Ô3°E´NÑCÔCÐCÐCÐ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Ñ6Ô6ð -¨cð ð ñ ð :€CÔ9Ñ;Ô;ð 2°3ð ð ñ ð 7€CÔ6Ñ8Ô8ð /°ð ð ñ ð ?€CÔ>Ñ@Ô@ð 7¸ð ð ñ ð 9€CÔ8Ñ:Ô:ð 1°#ð ð ñ ð :€CÔ9Ñ;Ô;ð 2°3ð ð ñ ð 7€CÔ6Ñ8Ô8ð /°ð ð ñ ð 8€CÔ7Ñ9Ô9ð 0°ð ð ñ ð 8€CÔ7Ñ9Ô9ð 0°ð ð ñ ð
!°eð !ð !ð !ð !ð1ð 1ð 1ð 1ð 1ñ 1ô 1ð 1ð()$Ø6ð)$Ø=Bð)$à
ð)$ð )$ð )$ð )$ð^ Ø@ð	@-ð @-Ø6ð@-àð@-ð 	�Œð@-ð 
ð	@-ð
 ð@-ð @-ð @-ð @-ðF2DØ6ð2Dàð2Dð 
ð2Dð 
ð	2Dð 2Dð 2Dð 2Dðp ðUð UØ6ðUàðUð 	�ŒðUð ˆ5�#ˆ:Ôð	Uð Uð Uð UðpDØ6ðDà	ðDð Dð Dð Dð Dð Dr   