+
    THi.              
       
   R t ^ RIHu Ht ^ RIHt ^ RIH	t	 ^ RI
HtHtHt ^ RIHt ^ RIHt R.tRtR	tR
t ! R R]P,                  ]P.                  ]P0                  ]P2                  ]P4                  ]P6                  4      tR# )zscrypt password hashN)scrypt)to_bytes)b64s_decodeb64s_encodeh64)bascii_to_str)classpropertyr   z$scrypt$z$7$$c                   L  a a ] tR t^t oRtR tRt^ t]t	]]
3t^tRt^t^t^tRt^t^t]RV 3R ll4       t]R 4       t]R 4       t]R 4       t]R 4       tR	 tRV 3R
 llt]RR l4       tV 3R lt]R 4       t]R 4       t ]RR l4       t!]RR l4       t"R t#V 3R lt$Rt%Vt&V ;t'# )r   a  This class implements an SCrypt-based password [#scrypt-home]_ hash, and follows the :ref:`password-hash-api`.

It supports a variable-length salt, a variable number of rounds,
as well as some custom tuning parameters unique to scrypt (see below).

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

:type salt: str
:param salt:
    Optional salt string.
    If specified, the length must be between 0-1024 bytes.
    If not specified, one will be auto-generated (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 16, but must be within ``range(1,32)``.

    .. warning::

        Unlike many hash algorithms, increasing the rounds value
        will increase both the time *and memory* required to hash a password.

:type block_size: int
:param block_size:
    Optional block size to pass to scrypt hash function (the ``r`` parameter).
    Useful for tuning scrypt to optimal performance for your CPU architecture.
    Defaults to 8.

:type parallelism: int
:param parallelism:
    Optional parallelism to pass to scrypt hash function (the ``p`` parameter).
    Defaults to 1.

: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.

.. note::

    The underlying scrypt hash function has a number of limitations
    on it's parameter values, which forbids certain combinations of settings.
    The requirements are:

    * ``linear_rounds = 2**<some positive integer>``
    * ``linear_rounds < 2**(16 * block_size)``
    * ``block_size * parallelism <= 2**30-1``

.. todo::

    This class currently does not support configuring default values
    for ``block_size`` or ``parallelism`` via a :class:`~passlib.context.CryptContext`
    configuration.
i   log2c                  < \         SV `  ! R/ VB pVeH   \        V\        4      '       d   \	        V4      pVP                  WP                  R4      R7      Vn         \        P                  ! ^V P                  ,          V P                  V P                  4       V#   \         d"   p\        R\        T4      ,           4      R hR p?ii ; i)Nrelaxed)r   z&scrypt: invalid settings combination:  )superusing
isinstancestrint_norm_block_sizeget
block_size_scryptvalidatedefault_roundsparallelism
ValueError)clsr   kwdssubclserr	__class__s   &&,  9/usr/lib/python3/dist-packages/passlib/handlers/scrypt.pyr   scrypt.using   s    &&!*c** _
 & 7 7HHY$7 !8 !F
	Q#"4"44cnncooV   	83s8C	s   =B C	(CC	c                0    V ! R/ V P                  V4      B # )Nr   )parse)r   hashs   &&r!   from_stringscrypt.from_string   s    %SYYt_%%    c                    V P                  V4      w  r#\        V R VP                  \        4       R2R4      pV'       d	   V! V4      # \        P
                  P                  V 4      h)_parse__stringN)_parse_identgetattrstrip_UDOLLARuhexcInvalidHashError)r   r%   identsuffixfuncs   &&   r!   r$   scrypt.parse   sW    ((.sgekk(&;%<GDdK<ff%%c**r(   c                   VP                  R 4      p\        V4      ^8X  d   Vw  r4pM7\        V4      ^8X  d   Vw  r4RpM \        P                  P	                  V R4      hVP                  R4      p\        V4      ^8X  dR   Vw  rgpVP                  R4      '       g   Q hVP                  R4      '       g   Q hVP                  R4      '       g   Q hM \        P                  P	                  V R4      h\        \        \        VR,          4      \        VR	,          4      \        VR	,          4      \        VP                  R
4      4      V'       d    \        VP                  R
4      4      R7      # RR7      # )r	   Nzmalformed hash,zln=zr=zp=zmalformed settings field:   NN:   NNasciir3   roundsr   r   saltchecksum)splitlenr0   r1   MalformedHashError
startswithdictIDENT_SCRYPTr   r   encode)	r   r4   partsparamsr>   digestnstrbstrpstrs	   &&       r!   _parse_scrypt_stringscrypt._parse_scrypt_string   s8    S!u:?#( F&Z1_ LFF&&++C1ABB S!u:?$D??5))))??4((((??4((((&&++C1KLLtBx=48}DHT[[12<B[w!78
 	
 IM
 	
r(   c           
     N   VP                  R 4      P                  R4      p\        V4      ^8X  d   Vw  r4M1\        V4      ^8X  d   Vw  pRpM\        P                  P
                  h\        V4      ^8  d!   \        P                  P                  V R4      h\        \        \        P                  ! VR,          4      \        P                  ! VR,          4      \        P                  ! VR,          4      VR,          V'       d   \        P                  ! V4      R7      # RR7      # )	r;      $Nzparams field too short:N   N:rQ      N:rR      N:rS   NNr<   )rF   r@   rA   r0   r1   rB   rD   IDENT_7r   decode_int6decode_int30decode_bytes)r   r4   rG   rH   rI   s   &&   r!   _parse_7_stringscrypt._parse_7_string   s     g&,,T2u:?"NFFZ1_IVF&&+++ v;&&++C1IJJ??6":.''s4((617S%%f-
 	
 >B
 	
r(   c                   V P                   pV\        8X  de   R V P                  V P                  V P                  \        \        V P                  4      4      \        \        V P                  4      4      3,          # V\        8X  g   Q hV P                  p VP                  R4       \        RP                  R\        P                  ! T P                  4      \        P                   ! T P                  4      \        P                   ! T P                  4      T P                  R\        P"                  ! T P                  4      .4      4      #   \         d    \        R4      Rhi ; i)z$scrypt$ln=%d,r=%d,p=%d$%s$%sr;   z.scrypt $7$ hashes dont support non-ascii saltsNr(   s   $7$rP   )r3   rE   r=   r   r   r   r   r>   r?   rT   decodeUnicodeDecodeErrorNotImplementedErrorjoinr   encode_int6encode_int30encode_bytes)selfr3   r>   s   &  r!   	to_stringscrypt.to_string   s!   

L 2  k$))45k$--896   yy	KK 
 HHOODKK0$$T__5$$T%5%56II$$T]]3

 	
	 " 	%@	s   E
 
E"c                   < \         SV `  ! R/ VB  Vf8   \        P                  ! W P                  V P
                  RR7      '       g   Q hR # V P                  V4      V n        R # )Nr   paramr   )r   __init__r0   validate_default_valuer   r   )rb   r   r   r    s   &&,r!   rh   scrypt.__init__  s]     4  ,,oot'<'<L    #33J?DOr(   c                6    \         P                  ! W^RVR7      # )rQ   r   )minrg   r   )r0   norm_integer)r   r   r   s   &&&r!   r   scrypt._norm_block_size+  s    ,
 	
r(   c                d   < \         SV `  4       pV P                  \        8X  d   \	        V4      pV# N)r   _generate_saltr3   rT   r   )rb   r>   r    s   & r!   rq   scrypt._generate_salt1  s-    w%'::  t$Dr(   c                "    \         P                  # rp   )r   backend_valuesr   s   &r!   backendsscrypt.backends?  s    %%%r(   c                "    \         P                  # rp   )r   backendru   s   &r!   get_backendscrypt.get_backendC  s    r(   c                z     V P                  VR R7       R #   \        P                  P                   d     R# i ; i)TdryrunF)set_backendr0   r1   MissingBackendError)r   names   &&r!   has_backendscrypt.has_backendG  s6    	OODO.vv)) 		s    ::c                4    \         P                  ! WR 7       R# )r}   N)r   _set_backend)r   r   r~   s   &&&r!   r   scrypt.set_backendO  s    T1r(   c           	         \        VR R7      p\        P                  ! VV P                  ^V P                  ,          V P
                  V P                  V P                  R7      # )secretrf   )nrpkeylen)r   r   r   r>   r=   r   r   checksum_size)rb   r   s   &&r!   _calc_checksumscrypt._calc_checksumS  sN    &1~~IIDKKoo%%
 	
r(   c                p   < V P                   \        V 4      P                   8w  d   R# \        SV `  ! R/ VB # )zB
mark hash as needing update if rounds is outside desired bounds.
Tr   )r   typer   _calc_needs_update)rb   r   r    s   &,r!   r   scrypt._calc_needs_update^  s1    
 ??d4j333w)1D11r(   )r   )r3   r>   	salt_sizer=   r   r   rp   )F)any)r   F)(__name__
__module____qualname____firstlineno____doc__r   setting_kwdsr   rE   default_identrT   ident_valuesdefault_salt_sizemax_salt_sizer   
min_rounds
max_roundsrounds_costr   r   classmethodr   r&   r$   rM   rX   rc   rh   r   rq   r   rv   rz   r   r   r   r   __static_attributes____classdictcell____classcell__)r    __classdict__s   @@r!   r   r      sG    >F DXL M
 !M '*L
 M NJJK
 K J & & & + +$ 
 
Z 
 
4
@	@ 
 

 & &     2 2	
2 2r(   )r   passlib.utils.handlersutilshandlersr0   passlib.cryptor   r   passlib.utilsr   passlib.utils.binaryr   r   r   passlib.utils.compatr   passlib.utils.decorr   __all__rE   rT   r/   ParallelismMixin	HasRounds
HasRawSaltHasRawChecksumHasManyIdentsGenericHandlerr   r(   r!   <module>r      s{     # # , " > > . - 
 
P2LLMMP2r(   