%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /lib/python3.9/site-packages/passlib/handlers/__pycache__/
Upload File :
Create Path :
Current File : //lib/python3.9/site-packages/passlib/handlers/__pycache__/pbkdf2.cpython-39.opt-1.pyc

a

f�WcBJ�@s�dZddlmZmZddlmZmZddlZe�e	�Z
ddlmZddl
mZmZddlmZmZmZmZddlmZddlmmZgd	�ZGd
d�dejejejej�Z dde	fd
d�Z!e!ddded�d�Z"e!ddd�Z#e!ddd�Z$ej%de"dddd�Z&ej%de#dddd�Z'ej%d e$d!d"dd�Z(d#Z)Gd$d%�d%ejejejej�Z*Gd&d'�d'ejej+ej�Z,Gd(d)�d)ejejej�Z-Gd*d+�d+ejejejej�Z.dS),z,passlib.handlers.pbkdf - PBKDF2 based hashes�)�hexlify�	unhexlify)�	b64encode�	b64decodeN)�
to_unicode)�ab64_decode�ab64_encode)�
str_to_bascii�u�
uascii_to_str�unicode)�pbkdf2_hmac)�pbkdf2_sha1�
pbkdf2_sha256�
pbkdf2_sha512�cta_pbkdf2_sha1�dlitz_pbkdf2_sha1�grub_pbkdf2_sha512c@sReZdZdZdZejZdZdZ	dZ
dZdZdZ
dZed	d
��Zdd�Zd
d�ZdS)�Pbkdf2DigestHandlerz1base class for various pbkdf2_{digest} algorithms��saltZ	salt_size�rounds��N�����linearcCsFtj||j|d�\}}}t|�d��}|r8t|�d��}||||d�S)N)�handler�ascii�rr�checksum)�uh�	parse_mc3�identr�encode��cls�hashrr�chk�r)�;/usr/lib/python3.9/site-packages/passlib/handlers/pbkdf2.py�from_string?s
zPbkdf2DigestHandler.from_stringcCs4t|j��d�}t|j��d�}t�|j|j||�S�Nr)rr�decoder r!�
render_mc3r#r��selfrr(r)r)r*�	to_stringGszPbkdf2DigestHandler.to_stringcCst|j||j|j|j�S)N)r
�_digestrr�
checksum_size�r0�secretr)r)r*�_calc_checksumLsz"Pbkdf2DigestHandler._calc_checksum)�__name__�
__module__�__qualname__�__doc__�setting_kwdsr!�HASH64_CHARSZchecksum_chars�default_salt_size�
max_salt_size�default_rounds�
min_rounds�
max_rounds�rounds_costr2�classmethodr+r1r6r)r)r)r*rs

ri�.cCsdd|}|durtd�|f}t}t||ft|||||||ddddt|��|j|d�d	��S)
z;create new Pbkdf2DigestHandler subclass for a specific hashZpbkdf2_Nz$pbkdf2-%s$���a$This class implements a generic ``PBKDF2-HMAC-%(digest)s``-based password hash, and follows the :ref:`password-hash-api`.

    It supports a variable-length salt, and a variable number of rounds.

    The :meth:`~passlib.ifc.PasswordHash.using` method accepts the following optional keywords:

    :type salt: bytes
    :param salt:
        Optional salt bytes.
        If specified, the length must be between 0-1024 bytes.
        If not specified, a %(dsc)d byte salt will be autogenerated (this is recommended).

    :type salt_size: int
    :param salt_size:
        Optional number of bytes to use when autogenerating new salts.
        Defaults to %(dsc)d bytes, but can be any value between 0 and 1024.

    :type rounds: int
    :param rounds:
        Optional number of rounds to use.
        Defaults to %(dr)d, but must be within ``range(1,1<<32)``.

    :type relaxed: bool
    :param relaxed:
        By default, providing an invalid value for one of the other
        keywords will result in a :exc:`ValueError`. If ``relaxed=True``,
        and the error can be corrected, a :exc:`~passlib.exc.PasslibHashWarning`
        will be issued instead. Correctable errors include ``rounds``
        that are too small or too large, and ``salt`` strings that are too long.

        .. versionadded:: 1.6
    )�digestZdscZdr)r8�namer#r2r?r3Zencoded_checksum_sizer:)r
