+
    ¢THiz"  ã                   ó´   € R t ^ RIHt ^ RIHt ^ RIHt RR.tRtRt	Rt
R t^tRR ltRsRsRR	 ltR
 tR tR tRt]! ]]]R7      tRR lt]! R4       R tR# )z'scrypt hash frontend and help utilities)Úwarn)Úexc)Úto_bytesÚvalidateÚscryptc                óü   € V^8  d   \        RV: 24      hV^8  d   \        RV: 24      hW,          \        8”  d   \        RV: RV: 24      hV ^8  g   W ^,
          ,          '       d   \        RV : 24      hR# )a-  
helper which validates a set of scrypt config parameters.
scrypt will take ``O(n * r * p)`` time and ``O(n * r)`` memory.
limitations are that ``n = 2**<positive integer>``, ``n < 2**(16*r)``, ``r * p < 2 ** 30``.

:param n: scrypt rounds
:param r: scrypt block size
:param p: scrypt parallel factor
zr must be > 0: r=zp must be > 0: p=zr * p must be < 2**30: r=z, p=z#n must be > 1, and a power of 2: n=T)Ú
ValueErrorÚMAX_RP)ÚnÚrÚps   &&&Ú@/usr/lib/python3/dist-packages/passlib/crypto/scrypt/__init__.pyr   r      sƒ   € ð 	ˆ1„uÜÐ,¨Q©EÐ2Ó3Ð3àˆ1„uÜÐ,¨Q©EÐ2Ó3Ð3à…uŒv„~ô Ð4°Q±E¸¸a¹UÐCÓDÐDàˆ1„u�˜•U—”ÜÐ>¸q¹eÐDÓEÐEáó    c                ó„   € V^€V,          ^ V ^,           ,          \         ,          ,           ,          p\        WC,          4      # )a#  
calculate memory required for parameter combination.
assumes parameters have already been validated.

.. warning::
    this is derived from OpenSSL's scrypt maxmem formula;
    and may not be correct for other implementations
    (additional buffers, different parallelism tradeoffs, etc).
)ÚUINT32_SIZEÚint)r
   r   r   ÚfudgeÚmaxmems   &&&& r   Úestimate_maxmemr   <   s1   € ð" �#˜•'˜B ! a¥%�L¬;Õ6Õ6Õ7€Fäˆv�~ÓÐr   Nc                óÎ   € \        W#V4       \        V RR7      p \        VRR7      pV^8  d   \        R4      hV\        8”  d   \        R\        ,          4      h\	        WW#WE4      # )aÀ  run SCrypt key derivation function using specified parameters.

:arg secret:
    passphrase string (str is encoded to bytes using utf-8).

:arg salt:
    salt string (str is encoded to bytes using utf-8).

:arg n:
    integer 'N' parameter

:arg r:
    integer 'r' parameter

:arg p:
    integer 'p' parameter

:arg keylen:
    number of bytes of key to generate.
    defaults to 32 (the internal block size).

:returns:
    a *keylen*-sized bytes instance

SCrypt imposes a number of constraints on it's input parameters:

* ``r * p < 2**30`` -- due to a limitation of PBKDF2-HMAC-SHA256.
* ``keylen < (2**32 - 1) * 32`` -- due to a limitation of PBKDF2-HMAC-SHA256.
* ``n`` must a be a power of 2, and > 1 -- internal limitation of scrypt() implementation

:raises ValueError: if the provided parameters are invalid (see constraints above).

.. warning::

    Unless the third-party ``scrypt <https://pypi.python.org/pypi/scrypt/>``_ package
    is installed, passlib will use a builtin pure-python implementation of scrypt,
    which is *considerably* slower (and thus requires a much lower / less secure
    ``n`` value in order to be usuable). Installing the :mod:`!scrypt` package
    is strongly recommended.
Úsecret)ÚparamÚsaltzkeylen must be at least 1zkeylen too large, must be <= %d)r   r   r   Ú
MAX_KEYLENÚ_scrypt)r   r   r
   r   r   Úkeylens   &&&&&&r   r   r   \   sb   € ôR ˆQ�1ÔÜ�f HÔ-€FÜ�D Ô'€DØ�„zÜÐ4Ó5Ð5Ø”
ÔÜÐ:¼ZÕGÓHÐHÜ�6  qÓ1Ð1r   c                 ól   € ^dp \        RV ,          \        P                  4       ^RIHp VP
                  # )z<
