§
    HŠtj°  ã                   óø   — d Z ddlmZ ddlZ ej        e¦  «        ZddlmZ ddl	m
Z
 ddlmZ ddlmZmZmZmZmZ g d¢Zdd	lmZ  ed
e¦  «           e
dded¬¦  «        e¦  «        Zi adZd„ Zdd„Zdd„ZdS )z¡passlib.pbkdf2 - PBKDF2 support

this module is getting increasingly poorly named.
maybe rename to "kdf" since it's getting more key derivation functions added.
é    )ÚdivisionN)ÚExpectedTypeError)Údeprecated_function)Únative_string_types)Únorm_hash_nameÚlookup_hashÚpbkdf1Úpbkdf2_hmacÚcompile_hmac)r   Úget_prfr	   Úpbkdf2)ÚwarnzŠthe module 'passlib.utils.pbkdf2' is deprecated as of Passlib 1.7, and will be removed in Passlib 2.0, please use 'passlib.crypto' insteadz1.7z1.8z$passlib.crypto.digest.norm_hash_name)Ú
deprecatedÚremovedÚfunc_moduleÚreplacement)Úhmac_zhmac-c                 ó¦  ‡— | t           v rt           |          S t          | t          ¦  «        r\|                      t          ¦  «        st          d| ›�¦  «        ‚t          | dd…         ¦  «        j        Šˆfd„}||j        j	        f}n>t          | ¦  «        rt           | dd¦  «        ¦  «        }| |f}nt          | dd¦  «        ‚|t           | <   |S )	a  Lookup pseudo-random family (PRF) by name.

    :arg name:
        This must be the name of a recognized prf.
        Currently this only recognizes names with the format
        :samp:`hmac-{digest}`, where :samp:`{digest}`
        is the name of a hash function such as
        ``md5``, ``sha256``, etc.

        todo: restore text about callables.

    :raises ValueError: if the name is not known
    :raises TypeError: if the name is not a callable or string

    :returns:
        a tuple of :samp:`({prf_func}, {digest_size})`, where:

        * :samp:`{prf_func}` is a function implementing
          the specified PRF, and has the signature
          ``prf_func(secret, message) -> digest``.

        * :samp:`{digest_size}` is an integer indicating
          the number of bytes the function returns.

    Usage example::

        >>> from passlib.utils.pbkdf2 import get_prf
        >>> hmac_sha256, dsize = get_prf("hmac-sha256")
        >>> hmac_sha256
        <function hmac_sha256 at 0x1e37c80>
        >>> dsize
        32
        >>> digest = hmac_sha256('password', 'message')

    .. deprecated:: 1.7

        This function is deprecated, and will be removed in Passlib 2.0.
        This only related replacement is :func:`passlib.crypto.digest.compile_hmac`.
    zunknown prf algorithm: é   Nc                 ó6   •—  t          ‰| ¦  «        |¦  «        S )N)r   )ÚkeyÚmsgÚdigests     €úR/var/www/html/CA-Chatbot/venv/lib/python3.11/site-packages/passlib/utils/pbkdf2.pyÚhmaczget_prf.<locals>.hmach   s   ø€ Ø,•< ¨Ñ,Ô,¨SÑ1Ô1Ð1ó    ó   xó   yzstr or callablezprf name)Ú
