https://t.me/RX1948
Server : Apache
System : Linux iad1-shared-b8-43 6.6.49-grsec-jammy+ #10 SMP Thu Sep 12 23:23:08 UTC 2024 x86_64
User : dh_edsupp ( 6597262)
PHP Version : 8.2.26
Disable Function : NONE
Directory :  /lib/python3/dist-packages/nacl/bindings/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //lib/python3/dist-packages/nacl/bindings/__pycache__/crypto_pwhash.cpython-310.pyc
o

��a�I�@s~UddlZddlmZddlmZddlmZmZddlm	Z	e
ej�ZdZ
dZdZdZdZdZdZdZdZdZdZdZdZdZdZer�e�e�de����dd�Z
e��Ze� �Ze�!�Ze�"�Ze�#�Ze�$�Ze�%�Ze�&�Ze�'�Ze�(�Ze�)�Ze�*�Ze�+�Ze�,�Ze�-�Z.e/e0d<e�1�Z2e/e0d<e�3�Z4e/e0d	<e�5�Z6e/e0d
<e�7�Z8e/e0d<e�9�Z:e/e0d<e�;�Z<e/e0d
<e�=�Z>e/e0d<e�?�Z@e/e0d<e�e�de�A���dd�ZBeCe0d<e�D�ZEe/e0d<e�F�ZGe/e0d<e�H�ZIe/e0d<e�J�ZKe/e0d<e�L�ZMe/e0d<e�N�ZOe/e0d<e�P�ZQe/e0d<e�R�ZSe/e0d<e�T�ZUe/e0d<e�V�ZWe/e0d<e�e�de�X���dd�ZYeCe0d<e�Z�Z[e/e0d<e�\�Z]e/e0d<e�^�Z_e/e0d<e�`�Zae/e0d<e�b�Zce/e0d <e�d�Zee/e0d!<e�f�Zge/e0d"<e�h�Zie/e0d#<e�j�Zke/e0d$<e�l�Zme/e0d%<eZneZoeZpeZqeZreZsd&Ztd'Zud(Zvd)Zwewfd*e/d+e/d,e/d-e/d.df
d/d0�Zxd1e/d2e/d.ee/e/e/ffd3d4�Zyd5ewfd6eCd7eCd*e/d+e/d,e/d8e/d-e/d.eCfd9d:�Zzeneofd6eCd1e/d2e/d.eCfd;d<�Z{d=eCd6eCd.e
fd>d?�Z|d1e/d2e/d@e/d.dfdAdB�Z}dCe/d6eCd7eCd1e/d2e/d@e/d.eCfdDdE�Z~d6eCd1e/d2e/d@e/d.eCf
dFdG�Zd=eCd6eCd.e
fdHdI�Z�e�Z�dS)J�N)�Tuple)�ffi�lib)�ensure��char *�crypto_pwhash_ALG_ARGON2I13�crypto_pwhash_ALG_ARGON2ID13�crypto_pwhash_ALG_DEFAULT�crypto_pwhash_SALTBYTES�crypto_pwhash_STRBYTES�crypto_pwhash_PASSWD_MIN�crypto_pwhash_PASSWD_MAX�crypto_pwhash_BYTES_MIN�crypto_pwhash_BYTES_MAX�crypto_pwhash_argon2i_STRPREFIX�"crypto_pwhash_argon2i_MEMLIMIT_MIN�"crypto_pwhash_argon2i_MEMLIMIT_MAX�"crypto_pwhash_argon2i_OPSLIMIT_MIN�"crypto_pwhash_argon2i_OPSLIMIT_MAX�*crypto_pwhash_argon2i_OPSLIMIT_INTERACTIVE�*crypto_pwhash_argon2i_MEMLIMIT_INTERACTIVE�'crypto_pwhash_argon2i_OPSLIMIT_MODERATE�'crypto_pwhash_argon2i_MEMLIMIT_MODERATE�(crypto_pwhash_argon2i_OPSLIMIT_SENSITIVE�(crypto_pwhash_argon2i_MEMLIMIT_SENSITIVE� crypto_pwhash_argon2id_STRPREFIX�#crypto_pwhash_argon2id_MEMLIMIT_MIN�#crypto_pwhash_argon2id_MEMLIMIT_MAX�#crypto_pwhash_argon2id_OPSLIMIT_MIN�#crypto_pwhash_argon2id_OPSLIMIT_MAX�+crypto_pwhash_argon2id_OPSLIMIT_INTERACTIVE�+crypto_pwhash_argon2id_MEMLIMIT_INTERACTIVE�(crypto_pwhash_argon2id_OPSLIMIT_MODERATE�(crypto_pwhash_argon2id_MEMLIMIT_MODERATE�)crypto_pwhash_argon2id_OPSLIMIT_SENSITIVE�)crypto_pwhash_argon2id_MEMLIMIT_SENSITIVE��?�?l����i�n�r�p�maxmem�returncCst|dkdtjd�t|dkdtjd�t||d@dkdtjd�t|dkdtjd�t|t|kd�t�tjd�t|dd	|>ktjd�|d
|}td
}t|d||ktjd�d||dd
}t|t|ktjd�t|tj|ktjd�t|||kdtjd�dS)NrzInvalid block size��raisingzInvalid parallelization factor�z Cost factor must be a power of 2zCost factor must be at least 2zp*r is greater than {}���� �z7Memory limit would be exceeded with the choosen n, r, p)r�exc�
ValueError�
SCRYPT_PR_MAX�format�
UINT64_MAX�sys�maxsize)r)r*r+r,�Blen�i�Vlen�r@�=/usr/lib/python3/dist-packages/nacl/bindings/crypto_pwhash.py�_check_memory_occupation�s2�
�

�rB�opslimit�memlimitcCs�|dkrd}d}||dkr)d}|d|}tdd�D]}d||dkr'nqn*||d}tdd�D]}d||dkr@nq4|dd|}|d	krOd	}||}|||fS)
z/Python implementation of libsodium's pickparamsi��r4r0r5r(r3r2r')�range)rCrDr*r+�maxn�n_log2�maxrpr@r@rA� nacl_bindings_pick_scrypt_params�s*���
rJ�@�passwd�salt�dklenc	Cs�ttdtjd�tt|t�td�tt|t�td�tt|t�td�tt|t�td�tt|t�td�t||||�t	�
d|�}t�|t
|�|t
|�|||||�	}t|dkdtjd�t	�t	�d|�|�dd�S)a�
    Derive a cryptographic key using the ``passwd`` and ``salt``
    given as input.

    The work factor can be tuned by by picking different
    values for the parameters

    :param bytes passwd:
    :param bytes salt:
    :param bytes salt: *must* be *exactly* :py:const:`.SALTBYTES` long
    :param int dklen:
    :param int opslimit:
    :param int n:
    :param int r: block size,
    :param int p: the parallelism factor
    :param int maxmem: the maximum available memory available for scrypt's
                       operations
    :rtype: bytes
    :raises nacl.exceptions.UnavailableError: If called when using a
        minimal build of libsodium.
    �Not available in minimal buildr.z	uint8_t[]r�$Unexpected failure in key derivationrN)r�&has_crypto_pwhash_scryptsalsa208sha256r6�UnavailableError�
isinstance�int�	TypeError�bytesrBr�newr�%crypto_pwhash_scryptsalsa208sha256_ll�len�RuntimeError�buffer�cast)	rLrMr)r*r+rNr,�buf�retr@r@rArX	s*���rXcCsPttdtjd�t�dt�}t�||t	|�||�}t|dkdtj
d�t�|�S)a�
    Derive a cryptographic key using the ``passwd`` and ``salt``
    given as input, returning a string representation which includes
    the salt and the tuning parameters.

    The returned string can be directly stored as a password hash.

    See :py:func:`.crypto_pwhash_scryptsalsa208sha256` for a short
    discussion about ``opslimit`` and ``memlimit`` values.

    :param bytes passwd:
    :param int opslimit:
    :param int memlimit:
    :return: serialized key hash, including salt and tuning parameters
    :rtype: bytes
    :raises nacl.exceptions.UnavailableError: If called when using a
        minimal build of libsodium.
    rOr.�char[]rz&Unexpected failure in password hashing)rrQr6rRrrW�SCRYPT_STRBYTESr�&crypto_pwhash_scryptsalsa208sha256_strrYrZ�string)rLrCrDr]r^r@r@rAraEs���
ra�passwd_hashcCsVttdtjd�tt|�tdkdtjd�t�||t|��}t|dkdtj	d�dS)a9
    Verifies the ``passwd`` against the ``passwd_hash`` that was generated.
    Returns True or False depending on the success

    :param passwd_hash: bytes
    :param passwd: bytes
    :rtype: boolean
    :raises nacl.exceptions.UnavailableError: If called when using a
        minimal build of libsodium.
    rOr.r0zInvalid password hashr�Wrong passwordT)
rrQr6rRrYr`r7r�-crypto_pwhash_scryptsalsa208sha256_str_verify�InvalidkeyError�rcrLr^r@r@rAreqs
��
�re�algcCs�|tkr6|tkrt�d�t���|tkrt�d�t���|tkr(t�d�t���|tkr4t�d�t���dS|tkrl|t	krFt�d�t	���|t
krRt�d�t
���|tkr^t�d�t���|tkrjt�d�t���dSt�
d��)Nz"memlimit must be at least {} bytesz!memlimit must be at most {} byteszopslimit must be at least {}zopslimit must be at most {}zUnsupported algorithm)rrr6r7r9rrrr	rrrr rU)rCrDrhr@r@rA�_check_argon2_limits_alg�sj������������������
ri�outlenc
Cstt|t�tjd�tt|t�tjd�tt|t�tjd�tt|t�tjd�tt|t�tjd�t|�tkr@t�d�	t���|t
krLt�d�	t
���|tkrXt�d�	t���t|||�t
�d|�}t�|||t|�||||�}t|dkdtjd�t
�||�dd�S)	a
    Derive a raw cryptographic key using the ``passwd`` and the ``salt``
    given as input to the ``alg`` algorithm.

    :param outlen: the length of the derived key
    :type outlen: int
    :param passwd: The input password
    :type passwd: bytes
    :param salt:
    :type salt: bytes
    :param opslimit: computational cost
    :type opslimit: int
    :param memlimit: memory cost
    :type memlimit: int
    :param alg: algorithm identifier
    :type alg: int
    :return: derived key
    :rtype: bytes
    r.z"salt must be exactly {} bytes longz*derived key must be at least {} bytes longz)derived key must be at most {} bytes longzunsigned char[]rrPN)rrSrTr6rUrVrYrr7r9rrrirrWr�
