Ë
    àU.jù2  ã                   ó  — d Z ddlmZmZ ddlmZmZmZmZ ddl	Z	 e	j                  e«      ZddlZddlmZ ddlmZmZ ddlmZmZmZ ddlmZ ddlmc mZ g d	¢Z G d
„ dej<                  «      Z G d„ dej@                  ejB                  ejD                  «      Z# G d„ de«      Z$ G d„ de«      Z% G d„ de#«      Z& G d„ de#«      Z' G d„ de#«      Z( G d„ de#«      Z) G d„ de«      Z*eD � cg c]  } d| z   ‘Œ	 c} Z+d„ Z, e,«        yc c} w )z.passlib.handlers.digests - plain hash digests
é    )Ú	b64encodeÚ	b64decode)Úmd5Úsha1Úsha256Úsha512N)Ú	plaintext)Úunix_crypt_schemesÚ
to_unicode)Úuascii_to_strÚunicodeÚu)Úclassproperty)Úldap_plaintextÚldap_md5Ú	ldap_sha1Úldap_salted_md5Úldap_salted_sha1Úldap_salted_sha256Úldap_salted_sha512Úldap_des_cryptÚldap_bsdi_cryptÚldap_md5_cryptÚldap_sha1_cryptÚldap_bcryptÚldap_sha256_cryptÚldap_sha512_cryptc                   óJ   — e Zd ZdZdZdZdZej                  Z	e
d„ «       Zd„ Zy)Ú_Base64DigestHelperzhelper for ldap_md5 / ldap_sha1Nc                 ó   — | j                   S )z/tell StaticHandler to strip ident from checksum)Úident©Úclss    ú_C:\xampp\htdocs\tradingbinance\backend\.venv\Lib\site-packages\passlib/handlers/ldap_digests.pyÚ_hash_prefixz _Base64DigestHelper._hash_prefix2   s   € ð �y‰yÐó    c                 ó¶   — t        |t        «      r|j                  d«      }| j                  |«      j	                  «       }t        |«      j                  d«      S )Núutf-8Úascii)Ú
isinstancer   ÚencodeÚ
_hash_funcÚdigestr   Údecode)ÚselfÚsecretÚchks      r$   Ú_calc_checksumz"_Base64DigestHelper._calc_checksum7   sF   € Ü�fœgÔ&Ø—]‘] 7Ó+ˆFØ�o‰o˜fÓ%×,Ñ,Ó.ˆÜ˜‹~×$Ñ$ WÓ-Ð-r&   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__r!   r,   Ú_hash_regexÚuhÚPADDED_BASE64_CHARSÚchecksum_charsr   r%   r2   © r&   r$   r   r   )   s8   „ Ù)ð €EØ€JØ€KØ×+Ñ+€Nàñó ðó.r&   r   c                   óh   — e Zd ZdZdZej                  ZdZdZ	dZ
dxZZdZdZdZed„ «       Zd„ Zd„ Zy)	Ú_SaltedBase64DigestHelperz-helper for ldap_salted_md5 / ldap_salted_sha1)ÚsaltÚ	salt_sizeNé   é   c                 ó€  — t        |dd«      }| j                  j                  |«      }|st        j                  j                  | «      ‚	 t        |j                  d«      j                  d«      «      }| j                  }|sJ ‚ | |d | ||d  ¬«      S # t        $ r  t        j                  j                  | «      ‚w xY w)Nr)   ÚhashÚtmp)Úchecksumr>   )r   r7   Úmatchr8   ÚexcÚInvalidHashErrorr   Úgroupr+   Ú	TypeErrorÚMalformedHashErrorÚchecksum_size)r#   rC   ÚmÚdataÚcss        r$   Úfrom_stringz%_SaltedBase64DigestHelper.from_stringN   s±   € ä˜$ ¨Ó0ˆØ�O‰O×!Ñ! $Ó'ˆÙÜ—&‘&×)Ñ)¨#Ó.Ð.ð	1Ü˜QŸW™W U›^×2Ñ2°7Ó;Ó<ˆDð ×ÑˆÙˆ	ˆrÙ˜D  "˜I¨D°°¨IÔ6Ð6øô	 ò 	1Ü—&‘&×+Ñ+¨CÓ0Ð0ð	1ús   Á)B Â)B=c                 ó˜   — | j                   | j                  z   }| j                  t        |«      j	                  d«      z   }t        |«      S )Nr)   )rE   r>   r!   r   r.   r   )r/   rN   rC   s      r$   Ú	to_stringz#_SaltedBase64DigestHelper.to_string\   s<   € Ø�}‰}˜tŸy™yÑ(ˆØ�z‰zœI d›O×2Ñ2°7Ó;Ñ;ˆÜ˜TÓ"Ð"r&   c                 óœ   — t        |t        «      r|j                  d«      }| j                  || j                  z   «      j                  «       S )Nr(   )r*   r   r+   r,   r>   r-   )r/   r0   s     r$   r2   z(_SaltedBase64DigestHelper._calc_checksuma   s;   € Ü�fœgÔ&Ø—]‘] 7Ó+ˆFØ�‰˜v¨¯	©	Ñ1Ó2×9Ñ9Ó;Ð;r&   )r3   r4   r5   r6   Úsetting_kwdsr8   r9   r:   r!   r,   r7   Úmin_salt_sizeÚmax_salt_sizeÚdefault_salt_sizeÚclassmethodrP   rR   r2   r;   r&   r$   r=   r=   =   s\   „ Ù7Ø(€LØ×+Ñ+€Nà€EØ€JØ€KØ$%Ð%€M�Mð
 €MØÐØ€Màñ7ó ð7ò#ó
