Ë
    àU.j>�  ã                   óJ  — d Z ddlmZ ddlZddlZ ej
                  e«      Z	 ddlmZ	 e	j                  dk(  rej                  d«       dZ	ddlZddlZddlm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mZ ddlmZm Z m!Z!m"Z"m#Z# ddl$m%Z% g d¢Z&dZ'dZ(g d¢Z)ddddddddddddddddœZ*d„ Z+i Z,d„ Z-d„ Z.	 dGd!„Z/e,j`                  e/_1        dHd"„Z2 G d#„ d$e«      Z3d a4 e5g d%¢«      Z6dId&„Z7 eejp                  js                  d'«      «      r e7«         ed(„  ed)«      D «       «      Z: ed*„  ed)«      D «       «      Z;dJd+„Z<dKd,„Z= ed-«      j|                  Z?dKd.„Zejp                  js                  d/«      xs d0Z@e"re@d1v rdd2lAmBZB d3„ ZCd4„ ZDd5ZEn7e@d6v rddlmZ dd7lmFZF eFd8k\  ZGi ZHd9„ ZCd:ZEne@d;v sJ ‚dd<lImJZK dd=lmLZL d>„ ZCd?„ ZDd@ZEe@eEk(  rdxZZ	erdAnde	rdBnddCeEz   fD � cg c]  } | r| ‘Œ c} ZMdAeMv rdDZNydBeMv rdEZNydFZNy# e$ r dZ	Y �ŒÂw xY w# e$ r dZY �Œµw xY wc c} w )Lzlpasslib.crypto.digest -- crytographic helpers used by the password hashes in passlib

.. versionadded:: 1.7
é    )ÚdivisionN)Úpbkdf2_hmacÚhashlibz*ignoring pure-python hashlib.pbkdf2_hmac())ÚStruct)Úwarn)Úexc)Ú
join_bytesÚto_native_strÚjoin_byte_valuesÚto_bytesÚSequenceMixinÚas_bool)ÚirangeÚ	int_typesÚunicode_or_bytes_typesÚPY3Ú
error_from)Úmemoized_property)Úlookup_hashÚHashInfoÚnorm_hash_nameÚcompile_hmacÚpbkdf1r   l   ÿÿ l   ÿÿÿÿ ))Úmd2r   )Úmd5r   )Úsha1zsha-1)Úsha224zsha-224zsha2-224)Úsha256zsha-256zsha2-256)Úsha384zsha-384zsha2-384)Úsha512zsha-512zsha2-512)Úblake2bzblake-2b)Úblake2szblake-2s)Úmd4r#   )Ú	ripemd160z
ripemd-160Úripemd)é@   é€   )é    r&   )é   r&   )é   r&   )é   r&   )é0   r'   )r+   é�   )r(   éˆ   )r,   éh   )r&   éH   )r)   é¨   )r!   r"   r#   r   r   r   r   r   Úsha3_224Úsha3_256Úsha3_384Úsha3_512r    Úshake128Úshake256c                  óÀ   — i } t        t        j                  t        dg«      z  «      D ]2  }t	        |«      }|j
                  |j                  f| |j                  <   Œ4 | S )z™
    internal helper used to generate ``_fallback_info`` dict.
    currently only run manually to update the above list;
    not invoked at runtime.
    r#   )Úsortedr   Úalgorithms_availableÚsetr   Údigest_sizeÚ
block_sizeÚname)ÚoutÚalgÚinfos      úWC:\xampp\htdocs\tradingbinance\backend\.venv\Lib\site-packages\passlib/crypto/digest.pyÚ_gen_fallback_inforC   z   sW   € ð €CÜ”g×2Ñ2´S¸%¸³\ÑAÖBˆÜ˜3ÓˆØ×*Ñ*¨D¯O©OÐ<ˆˆD�I‰IŠð Cð €Jó    c                 óh  — | }t        | t        «      st        | dd«      } t        j                  dd| j                  «       j                  «       «      } | j                  d«      r| dd } | j                  d«      r| dd	 } d
„ } || «      }|r|S t        j                  d| «      }|r^|j                  ddd«      \  }}}|r||z  }|}|r|d|z   z  }|r|dz  }||z  } ||«      }|r|S t        j                  d|||«       ||fS | }| j                  dd«      }t        j                  d|||«       ||fS )aA  
    internal helper used by :func:`lookup_hash` --
    normalize arbitrary hash name to hashlib format.
    if name not recognized, returns dummy record and issues a warning.

    :arg name:
        unnormalized name

    :returns:
        tuple with 2+ elements: ``(hashlib_name, iana_name|None, ... 0+ aliases)``.
    zutf-8z	hash namez[_ /]Ú-zscram-é   Nz-pluséûÿÿÿc                 ó*   — t         D ]
  }| |v sŒ|c S  y ©N)Ú_known_hash_names)r>   Úrows     rB   Úcheck_tablez&_get_hash_aliases.<locals>.check_table¢   s   € ß$ˆCØ�sŠ{Ø’
ñ %rD   z8(?i)^(?P<name>[a-z]+)-?(?P<rev>\d)?-?(?P<size>\d{3,4})?$r>   ÚrevÚsizeÚ_z0normalizing unrecognized hash name %r => %r / %rz;normalizing unrecognized hash name and format %r => %r / %r)Ú
isinstanceÚstrr
   ÚreÚsubÚstripÚlowerÚ
