|
Server : LiteSpeed System : Linux server51.dnsbootclub.com 4.18.0-553.62.1.lve.el8.x86_64 #1 SMP Mon Jul 21 17:50:35 UTC 2025 x86_64 User : nandedex ( 1060) PHP Version : 8.1.33 Disable Function : NONE Directory : /opt/cppython/lib/python3.8/site-packages/nacl/pwhash/__pycache__/ |
U
O��gJ � @ s& d dl mZ d dlZd dlZd dlmZ d dlmZ ej j
Zej jZ
ej jZej jZej jZej jZed Zej jZej jZej jZej jZej jZ ej j!Z"ej j#Z$ej j%Z&ej j'Z(ej j)Z*de$ Z+de& Z,e(e*ej-j.fe/e0e0e/e/ej-j1e0d�dd �Z2e$e&fe0e/e/e0d
�dd�Z3e0e0e4d
�dd�Z5dS )� )�castN)�
exceptions)�ensure� � )�size�password�salt�opslimit�memlimit�encoder�returnc
C sz t tdtjd� t t|�tkdtt|�f tjd� tj� ||�\}}}|d } |�
tjj||tt
d| �||| | d��S )al
Derive a ``size`` bytes long key from a caller-supplied
``password`` and ``salt`` pair using the scryptsalsa208sha256
memory-hard construct.
the enclosing module provides the constants
- :py:const:`.OPSLIMIT_INTERACTIVE`
- :py:const:`.MEMLIMIT_INTERACTIVE`
- :py:const:`.OPSLIMIT_SENSITIVE`
- :py:const:`.MEMLIMIT_SENSITIVE`
- :py:const:`.OPSLIMIT_MODERATE`
- :py:const:`.MEMLIMIT_MODERATE`
as a guidance for correct settings respectively for the
interactive login and the long term key protecting sensitive data
use cases.
:param size: derived key size, must be between
:py:const:`.BYTES_MIN` and
:py:const:`.BYTES_MAX`
:type size: int
:param password: password used to seed the key derivation procedure;
it length must be between
:py:const:`.PASSWD_MIN` and
:py:const:`.PASSWD_MAX`
:type password: bytes
:param salt: **RANDOM** salt used in the key derivation procedure;
its length must be exactly :py:const:`.SALTBYTES`
:type salt: bytes
:param opslimit: the time component (operation count)
of the key derivation procedure's computational cost;
it must be between
:py:const:`.OPSLIMIT_MIN` and
:py:const:`.OPSLIMIT_MAX`
:type opslimit: int
:param memlimit: the memory occupation component
of the key derivation procedure's computational cost;
it must be between
:py:const:`.MEMLIMIT_MIN` and
:py:const:`.MEMLIMIT_MAX`
:type memlimit: int
:rtype: bytes
:raises nacl.exceptions.UnavailableError: If called when using a
minimal build of libsodium.
.. versionadded:: 1.2
�Not available in minimal build�Zraisingz.The salt must be exactly %s, not %s bytes longi � )�maxmemZdklen)r � AVAILABLE�exc�UnavailableError�len� SALTBYTES�
ValueError�nacl�bindingsZ nacl_bindings_pick_scrypt_params�encodeZ%crypto_pwhash_scryptsalsa208sha256_llr �int)
r r r r
r r Zn_log2�r�pr � r �?/opt/cppython/lib/python3.8/site-packages/nacl/pwhash/scrypt.py�kdf; s8 9�
�� �
��r )r r
r r
c C s t tdtjd� tj�| ||�S )a$
Hashes a password with a random salt, using the memory-hard
scryptsalsa208sha256 construct and returning an ascii string
that has all the needed info to check against a future password
The default settings for opslimit and memlimit are those deemed
correct for the interactive user login case.
:param bytes password:
:param int opslimit:
:param int memlimit:
:rtype: bytes
:raises nacl.exceptions.UnavailableError: If called when using a
minimal build of libsodium.
.. versionadded:: 1.2
r r )r r r r r r Z&crypto_pwhash_scryptsalsa208sha256_str)r r
r r r r �str� s � �r! )�
password_hashr r
c C s>