%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__/sha2_crypt.cpython-39.opt-1.pyc

a

f�Wc(U�@s�dZddlZddlZe�e�ZddlmZmZm	Z	m
Z
ddlmZddl
mZmZmZmZddlmmZddgZdZd	Zd
ZdZdd
d�Zed�Zed�Zed�ZGdd�dejej ej!ej"�Z#Gdd�de#�Z$Gdd�de#�Z%dS)z9passlib.handlers.sha2_crypt - SHA256-Crypt / SHA512-Crypt�N)�
safe_crypt�
test_crypt�
repeat_string�
to_unicode)�h64)�byte_elem_value�u�
uascii_to_str�unicode�sha512_crypt�sha256_crypt�))r�����rr)r�rr�rr)�rrr)rrrrr)rrrr)rrrrr) ��
r�r�r����
r�r�r��������������	��)@�*rrr�+rrr�,�-rrr�.r r"r�/�0r'r$r&�1r)r+r(�2�3r.r-r�4r/� r�5�6�!rr�7�"�#r�8�9�$r!r#�:�%�&r%�;�<�'r*r,�=�(�)r�>�?FcsJt|t�r|�d�}t|vr0tj�|r*tnt��t	|�}|�d�}t	|�}|rZt
j}t}n
t
j
}t}||||���}|||�}	|	j}
|
t||��|}|r�|
|d@r�|n|�|dL}q�|	��}|dkr�t|||���|�}
n<||�}|j}|d}|�r||�|d8}q�t|��|�}
||dt|d����d|�}|
|
}|
|}|
||||
||
||g��fdd	�tD�}|}t|d
�\}}|�r�|D]&\}}|||||������}�q�|d8}�q�|�r8|d?}|d|�D]&\}}|||||������}�q�|d@�r8||||d���}t�||��d�S)a�perform raw sha256-crypt / sha512-crypt

    this function provides a pure-python implementation of the internals
    for the SHA256-Crypt and SHA512-Crypt algorithms; it doesn't
    handle any of the parsing/validation of the hash strings themselves.

    :arg pwd: password chars/bytes to hash
    :arg salt: salt chars to use
    :arg rounds: linear rounds cost
    :arg use_512: use sha512-crypt instead of sha256-crypt mode

    :returns:
        encoded checksum chars
    zutf-8�asciir�`r#rNcs g|]\}}�|�|f�qS�rR)�.0�even�odd�ZpermsrR�?/usr/lib/python3.9/site-packages/passlib/handlers/sha2_crypt.py�
<listcomp>��z#_raw_sha2_crypt.<locals>.<listcomp>r0)�
isinstancer
�encode�_BNULL�uh�excZNullPasswordErrorrr�len�hashlibZsha512�_512_transpose_mapZsha256�_256_transpose_map�digest�updaterr�_c_digest_offsets�divmodrZencode_transposed_bytes�decode)�pwd�salt�roundsZuse_512Zpwd_lenZsalt_lenZ
hash_constZ
transpose_mapZdbZa_ctxZa_ctx_update�i�daZdpZtmp_ctxZtmp_ctx_updateZdsZdp_dpZdp_ds�dataZdcZblocks�tailrTrU�pairsrRrVrW�_raw_sha2_crypt8s`!





$/  
rpzrounds=�$�0cs�eZdZdZdZejZdZejZ	dZ
dZdZdZ
dZdZd�fd	d
�	Zdd�Zd
d�Zedd��Zdd�ZdZdZedd��Zdd�Zedd��Zdd�Z�ZS)�_SHA2_CommonzBclass containing common code shared by sha256_crypt & sha512_crypt)rirj�implicit_roundsZ	salt_sizer#i�i�ɚ;ZlinearFNcs8tt|�jfi|��|dur.|jo,|jdk}||_dS)N�)�superrs�__init__Zuse_defaultsrjrt)�selfrt�kwds��	__class__rRrWrwsz_SHA2_Common.__init__cCs|j||jdud�S�N)Zrelaxed)Z
_norm_salt�checksum)rxrirRrRrW�_parse_saltsz_SHA2_Common._parse_saltcCs|j||jdud�Sr|)Z_norm_roundsr})rxrjrRrRrW�
_parse_rounds#sz_SHA2_Common._parse_roundscCs�t|dd�}|j}|�|�s(tj�|��|dd��t�}|d�t�r�|�	d�dd�}|�t
�rx|t
krxtj�|��t|�}d}nd}d}t
|�d	kr�|\}}n&t
|�d
kr�|d}d}ntj�|��||||p�d|d�S)NrP�hashrrr&FruTrr)rjrir}rt)r�ident�
startswithr]r^ZInvalidHashError�split�_UDOLLAR�_UROUNDS�pop�_UZEROZZeroPaddedRoundsError�intr_ZMalformedHashError)�clsr�r��partsrjrtriZchkrRrRrW�from_string's2	