startswithÚendswithÚmatchÚgroupÚlogrA   ÚreplaceÚwarning)	r>   ÚorigrM   ÚresultÚmÚ	iana_namerN   rO   Úhashlib_names	            rB   Ú_get_hash_aliasesrc   Š   se  € ð €DÜ�dœCÔ Ü˜T 7¨KÓ8ˆÜ�6‰6�'˜3 §
¡
£× 2Ñ 2Ó 4Ó5€DØ‡��xÔ Ø�A�BˆxˆØ�=‰=˜Ô!Ø˜˜�9ˆDòñ ˜Ó€FÙØˆô 	�‰ÐLÈdÓS€AÙð  !Ÿw™w v¨u°fÓ=Ñˆ	�3˜ÙØ˜ÑˆIØ ˆÙØ˜˜t™Ñ#ˆIÙØ Ñ#�Ø˜DÑ ˆLÙ˜YÓ'ˆÙØˆMô 	�‰ÐCØ�| Yô	0ð ˜Ð"Ð"ð ˆ	Ø—|‘| C¨Ó-ˆÜ�‰ÐQØ˜,¨	ô	3ð ˜Ð"Ð"rD   c                 ó   ‡ ‡— ‰ j                  d«      s‰ dvr	 t        t        ‰ «      S t        j                  Š	  ‰‰ d«       dˆ ˆfd„	}‰ |_        d|_        d‰ z  |_        |S # t        $ r Y ŒFw xY w# t        $ r Y nw xY w‰ dk(  rdd	l	m
} |S y
)a  
    internal helper used by :func:`lookup_hash` --
    lookup hash constructor by name

    :arg name:
        name (normalized to hashlib format, e.g. ``"sha256"``)

    :returns:
        hash constructor, e.g. ``hashlib.sha256()``;
        or None if hash can't be located.
    rP   )ÚnewÚ
algorithmsrD   c                 ó   •—  ‰‰| «      S rJ   © )Úmsgr>   Únew_ssl_hashs    €€rB   Úconstz_get_hash_const.<locals>.constç   s   ø€ Ù  cÓ*Ð*rD   r   zMwrapper for hashlib.new(%r),
generated by passlib.crypto.digest.lookup_hash()r#   r   )r#   N©rD   )rW   Úgetattrr   ÚAttributeErrorre   Ú__name__Ú
__module__Ú__doc__Ú
ValueErrorÚpasslib.crypto._md4r#   )r>   rk   r#   rj   s   `  @rB   Ú_get_hash_constrt   Ê   s®   ù€ ð �?‰?˜3Ô DÐ0EÑ$Eð	Üœ7 DÓ)Ð)ô
 —;‘;€Lðá�T˜3Ôö	+àˆŒØ$ˆÔðLØOSñTˆŒàˆøô' ò 	Ùð	ûô ò Ùðúð ˆu‚}Ý+Øˆ
ð
 s"   ™A$ º	A3 Á$	A0Á/A0Á3	A?Á>A?Fc                 ót  ‡	— t         }	 ||    S # t        t        f$ r Y nw xY w|rd}d}t        | t        «      rOt        | «      }|d   Š	‰	sJ ‚‰	| k7  rt        ‰	|¬«      }||| <   |S t        ‰	«      }|r€t        rz‰	t        vrrdˆ	fd„	}nkt        | t        «      r| S t        | «      r7| }t         |«       j                  «      }|d   Š	t        ‰	«      }|€n||u rnd}nt        j                  | dd«      ‚t        |||¬	«      }|�|||<   |r.|D ])  Š	‰	sŒ|j                  ‰	«      d|fv s
