HEX
Server: Apache
System: Linux scp1.abinfocom.com 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64
User: confeduphaar (1010)
PHP: 8.1.33
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //usr/lib/python3/dist-packages/nacl/bindings/__pycache__/crypto_generichash.cpython-38.pyc
U

�֫[J�@s�ddlmZmZmZddlmZddlmZddl	m
Z
mZddlm
Z
e��Ze��Ze��Ze��Ze��Ze��Ze��Ze��Ze��ZdZ dZ!dd	�Z"ed
d
d
fdd�Z#d
d
d
efd
d�Z$dd�Z%dd�Z&dd�Z'dS)�)�absolute_import�division�print_function)�
integer_types)�
exceptions)�ffi�lib)�ensurez!{0} length greater than {1} bytesz{0} greater than {1}cCs�tt|t�dtjd�tt|t�dtjd�tt|t�dtjd�tt|t�dtjd�t|tkt�dt�tj	d�tt
|�tkt�dt�tj	d�tt
|�t
kt�dt
�tj	d�tt
|�tkt�d	t�tj	d�d
S)zCheck hash paramterszKey must be a bytes sequence�ZraisingzSalt must be a bytes sequencezPerson must be a bytes sequencez%Digest size must be an integer numberZDigest_sizeZKeyZSaltZPersonN)r	�
isinstance�bytes�exc�	TypeErrorr�crypto_generichash_BYTES_MAX�_TOOBIG�format�
ValueError�len�crypto_generichash_KEYBYTES_MAX�	_OVERLONG�crypto_generichash_SALTBYTES� crypto_generichash_PERSONALBYTES)�digest_size�key�salt�person�r�B/usr/lib/python3/dist-packages/nacl/bindings/crypto_generichash.py�_checkparams's@
�
�
�
�
�
�
�
�r�c	
Cs�t||||�tt|t�dtjd�t�d|�}t�dt�}t�dt	�}t�
||t|��t�
||t|��t�
|||t|�|t|�||�}t|dkdtjd�t�||�dd�S)aLOne shot hash interface

    :param data: the input data to the hash function
    :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)rr	rrr
rr�newrr�memmoverrZ(crypto_generichash_blake2b_salt_personal�RuntimeError�buffer)	�datarrrrZdigest�_salt�_person�rcrrr�!generichash_blake2b_salt_personalJs,
��
�r,cCs�t||||�t�dt�}t�dt�}t�dt�}t�||t|��t�||t|��t�	||t|�|||�}t
|dkdtjd�|S)a7
    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: an initizialized state buffer
    :rtype: object
    r!r"rr#r
)
rrr$�crypto_generichash_STATEBYTESrrr%rrZ-crypto_generichash_blake2b_init_salt_personalr	r
r&)rrrr�statebufr)r*r+rrr�generichash_blake2b_init}s"�
�r/cCs@tt|t�dtjd�t�||t|��}t|dkdtjd�dS)z�Update the blake2b hash state

    :param statebuf: an initialized blake2b state buffer as returned from
                     :py:func:`.crypto_generichash_blake2b_init`
    :type statebuf: object
    :param data:
    :type data: bytes
    r r
rr#N)	r	rrr
rrZ!crypto_generichash_blake2b_updaterr&)r.r(r+rrr�generichash_blake2b_update�s

�
�r0cCsBt�dt�}t�|||�}t|dkdtjd�t�||�dd�S)z�Finalize the blake2b hash state and return the digest.

    :param statebuf:
    :type statebuf: object
    :param digest_size:
    :type digest_size: int
    :return: the blake2 digest of the passed-in data stream
    :rtype: bytes
    r!rr#r
N)	rr$rrZ crypto_generichash_blake2b_finalr	r
r&r')r.rZ_digestr+rrr�generichash_blake2b_final�s
�r1cCst�dt�}t�||t�|S)z-Return a copy of the given blake2b hash stater!)rr$r-r%)r.Znewstaterrr�generichash_blake2b_state_copy�sr2N)(Z
__future__rrrZsixrZnaclrr
Znacl._sodiumrrZnacl.exceptionsr	Z crypto_generichash_blake2b_bytesZcrypto_generichash_BYTESZ$crypto_generichash_blake2b_bytes_minZcrypto_generichash_BYTES_MINZ$crypto_generichash_blake2b_bytes_maxrZ#crypto_generichash_blake2b_keybytesZcrypto_generichash_KEYBYTESZ'crypto_generichash_blake2b_keybytes_minZcrypto_generichash_KEYBYTES_MINZ'crypto_generichash_blake2b_keybytes_maxrZ$crypto_generichash_blake2b_saltbytesrZ(crypto_generichash_blake2b_personalbytesrZcrypto_generichash_statebytesr-rrrr,r/r0r1r2rrrr�<module>s:�$�
3�
/