<r&   r=   c                   óX   — e Zd ZdZd Z ed«      ZeZ e	j                   ed«      «      Zy)r   zìThis class stores passwords using LDAP's plain MD5 format, and follows the :ref:`password-hash-api`.

    The :meth:`~passlib.ifc.PasswordHash.hash` and :meth:`~passlib.ifc.PasswordHash.genconfig` methods have no optional keywords.
    z{MD5}z%^\{MD5\}(?P<chk>[+/a-zA-Z0-9]{22}==)$N)r3   r4   r5   r6   Únamer   r!   r   r,   ÚreÚcompiler7   r;   r&   r$   r   r   i   s2   „ ñð €DÙˆg‹J€EØ€JØ�"—*‘*™QÐGÓHÓI�Kr&   r   c                   óX   — e Zd ZdZd Z ed«      ZeZ e	j                   ed«      «      Zy)r   zíThis class stores passwords using LDAP's plain SHA1 format, and follows the :ref:`password-hash-api`.

    The :meth:`~passlib.ifc.PasswordHash.hash` and :meth:`~passlib.ifc.PasswordHash.genconfig` methods have no optional keywords.
    z{SHA}z$^\{SHA\}(?P<chk>[+/a-zA-Z0-9]{27}=)$N)r3   r4   r5   r6   rZ   r   r!   r   r,   r[   r\   r7   r;   r&   r$   r   r   s   s2   „ ñð €DÙˆg‹J€EØ€JØ�"—*‘*™QÐFÓGÓH�Kr&   r   c                   ó\   — e Zd ZdZd Z ed«      ZdZeZ	 e
j                   ed«      «      Zy)r   aÏ  This class stores passwords using LDAP's salted MD5 format, and follows the :ref:`password-hash-api`.

    It supports a 4-16 byte salt.

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

    :type salt: bytes
    :param salt:
        Optional salt string.
        If not specified, one will be autogenerated (this is recommended).
        If specified, it may be any 4-16 byte string.

    :type salt_size: int
    :param salt_size:
        Optional number of bytes to use when autogenerating new salts.
        Defaults to 4 bytes for compatibility with the LDAP spec,
        but some systems use larger salts, and Passlib supports
        any value between 4-16.

    :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

    .. versionchanged:: 1.6
        This format now supports variable length salts, instead of a fix 4 bytes.
    z{SMD5}rA   z+^\{SMD5\}(?P<tmp>[+/a-zA-Z0-9]{27,}={0,2})$N)r3   r4   r5   r6   rZ   r   r!   rL   r   r,   r[   r\   r7   r;   r&   r$   r   r   }   s8   „ ñð@ €DÙˆh‹K€EØ€MØ€JØ�"—*‘*™QÐMÓNÓO�Kr&   r   c                   ó\   — e Zd ZdZd Z ed«      ZdZeZ	 e