J d
‰	z  «       ‚||‰	<   Œ+ |S )af  
    Returns a :class:`HashInfo` record containing information about a given hash function.
    Can be used to look up a hash constructor by name, normalize hash name representation, etc.

    :arg digest:
        This can be any of:

        * A string containing a :mod:`!hashlib` digest name (e.g. ``"sha256"``),
        * A string containing an IANA-assigned hash name,
        * A digest constructor function (e.g. ``hashlib.sha256``).

        Case is ignored, underscores are converted to hyphens,
        and various other cleanups are made.

    :param required:
        By default (True), this function will throw an :exc:`~passlib.exc.UnknownHashError` if no hash constructor
        can be found, or if the hash is not actually available.

        If this flag is False, it will instead return a dummy :class:`!HashInfo` record
        which will defer throwing the error until it's constructor function is called.
        This is mainly used by :func:`norm_hash_name`.

    :param return_unknown:

        .. deprecated:: 1.7.3

            deprecated, and will be removed in passlib 2.0.
            this acts like inverse of **required**.

    :returns HashInfo:
        :class:`HashInfo` instance containing information about specified digest.

        Multiple calls resolving to the same hash should always
        return the same :class:`!HashInfo` instance.
    FTr   ©Úrequiredc                 ó    •— t        d‰z  «      ‚)Nz4%r disabled for fips by passlib set_mock_fips_mode())rr   )Úsourcer>   s    €rB   rk   zlookup_hash.<locals>.constA  s   ø€ Ü Ð!WÐZ^Ñ!^Ó_Ð_rD   Nzdigest name or constructorÚdigest)rk   Únamesrw   z%r already in cacherl   )Ú_hash_info_cacheÚKeyErrorÚ	TypeErrorrQ   r   rc   r   rt   Úmock_fips_modeÚ_fips_algorithmsr   Úcallabler>   r   ÚExpectedTypeErrorÚget)
rz   Úreturn_unknownrw   ÚcacheÚcache_by_nameÚ	name_listrA   rk   Úother_constr>   s
            @rB   r   r   ú   sŒ  ø€ ôL €EðØ�V‰}ÐøÜ”iÐ ò áðúñ
 Øˆð €MÜ�&Ô0Ô1ä% fÓ-ˆ	Ø˜‰|ˆÙˆˆtð �6Š>Ü˜t¨hÔ7ˆDØ ˆE�&‰MØˆKô   Ó%ˆñ •^¨Ô4DÑ(Dö`ô 
�FœHÔ	%àˆä	�&Ô	ð ˆÜ%¡e£g§l¡lÓ3ˆ	Ø˜‰|ˆÜ% dÓ+ˆØÐð à˜EÑ!ð ð "‰Mô ×#Ñ# FÐ,HÈ(ÓSÐSô ˜% y¸8ÔD€Dð ÐØˆˆe‰ÙÛˆDÚØ—y‘y “¨4°¨,Ñ6ÐTÐ8MÐPTÑ8TÓTÐ6Ø"��d’ð ð €Ks   ‰ Ž Ÿ c                 óâ   — t        | d¬«      }|j                  r't        d|j                  z   t        j
                  «       |dk(  r|j                  S |dk(  r|j                  S t        d|›�«      ‚)a<  Normalize hash function name (convenience wrapper for :func:`lookup_hash`).

    :arg name:
        Original hash function name.

        This name can be a Python :mod:`~hashlib` digest name,
        a SCRAM mechanism name, IANA assigned hash name, etc.
        Case is ignored, and underscores are converted to hyphens.

    :param format:
        Naming convention to normalize to.
        Possible values are:

        * ``"hashlib"`` (the default) - normalizes name to be compatible
          with Python's :mod:`!hashlib`.

        * ``"iana"`` - normalizes name to IANA-assigned hash function name.
          For hashes which IANA hasn't assigned a name for, this issues a warning,
          and then uses a heuristic to return a "best guess" name.

    :returns:
        Hash name, returned as native :class:`!str`.
    Frv   znorm_hash_name(): r   Úianazunknown format: )	r   Úunknownr   Ú
error_textr   ÚPasslibRuntimeWarningr>   ra   rr   )r>   ÚformatrA   s      rB   r   r   s  sc   € ô0 �t eÔ,€DØ‡|‚|ÜÐ! D§O¡OÑ3´S×5NÑ5NÔOØ�ÒØ�y‰yÐØ	�6Ò	Ø�~‰~Ðå±Ð9Ó:Ð:rD   c                   óv   — e Zd ZdZdZdZdZdZdZdZ	dZ
dZ	 dd„Zd„ Zd„ Zed„ «       Zed	„ «       Zed
„ «       Zy)r   aç  
    Record containing information about a given hash algorithm, as returned :func:`lookup_hash`.

    This class exposes the following attributes:

    .. autoattribute:: const
    .. autoattribute:: digest_size
    .. autoattribute:: block_size
    .. autoattribute:: name
    .. autoattribute:: iana_name
    .. autoattribute:: aliases
    .. autoattribute:: supported

    This object can also be treated a 3-element sequence
    containing ``(const, digest_size, block_size)``.
    Nrh   Fc                 óÞ  ‡ ‡‡— |d   xŠ‰ _         |d   ‰ _        |dd ‰ _        ˆˆˆ fd„}|€#|t        v rd‰z  }nd‰z  }d‰ _         ||«       y	  |«       }|‰ _
        |j                  ‰ _        |j                  ‰ _        t        |j                  «       «      |j                  k7  rt        d‰ j                   z  «      ‚|j                   ‰ j                   k7  r8t!        d‰ j                   ›d|›d|j                   ›�t"        j$                  «       yy# t
        $ rR}d	t        |«      j                  «       v rd
‰z  }nd‰›dt        |«      j                  ›d|›d�} ||«       Y d}~yd}~ww xY w)a  
        initialize new instance.
        :arg const:
            hash constructor
        :arg names:
            list of 2+ names. should be list of ``(name, iana_name, ... 0+ aliases)``.
            names must be lower-case. only iana name may be None.
        r   é   é   Nc                 ó’   •‡ — dˆ ˆfd„	}‰r |«        	 ‰ ‰_         |‰_        	 t        ‰   \  ‰_        ‰_        y# t
        $ r Y yw xY w)zc
            helper that installs stub constructor which throws specified error <msg>.
            c                 ó0   •— t        j                  ‰‰«      ‚rJ   )r   ÚUnknownHashError)ry   ri   r>   s    €€rB   rk   z8HashInfo.__init__.<locals>.use_stub_const.<locals>.constÜ  s   ø€ Ü×*Ñ*¨3°Ó5Ð5rD   Nrl   )rŒ   rk   Ú_fallback_infor<   r=   r}   )ri   rk   r>   rw   Úselfs   ` €€€rB   Úuse_stub_constz)HashInfo.__init__.<locals>.use_stub_constØ  sN   ù€ ö6áñ ”Ø+Ø!ˆDŒOØˆDŒJðÜ4BÀ4Ñ4HÑ1�Ô  $¥/øÜò Ùðús   £: º	AÁAzunsupported hash: %rzunknown hash: %rTzdisabled for fipsz%r hash disabled for fipszinternal error in z constructor