crypto_pwhashrZr[)rjrLrMrCrDrh�outbufr^r@r@rA�crypto_pwhash_alg�sD��������rmcCs�tt|t�td�tt|t�td�tt|t�td�t|||�t�dd�}t�	||t
|�|||�}t|dkdtjd�t�
|�S)a
    Derive a cryptographic key using the ``passwd`` given as input
    and a random salt, returning a string representation which
    includes the salt, the tuning parameters and the used algorithm.

    :param passwd: The input password
    :type passwd: bytes
    :param opslimit: computational cost
    :type opslimit: int
    :param memlimit: memory cost
    :type memlimit: int
    :param alg: The algorithm to use
    :type alg: int
    :return: serialized derived key and parameters
    :rtype: bytes
    r.r_r2rrP)rrSrTrUrVrirrWr�crypto_pwhash_str_algrYr6rZrb)rLrCrDrhrlr^r@r@rArns��
rncCsftt|t�td�tt|t�td�tt|�dkdtjd�t�||t|��}t|dkdtj	d�dS)a4
    Verifies the ``passwd`` against a given password hash.

    Returns True on success, raises InvalidkeyError on failure
    :param passwd_hash: saved password hash
    :type passwd_hash: bytes
    :param passwd: password to be checked
    :type passwd: bytes
    :return: success
    :rtype: boolean
    r.�z#Hash must be at most 127 bytes longrrdT)
