
    7g<              
          U d dl 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ez   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 ez   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+e)z   Z,de-dee-         de-de-de-f
dZ.de-dee-         de-de-de-f
dZ/de-dee-         de-de-de-f
dZ0de-dee-         de-de-de-f
dZ1de-dee-         de-de-de-f
dZ2de-dee-         de-de-de-f
dZ3d S )!    )Optional)
exceptions)ffilib)ensure*crypto_aead_chacha20poly1305_ietf_KEYBYTES+crypto_aead_chacha20poly1305_ietf_NSECBYTES+crypto_aead_chacha20poly1305_ietf_NPUBBYTES(crypto_aead_chacha20poly1305_ietf_ABYTES2crypto_aead_chacha20poly1305_ietf_MESSAGEBYTES_MAX%crypto_aead_chacha20poly1305_KEYBYTES&crypto_aead_chacha20poly1305_NSECBYTES&crypto_aead_chacha20poly1305_NPUBBYTES#crypto_aead_chacha20poly1305_ABYTES-crypto_aead_chacha20poly1305_MESSAGEBYTES_MAX+crypto_aead_xchacha20poly1305_ietf_KEYBYTES,crypto_aead_xchacha20poly1305_ietf_NSECBYTES,crypto_aead_xchacha20poly1305_ietf_NPUBBYTES)crypto_aead_xchacha20poly1305_ietf_ABYTES3crypto_aead_xchacha20poly1305_ietf_MESSAGEBYTES_MAXmessageaadnoncekeyreturnc                 V   t          t          | t                    dt          j                   t          |           }t          |t          k    d                    t                    t          j                   t          t          |t                    p|du dt          j                   t          t          |t                    ot          |          t          k    d                    t                    t          j                   t          t          |t                    ot          |          t          k    d                    t                    t          j                   |r|}t          |          }nt          j        }d}|t          z   }t          j        d	          }t          j        d
|          }	t          j        |	|| |||t          j        ||	  	        }
t          |
dk    dt          j                   t          j        |	|d                   dd         S )aZ  
    Encrypt the given ``message`` using the IETF ratified chacha20poly1305
    construction described in RFC7539.

    :param message:
    :type message: bytes
    :param aad:
    :type aad: Optional[bytes]
    :param nonce:
    :type nonce: bytes
    :param key:
    :type key: bytes
    :return: authenticated ciphertext
    :rtype: bytes
     Input message type must be bytesraising%Message must be at most {} bytes longN%Additional data must be bytes or None,Nonce must be a {} bytes long bytes sequence*Key must be a {} bytes long bytes sequencer   unsigned long long *unsigned char[]Encryption failed.)r   
isinstancebytesexc	TypeErrorlenr   format
ValueErrorr
   r   r   NULLr   newr   )crypto_aead_chacha20poly1305_ietf_encryptCryptoErrorbufferr   r   r   r   mlen_aadaalenmxoutclen
ciphertextress              S/var/www/html/syslog/venv/lib/python3.11/site-packages/nacl/bindings/crypto_aead.pyr0   r0   W   s   $ 7E""*    w<<D
BB/66>	
 	
     3/3$;/    5%   	FJJEE6==7	
 	
     3 	CHHBB4;;6	
 	
      Cx;;E7)**D*E22J

7D'4uchs C 3!8)3?CCCC:j$q'**111--    r9   c                 V   t          t          | t                    dt          j                   t          |           }t          |t          k    d                    t                    t          j                   t          t          |t                    p|du dt          j                   t          t          |t                    ot          |          t          k    d                    t                    t          j                   t          t          |t                    ot          |          t          k    d                    t                    t          j                   |t          z
  }t          j        d          }t          j        d	|          }|r|}t          |          }	nt          j        }d
}	t          j        ||t          j        | |||	||	  	        }
t          |
d
k    dt          j                   t          j        ||d
                   dd         S )aR  
    Decrypt the given ``ciphertext`` using the IETF ratified chacha20poly1305
    construction described in RFC7539.

    :param ciphertext:
    :type ciphertext: bytes
    :param aad:
    :type aad: Optional[bytes]
    :param nonce:
    :type nonce: bytes
    :param key:
    :type key: bytes
    :return: message
    :rtype: bytes
    #Input ciphertext type must be bytesr   (Ciphertext must be at most {} bytes longNr!   r"   r#   r$   r%   r   Decryption failed.)r   r'   r(   r)   r*   r+   *_aead_chacha20poly1305_ietf_CRYPTBYTES_MAXr,   r-   r
   r   r   r   r/   r.   r   )crypto_aead_chacha20poly1305_ietf_decryptr1   r2   r9   r   r   r   r8   r7   r4   r   r5   r6   r:   s              r;   rB   rB      s   $ :u%%-    z??D
