%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /lib/python3/dist-packages/nacl/bindings/__pycache__/
Upload File :
Create Path :
Current File : //lib/python3/dist-packages/nacl/bindings/__pycache__/crypto_generichash.cpython-312.pyc

�

�f�"�
��UddlmZmZddlmZddlmZmZddl	m
Z
ej�Ze
ed<ej�Ze
ed<ej"�Ze
ed<ej&�Ze
ed<ej*�Ze
ed	<ej.�Ze
ed
<ej2�Ze
ed<ej6�Ze
ed<ej:�Ze
ed
<dZdZ de
de!de!de!ddf
d�Z"edddfde!de
de!de!de!de!fd�Z#edd��Z$Gd�d�Z%dddefde!de!de!de
de%f
d�Z&de%de!ddfd �Z'de%de!fd!�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�tt|t�dtj��tt|t�dtj��tt|t�dtj��tt|t
�dtj��t|tktjdt�tj��tt|�tktjdt�tj��tt|�tktjdt�tj��tt|�tktjd	t�tj��y
)zCheck hash parameterszKey must be a bytes sequence��raisingzSalt must be a bytes sequencezPerson 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�	_OVERLONGrr)rrrrs    �B/usr/lib/python3/dist-packages/nacl/bindings/crypto_generichash.py�_checkparamsr))s0����3���&��
�
����4���'��
�
����6�5�!�)��
�
����;��$�/��
�
����3�3����}�&B�C�������C��3�3����� ?�@�������D�	�1�1�����!=�>�������F��7�7�����#C�D�����r*�datac
�R�t||||�tt|t�dtj
��t
jd|�}t
jdt�}t
jdt�}t
j||t|��t
j||t|��tj|||t|�|t|�||�}t|dk(dtj��t
j||�ddS)abOne 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)rrrr r!r�newrr�memmover&r�(crypto_generichash_blake2b_salt_personal�RuntimeError�buffer)	r+rrrr�digest�_salt�_person�rcs	         r(�!generichash_blake2b_salt_personalr:^s���>��c�4��0�
��4���-��
�
���W�W�&��
4�F�
�G�G�&�(D�E�E��g�g�(�*J�K�G��K�K��t�S��Y�'��K�K����V��-�	�	5�	5���T�3�t�9�c�3�s�8�U�G�
�B��2��7�(�#�2B�2B�C��:�:�f�k�*�1�-�-r*�_Blake2State�Blake2State)�boundc�@�eZdZdZddgZdefd�Zdefd�Zde	de	fd�Z
y	)
r<zN
    Python-level wrapper for the crypto_generichash_blake2b state buffer
    �	_statebufrc�P�tjdt�|_||_y)Nr.)rr1rr?r)�selfrs  r(�__init__zBlake2State.__init__�s"������<�
���'��r*rc�^�tdj|jj���)zc
        Raise the same exception as hashlib's blake implementation
        on copy.copy()
        zcan't pickle {} objects)r!r$�	__class__�__name__)rAs r(�
__reduce__zBlake2State.__reduce__�s)��
�%�,�,�T�^�^�-D�-D�E�
�	
r*rAc��|j|j�}tj|j|jt
�|S)N)rDrrr2r?r)rA�_sts  r(�copyzBlake2State.copy�s9���n�n�T�-�-�.������M�M�4�>�>�+H�	
��
r*N)rE�
__module__�__qualname__�__doc__�	__slots__r"rBrrFr;rI�r*r(r<r<�s>����m�,�I�'�C�'�
�H�
��<��L�r*c��t||||�t|�}tjdt�}tjdt
�}tj||t|��tj||t|��tj|j|t|�|||�}t|dk(dtj��|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/rr0r)r)r<rr1rrr2r&r�-crypto_generichash_blake2b_init_salt_personalr?rr r4)rrrr�stater7r8r9s        r(�generichash_blake2b_initrR�s���:��c�4��0���$�E�
�G�G�&�(D�E�E��g�g�(�*J�K�G��K�K��t�S��Y�'��K�K����V��-�	�	:�	:�
����c�#�h��U�G�
�B��2��7�(�#�2B�2B�C��Lr*rQc�>�tt|t�dtj��tt|t
�dtj��t
j|j|t|��}t|dk(dtj��y)z�Update 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 objectrr-rr0N)rrr<r r!rr�!crypto_generichash_blake2b_updater?r&r4)rQr+r9s   r(�generichash_blake2b_updaterV�sx����5�+�&�,��
�
����4���-��
�
��

�	.�	.�
����s�4�y�
�B��2��7�(�#�2B�2B�Cr*c�d�tt|t�dtj��tjdt�}tj|j||j�}t|dk(dtj��tj||j�ddS)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
    rTrr.rr0N)rrr<r r!rr1rr� crypto_generichash_blake2b_finalr?rr4r5)rQ�_digestr9s   r(�generichash_blake2b_finalrZs�����5�+�&�,��
�
���g�g�'�)E�F�G�	�	-�	-�
����%�"3�"3�
�B��2��7�(�#�2B�2B�C��:�:�g�u�0�0�1�!�4�4r*))�typingrr�naclrr �nacl._sodiumrr�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_statebytesrr'r#rr)r:r;r<rRrVrZrNr*r(�<module>ris��%�$�"�!�"�!E�� D� D� F��#�F�$L�C�$L�$L�$N��c�N�$L�C�$L�$L�$N��c�N�#J�3�#J�#J�#L��S�L�/�C�/�/�1� ���0�C�/�/�1� ���%M�C�$L�$L�$N��c�N�0�C�0�0�2�!�#��&G�S�%F�%F�%H��s�H�/�	�
 ��2��2� �2�(-�2�7<�2�	�2�n0����5.�
�5.��5.�
�5.��	5.�

�5.��
5.�p�~�]�;����>���/�	-�	�-�
�-�
�-��	-�
�-�`D�k�D��D�4�D�85�[�5�U�5r*

Zerion Mini Shell 1.0