HEX
Server: Apache
System: Linux 185.122.168.184.host.secureserver.net 5.14.0-570.60.1.el9_6.x86_64 #1 SMP PREEMPT_DYNAMIC Wed Nov 5 05:00:59 EST 2025 x86_64
User: barbeatleanalyti (1024)
PHP: 8.1.33
Disabled: NONE
Upload Files
File: //var/opt/nydus/ops/oscrypto/_win/__pycache__/util.cpython-39.pyc
a

�,�hr�@s�ddlmZmZmZmZddlmZddlmZddl	m
Z
mZddlm
Z
ddlmZmZmZgd�Ze�Zed	kr�d
dlmZmZmZmZmZdd
�Zde_dd�ZnddlmZddlmZdS)�)�unicode_literals�division�absolute_import�print_function�)�backend)�pretty_message)�buffer_from_bytes�bytes_from_buffer)�
pkcs12_kdf)�	type_name�byte_cls�	int_types)�pbkdf2r�
rand_bytes�win�)�bcrypt�BcryptConst�handle_error�open_alg_handle�close_alg_handlec	Cs>t|t�sttdt|����t|t�s8ttdt|����t|t�sTttdt|����|dkrdtd��t|t�s�ttdt|����|dkr�td��|tgd��vr�ttd	t|����t	j
t	jt	jt	j
d�|}d
}zXt|t	j�}t|�}t�||t|�|t|�|||d�	}t|�t|�W|�r&t|�Sn|�r8t|�0d
S)a%
        PBKDF2 from PKCS#5

        :param hash_algorithm:
            The string name of the hash algorithm to use: "sha1", "sha256", "sha384", "sha512"

        :param password:
            A byte string of the password to use an input to the KDF

        :param salt:
            A cryptographic random byte string

        :param iterations:
            The numbers of iterations to use when deriving the key

        :param key_length:
            The length of the desired key in bytes

        :raises:
            ValueError - when any of the parameters contain an invalid value
            TypeError - when any of the parameters are of the wrong type
            OSError - when an error is returned by the OS crypto library

        :return:
            The derived key as a byte string
        zH
                password must be a byte string, not %s
                zD
                salt must be a byte string, not %s
                zG
                iterations must be an integer, not %s
                rz!iterations must be greater than 0zG
                key_length must be an integer, not %s
                z!key_length must be greater than 0)�sha1�sha256�sha384�sha512z|
                hash_algorithm must be one of "sha1", "sha256", "sha384", "sha512",
                not %s
                Nr)�
isinstancer
�	TypeErrorrrr�
ValueError�set�reprrZBCRYPT_SHA1_ALGORITHMZBCRYPT_SHA256_ALGORITHMZBCRYPT_SHA384_ALGORITHMZBCRYPT_SHA512_ALGORITHMrZBCRYPT_ALG_HANDLE_HMAC_FLAGr	rZBCryptDeriveKeyPBKDF2�lenrr
r)	Zhash_algorithm�passwordZsaltZ
iterationsZ
key_lengthZalg_constant�
alg_handleZ
output_buffer�res�r%�C/opt/nydus/tmp/pip-target-wkfpz8uv/lib/python/oscrypto/_win/util.pyrsx
�
�
�
��	�����rFcCs�t|t�sttdt|����|dkr,td��|dkr<td��d}zBttj�}t	|�}t
�|||d�}t|�t
|�W|r�t|�Sn|r�t|�0dS)a�
        Returns a number of random bytes suitable for cryptographic purposes

        :param length:
            The desired number of bytes

        :raises:
            ValueError - when any of the parameters contain an invalid value
            TypeError - when any of the parameters are of the wrong type
            OSError - when an error is returned by the OS crypto library

        :return:
            A byte string
        zC
                length must be an integer, not %s
                rzlength must be greater than 0iz$length must not be greater than 1024Nr)rrrrrrrrZBCRYPT_RNG_ALGORITHMr	rZBCryptGenRandomrr
r)�lengthr#�bufferr$r%r%r&r�s.
�
��r)r)rN)�
__future__rrrr�r�_errorsrZ_ffir	r
Z_pkcs12r�_typesrr
r�__all__Z_backendZ_cngrrrrrrZpure_pythonrZ_pkcs5Z_randr%r%r%r&�<module>sj
/