::2996	
 	
     3/3$;/    5%   	FJJEE6==7	
 	
     3 	CHHBB4;;6	
 	
     ;;E7)**Dg'//G
 Cx

7sxT4s C 3!8)3?CCCC:gtAw''**r<   c                 t   t          t          | t                    dt          j                   t          |           }t          |t          k    d                    t                    t          j                   t          t          |t                    p|du dt          j                   t          t          |t                    ot          |          t          k    d                    t                    t          j                   t          t          |t                    ot          |          t          k    d                    t                    t          j                   |r|}t          |          }nt          j        }d}t          |           }|t          z   }t          j        d	          }t          j        d
|          }	t          j        |	|| |||t          j        ||	  	        }
t          |
dk    dt          j                   t          j        |	|d                   dd         S )a[  
    Encrypt the given ``message`` using the "legacy" construction
    described in draft-agl-tls-chacha20poly1305.

    :param message:
    :type message: bytes
    :param aad:
    :type aad: Optional[bytes]
    :param nonce:
    :type nonce: bytes
    :param key:
    :type key: bytes
    :return: authenticated ciphertext
    :rtype: bytes
    r   r   r    Nr!   r"   r#   r   r$   r%   r&   )r   r'   r(   r)   r*   r+   r   r,   r-   r   r   r   r.   r   r/   r   $crypto_aead_chacha20poly1305_encryptr1   r2   r3   s              r;   rE   rE      s$   $ 7E""*    w<<D
==/669	
 	
     3/3$;/    5%   	AJJ@@6==2	
 	
     3 	>HH==4;;1	
 	
      Cxw<<D;;E7)**D*E22J

2D'4uchs C 3!8)3?CCCC:j$q'**111--r<   c                 V   t          t          | t                    dt          j                   t          |           }t          |t          k    d                    t                    t          j                   t          t          |t                    p|du dt          j                   t          t          |t                    ot          |          t          k    d                    t                    t          j                   t          t          |t                    ot          |          t          k    d                    t                    t          j                   |t          z
  }t          j        d          }t          j        d	|          }|r|}t          |          }	nt          j        }d
}	t          j        ||t          j        | |||	||	  	        }
t          |
d
k    dt          j                   t          j        ||d
                   dd         S )al  
    Decrypt the given ``ciphertext`` using the "legacy" construction
    described in draft-agl-tls-chacha20poly1305.

    :param ciphertext: authenticated ciphertext
    :type ciphertext: bytes
    :param aad:
    :type aad: Optional[bytes]
    :param nonce:
    :type nonce: bytes
    :param key:
    :type key: bytes
    :return: message
    :rtype: bytes
    r>   r   r?   Nr!   r"   r#   r$   r%   r   r@   )r   r'   r(   r)   r*   r+   %_aead_chacha20poly1305_CRYPTBYTES_MAXr,   r-   r   r   r   r   r/   r.   r   $crypto_aead_chacha20poly1305_decryptr1   r2   rC   s              r;   rH   rH   E  s   $ :u%%-    z??D
552991	
 	
     3/3$;/    5%   	AJJ@@6==2	
 	
     3 	>HH==4;;1	
 	
     66E7)**Dg'//G
 Cx

2sxT4s C 3!8)3?CCCC:gtAw''**r<   c                 t   t          t          | t                    dt          j                   t          |           }t          |t          k    d                    t                    t          j                   t          t          |t                    p|du dt          j                   t          t          |t                    ot          |          t          k    d                    t                    t          j                   t          t          |t                    ot          |          t          k    d                    t                    t          j                   |r|}t          |          }nt          j        }d}t          |           }|t          z   }t          j        d	          }t          j        d
|          }	t          j        |	|| |||t          j        ||	  	        }
t          |
dk    dt          j                   t          j        |	|d                   dd         S )aD  
    Encrypt the given ``message`` using the long-nonces xchacha20poly1305
    construction.

    :param message:
    :type message: bytes
    :param aad:
    :type aad: Optional[bytes]
    :param nonce:
    :type nonce: bytes
    :param key:
    :type key: bytes
    :return: authenticated ciphertext
    :rtype: bytes
    r   r   r    Nr!   r"   r#   r   r$   r%   r&   )r   r'   r(   r)   r*   r+   r   r,   r-   r   r   r   r.   r   r/   r   *crypto_aead_xchacha20poly1305_ietf_encryptr1   r2   r3   s              r;   rJ   rJ     s%   $ 7E""*    w<<D
