+
    ¢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
! \%        W„4      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×Òà�j‰j˜Ó!ˆÜ�cœ5×!Ò!Ð!Ð!Ü�„}Ü�f‰f×&Ñ&·w¤|ÓQÐQÄLÓQÐQÜ�#‹h€Gð �6Ö&˜YÔ&Ð8Ð(8Ó8Ñ&Ð8Ð(8Ó8Ð&ô �dœC× Ò Ð0 .Ó0Ð Ø�;‰;�wÓ€DÜ�4‹y€HØ�bŒ=Ð*Ð*Ó*ˆ=÷ Ü—^‘^ˆ
Ü*‰ä—^‘^ˆ
Ü*ˆÙ	�C•J Õ$Ó	%×	,Ñ	,Ó	.€Bá�s•zÓ"€EØ—<‘<€Lñ ”˜rÓ+Ô,ð 	€Aß
Ù˜1˜qŸ5œ5‘R cÔ*Ø	ˆa�Šð 
�‰‹€Bð �„|ô ™: c¥mÓ4×;Ñ;Ó=¸wÓG‰ñ ˜S“/ˆØ Ÿ™ˆØ�a�KˆßÙ˜3ÔØ��FŠAÜ˜7Ÿ>™>Ó+¨WÓ5ˆÜˆr‹7�gÔÐÐÙ	�D˜B  A¥�JÕ'Ó	(×	/Ñ	/Ó	1°)°8Ð	<€BÜˆr‹7�hÔÐ>Ð >Ó>Ðð\ �G€EØ��G€EØ�˜˜u r�z¨2°­7°B¸µJÐ?€Eõ 8IÔIÑ7H©)¨$°ˆU�4�[˜% �*Ó%Ñ7H€DÑIð 
€BÜ˜& "Ó%�L€FˆDß
Û‰IˆD�#Ù˜C¡*¨R°$­YÓ"7×">Ñ">Ó"@Õ@ÓA×HÑHÓJŠBñ à�!�Š÷ à˜•	ˆØ˜f˜u›‰IˆD�#Ù˜C¡*¨R°$­YÓ"7×">Ñ">Ó"@Õ@ÓA×HÑHÓJŠBñ &ð
 �!�8Œ8Ù˜B  e¥¨Q¥Õ/Ó0×7Ñ7Ó9ˆBÜ×&Ò& 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ÐG°D·K±KÀ4Ñ4GˆOØ.Öó    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×%Ò%Ü—&‘&×)Ñ)¨#Ó.Ð.Ü�5‹z˜QŒÐˆØ�R•—‘œxÓ(ˆð ��8×Ñœx×(Ò(Ü”x“= AÔ%Ð%Ð%Ø—Y‘Y˜q“\ "Õ%ˆFØ× Ñ ¤×(Ò(¨V´vÔ-=Ü—f‘f×2Ñ2°3Ó7Ð7Ü˜“[ˆFØ#‰OàˆFØ"ˆOô ˆu‹:˜Œ?Ø‰IˆD�#Ü�‹Z˜1Œ_Ø˜•8ˆDØ‰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Ø×#Ñ# D§J¡J°·	±	¸4¿=¹=×;NÐ;NÈBÓOˆDð ˆð 'Ø—
‘
Ø—‘Ø—	‘	Ø—‘×#Ð# ð	*õ ˆ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   € Ü˜v§y¡y°$·+±+¸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Ø×ÑØ‡L�LØ‡J�JØ×Ñô	lRô^5�<ô 5ôp9�<ö 9rN   