
    Mh<              
          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j2                         Zeed<    ej6                         Zeed<    ej:                         Zeed<    ej>                         Z eed<   e ez   Z! ejD                         Z#eed<    ejH                         Z%eed<    ejL                         Z'eed<    ejP                         Z)eed<    ejT                         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Z3y )!    )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                    t        t        | t              dt        j                         t        |       }t        |t        k  dj                  t              t        j                         t        t        |t              xs |du dt        j                         t        t        |t              xr t        |      t        k(  dj                  t              t        j                         t        t        |t              xr t        |      t        k(  dj                  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              q/var/www/pru.catia.catastroantioquia-mas.com/valormasv2/lib/python3.12/site-packages/nacl/bindings/crypto_aead.pyr0   r0   W   s   $ 7E"* w<D
BB/66>	
  3/3$;/ 5%  	FJEE6==7	
  3 	CHBB4;;6	
  Cxx;;E77)*D*E2J

7
7D'4uchhsC 3!8)3??C::j$q'*1--    r9   c                    t        t        | t              dt        j                         t        |       }t        |t        k  dj                  t              t        j                         t        t        |t              xs |du dt        j                         t        t        |t              xr t        |      t        k(  dj                  t              t        j                         t        t        |t              xr t        |      t        k(  dj                  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JEE6==7	
  3 	CHBB4;;6	
  ;;E77)*Dgg'/G
Cxx

7
7sxxT4sC 3!8)3??C::gtAw'**r<   c                 
   t        t        | t              dt        j                         t        |       }t        |t        k  dj                  t              t        j                         t        t        |t              xs |du dt        j                         t        t        |t              xr t        |      t        k(  dj                  t              t        j                         t        t        |t              xr t        |      t        k(  dj                  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J@@6==2	
  3 	>H==4;;1	
  Cxxw<D;;E77)*D*E2J

2
2D'4uchhsC 3!8)3??C::j$q'*1--r<   c                    t        t        | t              dt        j                         t        |       }t        |t        k  dj                  t              t        j                         t        t        |t              xs |du dt        j                         t        t        |t              xr t        |      t        k(  dj                  t              t        j                         t        t        |t              xr t        |      t        k(  dj                  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J@@6==2	
  3 	>H==4;;1	
  66E77)*Dgg'/G
Cxx

2
2sxxT4sC 3!8)3??C::gtAw'**r<   c                 
   t        t        | t              dt        j                         t        |       }t        |t        k  dj                  t              t        j                         t        t        |t              xs |du dt        j                         t        t        |t              xr t        |      t        k(  dj                  t              t        j                         t        t        |t              xr t        |      t        k(  dj                  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JFF6==8	
  3 	DHCC4;;7	
  Cxxw<D<<E77)*D*E2J

8
8D'4uchhsC 3!8)3??C::j$q'*1--r<   c                    t        t        | t              dt        j                         t        |       }t        |t        k  dj                  t              t        j                         t        t        |t              xs |du dt        j                         t        t        |t              xr t        |      t        k(  dj                  t              t        j                         t        t        |t              xr t        |      t        k(  dj                  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JFF6==8	
  3 	DHCC4;;7	
  <<E77)*Dgg'/G
Cxx

8
8sxxT4sC 3!8)3??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      sA    " ! " 3C224 +C  4C335 ,S  4C335 ,S  1C002 )#  ;C::< 3C  7./ + .C--/ &s  /C..0 '  /C..0 '  ,C++- $S  6C557 .s  2)* & 4C335 ,S  5C446 -c  5C446 -c  2C113 *3  <C;;= 4S  8/0 ,L.L.!%L.16L.=BL.
L.^L+L+$UOL+49L+@EL+
L+^M.M.!%M.16M.=BM.
M.`L+L+$UOL+49L+@EL+
L+^M.M.!%M.16M.=BM.
M.`K+K+$UOK+49K+@EK+
K+r<   