r�type�dict�upperr=)Z	hash_name�digest_sizerr#�modulerH�baser)r)r*�create_pbkdf2_hashPs 
��rO�sha1�i��z$pbkdf2$)r#Zsha256� iHq�sha512�@i�a�ldap_pbkdf2_sha1z{PBKDF2}T�ldap_pbkdf2_sha256z{PBKDF2-SHA256}z$pbkdf2-sha256$�ldap_pbkdf2_sha512z{PBKDF2-SHA512}z$pbkdf2-sha512$s-_c@sZeZdZdZdZdZed�ZdZdZ	dZ
ejZdZ
dZd	Zed
d��Zdd
�Zdd�ZdS)ra�This class implements Cryptacular's PBKDF2-based crypt algorithm, and follows the :ref:`password-hash-api`.

    It supports a variable-length salt, and a variable number of rounds.

    The :meth:`~passlib.ifc.PasswordHash.using` method accepts the following optional keywords:

    :type salt: bytes
    :param salt:
        Optional salt bytes.
        If specified, it may be any length.
        If not specified, a one will be autogenerated (this is recommended).

    :type salt_size: int
    :param salt_size:
        Optional number of bytes to use when autogenerating new salts.
        Defaults to 16 bytes, but can be any value between 0 and 1024.

    :type rounds: int
    :param rounds:
        Optional number of rounds to use.
        Defaults to 60000, must be within ``range(1,1<<32)``.

    :type relaxed: bool
    :param relaxed:
        By default, providing an invalid value for one of the other
        keywords will result in a :exc:`ValueError`. If ``relaxed=True``,
        and the error can be corrected, a :exc:`~passlib.exc.PasslibHashWarning`
        will be issued instead. Correctable errors include ``rounds``
        that are too small or too large, and ``salt`` strings that are too long.

        .. versionadded:: 1.6
    r�$p5k2$rQrrrrrcCsLtj||jd|d�\}}}t|�d�t�}|r>t|�d�t�}||||d�S)Nr)�rounds_baserrr)r!r"r#rr$�CTA_ALTCHARSr%r)r)r*r+�s
zcta_pbkdf2_sha1.from_stringcCs<t|jt��d�}t|jt��d�}tj|j|j||dd�S)Nrr�rY)	rrrZr-r r!r.r#rr/r)r)r*r1�szcta_pbkdf2_sha1.to_stringcCstd||j|jd�S)NrPrQ�r
rrr4r)r)r*r6�szcta_pbkdf2_sha1._calc_checksumN)r7r8r9r:rHr;r
r#r3r=r>rr?r@rArBrCr+r1r6r)r)r)r*r�s%

rc@sleZdZdZdZdZed�Zed�ZdZ	dZ
ejZ
ejZdZdZd	Zed
d��Zdd
�Zdd�Zdd�ZdS)raCThis class implements Dwayne Litzenberger's PBKDF2-based crypt algorithm, and follows the :ref:`password-hash-api`.

    It supports a variable-length salt, and a variable number of rounds.

    The :meth:`~passlib.ifc.PasswordHash.using` method accepts the following optional keywords:

    :type salt: str
    :param salt:
        Optional salt string.
        If specified, it may be any length, but must use the characters in the regexp range ``[./0-9A-Za-z]``.
        If not specified, a 16 character salt will be autogenerated (this is recommended).

    :type salt_size: int
    :param salt_size:
        Optional number of bytes to use when autogenerating new salts.
        Defaults to 16 bytes, but can be any value between 0 and 1024.

    :type rounds: int
    :param rounds:
        Optional number of rounds to use.
        Defaults to 60000, must be within ``range(1,1<<32)``.

    :type relaxed: bool
    :param relaxed:
        By default, providing an invalid value for one of the other
        keywords will result in a :exc:`ValueError`. If ``relaxed=True``,
        and the error can be corrected, a :exc:`~passlib.exc.PasslibHashWarning`
        will be issued instead. Correctable errors include ``rounds``
        that are too small or too large, and ``salt`` strings that are too long.

        .. versionadded:: 1.6
    rrXz1000000000000000000000000000000000000000000000000=rrrrrcCs*tj||jdd|d�\}}}||||d�S)Nr�)rYr?rr)r!r"r#r%r)r)r*r+9s�zdlitz_pbkdf2_sha1.from_stringcCs,|j}|dkrd}tj|j||j|jdd�S�Nr]rr[)rr!r.r#rr �r0rr)r)r*r1?szdlitz_pbkdf2_sha1.to_stringcCs*|j}|dkrd}tj|j||jddd�Sr^)rr!r.r#rr_r)r)r*�_get_configEszdlitz_pbkdf2_sha1._get_configcCs(|��}td|||jd�}t|��d�S)NrP�r)r`r
