+
    iB7              
       v   R t ^ RIHtHt ^ RIt]P
                  ! ]4      t^ RIH	t
 ^ RIHtHt ^ RIHtHtHt ^ RIHtHtHt ^ RIHt ^ RIHu Ht R.t]! R	4      t]! R
4      t]! R4      t ! R R]P>                  ]P@                  ]PB                  ]PD                  ]PF                  ]PH                  4      t	R# )z/passlib.handlers.scrypt -- scrypt password hash)with_statementabsolute_importN)scrypt)h64to_bytes)r   b64s_decodeb64s_encode)ubascii_to_strsuppress_cause)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           	       < \         \        V `
  ! R/ VB pVeR   \        V\        P
                  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      4      hR p?ii ; i)Nrelaxed)r   z&scrypt: invalid settings combination:  )superr   using
isinstanceuhnative_string_typesint_norm_block_sizeget
block_size_scryptvalidatedefault_roundsparallelism
ValueErrorr   str)clsr   kwdssubclserr	__class__s   &&,  U/var/www/html/photoedit/myenv/lib/python3.14/site-packages/passlib/handlers/scrypt.pyr   scrypt.using   s    vs)1D1!*b&<&<== _
 & 7 7
HHU^L_ 7 `F	bQ#"4"44cnncooV   	b ,TWZ[^W_,_!`aa	bs   ,=B+ +C6$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4      pV'       d	   V! V4      # \        P
                  P                  V 4      h)z_parse_%s_stringN)_parse_identgetattrstrip_UDOLLARr   excInvalidHashError)r"   r+   identsuffixfuncs   &&   r'   r*   scrypt.parse   sS    ((.s.X1FFM<&&))#..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r6   roundsr   r   saltchecksum)splitlenr   r4   MalformedHashError
startswithdictIDENT_SCRYPTr   r   encode)	r"   r7   partsparamsrA   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           
     V   VP                  R 4      P                  R4      p\        V4      ^8X  d   Vw  r4M5\        V4      ^8X  d   Vw  pRpM\        P                  P                  4       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:rT      N:rU      N:rV   NNr?   )rI   rC   rD   r   r4   rE   rG   IDENT_7r   decode_int6decode_int30decode_bytes)r"   r7   rJ   rK   rL   s   &&   r'   _parse_7_stringscrypt._parse_7_string   s     g&,,T2u:?"NFFZ1_GF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      4      hi ; i)z$scrypt$ln=%d,r=%d,p=%d$%s$%sr>   z.scrypt $7$ hashes dont support non-ascii saltsr.   s   $7$rS   )r6   rH   r@   r   r   r
   r   rA   rB   rW   decodeUnicodeDecodeErrorr   NotImplementedErrorjoinr   encode_int6encode_int30encode_bytes)selfr6   rA   s   &  r'   	to_stringscrypt.to_string  s"   

L 2  k$))45k$--896   G###99DlG$ !,  1  !1!12		  /+ "   & l$%89i%jkkls   E
 
 E*c                   < \         \        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   r   __init__r   validate_default_valuer   r   )re   r   r#   r&   s   &&,r'   rk   scrypt.__init__1  sc    fd$,t, ,,T??DDYDY3?A A A A #33J?DOr.   c                6    \         P                  ! W^RVR7      # )rT   r   )minrj   r   )r   norm_integer)r"   r   r   s   &&&r'   r   scrypt._norm_block_size>  s    sA\SZ[[r.   c                l   < \         \        V `  4       pV P                  \        8X  d   \        V4      pV# N)r   r   _generate_saltr6   rW   r   )re   rA   r&   s   & r'   rt   scrypt._generate_saltB  s/    VT13::  t$Dr.   c                "    \         P                  # rs   )r   backend_valuesr"   s   &r'   backendsscrypt.backendsP  s    %%%r.   c                "    \         P                  # rs   )r   backendrx   s   &r'   get_backendscrypt.get_backendT  s    r.   c                z     V P                  VR R7       R #   \        P                  P                   d     R# i ; i)TdryrunF)set_backendr   r4   MissingBackendError)r"   names   &&r'   has_backendscrypt.has_backendX  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_backend`  s    T1r.   c           	         \        VR R7      p\        P                  ! WP                  ^V P                  ,          V P
                  V P                  V P                  R7      # )secretri   )nrpkeylen)r   r   r   rA   r@   r   r   checksum_size)re   r   s   &&r'   _calc_checksumscrypt._calc_checksumg  sI    &1~~fiiA4D $ 0 09K9KM 	Mr.   c                x   < V P                   \        V 4      P                   8w  d   R# \        \        V `  ! R/ VB # )zB
mark hash as needing update if rounds is outside desired bounds.
Tr   )r   typer   r   _calc_needs_update)re   r#   r&   s   &,r'   r   scrypt._calc_needs_updatep  s3    
 ??d4j333VT5===r.   )r   )r6   rA   	salt_sizer@   r   r   rs   )F)any)r   F)(__name__
__module____qualname____firstlineno____doc__r   setting_kwdsr   rH   default_identrW   ident_valuesdefault_salt_sizemax_salt_sizer   
min_rounds
max_roundsrounds_costr   r   classmethodr   r,   r*   rP   r[   rf   rk   r   rt   r   ry   r}   r   r   r   r   __static_attributes____classdictcell____classcell__)r&   __classdict__s   @@r'   r   r   !   sK    >N DXL M
 !M '*L
 M NJJK K J  & & & / /&  Z 
 
:<@ \ \ & &     2 2M> >r.   )%r   
__future__r   r   logging	getLoggerr   logpasslib.cryptor   r   passlib.utilsr   r   passlib.utils.binaryr   r   passlib.utils.compatr	   r
   r   passlib.utils.decorr   passlib.utils.handlersutilshandlersr   __all__rH   rW   r3   ParallelismMixin	HasRounds
HasRawSaltHasRawChecksumHasManyIdentsGenericHandlerr   r.   r'   <module>r      s    5 7 g''1 - ' > > A A - # #  }
E(S6
V>R  ",,r?P?PRTRbRbV>r.   