o
    ç÷¡g0  ã                   @   sÒ   d dl Z d dlmZ d dlZd dlmZ ejjZ	ejj
ZejjZejjZejjZejjZejjZejjZejjZejjZejjZejjZG dd„ dƒZ 						
	dde!de!de"de"de"de"de"de!fdd„Z#dS )é    N)ÚNoReturn)Úbytes_as_stringc                   @   sÆ   e Zd ZdZeZeZeZ	e
Zdedddfdededededef
dd	„Zed
efdd„ƒZed
efdd„ƒZed
efdd„ƒZded
dfdd„Zd
efdd„Zd
efdd„Zddd„Zd
efdd„ZdS )Úblake2bzK
    :py:mod:`hashlib` API compatible blake2b algorithm implementation
    ó    ÚdataÚdigest_sizeÚkeyÚsaltÚpersonc                 C   s.   t ||||d�| _|| _|r|  |¡ dS dS )ab  
        :py:class:`.blake2b` algorithm initializer

        :param data:
        :type data: bytes
        :param int digest_size: the requested digest size; must be
                                at most :py:attr:`.MAX_DIGEST_SIZE`;
                                the default digest size is :py:data:`.BYTES`
        :param key: the key to be set for keyed MAC/PRF usage; if set,
                    the key must be at most :py:data:`.KEYBYTES_MAX` long
        :type key: bytes
        :param salt: a initialization salt at most
                     :py:attr:`.SALT_SIZE` long; it will be zero-padded
                     if needed
        :type salt: bytes
        :param person: a personalization string at most
                       :py:attr:`.PERSONAL_SIZE` long; it will be zero-padded
                       if needed
        :type person: bytes
        )r   r	   r
   r   N)Ú	_b2b_initÚ_stateÚ_digest_sizeÚupdate)Úselfr   r   r   r	   r
   © r   ú7/usr/local/lib/python3.10/dist-packages/nacl/hashlib.pyÚ__init__0   s   ÿÿzblake2b.__init__Úreturnc                 C   s   | j S ©N)r   ©r   r   r   r   r   U   s   zblake2b.digest_sizec                 C   ó   dS )Né€   r   r   r   r   r   Ú
block_sizeY   ó   zblake2b.block_sizec                 C   r   )Nr   r   r   r   r   r   Úname]   r   zblake2b.nameNc                 C   s   t | j|ƒ d S r   )Ú_b2b_updater   )r   r   r   r   r   r   a   s   zblake2b.updatec                 C   s   | j  ¡ }t|ƒS r   )r   ÚcopyÚ
_b2b_final)r   Ú_str   r   r   Údigestd   s   
zblake2b.digestc                 C   s   t t |  ¡ ¡ƒS r   )r   ÚbinasciiÚhexlifyr   r   r   r   r   Ú	hexdigesth   s   zblake2b.hexdigestc                 C   s$   t | ƒ| jd�}| j ¡ }||_|S )N)r   )Útyper   r   r   )r   Ú_cpr   r   r   r   r   k   s   
zblake2b.copyc                 C   s   t d | jj¡ƒ‚)zc
        Raise the same exception as hashlib's blake implementation
        on copy.copy()
        zcan't pickle {} objects)Ú	TypeErrorÚformatÚ	__class__Ú__name__r   r   r   r   Ú
__reduce__q   s   ÿzblake2b.__reduce__)r   r   )r(   Ú
__module__Ú__qualname__Ú__doc__ÚBYTESÚMAX_DIGEST_SIZEÚKEYBYTES_MAXÚMAX_KEY_SIZEÚPERSONALBYTESÚPERSON_SIZEÚ	SALTBYTESÚ	SALT_SIZEÚbytesÚintr   Úpropertyr   r   Ústrr   r   r   r"   r   r   r)   r   r   r   r   r   &   sB    úþýüû
ú%
r   r   é   é   é   é   é@   Úpasswordr	   ÚnÚrÚpÚmaxmemÚdklenr   c              	   C   s   t jj| ||||||d�S )a  
    Derive a cryptographic key using the scrypt KDF.

    :raises nacl.exceptions.UnavailableError: If called when using a
        minimal build of libsodium.

    Implements the same signature as the ``hashlib.scrypt`` implemented
    in cpython version 3.6
    )rB   rC   )ÚnaclÚbindingsÚ%crypto_pwhash_scryptsalsa208sha256_ll)r>   r	   r?   r@   rA   rB   rC   r   r   r   Úscrypt{   s   ÿrG   )r   r9   r:   r;   r<   r=   )$r    Útypingr   Únacl.bindingsrD   Ú
nacl.utilsr   rE   Úcrypto_generichash_BYTESr-   Úcrypto_generichash_BYTES_MINÚ	BYTES_MINÚcrypto_generichash_BYTES_MAXÚ	BYTES_MAXÚcrypto_generichash_KEYBYTESÚKEYBYTESÚcrypto_generichash_KEYBYTES_MINÚKEYBYTES_MINÚcrypto_generichash_KEYBYTES_MAXr/   Úcrypto_generichash_SALTBYTESr3   Ú crypto_generichash_PERSONALBYTESr1   Ú&has_crypto_pwhash_scryptsalsa208sha256ÚSCRYPT_AVAILABLEÚcrypto_generichash_blake2b_initr   Ú crypto_generichash_blake2b_finalr   Ú!crypto_generichash_blake2b_updater   r   r5   r6   rG   r   r   r   r   Ú<module>   sP   Wùÿþýüûúùø