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/_openssl/__pycache__/util.cpython-39.pyc
a

�,�h��@s�ddlmZmZmZmZddlmZddlmZm	Z	ddl
mZmZm
Z
ddlmZddlmZmZmZgd	�Zed
kr�ddlmZndd
�Zde_dd�ZdS)�)�unicode_literals�division�absolute_import�print_function�)�pretty_message)�buffer_from_bytes�bytes_from_buffer�)�	libcrypto�libcrypto_version_info�handle_openssl_error)�
rand_bytes)�	type_name�byte_cls�	int_types)�pbkdf2�
pkcs12_kdfr)r
)rc
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
t	jd�|�}t|�}t	�|t|�|t|�||||�}t|�t|�S)
a�
        PBKDF2 from PKCS#5

        :param hash_algorithm:
            The string name of the hash algorithm to use: "sha1", "sha224", "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

        :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�sha224�sha256�sha384�sha512z�
                hash_algorithm must be one of "sha1", "sha224", "sha256", "sha384",
                "sha512", not %s
                )�
isinstancer�	TypeErrorrrr�
ValueError�set�reprr�EVP_sha1�
EVP_sha224�
EVP_sha256�
EVP_sha384�
EVP_sha512rZPKCS5_PBKDF2_HMAC�lenr
r	)�hash_algorithm�password�salt�
iterations�
key_lengthZevp_md�
output_buffer�result�r+�G/opt/nydus/tmp/pip-target-wkfpz8uv/lib/python/oscrypto/_openssl/util.pyrsd
�
�
�
��	���
rFc
CsZt|t�sttdt|����t|t�s8ttdt|����t|t�sTttdt|����|dkrnttdt|����t|t�s�ttdt|����|dkr�ttdt|����|tgd��vr�ttd	t|����|tgd
��vr�ttdt|����|�	d��
d
�d}tjtj
tjtjtjtjd�|�}t|�}t�|t|�|t|�|||||�	}	t|	�t|�S)a0
    KDF from RFC7292 appendix B.2 - https://tools.ietf.org/html/rfc7292#page-19

    :param hash_algorithm:
        The string name of the hash algorithm to use: "md5", "sha1", "sha224", "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

    :param id_:
        The ID of the usage - 1 for key, 2 for iv, 3 for mac

    :raises:
        ValueError - when any of the parameters contain an invalid value
        TypeError - when any of the parameters are of the wrong type

    :return:
        The derived key as a byte string
    z@
            password must be a byte string, not %s
            z<
            salt must be a byte string, not %s
            z?
            iterations must be an integer, not %s
            r
zC
            iterations must be greater than 0 - is %s
            z?
            key_length must be an integer, not %s
            zC
            key_length must be greater than 0 - is %s
            )�md5rrrrrz�
            hash_algorithm must be one of "md5", "sha1", "sha224", "sha256",
            "sha384", "sha512", not %s
            )r
r�z<
            id_ must be one of 1, 2, 3, not %s
            zutf-8zutf-16bes)rrrrrrrrr�decode�encoderZEVP_md5rrr r!r"rZPKCS12_key_gen_unir#r
r	)
r$r%r&r'r(Zid_Zutf16_passwordZdigest_typer)r*r+r+r,r{s�
�
�
��
������	�rN)�
__future__rrrr�_errorsrZ_ffirr	Z
_libcryptorrr
Z_randr�_typesrrr�__all__Z_pkcs5rZpure_pythonrr+r+r+r,�<module>sa