(z: Ú)z"%r constructor failed sanity checkzinconsistent digest name: z resolved to z, which reports name as )r>   ra   ÚaliasesrK   r‹   rr   rR   rV   Útypero   rk   r<   r=   Úlenrz   ÚRuntimeErrorr   r   r�   )	r—   rk   r{   rw   r˜   ri   ÚhashÚerrr>   s	   `  `    @rB   Ú__init__zHashInfo.__init__É  s`  ú€ ð ! ™8Ð#ˆˆtŒyØ˜q™ˆŒØ˜Q˜R�yˆŒö	ð& ˆ=ØÔ)Ñ)Ø,¨tÑ3‘à(¨4Ñ/�Ø#�”Ù˜3Ôàð	Ù“7ˆDð ˆŒ
Ø×+Ñ+ˆÔØŸ/™/ˆŒô ˆt�{‰{‹}Ó ×!1Ñ!1Ò1ÜÐCÀdÇiÁiÑOÓPÐPð �9‰9˜Ÿ	™	Ò!ÝØ—)“)šU D§I¢Ið/Ü03×0IÑ0IõKð "øô- ò 
	ð
 #¤c¨#£h§n¡nÓ&6Ñ6Ø1°DÑ8‘ð 7ò GKÌDÐQTËI×L^ÓL^Ò`cÐd�Ù˜3ÔÜûð
	ús   ÁD Ä	E,ÄAE'Å'E,c                 óV   — d| j                   ›d| j                  ›d| j                  ›d�S )Nz<lookup_hash(z): digest_size=z block_size=r™   )r>   r<   r=   ©r—   s    rB   Ú__repr__zHashInfo.__repr__  s!   � à—	“	˜4×+Ó+¨T¯_«_ð>ð 	>rD   c                 óH   — | j                   | j                  | j                  fS rJ   )rk   r<   r=   r¢   s    rB   Ú	_as_tuplezHashInfo._as_tuple  s   € Ø�z‰z˜4×+Ñ+¨T¯_©_Ð<Ð<rD   c                 ó   — | j                   du S )zy
        whether hash is available for use
        (if False, constructor will throw UnknownHashError if called)
        N)rŒ   r¢   s    rB   Ú	supportedzHashInfo.supported  s   € ð �‰ $Ð&Ð&rD   c                 ób   — t         sy	 t        | j                  ddd«       y# t        $ r Y yw xY w)z5helper to detect if hash is supported by fastpbkdf2()Nó   pó   sr‘   TF)Ú_fast_pbkdf2_hmacr>   rr   r¢   s    rB   Úsupported_by_fastpbkdf2z HashInfo.supported_by_fastpbkdf2$  s6   € õ !Øð	Ü˜dŸi™i¨¨t°QÔ7ØøÜò 	áð	úó   ‰" ¢	.­.c                 ób   — t         sy	 t        | j                  ddd«       y# t        $ r Y yw xY w)z>helper to detect if hash is supported by hashlib.pbkdf2_hmac()Nr©   rª   r‘   TF)Ú_stdlib_pbkdf2_hmacr>   rr   r¢   s    rB   Úsupported_by_hashlib_pbkdf2z$HashInfo.supported_by_hashlib_pbkdf20  s6   € õ #Øð	Ü §	¡	¨4°°qÔ9ØøÜò 	áð	úr­   ©T)ro   rp   Ú__qualname__rq   r>   ra   rš   rk   r<   r=   rŒ   r‹   r    r£   r¥   r   r§   r¬   r°   rh   rD   rB   r   r   –  s’   „ ñð* €Dð €Ið €Gð €Eð €Kð €Jð €Jð €Gð )-óGKòX>ò=ð ñ'ó ð'ð ñ	ó ð	ð ñ	ó ñ	rD   r   )r   r   r   r   r    r2   r3   r4   r5   Ú	shake_128Ú	shake_256c                 ó0   — | a t        j                  «        y)zW
    UT helper which monkeypatches lookup_hash() internals to replicate FIPS mode.
    N)r   r   Úclear_cache)Úenables    rB   Ú_set_mock_fips_moder¸   _  s   € ð
 €NÜ×ÑÕrD   ÚPASSLIB_MOCK_FIPS_MODEc              #   ó&   K  — | ]	  }|d z  –— Œ y­w)é\   Nrh   ©Ú.0Úxs     rB   Ú	<genexpr>r¿   q  ó   è ø€ Ð=±¨A˜a $�h±ùó   ‚é   c              #   ó&   K  — | ]	  }|d z  –— Œ y­w)é6   Nrh   r¼   s     rB   r¿   r¿   r  rÀ   rÁ   c                 ó®  ‡	‡
