+
    THi                         ^ RI t ^ RIHtHt ^ RIHu Ht ^ RIH	t	 ^ RI
Ht ^ RIHt R.t ! R R]P                  ]P                   ]P"                  ]P$                  4      tR# )    N)	b64decode	b64encode)pbkdf1)
to_unicode)bascii_to_strfshpc            	         aa ] tR t^t oRtR tRt]P                  t	Rt
^tRtRt^tRtRt^t^ R^R^R^R/t]! ] U u. uF  p \)        V 4      V 3NK  	  up ]P+                  4        U Uu. uF  w  rV^ ,          V 3NK  	  upp ,           4      t]RV3R ll4       tRtRV3R llt]R	 4       t]R
 4       t]R 4       t]P@                  ! R]PB                  4      t"]R 4       t#R t$R t%Rt&Vt'V;t(# u up i u upp i )r   a  This class implements the FSHP password hash, and follows the :ref:`password-hash-api`.

It supports a variable-length salt, and a variable number of rounds.

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

:param salt:
    Optional raw salt string.
    If not specified, one will be autogenerated (this is recommended).

:param salt_size:
    Optional number of bytes to use when autogenerating new salts.
    Defaults to 16 bytes, but can be any non-negative value.

:param rounds:
    Optional number of rounds to use.
    Defaults to 480000, must be between 1 and 4294967295, inclusive.

:param variant:
    Optionally specifies variant of FSHP to use.

    * ``0`` - uses SHA-1 digest (deprecated).
    * ``1`` - uses SHA-2/256 digest (default).
    * ``2`` - uses SHA-2/384 digest.
    * ``3`` - uses SHA-2/512 digest.

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

    .. versionadded:: 1.6
z{FSHPNi S l    linearc                \   < \         SV `  ! R/ VB pVe   V P                  V4      Vn        V# )N )superusing_norm_variantdefault_variant)clsvariantkwdssubcls	__class__s   &&, 7/usr/lib/python3/dist-packages/passlib/handlers/fshp.pyr   
fshp.usingZ   s2    &&%(%6%6w%?F"    c                "  < VP                  R 4      V n        Ve   V P                  V4      pMKV P                  '       d/   V P                  pV P                  V4      V8X  g   Q RV: 24       hM\	        R4      hWn        \        SV `  ! R/ VB  R# )use_defaultsNzinvalid default variant: zno variant specifiedr   )getr   r   r   	TypeErrorr   r   __init__)selfr   r   r   s   &&,r   r   fshp.__init__c   s     HH^4((1G**G%%g.'9 +G;79 233 4 r   c                T   \        V\        4      '       d   VP                  R 4      p\        V\        4      '       d    V P                  V,          p\        V\        4      '       g   \        R4      hWP                  9  d   \        R4      hV#   \
         d    \        R4      hi ; i)asciizinvalid fshp variantz'fshp variant must be int or known alias)

isinstancebytesdecodestr_variant_aliasesKeyError
ValueErrorintr   _variant_info)r   r   s   &&r   r   fshp._norm_variantr   s    gu%%nnW-Ggs##9..w7 '3''EFF+++344  9 !7889s   B B'c                J    V P                   V P                  ,          ^ ,          # )r   r*   r   r   s   &r   checksum_algfshp.checksum_alg       !!$,,/22r   c                J    V P                   V P                  ,          ^,          # )   r-   r.   s   &r   checksum_sizefshp.checksum_size   r1   r   z
            ^
            \{FSHP
            (\d+)\| # variant
            (\d+)\| # salt size
            (\d+)\} # rounds
            ([a-zA-Z0-9+/]+={0,3}) # digest
            $c                   \        VR R4      pV P                  P                  V4      pV'       g    \        P                  P                  V 4      hVP                  ^^^^4      w  r4rV\        V4      p\        V4      p\        V4      p \        VP                  R 4      4      pTRT pYdR pT ! YxYSR7      #   \         d!    \        P                  P                  T 4      hi ; i)r!   hashN)saltchecksumroundsr   )r   _hash_regexmatchuhexcInvalidHashErrorgroupr)   r   encoder   MalformedHashError)	r   r7   mr   	salt_sizer:   datar8   chks	   &&       r   from_stringfshp.from_string   s    $0OO!!$'&&))#..+,771aA+>(Fg,	N	V	1T[[12D JY:6KK	  	1&&++C00	1s   	B6 6+C!c                    V P                   pV P                  p\        \        W!,           4      4      pR V P                  \        V4      V P                  V3,          # )z{FSHP%d|%d|%d}%s)r9   r8   r   r   r   lenr:   )r   rF   r8   rE   s   &   r   	to_stringfshp.to_string   sE    mmyyYtz23!T\\3t9dkk4$PPPr   c                    \        V\        4      '       d   VP                  R 4      p\        V P                  V P
                  VV P                  V P                  R7      # )zutf-8)digestsecretr8   r:   keylen)r"   r%   rA   r   r/   r8   r:   r4   )r   rO   s   &&r   _calc_checksumfshp._calc_checksum   sO    fc""]]7+F $$99;;%%
 	
r   )r   r   )r8   rD   r:   r   )sha1   )sha256    )sha3840   )sha512@   )N))__name__
__module____qualname____firstlineno____doc__namesetting_kwdsr=   PADDED_BASE64_CHARSchecksum_charsidentdefault_salt_sizemax_salt_sizedefault_rounds
min_rounds
max_roundsrounds_costr   r*   dictr%   itemsr&   classmethodr   r   r   r   propertyr/   r4   recompileVERBOSEr;   rG   rK   rQ   __static_attributes____classdictcell____classcell__)kvr   __classdict__s   00@@r   r   r      sj    #L D=L++NE M
 NJJK O 	
<	>	>	>M +,m#a&!m,!.!4!4!6
7!6AaD!9!6
7	8
   G!   3 3 3 3 **	 	


K L L"Q
 
o 	-
7s   C.(C3)ro   base64r   r   passlib.utils.handlersutilshandlersr=   passlib.crypto.digestr   passlib.utilsr   passlib.utils.compatr   __all__	HasRounds
HasRawSaltHasRawChecksumGenericHandlerr   r   r   r   <module>r      sR    	 ' # # ( $ . 
k
LLMM	k
r   