_prf_cacheÚ
isinstancer   Ú
startswithÚ_HMAC_PREFIXESÚ
ValueErrorr   ÚnameÚdigest_infoÚdigest_sizeÚcallableÚlenr   )r$   r   Úrecordr&   r   s       @r   r   r   9   só   ø€ ðR �zÐÐÝ˜$ÔÐÝ�$Õ+Ñ,Ô,ð EØ�Š�~Ñ.Ô.ð 	DÝ�*¸D¸DÐBÑCÔCÐCÝ˜T ! " "œXÑ&Ô&Ô+ˆð	2ð 	2ð 	2ð 	2ð 	2à˜Ô(Ô4Ð5ˆˆÝ	�$‰Œð Eå˜$˜$˜t TÑ*Ô*Ñ+Ô+ˆØ˜Ð$ˆˆå Ð&7¸ÑDÔDÐDØ…JˆtÑØ€Mr   Úsha1c                 ó(   — t          || |||¦  «        S )aL  pkcs#5 password-based key derivation v1.5

    :arg secret: passphrase to use to generate key
    :arg salt: salt string to use when generating key
    :param rounds: number of rounds to use to generate key
    :arg keylen: number of bytes to generate (if ``None``, uses digest's native size)
    :param hash:
        hash function to use. must be name of a hash recognized by hashlib.

    :returns:
        raw bytes of generated key

    .. note::

        This algorithm has been deprecated, new code should use PBKDF2.
        Among other limitations, ``keylen`` cannot be larger
        than the digest size of the specified hash.

    .. deprecated:: 1.7

        This has been relocated to :func:`passlib.crypto.digest.pbkdf1`,
        and this version will be removed in Passlib 2.0.
        *Note the call signature has changed.*
    )Ú_pbkdf1)ÚsecretÚsaltÚroundsÚkeylenÚhashs        r   r	   r	   w   s   € õ2 �4˜  v¨vÑ6Ô6Ð6r   ú	hmac-sha1c                 óÖ   — t          |¦  «        s/t          |t          ¦  «        r)|                     t          ¦  «        st          d¦  «        ‚|dd…         }t          || |||¦  «        S )aW  pkcs#5 password-based key derivation v2.0

    :arg secret:
        passphrase to use to generate key

    :arg salt:
        salt string to use when generating key

    :param rounds:
        number of rounds to use to generate key

    :arg keylen:
        number of bytes to generate.
        if set to ``None``, will use digest size of selected prf.

    :param prf:
        psuedo-random family to use for key strengthening.
        this must be a string starting with ``"hmac-"``, followed by the name of a known digest.
        this defaults to ``"hmac-sha1"`` (the only prf explicitly listed in
        the PBKDF2 specification)

        .. rst-class:: warning

        .. versionchanged 1.7:

            This argument no longer supports arbitrary PRF callables --
            These were rarely / never used, and created too many unwanted codepaths.

    :returns:
        raw bytes of generated key

    .. deprecated:: 1.7

        This has been deprecated in favor of :func:`passlib.crypto.digest.pbkdf2_hmac`,
        and will be removed in Passlib 2.0.  *Note the call signature has changed.*
    z1non-HMAC prfs are not supported as of Passlib 1.7r   N)r'   r    r   r!   r"   ÚNotImplementedErrorr
   )r-   r.   r/   r0   Úprfr   s         r   r   r   •   sn   € õJ ��}„}ð W� CÕ)<Ñ=Ô=ð WÀcÇnÂnÕUcÑFdÔFdð WÝ!Ð"UÑVÔVÐVØ���ŒW€FÝ�v˜v t¨V°VÑ<Ô<Ð<r   )Nr*   )Nr2   )Ú__doc__Ú
__future__r   ÚloggingÚ	getLoggerÚ__name__ÚlogÚpasslib.excr   Úpasslib.utils.decorr   Úpasslib.utils.compatr   Úpasslib.crypto.digestr   r   r	   r,   r
   r   Ú__all__Úwarningsr   ÚDeprecationWarningr   r"   r   r   © r   r   ú<module>rD      sg  ððð ð  Ð Ð Ð Ð Ð à €€€Ð'�gÔ'¨Ñ1Ô1�ð *Ð )Ð )Ð )Ð )Ð )Ø 3Ð 3Ð 3Ð 3Ð 3Ð 3Ø 4Ð 4Ð 4Ð 4Ð 4Ð 4Ø kÐ kÐ kÐ kÐ kÐ kÐ kÐ kÐ kÐ kÐ kÐ kÐ kÐ kð
ð 
ð 
€ð Ð Ð Ð Ð Ð à €ð Oàñô ð ð8Ð$Ð$°¸uÐRZØ6ð8ñ 8ô 8Ø8FñHô H€ð €
ð $€ð9ð 9ð 9ð|7ð 7ð 7ð 7ð<(=ð (=ð (=ð (=ð (=ð (=r   