j                   ed«      «      Zy)r   aÛ  
    This class stores passwords using LDAP's "Salted SHA1" format,
    and follows the :ref:`password-hash-api`.

    It supports a 4-16 byte salt.

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

    :type salt: bytes
    :param salt:
        Optional salt string.
        If not specified, one will be autogenerated (this is recommended).
        If specified, it may be any 4-16 byte string.

    :type salt_size: int
    :param salt_size:
        Optional number of bytes to use when autogenerating new salts.
        Defaults to 4 bytes for compatibility with the LDAP spec,
        but some systems use larger salts, and Passlib supports
        any value between 4-16.

    :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

    .. versionchanged:: 1.6
        This format now supports variable length salts, instead of a fix 4 bytes.
    z{SSHA}é   z+^\{SSHA\}(?P<tmp>[+/a-zA-Z0-9]{32,}={0,2})$N)r3   r4   r5   r6   rZ   r   r!   rL   r   r,   r[   r\   r7   r;   r&   r$   r   r   ¤   s8   „ ñ!ðD €DÙˆh‹K€EØ€MØ€Jà�"—*‘*™QÐMÓNÓO�Kr&   r   c                   ó`   — e Zd ZdZd Z ed«      ZdZdZe	Z
 ej                   ed«      «      Zy)r   aC  
    This class stores passwords using LDAP's "Salted SHA2-256" format,
    and follows the :ref:`password-hash-api`.

    It supports a 4-16 byte salt.

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

    :type salt: bytes
    :param salt:
        Optional salt string.
        If not specified, one will be autogenerated (this is recommended).
        If specified, it may be any 4-16 byte string.

    :type salt_size: int
    :param salt_size:
        Optional number of bytes to use when autogenerating new salts.
        Defaults to 8 bytes for compatibility with the LDAP spec,
        but Passlib supports any value between 4-16.

    :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.7.3
    z	{SSHA256}é    é   z.^\{SSHA256\}(?P<tmp>[+/a-zA-Z0-9]{48,}={0,2})$N)r3   r4   r5   r6   rZ   r   r!   rL   rW   r   r,   r[   r\   r7   r;   r&   r$   r   r   Ð   ó=   „ ñð<  €DÙˆk‹N€EØ€MØÐØ€Jà�"—*‘*™QÐPÓQÓR�Kr&   r   c                   ó`   — e Zd ZdZd Z ed«      ZdZdZe	Z
 ej                   ed«      «      Zy)r   aC  
    This class stores passwords using LDAP's "Salted SHA2-512" format,
    and follows the :ref:`password-hash-api`.

    It supports a 4-16 byte salt.

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

    :type salt: bytes
    :param salt:
        Optional salt string.
        If not specified, one will be autogenerated (this is recommended).
        If specified, it may be any 4-16 byte string.

    :type salt_size: int
    :param salt_size:
        Optional number of bytes to use when autogenerating new salts.
        Defaults to 8 bytes for compatibility with the LDAP spec,
        but Passlib supports any value between 4-16.

    :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.7.3
    z	{SSHA512}é@   rc   z.^\{SSHA512\}(?P<tmp>[+/a-zA-Z0-9]{91,}={0,2})$N)r3   r4   r5   r6   rZ   r   r!   rL   rW   r   r,   r[   r\   r7   r;   r&   r$   r   r   ø   rd   r&   r   c                   ó’   — e Zd ZdZd Z ej                   ed«      «      Z e	j                  dd¬«      ed„ «       «       Zed„ «       Zy)	r   aY  This class stores passwords in plaintext, and follows the :ref:`password-hash-api`.

    This class acts much like the generic :class:`!passlib.hash.plaintext` handler,
    except that it will identify a hash only if it does NOT begin with the ``{XXX}`` identifier prefix
    used by RFC2307 passwords.

    The :meth:`~passlib.ifc.PasswordHash.hash`, :meth:`~passlib.ifc.PasswordHash.genhash`, and :meth:`~passlib.ifc.PasswordHash.verify` methods all require the
    following additional contextual keyword:

    :type encoding: str
    :param encoding:
        This controls the character encoding to use (defaults to ``utf-8``).

        This encoding will be used to encode :class:`!unicode` passwords
        under Python 2, and decode :class:`!bytes` hashes under Python 3.

    .. versionchanged:: 1.6
        The ``encoding`` keyword was added.
    z^\{\w+\}.*$z1.7z2.0)Ú