CC/66?	
 	
     3/3$;/    5%   	GJJFF6==8	
 	
     3 	DHHCC4;;7	
 	
      Cxw<<D<<E7)**D*E22J

8D'4uchs C 3!8)3?CCCC:j$q'**111--r<   c                 V   t          t          | t                    dt          j                   t          |           }t          |t          k    d                    t                    t          j                   t          t          |t                    p|du dt          j                   t          t          |t                    ot          |          t          k    d                    t                    t          j                   t          t          |t                    ot          |          t          k    d                    t                    t          j                   |t          z
  }t          j        d          }t          j        d	|          }|r|}t          |          }	nt          j        }d
}	t          j        ||t          j        | |||	||	  	        }
t          |
d
k    dt          j                   t          j        ||d
                   dd         S )aU  
    Decrypt the given ``ciphertext`` using the long-nonces xchacha20poly1305
    construction.

    :param ciphertext: authenticated ciphertext
    :type ciphertext: bytes
    :param aad:
    :type aad: Optional[bytes]
    :param nonce:
    :type nonce: bytes
    :param key:
    :type key: bytes
    :return: message
    :rtype: bytes
    r>   r   r?   Nr!   r"   r#   r$   r%   r   r@   )r   r'   r(   r)   r*   r+   +_aead_xchacha20poly1305_ietf_CRYPTBYTES_MAXr,   r-   r   r   r   r   r/   r.   r   *crypto_aead_xchacha20poly1305_ietf_decryptr1   r2   rC   s              r;   rM   rM     s   $ :u%%-    z??D
;;2997	
 	
     3/3$;/    5%   	GJJFF6==8	
 	
     3 	DHHCC4;;7	
 	
     <<E7)**Dg'//G
 Cx

8sxT4s C 3!8)3?CCCC:gtAw''**r<   N)4typingr   naclr   r)   nacl._sodiumr   r   nacl.exceptionsr   *crypto_aead_chacha20poly1305_ietf_keybytesr   int__annotations__+crypto_aead_chacha20poly1305_ietf_nsecbytesr	   +crypto_aead_chacha20poly1305_ietf_npubbytesr
   (crypto_aead_chacha20poly1305_ietf_abytesr   2crypto_aead_chacha20poly1305_ietf_messagebytes_maxr   rA   %crypto_aead_chacha20poly1305_keybytesr   &crypto_aead_chacha20poly1305_nsecbytesr   &crypto_aead_chacha20poly1305_npubbytesr   #crypto_aead_chacha20poly1305_abytesr   -crypto_aead_chacha20poly1305_messagebytes_maxr   rG   +crypto_aead_xchacha20poly1305_ietf_keybytesr   ,crypto_aead_xchacha20poly1305_ietf_nsecbytesr   ,crypto_aead_xchacha20poly1305_ietf_npubbytesr   )crypto_aead_xchacha20poly1305_ietf_abytesr   3crypto_aead_xchacha20poly1305_ietf_messagebytes_maxr   rL   r(   r0   rB   rE   rH   rJ   rM    r<   r;   <module>rd      s          " " " " " " ! ! ! ! ! ! ! ! " " " " " " 3C244 +C    4C355 ,S    4C355 ,S    1C022 )#    ;C:<< 3C    7./ + .C-// &s    /C.00 '    /C.00 '    ,C+-- $S    6C577 .s    2)* & 4C355 ,S    5C466 -c    5C466 -c    2C133 *3    <C;== 4S    8/0 ,L.L.!%L.16L.=BL.
L. L. L. L.^L+L+$UOL+49L+@EL+
L+ L+ L+ L+^M.M.!%M.16M.=BM.
M. M. M. M.`L+L+$UOL+49L+@EL+
L+ L+ L+ L+^M.M.!%M.16M.=BM.
M. M. M. M.`K+K+$UOK+49K+@EK+
K+ K+ K+ K+ K+ K+r<   