Viewing File: /opt/imunify360/venv/lib/python3.11/site-packages/Crypto/Protocol/__pycache__/KDF.cpython-311.pyc
]j)W : d dl Z d dlZd dlmZ d dlmZmZmZmZm Z m
Z
mZ d dlm
Z
mZmZmZmZ d dlmZ d dlmZ d dlmZmZmZ d dlmZmZmZmZ ed d
Z edd Z!ddZ"ddZ# G d de$ Z%ddZ&d dZ'd Z(d Z)d Z*d!dZ+d Z,d"dZ-dS )# N)reduce)tobytesbord_copy_bytes
iter_rangetostrbchrbstr)SHA1SHA256HMACCMACBLAKE2s)strxor)get_random_bytes)size
long_to_bytes
bytes_to_long)load_pycryptodome_raw_libcreate_string_bufferget_raw_bufferc_size_tzCrypto.Cipher._Salsa20z
int Salsa20_8_core(const uint8_t *x, const uint8_t *y,
uint8_t *out);
zCrypto.Protocol._scrypta
typedef int (core_t)(const uint8_t [64], const uint8_t [64], uint8_t [64]);
int scryptROMix(const uint8_t *data_in, uint8_t *data_out,
size_t data_len, unsigned N, core_t *core);
c |st }t | } | | |z }|j }||k rt d|z t | dk rt
dt | z t |dz
D ])}| | }*| d| S )aM Derive one key from a password (or passphrase).
This function performs key derivation according to an old version of
the PKCS#5 standard (v1.5) or `RFC2898
<https://www.ietf.org/rfc/rfc2898.txt>`_.
Args:
password (string):
The secret password to generate the key from.
salt (byte string):
An 8 byte string to use for better protection from dictionary attacks.
This value does not need to be kept secret, but it should be randomly
chosen for each derivation.
dkLen (integer):
The length of the desired key. The default is 16 bytes, suitable for
instance for :mod:`Crypto.Cipher.AES`.
count (integer):
The number of iterations to carry out. The recommendation is 1000 or
more.
hashAlgo (module):
The hash algorithm to use, as a module or an object from the :mod:`Crypto.Hash` package.
The digest length must be no shorter than ``dkLen``.
The default algorithm is :mod:`Crypto.Hash.SHA1`.
Return:
A byte string of length ``dkLen`` that can be used as key.
z:Selected hash algorithm has a too short digest (%d bytes). z,Salt is not 8 bytes long (%d bytes instead). N) r r newdigest_size TypeErrorlen
ValueErrorr digest)passwordsaltdkLencounthashAlgopHashr"