rrSrVrUrYr6r7r�crypto_pwhash_str_verifyrfrgr@r@rArp=s
�rp)�r;�typingr�nacl.exceptions�
exceptionsr6�nacl._sodiumrrr�bool�-PYNACL_HAS_CRYPTO_PWHASH_SCRYPTSALSA208SHA256rQ�,crypto_pwhash_scryptsalsa208sha256_STRPREFIX�,crypto_pwhash_scryptsalsa208sha256_SALTBYTES�+crypto_pwhash_scryptsalsa208sha256_STRBYTES�-crypto_pwhash_scryptsalsa208sha256_PASSWD_MIN�-crypto_pwhash_scryptsalsa208sha256_PASSWD_MAX�,crypto_pwhash_scryptsalsa208sha256_BYTES_MIN�,crypto_pwhash_scryptsalsa208sha256_BYTES_MAX�/crypto_pwhash_scryptsalsa208sha256_MEMLIMIT_MIN�/crypto_pwhash_scryptsalsa208sha256_MEMLIMIT_MAX�/crypto_pwhash_scryptsalsa208sha256_OPSLIMIT_MIN�/crypto_pwhash_scryptsalsa208sha256_OPSLIMIT_MAX�7crypto_pwhash_scryptsalsa208sha256_OPSLIMIT_INTERACTIVE�7crypto_pwhash_scryptsalsa208sha256_MEMLIMIT_INTERACTIVE�5crypto_pwhash_scryptsalsa208sha256_OPSLIMIT_SENSITIVE�5crypto_pwhash_scryptsalsa208sha256_MEMLIMIT_SENSITIVErbr\�,crypto_pwhash_scryptsalsa208sha256_strprefix�,crypto_pwhash_scryptsalsa208sha256_saltbytes�+crypto_pwhash_scryptsalsa208sha256_strbytes�-crypto_pwhash_scryptsalsa208sha256_passwd_min�-crypto_pwhash_scryptsalsa208sha256_passwd_max�,crypto_pwhash_scryptsalsa208sha256_bytes_min�,crypto_pwhash_scryptsalsa208sha256_bytes_max�/crypto_pwhash_scryptsalsa208sha256_memlimit_min�/crypto_pwhash_scryptsalsa208sha256_memlimit_max�/crypto_pwhash_scryptsalsa208sha256_opslimit_min�/crypto_pwhash_scryptsalsa208sha256_opslimit_max�7crypto_pwhash_scryptsalsa208sha256_opslimit_interactive�7crypto_pwhash_scryptsalsa208sha256_memlimit_interactive�5crypto_pwhash_scryptsalsa208sha256_opslimit_sensitive�5crypto_pwhash_scryptsalsa208sha256_memlimit_sensitive�crypto_pwhash_alg_argon2i13rrT�__annotations__�crypto_pwhash_alg_argon2id13r	�crypto_pwhash_alg_defaultr
�crypto_pwhash_saltbytesr�crypto_pwhash_strbytesr�crypto_pwhash_passwd_minr
�crypto_pwhash_passwd_maxr�crypto_pwhash_bytes_minr�crypto_pwhash_bytes_maxr�crypto_pwhash_argon2i_strprefixrrV�"crypto_pwhash_argon2i_memlimit_minr�"crypto_pwhash_argon2i_memlimit_maxr�"crypto_pwhash_argon2i_opslimit_minr�"crypto_pwhash_argon2i_opslimit_maxr�*crypto_pwhash_argon2i_opslimit_interactiver�*crypto_pwhash_argon2i_memlimit_interactiver�'crypto_pwhash_argon2i_opslimit_moderater�'crypto_pwhash_argon2i_memlimit_moderater�(crypto_pwhash_argon2i_opslimit_sensitiver�(crypto_pwhash_argon2i_memlimit_sensitiver� crypto_pwhash_argon2id_strprefixr�#crypto_pwhash_argon2id_memlimit_minr�#crypto_pwhash_argon2id_memlimit_maxr�#crypto_pwhash_argon2id_opslimit_minr�#crypto_pwhash_argon2id_opslimit_maxr �+crypto_pwhash_argon2id_opslimit_interactiver!�+crypto_pwhash_argon2id_memlimit_interactiver"�(crypto_pwhash_argon2id_opslimit_moderater#�(crypto_pwhash_argon2id_memlimit_moderater$�)crypto_pwhash_argon2id_opslimit_sensitiver%�)crypto_pwhash_argon2id_memlimit_sensitiver&�SCRYPT_OPSLIMIT_INTERACTIVE�SCRYPT_MEMLIMIT_INTERACTIVE�SCRYPT_OPSLIMIT_SENSITIVE�SCRYPT_MEMLIMIT_SENSITIVE�SCRYPT_SALTBYTESr`r8�LOG2_UINT64_MAXr:�SCRYPT_MAX_MEMrBrJrXrarerirmrnrp� crypto_pwhash_argon2i_str_verifyr@r@r@rA�<module>s�
�������������������
�
�
�
�
�
�
�
�
�
���
�
�
�
�
�
�
�
�
�
����������
�*��
�&��������
�>����
�,��
�!9������
�G����
�+

https://t.me/RX1948 - 2025