+
    THiD                       R t ^ RIHt ^ RIt^ RIHu Ht ^ RIH	t	H
t
 ^ RIHt RR.tRtRtRtRtRR ltR	tR
tRt ! R R]P,                  ]P.                  ]P0                  ]P2                  4      t ! R R]4      t ! R R]4      tR# )zSHA256-Crypt / SHA512-Crypt)annotationsN)repeat_string
to_unicode)h64sha512_cryptsha256_crypt    c                   \        V \        4      '       d   V P                  R4      p \        V \        4      '       g   Q h\        V 9   d6   \
        P                  P                  V'       d   \        4      h\        4      h\        V 4      pRTu;8:  d   R8:  g   Q R4       h Q R4       h\        V\        4      '       g   Q R4       hVP                  R4      p\        V4      pV^8  g   Q R4       hV'       d   \        P                  p\        pM\        P                  p\        pV! W,           V ,           4      P!                  4       pV! W,           4      p	V	P"                  p
V
! \%        W4      4       TpV'       d%   T
! V^,          '       d   TMT 4       V^,          pK,  V	P!                  4       pV^`8  d(   \%        V! W,          4      P!                  4       V4      pMRV! V 4      pVP"                  pV^,
          pV'       d   V! V 4       V^,          pK  \%        VP!                  4       V4      p\        V4      V8X  g   Q hV! V^V^ ,          ,           ,          4      P!                  4       RV p\        V4      V8X  g   Q R	4       hW,           pVV,           pVVVVV,           VV,           VV,           .p\&         UUu. uF  w  ppVV,          VV,          3NK  	  pppTp\)        V^*4      w  ppV'       dP   V F>  w  ppV! VV! VV,           4      P!                  4       ,           4      P!                  4       pK@  	  V^,          pKW  V'       d   V^,	          pVRV  F>  w  ppV! VV! VV,           4      P!                  4       ,           4      P!                  4       pK@  	  V^,          '       d,   V! VVV,          ^ ,          ,           4      P!                  4       p\*        P,                  ! VV4      P/                  R4      # u uppi )
a  perform raw sha256-crypt / sha512-crypt

this function provides a pure-python implementation of the internals
for the SHA256-Crypt and SHA512-Crypt algorithms; it doesn't
handle any of the parsing/validation of the hash strings themselves.

:arg pwd: password chars/bytes to hash
:arg salt: salt chars to use
:arg rounds: linear rounds cost
:arg use_512: use sha512-crypt instead of sha256-crypt mode

:returns:
    encoded checksum chars
zutf-8  ɚ;zinvalid roundszsalt not strasciizsalt too largeNzsalt_len somehow > hash_len!)
isinstancestrencodebytes_BNULLuhexcNullPasswordErrorr   r   lenhashlibsha512_512_transpose_mapsha256_256_transpose_mapdigestupdater   _c_digest_offsetsdivmodr   encode_transposed_bytesdecode)pwdsaltroundsuse_512pwd_lensalt_len
hash_consttranspose_mapdba_ctxa_ctx_updateidadptmp_ctxtmp_ctx_updatedsdp_dpdp_dspermsevenodddatadcblockstailpairss   &&&&                       =/usr/lib/python3/dist-packages/passlib/handlers/sha2_crypt.py_raw_sha2_cryptr=      si   < #sjj!c5!!!!}ff&&w|QQLQQ#hG 6&Y&8(88&8(88& dC  0.0 ;;wD4yHb=***= ^^
*^^
*	CJ$	%	,	,	.Bsz"E<<L r+, 	A
1q55Rc*	a 
B | :cm4;;=wG S/ aK3FA7>>+W5r7g	DBAJ'	(	/	/	1)8	<Br7h> >>\ GEGEurz27BJ?E 8II7H)$U4[%*%7HDI 
B&"%LFD
ID#C*R$Y"7">">"@@AHHJB ! 	fuID#C*R$Y"7">">"@@AHHJB &
 !88BeQ/0779B&&r=9@@II+ Js   ?P zrounds=$0c                     a  ] tR tRtRtRt]P                  t^t	]P                  t