— t        | «      }|\  }}}|dk\  sJ d«       ‚t        |t        «      st        |d¬«      }t	        |«      }||kD  r ||«      j                  «       }|}||k  r|d||z
  z  z  } ||j                  t        «      «      j                  Š	 ||j                  t        «      «      j                  Š
|rˆ	ˆ
fd„}nˆ	ˆ
fd„}||_
        |S )a®  
    This function returns an efficient HMAC function, hardcoded with a specific digest & key.
    It can be used via ``hmac = compile_hmac(digest, key)``.

    :arg digest:
        digest name or constructor.

    :arg key:
        secret key as :class:`!bytes` or :class:`!unicode` (unicode will be encoded using utf-8).

    :param multipart:
        request a multipart constructor instead (see return description).

    :returns:
        By default, the returned function has the signature ``hmac(msg) -> digest output``.

        However, if ``multipart=True``, the returned function has the signature
        ``hmac() -> update, finalize``, where ``update(msg)`` may be called multiple times,
        and ``finalize() -> digest_output`` may be repeatedly called at any point to
        calculate the HMAC digest so far.

        The returned object will also have a ``digest_info`` attribute, containing
        a :class:`lookup_hash` instance for the specified digest.

    This function exists, and has the weird signature it does, in order to squeeze as
    provide as much efficiency as possible, by omitting much of the setup cost
    and features of the stdlib :mod:`hmac` module.
    r)   zblock size too smallÚkey©Úparamó    c                  ó<   •‡—  ‰«       Šˆˆfd„} ‰j                   | fS )z)generated by compile_hmac(multipart=True)c                  óp   •—  ‰«       } | j                  ‰j                  «       «       | j                  «       S rJ   ©Úupdaterz   )ÚouterÚ_outer_copyÚinners    €€rB   Úfinalizez,compile_hmac.<locals>.hmac.<locals>.finalize­  s(   ø€ Ù#›�Ø—‘˜UŸ\™\›^Ô,Ø—|‘|“~Ð%rD   )rÍ   )rÑ   rÐ   Ú_inner_copyrÏ   s    @€€rB   Úhmaczcompile_hmac.<locals>.hmacª  s    ù€ á“MˆEõ&ð —<‘< Ð)Ð)rD   c                 ó    •—  ‰«       }|j                  | «        ‰«       }|j                  |j                  «       «       |j                  «       S )zgenerated by compile_hmac()rÌ   )ri   rÐ   rÎ   rÒ   rÏ   s      €€rB   rÓ   zcompile_hmac.<locals>.hmacµ  s;   ø€ á“MˆEØ�L‰L˜ÔÙ“MˆEØ�L‰L˜Ÿ™›Ô(Ø—<‘<“>Ð!rD   )r   rQ   Úbytesr   rœ   rz   Ú	translateÚ	_TRANS_36ÚcopyÚ	_TRANS_5CÚdigest_info)rz   rÆ   Ú	multipartrÚ   rk   r<   r=   ÚklenrÓ   rÒ   rÏ   s            @@rB   r   r   t  sÜ   ù€ ô@ ˜fÓ%€KØ%0Ñ"€Eˆ;˜
Ø˜ÒÐ3Ð3Ó3Ðô �cœ5Ô!Ü�s %Ô(ˆÜˆs‹8€DØˆjÒÙ�C‹j×ÑÓ!ˆØˆØˆjÒØˆw˜* tÑ+Ñ,Ñ,ˆñ ˜Ÿ™¤iÓ0Ó1×6Ñ6€KÙ˜Ÿ™¤iÓ0Ó1×6Ñ6€Káö	*õ	"ð #€DÔØ€KrD   c                 óÆ  — t        | «      \  }}}t        |d¬«      }t        |d¬«      }t        |t        «      st	        j
                  |dd«      ‚|dk  rt        d«      ‚|€|}nMt        |t        «      st	        j
                  |d	d
«      ‚|dk  rt        d«      ‚||kD  rt        d|›d|›�«      ‚||z   }t        |«      D ]  }	 ||«      j                  «       }Œ |d| S )a;  pkcs#5 password-based key derivation v1.5

    :arg digest:
        digest name or constructor.
        
    :arg secret:
        secret to use when generating the key.
        may be :class:`!bytes` or :class:`unicode` (encoded using UTF-8).
        
    :arg salt:
        salt string to use when generating key.
        may be :class:`!bytes` or :class:`unicode` (encoded using UTF-8).

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

    :arg keylen:
        number of bytes to generate (if omitted / ``None``, uses digest's native size)

    :returns:
        raw :class:`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.
    ÚsecretrÇ   ÚsaltÚintÚroundsr‘   úrounds must be at least 1Núint or NoneÚkeylenr   zkeylen must be at least 0z keylength too large for digest: z > )	r   r   rQ   r   r   r‚   rr   r   rz   )
rz   rÞ   rß   rá   rä   rk   r<   r=   ÚblockrP   s
             rB   r   r   Ä  s÷   € ô< &1°Ó%8Ñ"€Eˆ;˜
ô �f HÔ-€FÜ�D Ô'€Dô �fœiÔ(Ü×#Ñ# F¨E°8Ó<Ð<Ø�‚zÜÐ4Ó5Ð5ð €~Ø‰Ü˜¤	Ô*Ü×#Ñ# F¨M¸8ÓDÐDØ	�!ŠÜÐ4Ó5Ð5Ø	�+Ò	ÝÚ ¡+ð/ó 0ð 	0ð �T‰M€EÜ�FŽ^ˆÙ�e“×#Ñ#Ó%‰ð à��&ˆ>ÐrD   z>Lc                 ó   ‡‡‡‡	— t        |d¬«      }t        ‰d¬«      Št        | «      }|j                  }t        ‰t        «      st        j                  ‰dd«      ‚‰dk  rt        d«      ‚|€|}n7t        |t        «      st        j                  |d	d
«      ‚|dk  rt        d«      ‚||z   dz
  |z  }|t        kD  rt        d«      ‚|j                  rt        |j                  |‰‰|«      S |j                  rt        |j                  |‰‰|«      S t        | |«      Š	t!        |«      Št#        ˆˆ	ˆˆfd„t%        d|dz   «      D «       «      d| S )a  pkcs#5 password-based key derivation v2.0 using HMAC + arbitrary digest.

    :arg digest:
        digest name or constructor.

    :arg secret:
        passphrase to use to generate key.
        may be :class:`!bytes` or :class:`unicode` (encoded using UTF-8).

    :arg salt:
        salt string to use when generating key.
        may be :class:`!bytes` or :class:`unicode` (encoded using UTF-8).

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

    :arg keylen:
        number of bytes to generate.
        if omitted / ``None``, will use digest's native output size.

    :returns:
        raw bytes of generated key

    .. versionchanged:: 1.7

        This function will use the first available of the following backends:

        * `fastpbk2 <https://pypi.python.org/pypi/fastpbkdf2>`_
        * :func:`hashlib.pbkdf2_hmac` (only available in py2 >= 2.7.8, and py3 >= 3.4)
        * builtin pure-python backend

        See :data:`passlib.crypto.digest.PBKDF2_BACKENDS` to determine
        which backend(s) are in use.
    rÞ   rÇ   rß   rà   rá   r‘   râ   Nrã   rä   zkeylen must be at least 1zkeylen too long for digestc           
   3   óV   •K  — | ]   } ‰‰ ‰‰t        |«      z   «      ‰«      –— Œ" y ­wrJ   )Ú_pack_uint32)r½   ÚiÚ