rrr-)r0r5r�resultr)r)r*r6Nsz dlitz_pbkdf2_sha1._calc_checksumN)r7r8r9r:rHr;r
r#Z_stub_checksumr=r>r!r<Z
salt_charsrr?r@rArBrCr+r1r`r6r)r)r)r*r�s"%

	rc@sHeZdZdZdZdZed�ZdZdZ	Z
edd��Zdd	�Z
d
d�ZdS)
�atlassian_pbkdf2_sha1aBThis class implements the PBKDF2 hash used by Atlassian.

    It supports a fixed-length salt, and a fixed number of rounds.

    The :meth:`~passlib.ifc.PasswordHash.using` method accepts the following optional keywords:

    :type salt: bytes
    :param salt:
        Optional salt bytes.
        If specified, the length must be exactly 16 bytes.
        If not specified, a salt will be autogenerated (this is recommended).

    :type relaxed: bool
    :param relaxed:
        By default, providing an invalid value for one of the other
        keywords will result in a :exc:`ValueError`. If ``relaxed=True``,
        and the error can be corrected, a :exc:`~passlib.exc.PasslibHashWarning`
        will be issued instead. Correctable errors include
        ``salt`` strings that are too long.

        .. versionadded:: 1.6
    )rz	{PKCS5S2}rRrcCsht|dd�}|j}|�|�s(tj�|��t|t|�d��d��}|dd�|dd�}}|||d�S)Nrr'r)rr )	rr#�
startswithr!�excZInvalidHashErrorr�lenr$)r&r'r#�datarr(r)r)r*r+{s
z!atlassian_pbkdf2_sha1.from_stringcCs(|j|j}|jt|��d�}t|�Sr,)rr r#rr-r)r0rgr'r)r)r*r1�szatlassian_pbkdf2_sha1.to_stringcCstd||jdd�S)NrPi'rR)r
rr4r)r)r*r6�sz$atlassian_pbkdf2_sha1._calc_checksumN)r7r8r9r:rHr;r
r#r3Z
min_salt_sizer>rCr+r1r6r)r)r)r*rc[s
	rcc@sZeZdZdZdZdZed�ZdZdZ	dZ
ejZdZ
dZdZed	d
��Zdd�Zd
d�ZdS)ra�This class implements Grub's pbkdf2-hmac-sha512 hash, and follows the :ref:`password-hash-api`.

    It supports a variable-length salt, and a variable number of rounds.

    The :meth:`~passlib.ifc.PasswordHash.using` method accepts the following optional keywords:

    :type salt: bytes
    :param salt:
        Optional salt bytes.
        If specified, the length must be between 0-1024 bytes.
        If not specified, a 64 byte salt will be autogenerated (this is recommended).

    :type salt_size: int
    :param salt_size:
        Optional number of bytes to use when autogenerating new salts.
        Defaults to 64 bytes, but can be any value between 0 and 1024.

    :type rounds: int
    :param rounds:
        Optional number of rounds to use.
        Defaults to 19000, but must be within ``range(1,1<<32)``.

    :type relaxed: bool
    :param relaxed:
        By default, providing an invalid value for one of the other
        keywords will result in a :exc:`ValueError`. If ``relaxed=True``,
        and the error can be corrected, a :exc:`~passlib.exc.PasslibHashWarning`
        will be issued instead. Correctable errors include ``rounds``
        that are too small or too large, and ``salt`` strings that are too long.

        .. versionadded:: 1.6
    rzgrub.pbkdf2.sha512.rTrrrrcCsLtj||jtd�|d�\}}}t|�d��}|r>t|�d��}||||d�S)N�.)�seprrr)r!r"r#r
rr$r%r)r)r*r+�s�zgrub_pbkdf2_sha512.from_stringcCsDt|j��d���}t|j��d���}tj|j|j||t	d�d�S)Nrrh)ri)
rrr-rKr r!r.r#rr
r/r)r)r*r1�szgrub_pbkdf2_sha512.to_stringcCstd||j|jd�S)NrSrTr\r4r)r)r*r6�sz!grub_pbkdf2_sha512._calc_checksumN)r7r8r9r:rHr;r
r#r3r=r>rr?r@rArBrCr+r1r6r)r)r)r*r�s 
r)/r:Zbinasciirr�base64rrZloggingZ	getLoggerr7�logZ
passlib.utilsrZpasslib.utils.binaryrrZpasslib.utils.compatr	r
rrZpasslib.crypto.digestr
Zpasslib.utils.handlersZutils�handlersr!�__all__Z	HasRoundsZ
HasRawSaltZHasRawChecksumZGenericHandlerrrOrrrZ
PrefixWrapperrUrVrWrZrZHasSaltrrcrr)r)r)r*�<module>s,33`i8

Zerion Mini Shell 1.0