RtRtRtRtRtRtRV 3R lltR	 tR
 t]R 4       tR tRt]R 4       tR tRtV ;t# )_SHA2_CommoniP  zBclass containing common code shared by sha256_crypt & sha512_cryptr
   r   linearFNc                	   < \         SV `  ! R/ VB  Vf$   V P                  ;'       d    V P                  R8H  pWn        R # )N   )super__init__use_defaultsr#   implicit_rounds)selfrI   kwds	__class__s   &&,r<   rG   _SHA2_Common.__init__i  s;     4 ""//GGDKK44GO.    c                	>    V P                  WP                  R J R7      # N)relaxed)
_norm_saltchecksum)rJ   r"   s   &&r<   _parse_salt_SHA2_Common._parse_saltp  s    t]]d-BCCrN   c                	>    V P                  WP                  R J R7      # rP   )_norm_roundsrS   )rJ   r#   s   &&r<   _parse_rounds_SHA2_Common._parse_roundst  s      $1F GGrN   c                	   \        VR R4      pV P                  pVP                  V4      '       g    \        P                  P                  V 4      h\        V4      ^8X  g   Q hVR,          P                  \        4      pV^ ,          P                  \        4      '       d   \        \        4      ^8X  g   Q hVP                  ^ 4      R,          pVP                  \        4      '       d+   V\        8w  d    \        P                  P                  V 4      h\        V4      pRpMRpRp\        V4      ^8X  d   Vw  rgM;\        V4      ^8X  d   V^ ,          pRpM\        P                  P                  V 4      hT ! TTT;'       g    RVR7      # )	r   hash:   NN:   NNFrD   TN)r#   r"   rS   rI   )r   ident
startswithr   r   InvalidHashErrorr   split_UDOLLAR_UROUNDSpop_UZEROZeroPaddedRoundsErrorintMalformedHashError)clsr[   r^   partsr#   rI   r"   chks   &&      r<   from_string_SHA2_Common.from_stringx  sF    $0		u%%&&))#..5zQRx( 8x((x=A%%%YYq\"%F  ((Vv-=ff22377[F#OF"O u:?ID#Z1_8DC&&++C00 [[D+	
 	
rN   c                	D   V P                   R 8X  dP   V P                  '       d>   RP                  V P                  V P                  V P
                  ;'       g    R4      pV# RV P                  V P                   V P                  V P
                  ;'       g    R3,          pV# )rD   z{}{}${} z%srounds=%d$%s$%s)r#   rI   formatr^   r"   rS   )rJ   r[   s   & r<   	to_string_SHA2_Common.to_string  s    ;;$4#7#7#7##DJJ		4==;N;NBOD  '

		##	* D rN   c                	<    V P                  V P                  4       R # )T)_set_calc_checksum_backend_calc_checksum_builtin)ri   s   &r<   _load_backend_builtin"_SHA2_Common._load_backend_builtin  s    &&s'A'ABrN   c                	X    \        WP                  V P                  V P                  4      # N)r=   r"   r#   _cdb_use_512)rJ   secrets   &&r<   ru   #_SHA2_Common._calc_checksum_builtin  s    vyy$++t?P?PQQrN   )rI   )r"   r#   rI   	salt_sizery   )builtin)__name__
__module____qualname____firstlineno____doc__setting_kwdsr   HASH64_CHARSchecksum_charsmax_salt_size
salt_chars
min_rounds
max_roundsrounds_costrz   _rounds_prefixrI   rG   rT   rX   classmethodrl   rq   backendsrv   ru   __static_attributes____classcell__)rL   s   @r<   rA   rA   P  s     M FL__N MJJJKLNO/DH *
 *
X
 H
  R RrN   rA   c                  .    ] tR tRtRtR tRt^+tRtRt	Rt
R# )r   i  a  This class implements the SHA256-Crypt 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:

:type salt: str
:param salt:
    Optional salt string.
    If not specified, one will be autogenerated (this is recommended).
    If specified, it must be 0-16 characters, drawn from the regexp range ``[./0-9A-Za-z]``.

:type rounds: int
:param rounds:
    Optional number of rounds to use.
    Defaults to 535000, must be between 1000 and 999999999, inclusive.

    .. note::
        per the official specification, when the rounds parameter is set to 5000,
        it may be omitted from the hash string.

: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

..
    commented out, currently only supported by :meth:`hash`, and not via :meth:`using`:

    :type implicit_rounds: bool
    :param implicit_rounds:
        this is an internal option which generally doesn't need to be touched.

        this flag determines whether the hash should omit the rounds parameter
        when encoding it to a string; this is only permitted by the spec for rounds=5000,
        and the flag is ignored otherwise. the spec requires the two different
        encodings be preserved as they are, instead of normalizing them.
z$5$i) rE   N)testz?$5$rounds=1000$test$QmQADEXMG8POI5WDsaeho0P36yK3Tcrgboabng6bkb/)r   r   r   r   r   namer^   checksum_sizedefault_rounds
_test_hashr   rE   rN   r<   r   r     s%    *X DEMNJrN   c                  2    ] tR tRtRtR tRt^VtRtRt	Rt
RtR# )	r   i  a  This class implements the SHA512-Crypt 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:

:type salt: str
:param salt:
    Optional salt string.
    If not specified, one will be autogenerated (this is recommended).
    If specified, it must be 0-16 characters, drawn from the regexp range ``[./0-9A-Za-z]``.

:type rounds: int
:param rounds:
    Optional number of rounds to use.
    Defaults to 656000, must be between 1000 and 999999999, inclusive.

    .. note::
        per the official specification, when the rounds parameter is set to 5000,
        it may be omitted from the hash string.

: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

..
    commented out, currently only supported by :meth:`hash`, and not via :meth:`using`:

    :type implicit_rounds: bool
    :param implicit_rounds:
        this is an internal option which generally doesn't need to be touched.

        this flag determines whether the hash should omit the rounds parameter
        when encoding it to a string; this is only permitted by the spec for rounds=5000,
        and the flag is ignored otherwise. the spec requires the two different
        encodings be preserved as they are, instead of normalizing them.
z$6$Ti
 rE   N)r   zj$6$rounds=1000$test$2M/Lx6MtobqjLjobw0Wmo4Q5OFx5nVLJvmgseatA6oMnyWeBdRDx4DU.1H3eGmse6pgsOgDisWBGI5c7TZauS0)r   r   r   r   r   r   r^   r   rz   r   r   r   rE   rN   r<   r   r     s*    *X DEMLNJrN   ))    r\         r   r\   )r      r   r   r   r\   )   r   r   r   )r   r   r   r   r   )r   r\   r   r   )r   r   r   r   r   )    
   r      r      r               r\      r      r                     r]                     	         )@*   r   r   r   +   r   r   r   ,   -   r   r\   r   .   r   r   r   /   0   r   r   r]   1   r   r   r   2   3   r   r   r   4   r       r   5   6   !   r   r   7   "   #   r   8   9   $   r   r   :   %   &   r   ;   <   '   r   r   =   (   )   r   >   ?   )F)r   
__future__r   r   passlib.utils.handlersutilshandlersr   passlib.utilsr   r   passlib.utils.binaryr   __all__r   r   r   r   r=   rc   rb   re   HasManyBackends	HasRoundsHasSaltGenericHandlerrA   r   r   rE   rN   r<   <module>r      s    ! "  # # 3 $  
 2! HA HiJX 	lRLLJJ	lR^5< 5p9< 9rN   