calc_blockÚ
keyed_hmacrá   rß   s     €€€€rB   r¿   zpbkdf2_hmac.<locals>.<genexpr>c  s0   øè ø€ ð á+ˆAñ 	�:™z¨$´¸a³Ñ*@ÓAÀ6×JÙ+ùs   ƒ&))r   r   r<   rQ   r   r   r‚   rr   Ú
MAX_UINT32ÚOverflowErrorr¬   r«   r>   r°   r¯   r   Ú_get_pbkdf2_looperr	   r   )
rz   rÞ   rß   rá   rä   rÚ   r<   Úblock_countrê   rë   s
     ``    @@rB   r   r     sf  û€ ôH �f HÔ-€FÜ�D Ô'€Dô ˜fÓ%€KØ×)Ñ)€Kô �fœiÔ(Ü×#Ñ# F¨E°8Ó<Ð<Ø�‚zÜÐ4Ó5Ð5ð €~Ø‰Ü˜¤	Ô*Ü×#Ñ# F¨M¸8ÓDÐDØ	�!ŠäÐ4Ó5Ð5ð ˜KÑ'¨!Ñ+°Ñ;€KØ”ZÒÜÐ8Ó9Ð9ð ×*Ò*Ü  ×!1Ñ!1°6¸4ÀÈÓPÐPð
 ×.Ò.Ü" ;×#3Ñ#3°V¸TÀ6È6ÓRÐRô ˜f fÓ-€Jô $ KÓ0€Jô ö ä˜˜;¨™?Ô+óó ð €vðð rD   ÚPASSLIB_PBKDF2_BACKENDÚany)rñ   ú
