
    Mh"                        U d dl 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j2                         Zeed<    ej6                         Zeed<    ej:                         Zeed<   dZdZ dede!de!de!ddf
dZ"edddfde!dede!de!de!de!fdZ# edd      Z$ G d d      Z%dddefde!de!de!dede%f
dZ&de%de!ddfd Z'de%de!fd!Z(y)"    )NoReturnTypeVar)
exceptions)ffilib)ensurecrypto_generichash_BYTEScrypto_generichash_BYTES_MINcrypto_generichash_BYTES_MAXcrypto_generichash_KEYBYTEScrypto_generichash_KEYBYTES_MINcrypto_generichash_KEYBYTES_MAXcrypto_generichash_SALTBYTES crypto_generichash_PERSONALBYTEScrypto_generichash_STATEBYTESz!{0} length greater than {1} bytesz{0} greater than {1}digest_sizekeysaltpersonreturnNc                 b   t        t        |t              dt        j                         t        t        |t              dt        j                         t        t        |t              dt        j                         t        t        | t
              dt        j                         t        | t        k  t        j                  dt              t        j                         t        t        |      t        k  t        j                  dt              t        j                         t        t        |      t        k  t        j                  dt              t        j                         t        t        |      t        k  t        j                  d	t              t        j                         y
)zCheck hash parameterszKey must be a bytes sequenceraisingzSalt must be a bytes sequencezPerson must be a bytes sequencez%Digest size must be an integer numberDigest_sizeKeySaltPersonN)r   
isinstancebytesexc	TypeErrorintr   _TOOBIGformat
ValueErrorlenr   	_OVERLONGr   r   )r   r   r   r   s       x/var/www/pru.catia.catastroantioquia-mas.com/valormasv2/lib/python3.12/site-packages/nacl/bindings/crypto_generichash.py_checkparamsr)   )   s0    3& 4' 65!) ;$/ 33}&BC C33 ?@ D	11!=> F77#CD    r*   datac           
      R   t        ||||       t        t        | t              dt        j
                         t        j                  d|      }t        j                  dt              }t        j                  dt              }t        j                  ||t        |             t        j                  ||t        |             t        j                  ||| t        |       |t        |      ||      }t        |dk(  dt        j                         t        j                  ||      dd S )ab  One shot hash interface

    :param data: the input data to the hash function
    :type data: bytes
    :param digest_size: must be at most
                        :py:data:`.crypto_generichash_BYTES_MAX`;
                        the default digest size is
                        :py:data:`.crypto_generichash_BYTES`
    :type digest_size: int
    :param key: must be at most
                :py:data:`.crypto_generichash_KEYBYTES_MAX` long
    :type key: bytes
    :param salt: must be at most
                 :py:data:`.crypto_generichash_SALTBYTES` long;
                 will be zero-padded if needed
    :type salt: bytes
    :param person: must be at most
                   :py:data:`.crypto_generichash_PERSONALBYTES` long:
                   will be zero-padded if needed
    :type person: bytes
    :return: digest_size long digest
    :rtype: bytes
    #Input data must be a bytes sequencer   unsigned char[]unsigned char []r   Unexpected failureN)r)   r   r   r   r    r!   r   newr   r   memmover&   r   (crypto_generichash_blake2b_salt_personalRuntimeErrorbuffer)	r+   r   r   r   r   digest_salt_personrcs	            r(   !generichash_blake2b_salt_personalr:   ^   s    > c40
4- WW&4F GG&(DEEgg(*JKGKKtSY'KKV-		5	5T3t9c3s8UG
B 27(#2B2BC::fk*1--r*   _Blake2StateBlake2State)boundc                   @    e Zd ZdZddgZdefdZdefdZde	de	fdZ
y	)
r<   zN
    Python-level wrapper for the crypto_generichash_blake2b state buffer
    	_statebufr   c                 P    t        j                  dt              | _        || _        y )Nr.   )r   r1   r   r?   r   )selfr   s     r(   __init__zBlake2State.__init__   s"    <
 'r*   r   c                 ^    t        dj                  | j                  j                              )zc
        Raise the same exception as hashlib's blake implementation
        on copy.copy()
        zcan't pickle {} objects)r!   r$   	__class____name__)rA   s    r(   
__reduce__zBlake2State.__reduce__   s)    
 %,,T^^-D-DE
 	