Load pure-python scrypt implementation built into passlib.
z¦Using builtin scrypt backend, which is %dx slower than is required for adequate security. Installing scrypt support (via 'pip install scrypt') is strongly recommended)ÚScryptEngine)r   r   ÚPasslibSecurityWarningÚ_builtinr   Úexecute)Úslowdownr   s     r   Ú_load_builtin_backendr"   �   s:   € ð €HÜð	"à$,õ	-ô 	×"Ñ"ô	õ 'à×ÑÐr   c                 óþ   €  ^ RI Hp  V #   \         d     Mi ; i ^ RI p\        R\        P
                  4       R#   \         d6   pR\        T4      9  d   \        R\        P
                  4        Rp?R# Rp?ii ; i)z�
Try to import the ctypes-based scrypt hash function provided by the
``scrypt <https://pypi.python.org/pypi/scrypt/>``_ package.
)ÚhashNz5'scrypt' package is too old (lacks ``hash()`` method)r   zJ'scrypt' package failed to import correctly (possible installation issue?))r   r$   ÚImportErrorr   r   ÚPasslibWarningÚstr)r$   r   Úerrs      r   Ú_load_cffi_backendr)   Ÿ   s}   € ð
ÝàˆøÜô Ùðúð
Ûô 	ØCÄS×EWÑEWô	
ñ øô ô Øœ3˜s›8Ô#ô Ø\Ü×"Ñ"ôûñ ûðús!   ‚
 Š—œ< ¼A<Á*A7Á7A<c                 óF   a€  ^ RI Ho T3R lp T #   \         d     R# i ; i)zZ
Attempt to load stdlib scrypt() implement and return wrapper.
Returns None if not found.
)r   Nc           
      óN   <€ \         pV^ 8  d   \        W#V4      pS! WW#WEVR7      # )é    )Úpasswordr   r
   r   r   Údklenr   )ÚSCRYPT_MAXMEMr   )r   r   r
   r   r   r   r   Ústdlib_scrypts   &&&&&& €r   Ústdlib_scrypt_wrapperÚ3_load_stdlib_backend.<locals>.stdlib_scrypt_wrapperÈ   s3   ø€ ô ˆØ�AŒ:Ü$ Q¨1Ó-ˆFÙØ¨!°AÈFô
ð 	
r   )Úhashlibr   r%   )r1   r0   s    @r   Ú_load_stdlib_backendr4   ½   s,   ø€ ð
å3õ
ð& !Ð øô- ô Úðús   ƒ ‘ Ÿ )Ústdlibr   Úbuiltinc                óˆ  € V R8X  d   R# V R8X  d2   \          F  p  \        WR7        R# 	  \        P                  ! R4      h\        P                  V 4      pV'       g   \        RV : 24      hV! 4       pV'       g   \        P                  ! RV : R24      hV'       d   R# V sVsR#   \        P                   d     K©  i ; i)	zÜ
set backend for scrypt(). if name not specified, loads first available.

:raises ~passlib.exc.MissingBackendError: if backend can't be found

.. note:: mainly intended to be called by unittests, and scrypt hash handler
ÚanyNÚdefault©Údryrunzno scrypt backends availablezunknown scrypt backend: zscrypt backend z not available)	Úbackend_valuesÚ_set_backendr   ÚMissingBackendErrorÚ_backend_loadersÚgetr   Úbackendr   )Únamer;   Úloaderr$   s   &&  r   r=   r=   é   s¸   € ð ˆu„}ÙØˆyÔß"ˆDðÜ˜TÕ1Úñ #ô ×%Ò%Ð&DÓEÐEÜ×!Ñ! $Ó'€FßÜÐ3°D±8Ð<Ó=Ð=Ù‹8€DßÜ×%Ò%¨¸±x¸~Ð&NÓOÐOßÙà€GØ‚Gøô ×*Ñ*ô Úðús   ›B(Â(CÃ Cr9   c                 óZ   €  \        V R R7       R #   \        P                   d     R# i ; i)Tr:   F)r=   r   r>   )rB   s   &r   Ú_has_backendrE     s,   € ðÜ�T $Õ'ÙøÜ×"Ñ"ô Úðús   ‚ ‘*©*éÿÿÿÿl   àÿ iÿÿÿ?)gÍÌÌÌÌÌð?)é   é    )F)Ú__doc__Úwarningsr   Úpasslibr   Úpasslib.utilsr   Ú__all__r/   r   r	   r   r   r   r   rA   r   r"   r)   r4   r<   Údictr?   r=   rE   © r   r   Ú<module>rP      sœ   ðÙ -å å Ý "ð Øð€ð €ð "€
ð 
€òð8 €ôð4 €ð €ô02òf ò ò<!ðD 1€ñ ØØØ!ôÐ ôñ@ ˆYÔ ôr   