%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_pwhash.cpython-312.pyc

�

�f�I��

�UddlZddlmZddlmZddlmZmZddlm	Z	e
ej�ZdZ
dZdZdZdZdZdZdZdZdZdZdZdZdZdZe�r#ej8ej:dej<���ddZ
ej>�Zej@�ZejB�ZejD�ZejF�ZejH�ZejJ�ZejL�ZejN�ZejP�ZejR�ZejT�ZejV�ZejX�ZejZ�Z.e/e0d<ejb�Z2e/e0d<ejf�Z4e/e0d	<ejj�Z6e/e0d
<ejn�Z8e/e0d<ejr�Z:e/e0d<ejv�Z<e/e0d
<ejz�Z>e/e0d<ej~�Z@e/e0d<ej8ej:dej����ddZBeCe0d<ej��ZEe/e0d<ej��ZGe/e0d<ej��ZIe/e0d<ej��ZKe/e0d<ej��ZMe/e0d<ej��ZOe/e0d<ej��ZQe/e0d<ej��ZSe/e0d<ej��ZUe/e0d<ej��ZWe/e0d<ej8ej:dej����ddZYeCe0d<ej��Z[e/e0d<ej��Z]e/e0d<ej��Z_e/e0d<ej��Zae/e0d<ej��Zce/e0d <ej��Zee/e0d!<ej��Zge/e0d"<ej��Zie/e0d#<ej��Zke/e0d$<ej��Zme/e0d%<eZneZoeZpeZqeZreZsd&Ztd'Zud(Zvd)Zwewfd*e/d+e/d,e/d-e/d.df
d/�Zxd0e/d1e/d.ee/e/e/ffd2�Zyd3ewfd4eCd5eCd*e/d+e/d,e/d6e/d-e/d.eCfd7�Zzeneofd4eCd0e/d1e/d.eCfd8�Z{d9eCd4eCd.e
fd:�Z|d0e/d1e/d;e/d.dfd<�Z}d=e/d4eCd5eCd0e/d1e/d;e/d.eCfd>�Z~d4eCd0e/d1e/d;e/d.eCf
d?�Zd9eCd4eCd.e
fd@�Z�e�Z�y)A�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�returnc�4�t|dk7dtj��t|dk7dtj��t||dz
zdk(dtj��t|dkDdtj��t|t|zkdj	t�tj��t|dd	|zzktj��|d
z|z}t
d
z}t|dz||zktj��d|z|dzzd
z}t|t
|z
ktj��t|tj|z
ktj��t||z|kdtj��y)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�Vlens       �=/usr/lib/python3/dist-packages/nacl/bindings/crypto_pwhash.py�_check_memory_occupationrC�sH���1��6�'����@�
�1��6�3�S�^�^�L�
�	
�a�!�e����*������1�q�5�2�C�N�N�K�
�	�]�Q�
�� �'�'�
�6������1��b�1�f�
�����7��s�7�Q�;�D��S��A�
�1�q�5�A��E�>�3�>�>�2�
��6�Q��U��a��D�
�4�:��$�$�c�n�n�=�
�4�3�;�;��%�%�s�~�~�>�
��t��v��A����r�opslimit�memlimitc��|dkrd}d}||dzkr)d}|d|zz}tdd�D]}d|z|dzkDs�n?n=||dzz}tdd�D]}d|z|dzkDs�n|dzdzz}|d	kDrd	}||z}||fS)
z/Python implementation of libsodium's pickparamsi��r6r2r7r)r5r4r()�range)rDrEr+r,�maxn�n_log2�maxrps       rB� nacl_bindings_pick_scrypt_paramsrL�s���
�%����	�A��8�r�>�"�
���A��E�"���A�r�l�	�F��V����	�*��	��A��G�$���A�r�l�	�F��V��t�q�y�(��	��Q��A��K�0���:���E��Q�J���1�a�<�r�@�passwd�salt�dklenc��ttdtj��tt	|t
�t��tt	|t
�t��tt	|t
�t��tt	|t�t��tt	|t�t��t||||�tjd|�}tj|t|�|t|�|||||�	}t|dk(dtj��tjtj d|�|�ddS)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 buildr0z	uint8_t[]r�$Unexpected failure in key derivationrN)r�&has_crypto_pwhash_scryptsalsa208sha256r8�UnavailableError�
isinstance�int�	TypeError�bytesrCr�newr�%crypto_pwhash_scryptsalsa208sha256_ll�len�RuntimeError�buffer�cast)	rNrOr*r+r,rPr-�buf�rets	         rBr[r[	s���<�.�(��$�$���:�a���y�1�
�:�a���y�1�
�:�a���y�1�
�:�f�e�$�i�8�
�:�d�E�"�I�6��Q��1�f�-�

�'�'�+�u�
%�C�

�
3�
3���F��T�3�t�9�a��A�s�E��C���q��.�� � ���:�:�c�h�h�x��-�u�5�a�8�8rc�"�ttdtj��t	j
dt�}tj||t|�||�}t|dk(dtj��t	j|�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.
    rRr0�char[]rz&Unexpected failure in password hashing)rrTr8rUrrZ�SCRYPT_STRBYTESr�&crypto_pwhash_scryptsalsa208sha256_strr\r]�string)rNrDrEr`ras     rBrereEsy��.�.�(��$�$���'�'�(�O�
,�C�

�
4�
4��V�S��[�(�H��C���q��0�� � ���:�:�c�?�r�passwd_hashc� �ttdtj��tt	|�t
dz
k(dtj��tj||t	|��}t|dk(dtj��y)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.
    rRr0r2zInvalid password hashr�Wrong passwordT)
rrTr8rUr\rdr9r�-crypto_pwhash_scryptsalsa208sha256_str_verify�InvalidkeyError�rgrNras   rBrjrjqsz���.�(��$�$����K��O�a�/�/�������
;�
;��V�S��[��C��3�!�8�%�s�/B�/B�C�r�algc�d�|tk(r�|tkr(tjdj	t���|t
kDr(tjdj	t
���|tkr(tjdj	t���|tkDr(tjdj	t���y|tk(r�|tkr(tjdj	t���|tkDr(tjdj	t���|tkr(tjdj	t���|tkDr(tjdj	t���ytjd��)Nz"memlimit must be at least {} bytesz!memlimit must be at most {} byteszopslimit must be at least {}zopslimit must be at most {}zUnsupported algorithm)r	rr8r9r;rrrr
rrr r!rX)rDrErms   rB�_check_argon2_limits_algro�s���
�)�)��8�8��.�.�4�;�;�6���
�
�:�
:��.�.�3�:�:�6���
�
�8�8��.�.�.�5�5�6���
�
�:�
:��.�.�-�4�4�6���
�;�

�,�	,��9�9��.�.�4�;�;�7���
�
�;�
;��.�.�3�:�:�7���
�
�9�9��.�.�.�5�5�7���
�
�;�
;��.�.�-�4�4�7���
�<��m�m�3�4�4r�outlenc
���tt|t�tj��tt|t�tj��tt|t�tj��tt|t�tj��tt|t
�tj��t
|�tk7r(tjdjt���|tkr(tjdjt���|tkDr(tjdjt���t|||�tjd|�}tj |||t
|�||||�}t|dk(dtj"��tj$||�ddS)	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
    r0z"salt must be exactly {} bytes longz*derived key must be at least {} bytes longz)derived key must be at most {} bytes longzunsigned char[]rrSN)rrVrWr8rXrYr\rr9r;rrrorrZr�
crypto_pwhashr]r^)rprNrOrDrErm�outbufras        rB�crypto_pwhash_algrt�so��6�:�f�c�"�C�M�M�:�
�:�h��$�c�m�m�<�
�:�h��$�c�m�m�<�
�:�c�3�����7�
�:�f�e�$�c�m�m�<�
�4�y�+�+��n�n�0�7�7�'�
�
�	
��'�'��n�n�8�?�?�'�
�
�	
�
�)�	)��n�n�7�>�>�'�
�
�	
��X�x��5�
�W�W�&��
/�F�

�
�
�����F��T�8�X�s��C���q��.�� � ���:�:�f�f�%�a�(�(rc��tt|t�t��tt|t�t��tt|t�t��t|||�t
jdd�}tj||t|�|||�}t|dk(dtj��t
j|�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
    r0rcr4rrS)rrVrWrXrYrorrZr�crypto_pwhash_str_algr\r8r]rf)rNrDrErmrsras      rBrvrvs���,�:�h��$�i�8�
�:�h��$�i�8�
�:�f�e�$�i�8��X�x��5�
�W�W�X�s�
#�F�

�
#�
#����F��X�x���C���q��.�� � ���:�:�f��rc�N�tt|t�t��tt|t�t��tt	|�dkdt
j��tj||t	|��}t|dk(dt
j��y)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
    r0�z#Hash must be at most 127 bytes longrriT)
rrVrYrXr\r8r9r�crypto_pwhash_str_verifyrkrls   rBryry=sy���:�k�5�)�9�=�
�:�f�e�$�i�8�
��K��C��-������
&�
&�{�F�C��K�
H�C�
�3�!�8�%�s�/B�/B�C�r)�r=�typingr�nacl.exceptions�
exceptionsr8�nacl._sodiumrrr�bool�-PYNACL_HAS_CRYPTO_PWHASH_SCRYPTSALSA208SHA256rT�,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_SENSITIVErfr_�,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_argon2i13r	rW�__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_strprefixrrY�"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_SALTBYTESrdr:�LOG2_UINT64_MAXr<�SCRYPT_MAX_MEMrCrLr[rerjrortrvry� crypto_pwhash_argon2i_str_verify�rrB�<module>r�su�����!�"�*.��5�5�*�&�03�,�/0�,�./�+�01�-�01�-�/0�,�/0�,�23�/�23�/�23�/�23�/�:;�7�:;�7�89�5�89�5�)�3=�3�:�:������K�3�K�K�M�N�4��4	�0�	9��8�8�:�1�	8��7�7�9�0�	:��9�9�;�2�	:��9�9�;�2�	9��8�8�:�1�	9��8�8�:�1�	<��;�;�=�4�	<��;�;�=�4�	<��;�;�=�4�	<��;�;�=�4�	D��C�C�E�<�	D��C�C�E�<�	B��A�A�C�:�	B��A�A�C�:�$C�3�#B�#B�#D��S�D�$D�C�$D�$D�$F��c�F�!>��!>�!>�!@��3�@�:�s�:�:�<���<�8�c�8�8�:���:� <�� <� <� >��#�>� <�� <� <� >��#�>�:�s�:�:�<���<�:�s�:�:�<���<�)3�����C�H�H�X�:�s�:�:�<�=�*��*����+�C�*�*�,�#�C��+�C�*�*�,�#�C��+�C�*�*�,�#�C��+�C�*�*�,�#�C��3�C�2�2�4�+�C��3�C�2�2�4�+�C��0�C�/�/�1�(���0�C�/�/�1�(���1�C�0�0�2�)�#��1�C�0�0�2�)�#��+5�#�*�*��C�H�H�X�;�s�;�;�=�>�+��+� �%��,�C�+�+�-�$�S��,�C�+�+�-�$�S��,�C�+�+�-�$�S��,�C�+�+�-�$�S��4�C�3�3�5�,�S��4�C�3�3�5�,�S��1�C�0�0�2�)�#��1�C�0�0�2�)�#��2�C�1�1�3�*�3��2�C�1�1�3�*�3��
<��<��:��:��@��=���
���
�
�#��+9�'�
�'��'��'�$'�'�	�'�T��� ��
�3��S�=���L� �99��99�
�99��99��	99�
�99��
99�
�99��99�|0�/�)��)��)��)��	)�X��� %��	��B65�s�65�c�65��65��65�rD)��D)��D)��D)��	D)�
�D)�

�
D)��D)�N(��(��(��(�

�	(�
�(�V�%����4��6$<� r

Zerion Mini Shell 1.0