from-bytes)Úpartialc                 ó"   — t        t        | «      S rJ   )ró   Ú_pbkdf2_looper©r<   s    rB   rî   rî   r  s   € Ü”~ {Ó3Ð3rD   c                 óª   — t         j                  }d} |||«      }t        |dz
  «      D ]  } ||«      }| |||«      z  }Œ |j                  | |«      S )zk
        py3-only implementation of pbkdf2 inner loop;
        uses 'int.from_bytes' + integer XOR
        Úbigr‘   )rà   Ú
from_bytesr   r   )r<   rë   rz   rá   rù   ÚBIGÚaccumrP   s           rB   rõ   rõ   u  s_   € ô
 —^‘^ˆ
ØˆÙ˜6 3Ó'ˆÜ˜ ™
Ö#ˆAÙ Ó'ˆFØ‘Z ¨Ó,Ñ,‰Eð $ð �~‰~˜k¨3Ó/Ð/rD   rò   )rñ   Úunpackrò   )Úsys_bitsr&   c           
      ó’  — 	 t         |    S # t        $ r Y nw xY wt        r| dz  s| dz	  }d|z  }n4| dz  s!t        r| dz	  }d|z  }|dz  }n| dz	  }d|z  }nt        d| z  «      ‚t	        |«      }t        | d	j                  d
„ t        |«      D «       «      d	j                  d„ t        |«      D «       «      ¬«      } dj                  di |¤Ž}t        |«      D ]  }|d||fz  z  }Œ | dj                  di |¤Žz  }t        |dd«      }t        t        |¬«      }t        «       }	t        |||	«       |	d   }
	 ||
_        |
t         | <   |
S )a)  
        We want a helper function which performs equivalent of the following::

          def helper(keyed_hmac, digest, rounds):
              accum = digest
              for _ in irange(rounds - 1):
                  digest = keyed_hmac(digest)
                  accum ^= digest
              return accum

        However, no efficient way to implement "bytes ^ bytes" in python.
        Instead, using approach where we dynamically compile a helper function based
        on digest size.  Instead of a single `accum` var, this helper breaks the digest
        into a series of integers.

        It stores these in a series of`accum_<i>` vars, and performs `accum ^= digest`
        by unpacking digest and perform xor for each "accum_<i> ^= digest_<i>".
        this keeps everything in locals, avoiding excessive list creation, encoding or decoding,
        etc.

        :param digest_size:
            digest size to compile for, in bytes. (must be multiple of 4).

        :return:
            helper function with call signature outlined above.
        é   é   z=%dQz=%dQIr‘   r’   z=%dIzunsupported digest size: %dz, c              3   ó&   K  — | ]	  }d |z  –— Œ y­w)zacc_%dNrh   ©r½   ré   s     rB   r¿   z%_get_pbkdf2_looper.<locals>.<genexpr>Ì  s   è ø€ Ð E±}°! ¨A¥±}ùrÁ   c              3   ó&   K  — | ]	  }d |z  –— Œ y­w)zdig_%dNrh   r  s     rB   r¿   z%_get_pbkdf2_looper.<locals>.<genexpr>Í  s   è ø€ Ð!F¹°1 (¨Q¥,¹ùrÁ   )r<   Ú
accum_varsÚdigest_varsa   def helper(keyed_hmac, digest, rounds):
    '''pbkdf2 loop helper for digest_size={digest_size}'''
    unpack_digest = struct.unpack
    {accum_vars} = unpack_digest(digest)
    for _ in irange(1, rounds):
        digest = keyed_hmac(digest)
        {digest_vars} = unpack_digest(digest)