deprecatedÚremovedc                  ó   — y)NÚ!r;   r"   s    r$   Ú	genconfigzldap_plaintext.genconfig:  s   € ð
 r&   c                 ó€   — t        j                  |«      }t        |«      xr | j                  j	                  |«      d u S )N)r8   Úto_unicode_for_identifyÚboolÚ	_2307_patrF   )r#   rC   s     r$   Úidentifyzldap_plaintext.identifyA  s7   € ô ×)Ñ)¨$Ó/ˆÜ�D‹zÒ?˜cŸm™m×1Ñ1°$Ó7¸4Ð?Ð?r&   N)r3   r4   r5   r6   rZ   r[   r\   r   rp   r8   Údeprecated_methodrX   rl   rq   r;   r&   r$   r   r      sb   „ ñð, €DØ�—
‘
™1˜^Ó,Ó-€Ià€R×Ñ U°EÔ:Øñó ó ;ðð
 ñ@ó ñ@r&   r   Úldap_c                  ó„   — t        «       } t        D ],  }d|z   }t        j                  ||t	        d«      d¬«      | |<   Œ. ~ y )Nrs   z{CRYPT}T)ÚprefixÚlazy)Úglobalsr
   r8   ÚPrefixWrapperr   )ÚgÚwnamerZ   s      r$   Ú_init_ldap_crypt_handlersr{   N  sA   € ô 	‹	€Aß#ˆØ˜‰ˆÜ×"Ñ" 4¨´q¸³|È$ÔOˆˆ$Šð $ñ 	
r&   )-r6   Úbase64r   r   Úhashlibr   r   r   r   ÚloggingÚ	getLoggerr3   Úlogr[   Úpasslib.handlers.miscr	   Úpasslib.utilsr
   r   Úpasslib.utils.compatr   r   r   Úpasslib.utils.decorr   Úpasslib.utils.handlersÚutilsÚhandlersr8   Ú__all__ÚStaticHandlerr   Ú
HasRawSaltÚHasRawChecksumÚGenericHandlerr=   r   r   r   r   r   r   r   Úldap_crypt_schemesr{   )rZ   s   0r$   Ú<module>rŽ      s  ðñ÷ (ß -Ó -Û Ð'�g×'Ñ'¨Ó1�Û 	õ ,ß 8ß :Ñ :Ý -ß #Ð #ò€ô,.˜"×*Ñ*ô .ô('< §¡¨r×/@Ñ/@À"×BSÑBSô '<ôXJÐ"ô JôIÐ#ô Iô%PÐ/ô %PôN(PÐ0ô (PôX%SÐ2ô %SôP%SÐ2ô %SôP%@�Yô %@ñX 3EÓFÑ2D¨$�w “~Ð2DÑFÐ ò
ñ Õ ùò Gs   Ã-D