�z_SHA2_Common.from_stringcCs^|jdkr2|jr2td�|j|j|jp*td�f}n$td�|j|j|j|jpPtd�f}t|�S)Nruz%s%s$%s�z%srounds=%d$%s$%s)rjrtrr�rir}r	)rxr�rRrRrW�	to_stringTs��z_SHA2_Common.to_string)Zos_cryptZbuiltincCs"t|j�r|�|j�dSdSdS)NTF)r�
_test_hash�_set_calc_checksum_backend�_calc_checksum_os_crypt�r�rRrRrW�_load_backend_os_cryptis
z#_SHA2_Common._load_backend_os_cryptcCsf|��}t||�}|dur$|�|�S|j}|�|j�rH||dtkrXtj�	|||��||d�S)Nr)
r�r�_calc_checksum_builtin�
checksum_sizer�r�r�r]r^ZCryptBackendError)rx�secretZconfigr��csrRrRrWr�qs

z$_SHA2_Common._calc_checksum_os_cryptcCs|�|j�dS)NT)r�r�r�rRrRrW�_load_backend_builtin�sz"_SHA2_Common._load_backend_builtincCst||j|j|j�S)N)rprirj�_cdb_use_512)rxr�rRrRrWr��s�z#_SHA2_Common._calc_checksum_builtin)N)�__name__�
__module__�__qualname__�__doc__Zsetting_kwdsr]ZHASH64_CHARSZchecksum_charsZ
max_salt_sizeZ
salt_charsZ
min_roundsZ
max_roundsZrounds_costr�Z_rounds_prefixrtrwr~r�classmethodr�r�Zbackendsr�r�r�r�r��
__classcell__rRrRrzrWrs�s2
,

rsc@s(eZdZdZdZed�ZdZdZdZ	dS)raKThis class implements the SHA256-Crypt 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: str
    :param salt:
        Optional salt string.
        If not specified, one will be autogenerated (this is recommended).
        If specified, it must be 0-16 characters, drawn from the regexp range ``[./0-9A-Za-z]``.

    :type rounds: int
    :param rounds:
        Optional number of rounds to use.
        Defaults to 535000, must be between 1000 and 999999999, inclusive.

        .. note::
            per the official specification, when the rounds parameter is set to 5000,
            it may be omitted from the hash string.

    :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

    ..
        commented out, currently only supported by :meth:`hash`, and not via :meth:`using`:

        :type implicit_rounds: bool
        :param implicit_rounds:
            this is an internal option which generally doesn't need to be touched.

            this flag determines whether the hash should omit the rounds parameter
            when encoding it to a string; this is only permitted by the spec for rounds=5000,
            and the flag is ignored otherwise. the spec requires the two different
            encodings be preserved as they are, instead of normalizing them.
    z$5$r1i�))�testz?$5$rounds=1000$test$QmQADEXMG8POI5WDsaeho0P36yK3Tcrgboabng6bkb/N)
r�r�r�r��namerr�r��default_roundsr�rRrRrRrWr�s.c@s,eZdZdZdZed�ZdZdZdZ	dZ
dS)raKThis class implements the SHA512-Crypt 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: str
    :param salt:
        Optional salt string.
        If not specified, one will be autogenerated (this is recommended).
        If specified, it must be 0-16 characters, drawn from the regexp range ``[./0-9A-Za-z]``.

    :type rounds: int
    :param rounds:
        Optional number of rounds to use.
        Defaults to 656000, must be between 1000 and 999999999, inclusive.

        .. note::
            per the official specification, when the rounds parameter is set to 5000,
            it may be omitted from the hash string.

    :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

    ..
        commented out, currently only supported by :meth:`hash`, and not via :meth:`using`:

        :type implicit_rounds: bool
        :param implicit_rounds:
            this is an internal option which generally doesn't need to be touched.

            this flag determines whether the hash should omit the rounds parameter
            when encoding it to a string; this is only permitted by the spec for rounds=5000,
            and the flag is ignored otherwise. the spec requires the two different
            encodings be preserved as they are, instead of normalizing them.
    z$6$�VTi�
)r�zj$6$rounds=1000$test$2M/Lx6MtobqjLjobw0Wmo4Q5OFx5nVLJvmgseatA6oMnyWeBdRDx4DU.1H3eGmse6pgsOgDisWBGI5c7TZauS0N)r�r�r�r�r�rr�r�r�r�r�rRrRrRrWr�s/)F)&r�r`ZloggingZ	getLoggerr��logZ
passlib.utilsrrrrZpasslib.utils.binaryrZpasslib.utils.compatrrr	r
Zpasslib.utils.handlersZutils�handlersr]�__all__r\rerbrarpr�r�r�ZHasManyBackendsZ	HasRoundsZHasSaltZGenericHandlerrsrrrRrRrRrW�<module>s0�	

B�B

Zerion Mini Shell 1.0