z        acc_%d ^= dig_%d
z%    return struct.pack({accum_vars})
z9<generated by passlib.crypto.digest._get_pbkdf2_looper()>Úexec)r   ÚstructÚhelperrh   )Ú_looper_cacher}   Ú_have_64_bitÚNotImplementedErrorr   ÚdictÚjoinr   rŽ   ÚcompileÚevalÚ
__source__)r<   ÚcountÚfmtr  Útdictry   ré   ÚcodeÚgdictÚldictr  s              rB   rî   rî   �  s‘  € ð<	Ü  Ñ-Ð-øÜò 	Ùð	úõ  ¨cÒ 1à  AÑ%ˆEØ˜5‘.‰CØ˜sÒ"Ýà$¨Ñ)�Ø ‘o�Ø˜‘
‘ð %¨Ñ)�Ø˜u‘n‘ô &Ð&CÀkÑ&QÓRÐRÜ˜“ˆô
 Ø#Ø—y‘yÑ E´v¸e´}Ó EÓEØŸ	™	Ñ!F¼¸u¼Ó!FÓFô
ˆððJ÷ ‰&ñð ñˆô ˜–ˆAØÐ4¸¸1°vÑ=Ñ=‰Fð ð 	ÐGÐ@×GÑGÑPÈ%ÑPÑPˆô
 �vÐZÐ\bÓcˆÜœF¨6Ô2ˆÜ“ˆÜˆT�5˜%Ô Ø�x‘ˆØØ &ˆFÔð
 &,Œ�kÑ"Øˆs   ‚ ‹	–rü   )rñ   Úhexlify)r  )Úint_to_bytesc                 ó   — t         S rJ   )rõ   rö   s    rB   rî   rî   þ  s   € ÜÐrD   c                 ó¼   — t         }t         ||«      d«      }t        |dz
  «      D ]  } | |«      }|t         ||«      d«      z  }Œ! t        |t	        |«      «      S )Nr)   r‘   )Ú_hexlifyrà   r   r  rœ   )rë   rz   rá   r  rû   rP   s         rB   rõ   rõ     s\   € ÜˆÜ‘G˜F“O RÓ(ˆÜ˜ ™
Ö#ˆAÙ Ó'ˆFØ”S™ ›¨"Ó-Ñ-‰Eð $ô ˜E¤3 v£;Ó/Ð/rD   r  Ú
fastpbkdf2zhashlib-sslzbuiltin-r   gffffffö?r‘   )FT)r   r±   )FrJ   )Orq   Ú
__future__r   r   ÚloggingÚ	getLoggerro   r[   r   r¯   rp   ÚdebugÚImportErrorrS   Úosr  r   Úwarningsr   r  r«   Úpasslibr   Úpasslib.utilsr	   r
   r   r   r   r   Úpasslib.utils.compatr   r   r   r   r   Úpasslib.utils.decorr   Ú__all__rì   Ú
MAX_UINT64rK   r–   rC   r|   rc   rt   r   Úclearr¶   r   r   r   r;   r€   r¸   Úenvironrƒ   rÙ   r×   r   r   Úpackrè   Ú_force_backendÚ	functoolsró   rî   rõ   Ú_builtin_backendrý   r
  r	  Úbinasciir  r  r  ÚPBKDF2_BACKENDSÚPBKDF2_SPEED_FACTOR)Úbs   0rB   Ú<module>r4     sí  ðñõ  ã Û Ð'�g×'Ñ'¨Ó1�ð	å:Ø×%Ñ%¨Ò2ð 	�	‰	Ð>Ô?Ø"Ðó 
Û 	Ý Ý ðå;õ ÷1÷ 1ç [Õ [Ý 1ò€ð& €
ð €
òÐ ðH ØØØØØØØØØØØØØØñ!€ò(
ð Ð ò=#ò@-ðb 04ósðl +×0Ñ0€Ô ó ;ôFdˆ}ô dð` €ñ
 ò ó Ð ó(ñ ˆ2�:‰:�>‰>Ð2Ó3Ô4ÙÔñ Ñ=±¸´Ó=Ó=€	ÙÑ=±¸´Ó=Ó=€	óKó`9ñ~ �d‹|× Ñ €óaðP —‘—‘Ð 8Ó9ÒB¸U€áˆ>Ð2Ñ2Ý!ò4ò0ð $ÑàÐ6Ñ6ÝÝ&à ‘N€Lð €MòdðL  Ñð Ð/Ñ/Ð/Ð/õ
 -Ý*òò0ð !Ðð Ð%Ò%Ø.2Ð2ÐÐ+ñ &�L¨4Ù(�M¨dØÐ!Ñ!ñó ñ ˜ñ ò	 ð ñ €ð �?Ñ"ØÑØ�oÑ%ØÑð ÑøðS  ò ØÓðûð ò ØÓðüòds)   ¤(H Á!H Ç%H ÈHÈHÈHÈH