r*   rA   c                     | j                  | j                        }t        j                  |j                  | j                  t
               |S )N)rD   r   r   r2   r?   r   )rA   _sts     r(   copyzBlake2State.copy   s9    nnT--.MM4>>+H	
 
r*   N)rE   
__module____qualname____doc__	__slots__r"   rB   r   rF   r;   rI    r*   r(   r<   r<      s>     m,I'C '
H 
< L r*   c                    t        || ||       t        |      }t        j                  dt              }t        j                  dt
              }t        j                  ||t        |             t        j                  ||t        |             t        j                  |j                  | t        |       |||      }t        |dk(  dt        j                         |S )a@  
    Create a new initialized blake2b hash state

    :param key: must be at most
                :py:data:`.crypto_generichash_KEYBYTES_MAX` long
    :type key: bytes
    :param salt: must be at most
                 :py:data:`.crypto_generichash_SALTBYTES` long;
                 will be zero-padded if needed
    :type salt: bytes
    :param person: must be at most
                   :py:data:`.crypto_generichash_PERSONALBYTES` long:
                   will be zero-padded if needed
    :type person: bytes
    :param digest_size: must be at most
                        :py:data:`.crypto_generichash_BYTES_MAX`;
                        the default digest size is
                        :py:data:`.crypto_generichash_BYTES`
    :type digest_size: int
    :return: a initialized :py:class:`.Blake2State`
    :rtype: object
    r/   r   r0   r   )r)   r<   r   r1   r   r   r2   r&   r   -crypto_generichash_blake2b_init_salt_personalr?   r   r    r4   )r   r   r   r   stater7   r8   r9   s           r(   generichash_blake2b_initrR      s    : c40$E GG&(DEEgg(*JKGKKtSY'KKV-		:	:c#hUG
B 27(#2B2BCLr*   rQ   c                 >   t        t        | t              dt        j                         t        t        |t
              dt        j                         t        j                  | j                  |t        |            }t        |dk(  dt        j                         y)zUpdate the blake2b hash state

    :param state: a initialized Blake2bState object as returned from
                     :py:func:`.crypto_generichash_blake2b_init`
    :type state: :py:class:`.Blake2State`
    :param data:
    :type data: bytes
    "State must be a Blake2State objectr   r-   r   r0   N)r   r   r<   r    r!   r   r   !crypto_generichash_blake2b_updater?   r&   r4   )rQ   r+   r9   s      r(   generichash_blake2b_updaterV      sx     5+&, 4- 
	.	.s4y
B 27(#2B2BCr*   c                 d   t        t        | t              dt        j                         t        j                  dt              }t        j                  | j                  || j                        }t        |dk(  dt        j                         t        j                  || j                        dd S )a:  Finalize the blake2b hash state and return the digest.

    :param state: a initialized Blake2bState object as returned from
                     :py:func:`.crypto_generichash_blake2b_init`
    :type state: :py:class:`.Blake2State`
    :return: the blake2 digest of the passed-in data stream
    :rtype: bytes
    rT   r   r.   r   r0   N)r   r   r<   r    r!   r   r1   r   r    crypto_generichash_blake2b_finalr?   r   r4   r5   )rQ   _digestr9   s      r(   generichash_blake2b_finalrZ     s     5+&, gg')EFG		-	-%"3"3
B 27(#2B2BC::gu001!44r*   ))typingr   r   naclr   r    nacl._sodiumr   r   nacl.exceptionsr    crypto_generichash_blake2b_bytesr	   r"   __annotations__$crypto_generichash_blake2b_bytes_minr
   $crypto_generichash_blake2b_bytes_maxr   #crypto_generichash_blake2b_keybytesr   'crypto_generichash_blake2b_keybytes_minr   'crypto_generichash_blake2b_keybytes_maxr   $crypto_generichash_blake2b_saltbytesr   (crypto_generichash_blake2b_personalbytesr   crypto_generichash_statebytesr   r'   r#   r   r)   r:   r;   r<   rR   rV   rZ   rN   r*   r(   <module>ri      s   % $ " ! " !E D D F # F$LC$L$L$N c N$LC$L$L$N c N#J3#J#J#L S L/C//1    0C//1    %MC$L$L$N c N0C002 !#  &GS%F%F%H s H/	
 22 2(-27<2	2n 05.
5.5. 
5. 	5.
 5. 5.p ~]; > /	-	-
- - 	-
 -`Dk D D4 D85[ 5U 5r*   