⚝
One Hat Cyber Team
⚝
Your IP:
216.73.216.184
Server IP:
97.74.87.16
Server:
Linux 16.87.74.97.host.secureserver.net 5.14.0-503.38.1.el9_5.x86_64 #1 SMP PREEMPT_DYNAMIC Fri Apr 18 08:52:10 EDT 2025 x86_64
Server Software:
Apache
PHP Version:
8.2.28
Buat File
|
Buat Folder
Eksekusi
Dir :
~
/
var
/
opt
/
nydus
/
ops
/
oscrypto
/
_win
/
__pycache__
/
View File Name :
util.cpython-39.pyc
a ���gr � @ s� d dl mZmZmZmZ ddlmZ ddlmZ ddl m Z mZ ddlm Z ddlmZmZmZ g d�Ze� Zed kr�d dlmZmZmZmZmZ dd � Zde_dd� ZnddlmZ ddlmZ dS )� )�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 C s> t |t�sttdt|����t |t�s8ttdt|����t |t�sTttdt|����|dk rdtd��t |t�s�ttdt|����|dk r�td��| tg d��vr�ttd t| ����t j t jt jt j d�| }d }zXt|t j�}t|�}t�||t|�|t|�|||d� }t|� t|�W |�r&t|� S n|�r8t|� 0 d 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 r z!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 � TypeErrorr r r � ValueError�set�reprr ZBCRYPT_SHA1_ALGORITHMZBCRYPT_SHA256_ALGORITHMZBCRYPT_SHA384_ALGORITHMZBCRYPT_SHA512_ALGORITHMr ZBCRYPT_ALG_HANDLE_HMAC_FLAGr r ZBCryptDeriveKeyPBKDF2�lenr r r ) Zhash_algorithm�passwordZsaltZ iterationsZ key_lengthZalg_constant� alg_handleZ output_buffer�res� r% �C/opt/nydus/tmp/pip-target-mke_irhy/lib/python/oscrypto/_win/util.pyr sx � � � �� ���� �r Fc C s� t | t�sttdt| ����| dk r,td��| dkr<td��d}zBttj�}t | �}t �||| d�}t|� t |�W |r�t|� S n|r�t|� 0 dS )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 r zlength must be greater than 0i z$length must not be greater than 1024Nr )r r r r r r r r ZBCRYPT_RNG_ALGORITHMr r ZBCryptGenRandomr r r )�lengthr# �bufferr$ r% r% r&