
    gBJ                     p   S r SSKJrJr  SSKJrJr  SSKr\R                  " \	5      r
SSKJr  SSKJrJr  SSKJrJrJrJr  SSKJr  SSKJs  Jr  / S	Qr " S
 S\R8                  \R:                  \R<                  \R>                  5      r SS\	4S jr!\!" SSS\" S5      S9r"\!" SSS5      r#\!" SSS5      r$\RJ                  " S\"SSSS9r&\RJ                  " S\#SSSS9r'\RJ                  " S\$S S!SS9r(S"r) " S# S$\R8                  \R:                  \R<                  \R>                  5      r* " S% S&\R8                  \RV                  \R>                  5      r, " S' S(\R:                  \R<                  \R>                  5      r- " S) S*\R8                  \R:                  \R<                  \R>                  5      r.g)+z,passlib.handlers.pbkdf - PBKDF2 based hashes    )hexlify	unhexlify)	b64encode	b64decodeN)
to_unicode)ab64_decodeab64_encode)str_to_basciiuuascii_to_strunicode)pbkdf2_hmac)pbkdf2_sha1pbkdf2_sha256pbkdf2_sha512cta_pbkdf2_sha1dlitz_pbkdf2_sha1grub_pbkdf2_sha512c                   l    \ rS rSrSrSr\R                  rSr	Sr
SrSrSrS	rSr\S
 5       rS rS rSrg)Pbkdf2DigestHandler   z1base class for various pbkdf2_{digest} algorithmssalt	salt_sizerounds      N       linearc                     [         R                  " XR                  U S9u  p#n[        UR	                  S5      5      nU(       a  [        UR	                  S5      5      nU " X#US9$ )N)handlerasciir   r   checksum)uh	parse_mc3identr   encodeclshashr   r   chks        P/home/matz/Project1/venv/lib/python3.13/site-packages/passlib/handlers/pbkdf2.pyfrom_stringPbkdf2DigestHandler.from_string?   sQ    LLyy#Fc4;;w/0cjj12C&c::    c                     [        U R                  5      R                  S5      n[        U R                  5      R                  S5      n[        R
                  " U R                  U R                  X5      $ Nr#   )r	   r   decoder%   r&   
render_mc3r(   r   selfr   r-   s      r.   	to_stringPbkdf2DigestHandler.to_stringG   sO    499%,,W5$--(//8}}TZZd@@r1   c                 n    [        U R                  XR                  U R                  U R                  5      $ )N)r   _digestr   r   checksum_sizer7   secrets     r.   _calc_checksum"Pbkdf2DigestHandler._calc_checksumL   s%    4<<DKKI[I[\\r1    )__name__
__module____qualname____firstlineno____doc__setting_kwdsr&   HASH64_CHARSchecksum_charsdefault_salt_sizemax_salt_sizedefault_rounds
min_rounds
max_roundsrounds_costr;   classmethodr/   r8   r?   __static_attributes__rA   r1   r.   r   r      s_    ; 3L__N M NJJK G ; ;A
]r1   r   i.  c                     SU -   nUc  [        S5      U 4-  n[        n[        XV4[        UUUU UUUS-  S-   S-  S[        U R	                  5       UR
                  US9-  S95      $ )	z;create new Pbkdf2DigestHandler subclass for a specific hashpbkdf2_z$pbkdf2-%s$         a$  This class implements a generic ``PBKDF2-HMAC-%(digest)s``-based 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: bytes
    :param salt:
        Optional salt bytes.
        If specified, the length must be between 0-1024 bytes.
        If not specified, a %(dsc)d byte salt will be autogenerated (this is recommended).

    :type salt_size: int
    :param salt_size:
        Optional number of bytes to use when autogenerating new salts.
        Defaults to %(dsc)d bytes, but can be any value between 0 and 1024.

    :type rounds: int
    :param rounds:
        Optional number of rounds to use.
        Defaults to %(dr)d, but must be within ``range(1,1<<32)``.

    :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
    )digestdscdr)rC   namer(   r;   rL   r<   encoded_checksum_sizerF   )r   r   typedictupperrJ   )	hash_namedigest_sizer   r(   modulerZ   bases          r.   create_pbkdf2_hashrc   P   s    y D}- I</Dgt!*1}Q2> ioo'T-C-C
O?P(  ( (r1   sha1   i z$pbkdf2$)r(   sha256    iHq  sha512@   ia  ldap_pbkdf2_sha1z{PBKDF2}Tldap_pbkdf2_sha256z{PBKDF2-SHA256}z$pbkdf2-sha256$ldap_pbkdf2_sha512z{PBKDF2-SHA512}z$pbkdf2-sha512$s   -_c                   |    \ rS rSrSrS rSr\" S5      rSr	Sr
Sr\R                  rSrS	rS
r\S 5       rS rS rSrg)r      a  This class implements Cryptacular's PBKDF2-based crypt algorithm, 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: bytes
:param salt:
    Optional salt bytes.
    If specified, it may be any length.
    If not specified, a one will be autogenerated (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 60000, must be within ``range(1,1<<32)``.

: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
r   $p5k2$re   r   r   r   r   r    c                     [         R                  " XR                  SU S9u  p#n[        UR	                  S5      [
        5      nU(       a  [        UR	                  S5      [
        5      nU " X#US9$ )Nr   )rounds_baser"   r#   r$   )r&   r'   r(   r   r)   CTA_ALTCHARSr*   s        r.   r/   cta_pbkdf2_sha1.from_string   sZ     LLyybRUVcW-|<CJJw/>C&c::r1   c                     [        U R                  [        5      R                  S5      n[        U R                  [        5      R                  S5      n[
        R                  " U R                  U R                  XSS9$ )Nr#   r   rq   )	r   r   rr   r4   r%   r&   r5   r(   r   r6   s      r.   r8   cta_pbkdf2_sha1.to_string   sU    L188A|4;;GD}}TZZdRPPr1   c                 F    [        SXR                  U R                  S5      $ )Nrd   re   r   r   r   r=   s     r.   r?   cta_pbkdf2_sha1._calc_checksum   s    6699dkk2FFr1   rA   N)rB   rC   rD   rE   rF   rZ   rG   r   r(   r<   rJ   rK   r   rL   rM   rN   rO   rP   r/   r8   r?   rQ   rA   r1   r.   r   r      sk    J D2LhKEM M !//NJJK ; ;QGr1   r   c                       \ rS rSrSrS rSr\" S5      r\" S5      r	Sr
Sr\R                  r\R                   rSrS	rS
r\S 5       rS rS rS rSrg)r      a  This class implements Dwayne Litzenberger's PBKDF2-based crypt algorithm, 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 specified, it may be any length, but must use the characters in the regexp range ``[./0-9A-Za-z]``.
    If not specified, a 16 character salt will be autogenerated (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 60000, must be within ``range(1,1<<32)``.

: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
r   ro   z1000000000000000000000000000000000000000000000000=r   r   r   r   r    c                 X    [         R                  " XR                  SSU S9u  p#nU " X#US9$ )Nr     )rq   rL   r"   r$   )r&   r'   r(   r*   s        r.   r/   dlitz_pbkdf2_sha1.from_string9  s0    LLyyb8;SJc&c::r1   c                     U R                   nUS:X  a  S n[        R                  " U R                  XR                  U R
                  SS9$ Nr}   r   ru   )r   r&   r5   r(   r   r%   r7   r   s     r.   r8   dlitz_pbkdf2_sha1.to_string?  s9    S=F}}TZZDMMWYZZr1   c                     U R                   nUS:X  a  S n[        R                  " U R                  XR                  S SS9$ r   )r   r&   r5   r(   r   r   s     r.   _get_configdlitz_pbkdf2_sha1._get_configE  s4    S=F}}TZZDbQQr1   c                     U R                  5       n[        SXU R                  S5      n[        U5      R	                  S5      $ )Nrd      r#   )r   r   r   r	   r4   )r7   r>   r   results       r.   r?    dlitz_pbkdf2_sha1._calc_checksumN  s:    !VV4;;C6"))'22r1   rA   N)rB   rC   rD   rE   rF   rZ   rG   r   r(   _stub_checksumrJ   rK   r&   rH   
salt_charsr   rL   rM   rN   rO   rP   r/   r8   r   r?   rQ   rA   r1   r.   r   r      s~    J D2LhKE~&N MJ
 !//NJJK ; ;
[R3r1   r   c                   X    \ rS rSrSrS rSr\" S5      rSr	S=r
r\S 5       rS rS	 rS
rg)atlassian_pbkdf2_sha1i[  a  This class implements the PBKDF2 hash used by Atlassian.

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

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

:type salt: bytes
:param salt:
    Optional salt bytes.
    If specified, the length must be exactly 16 bytes.
    If not specified, a salt will be autogenerated (this is recommended).

: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
    ``salt`` strings that are too long.

    .. versionadded:: 1.6
)r   z	{PKCS5S2}rg   r   c                    [        USS5      nU R                  nUR                  U5      (       d  [        R                  R                  U 5      e[        U[        U5      S  R                  S5      5      nUS S USS  pTU " XES9$ )Nr#   r,   r   )r   r%   )	r   r(   
startswithr&   excInvalidHashErrorr   lenr)   )r+   r,   r(   datar   r-   s         r.   r/   !atlassian_pbkdf2_sha1.from_string{  s{    $0		u%%&&))#..c%jk*11':;"ItBCyc++r1   c                     U R                   U R                  -   nU R                  [        U5      R	                  S5      -   n[        U5      $ r3   )r   r%   r(   r   r4   r   )r7   r   r,   s      r.   r8   atlassian_pbkdf2_sha1.to_string  s<    yy4==(zzIdO227;;T""r1   c                 2    [        SXR                  SS5      $ )Nrd   i'  rg   )r   r   r=   s     r.   r?   $atlassian_pbkdf2_sha1._calc_checksum  s     6699eR@@r1   rA   N)rB   rC   rD   rE   rF   rZ   rG   r   r(   r<   min_salt_sizerK   rP   r/   r8   r?   rQ   rA   r1   r.   r   r   [  sJ    . #DLkNEM %'&MM, ,#
Ar1   r   c                   |    \ rS rSrSrS rSr\" S5      rSr	Sr
Sr\R                  rSrSrS	r\S
 5       rS rS rSrg)r   i  a  This class implements Grub's pbkdf2-hmac-sha512 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: bytes
:param salt:
    Optional salt bytes.
    If specified, the length must be between 0-1024 bytes.
    If not specified, a 64 byte salt will be autogenerated (this is recommended).

:type salt_size: int
:param salt_size:
    Optional number of bytes to use when autogenerating new salts.
    Defaults to 64 bytes, but can be any value between 0 and 1024.

:type rounds: int
:param rounds:
    Optional number of rounds to use.
    Defaults to 19000, but must be within ``range(1,1<<32)``.

: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
r   zgrub.pbkdf2.sha512.ri   r   r   r   r    c                     [         R                  " XR                  [        S5      U S9u  p#n[	        UR                  S5      5      nU(       a  [	        UR                  S5      5      nU " X#US9$ )N.)sepr"   r#   r$   )r&   r'   r(   r   r   r)   r*   s        r.   r/   grub_pbkdf2_sha512.from_string  sZ    LLyyaf146cW-.CJJw/0C&c::r1   c           	      2   [        U R                  5      R                  S5      R                  5       n[        U R                  5      R                  S5      R                  5       n[
        R                  " U R                  U R                  X[        S5      S9$ )Nr#   r   )r   )
r   r   r4   r^   r%   r&   r5   r(   r   r   r6   s      r.   r8   grub_pbkdf2_sha512.to_string  sg    tyy!((1779dmm$++G4::<}}TZZdQsVLLr1   c                 F    [        SXR                  U R                  S5      $ )Nrh   ri   rx   r=   s     r.   r?   !grub_pbkdf2_sha512._calc_checksum  s     8VYYRHHr1   rA   N)rB   rC   rD   rE   rF   rZ   rG   r   r(   r<   rJ   rK   r   rL   rM   rN   rO   rP   r/   r8   r?   rQ   rA   r1   r.   r   r     si    @  D2L#$EM M"11NJJK; ;M
Ir1   r   )/rF   binasciir   r   base64r   r   logging	getLoggerrB   logpasslib.utilsr   passlib.utils.binaryr   r	   passlib.utils.compatr
   r   r   r   passlib.crypto.digestr   passlib.utils.handlersutilshandlersr&   __all__	HasRounds
HasRawSaltHasRawChecksumGenericHandlerr   rc   r   r   r   PrefixWrapperrj   rk   rl   rr   r   HasSaltr   r   r   rA   r1   r.   <module>r      s   2
 ( ' g''1 % 9 I I - # #1]",,r7H7H"J[J[ 1]f 7<4PX .f !V1Z=I"8R7"8R7##$6ZQ[cgh %%&:MK\^ow{| %%&:MK\^ow{|  WGbllBMM23D3DbFWFW WG@`3bjj"2C2C `3R3ABMM2+<+<b>O>O 3ApDIr}}b6G6GIZIZ DIr1   