§
    HŠtj`0  ã                   óž  — d Z ddlmZ ddlZ ej        e¦  «        ZddlmZ ddl	m
Z
mZ ddlmZ ddlmZ  ed¦  «        j        Zddlmc mZ g d	¢Z G d
„ dej        ej        ej        ¦  «        Z G d„ dej        ¦  «        Z ej        deddd¬¦  «        Z G d„ dej        ej        ¦  «        Z G d„ dej        ej        ¦  «        Z dS )z;passlib.handlers.nthash - Microsoft Windows -related hashesé    )ÚhexlifyN)Úwarn)Ú
to_unicodeÚright_pad_string)Úunicode)Úlookup_hashÚmd4)ÚlmhashÚnthashÚ
bsd_nthashÚmsdccÚmsdcc2c                   ól   — e Zd ZdZd ZdZej        ZdZ	dZ
dZed„ ¦   «         Zd„ ZdZedd
„¦   «         Zd	S )r
   aö  This class implements the Lan Manager Password hash, and follows the :ref:`password-hash-api`.

    It has no salt and a single fixed round.

    The :meth:`~passlib.ifc.PasswordHash.using` method accepts a single
    optional keyword:

    :param bool truncate_error:
        By default, this will silently truncate passwords larger than 14 bytes.
        Setting ``truncate_error=True`` will cause :meth:`~passlib.ifc.PasswordHash.hash`
        to raise a :exc:`~passlib.exc.PasswordTruncateError` instead.

        .. versionadded:: 1.7

    The :meth:`~passlib.ifc.PasswordHash.hash` and :meth:`~passlib.ifc.PasswordHash.verify` methods accept a single
    optional keyword:

    :type encoding: str
    :param encoding:

        This specifies what character encoding LMHASH should use when
        calculating digest. It defaults to ``cp437``, the most
        common encoding encountered.

    Note that while this class outputs digests in lower-case hexadecimal,
    it will accept upper-case as well.
    )Útruncate_erroré    é   Úcp437c                 ó*   — |                      ¦   «         S ©N©Úlower©ÚclsÚhashs     úV/var/www/html/CA-Chatbot/venv/lib/python3.11/site-packages/passlib/handlers/windows.pyÚ
_norm_hashzlmhash._norm_hashU   ó   € à�zŠz‰|Œ|Ðó    c                 ó°   — | j         r|                      |¦  «         t          |                      || j        ¦  «        ¦  «                             d¦  «        S ©NÚascii)Úuse_defaultsÚ_check_truncate_policyr   ÚrawÚencodingÚdecode©ÚselfÚsecrets     r   Ú_calc_checksumzlmhash._calc_checksumY   sM   € àÔð 	0Ø×'Ò'¨Ñ/Ô/Ð/å�t—x’x ¨¬Ñ6Ô6Ñ7Ô7×>Ò>¸wÑGÔGÐGr   s   KGS!@#$%Nc                 óŒ  — |s| j         }ddlm} | j        }t	          |t
          ¦  «        r(|                     ¦   «                              |¦  «        }n9t	          |t          ¦  «        r|                     ¦   «         }nt          d¦  «        ‚t          |d¦  «        } ||dd…         |¦  «         ||dd…         |¦  «        z   S )aŒ  encode password using LANMAN hash algorithm.

        :type secret: unicode or utf-8 encoded bytes
        :arg secret: secret to hash
        :type encoding: str
        :arg encoding:
            optional encoding to use for unicode inputs.
            this defaults to ``cp437``, which is the
            common case for most situations.

        :returns: returns string of raw bytes
        r   )Údes_encrypt_blockzsecret must be unicode or bytesr   é   )Údefault_encodingÚpasslib.crypto.desr,   Ú_magicÚ
isinstancer   ÚupperÚencodeÚbytesÚ	TypeErrorr   )r   r)   r%   r,   ÚMAGICs        r   r$   z
lmhash.rawc   sÛ   € ð ð 	,ØÔ+ˆHð 	9Ð8Ð8Ð8Ð8Ð8Ø”
ˆÝ�f�gÑ&Ô&ð 	?ð —\’\‘^”^×*Ò*¨8Ñ4Ô4ˆFˆFÝ˜¥Ñ&Ô&ð 	?ð
 —\’\‘^”^ˆFˆFåÐ=Ñ>Ô>Ð>Ý! &¨"Ñ-Ô-ˆØ Ð  ¨¨!¨¤¨eÑ4Ô4Ø Ð  ¨¨"¨¤¨uÑ5Ô5ñ6ð 	6r   r   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__ÚnameÚsetting_kwdsÚuhÚ	HEX_CHARSÚchecksum_charsÚchecksum_sizeÚtruncate_sizer.   Úclassmethodr   r*   r0   r$   © r   r   r
   r
      sš   € € € € € ðð ðD €DØ&€Lð
 ”\€NØ€Mð
 €Mð
 Ðð
 ðð ñ „[ððHð Hð Hð €Fàð#6ð #6ð #6ñ „[ð#6ð #6ð #6r   r
   c                   ór   — e Zd ZdZd Zej        ZdZe	d„ ¦   «         Z
d„ Ze	d„ ¦   «         Ze	d	d„¦   «         ZdS )
r   a„  This class implements the NT Password hash, and follows the :ref:`password-hash-api`.

    It has no salt and a single fixed round.

    The :meth:`~passlib.ifc.PasswordHash.hash` and :meth:`~passlib.ifc.PasswordHash.genconfig` methods accept no optional keywords.

    Note that while this class outputs lower-case hexadecimal digests,
    it will accept upper-case digests as well.
    r   c                 ó*   — |                      ¦   «         S r   r   r   s     r   r   znthash._norm_hash¤   r   r   c                 ól   — t          |                      |¦  «        ¦  «                             d¦  «        S r    )r   r$   r&   r'   s     r   r*   znthash._calc_checksum¨   s*   € Ý�t—x’x Ñ'Ô'Ñ(Ô(×/Ò/°Ñ8Ô8Ð8r   c                 óŽ   — t          |dd¬¦  «        }t          |                     d¦  «        ¦  «                             ¦   «         S )z§encode password using MD4-based NTHASH algorithm

        :arg secret: secret as unicode or utf-8 encoded bytes

        :returns: returns string of raw bytes
        úutf-8r)   ©Úparamú	utf-16-le)r   r	   r3   Údigest)r   r)   s     r   r$   z
nthash.raw«   s>   € õ ˜F G°8Ð<Ñ<Ô<ˆå�6—=’= Ñ-Ô-Ñ.Ô.×5Ò5Ñ7Ô7Ð7r   Fc                 ó¬   — t          dt          ¦  «         t                               |¦  «        }|r"t	          |¦  «                             d¦  «        n|S )Nzfnthash.raw_nthash() is deprecated, and will be removed in Passlib 1.8, please use nthash.raw() insteadr!   )r   ÚDeprecationWarningr   r$   r   r&   )r   r)   ÚhexÚrets       r   Ú
raw_nthashznthash.raw_nthash·   sS   € åð ?åñ	!ô 	!ð 	!õ �jŠj˜Ñ Ô ˆØ/2Ð;�w�s‰|Œ|×"Ò" 7Ñ+Ô+Ð+¸Ð;r   N)F)r7   r8   r9   r:   r;   r=   r>   r?   r@   rB   r   r*   r$   rQ   rC   r   r   r   r   �   s–   € € € € € ðð ð €DØ”\€NØ€Mð
 ðð ñ „[ðð9ð 9ð 9ð ð	8ð 	8ñ „[ð	8ð ð<ð <ð <ñ „[ð<ð <ð <r   r   r   z$3$$aZ  The class support FreeBSD's representation of NTHASH
    (which is compatible with the :ref:`modular-crypt-format`),
    and follows the :ref:`password-hash-api`.

    It has no salt and a single fixed round.

    The :meth:`~passlib.ifc.PasswordHash.hash` and :meth:`~passlib.ifc.PasswordHash.genconfig` methods accept no optional keywords.
    )ÚprefixÚidentÚdocc                   óZ   — e Zd ZdZd Zej        ZdZe	d„ ¦   «         Z
d„ Ze	d„ ¦   «         ZdS )r   aK  This class implements Microsoft's Domain Cached Credentials password hash,
    and follows the :ref:`password-hash-api`.

    It has a fixed number of rounds, and uses the associated
    username as the salt.

    The :meth:`~passlib.ifc.PasswordHash.hash`, :meth:`~passlib.ifc.PasswordHash.genhash`, and :meth:`~passlib.ifc.PasswordHash.verify` methods
    have the following optional keywords:

    :type user: str
    :param user:
        String containing name of user account this password is associated with.
        This is required to properly calculate the hash.

        This keyword is case-insensitive, and should contain just the username
        (e.g. ``Administrator``, not ``SOMEDOMAIN\Administrator``).

    Note that while this class outputs lower-case hexadecimal digests,
    it will accept upper-case digests as well.
    r   c                 ó*   — |                      ¦   «         S r   r   r   s     r   r   zmsdcc._norm_hash  r   r   c                 óx   — t          |                      || j        ¦  «        ¦  «                             d¦  «        S r    ©r   r$   Úuserr&   r'   s     r   r*   zmsdcc._calc_checksum
  ó.   € Ý�t—x’x ¨¬	Ñ2Ô2Ñ3Ô3×:Ò:¸7ÑCÔCÐCr   c                 ó@  — t          |dd¬¦  «                             d¦  «        }t          |dd¬¦  «                             ¦   «                              d¦  «        }t          t          |¦  «                             ¦   «         |z   ¦  «                             ¦   «         S )zËencode password using mscash v1 algorithm

        :arg secret: secret as unicode or utf-8 encoded bytes
        :arg user: username to use as salt

        :returns: returns string of raw bytes
        rH   r)   rI   rK   rY   )r   r3   r   r	   rL   )r   r)   rY   s      r   r$   z	msdcc.raw  s…   € õ ˜F G°8Ð<Ñ<Ô<×CÒCÀKÑPÔPˆÝ˜$ ¨vÐ6Ñ6Ô6×<Ò<Ñ>Ô>×EÒEÀkÑRÔRˆÝ•3�v‘;”;×%Ò%Ñ'Ô'¨$Ñ.Ñ/Ô/×6Ò6Ñ8Ô8Ð8r   N©r7   r8   r9   r:   r;   r=   r>   r?   r@   rB   r   r*   r$   rC   r   r   r   r   í   sw   € € € € € ðð ð( €DØ”\€NØ€Màðð ñ „[ððDð Dð Dð ð
9ð 
9ñ „[ð
9ð 
9ð 
9r   r   c                   óZ   — e Zd ZdZd Zej        ZdZe	d„ ¦   «         Z
d„ Ze	d„ ¦   «         ZdS )r   aÝ  This class implements version 2 of Microsoft's Domain Cached Credentials
    password hash, and follows the :ref:`password-hash-api`.

    It has a fixed number of rounds, and uses the associated
    username as the salt.

    The :meth:`~passlib.ifc.PasswordHash.hash`, :meth:`~passlib.ifc.PasswordHash.genhash`, and :meth:`~passlib.ifc.PasswordHash.verify` methods
    have the following extra keyword:

    :type user: str
    :param user:
        String containing name of user account this password is associated with.
        This is required to properly calculate the hash.

        This keyword is case-insensitive, and should contain just the username
        (e.g. ``Administrator``, not ``SOMEDOMAIN\Administrator``).
    r   c                 ó*   — |                      ¦   «         S r   r   r   s     r   r   zmsdcc2._norm_hash3  r   r   c                 óx   — t          |                      || j        ¦  «        ¦  «                             d¦  «        S r    rX   r'   s     r   r*   zmsdcc2._calc_checksum7  rZ   r   c                 ój  — ddl m} t          |dd¬¦  «                             d¦  «        }t          |dd¬¦  «                             ¦   «                              d¦  «        }t          t          |¦  «                             ¦   «         |z   ¦  «                             ¦   «         } |d||d	d
¦  «        S )zîencode password using msdcc v2 algorithm

        :type secret: unicode or utf-8 bytes
        :arg secret: secret

        :type user: str
        :arg user: username to use as salt

        :returns: returns string of raw bytes
        r   )Úpbkdf2_hmacrH   r)   rI   rK   rY   Úsha1i (  é   )Úpasslib.crypto.digestra   r   r3   r   r	   rL   )r   r)   rY   ra   Útmps        r   r$   z
msdcc2.raw:  s®   € ð 	6Ð5Ð5Ð5Ð5Ð5Ý˜F G°8Ð<Ñ<Ô<×CÒCÀKÑPÔPˆÝ˜$ ¨vÐ6Ñ6Ô6×<Ò<Ñ>Ô>×EÒEÀkÑRÔRˆÝ•#�f‘+”+×$Ò$Ñ&Ô&¨Ñ-Ñ.Ô.×5Ò5Ñ7Ô7ˆØˆ{˜6 3¨¨e°RÑ8Ô8Ð8r   Nr\   rC   r   r   r   r     sw   € € € € € ðð ð" €DØ”\€NØ€Màðð ñ „[ððDð Dð Dð ð9ð 9ñ „[ð9ð 9ð 9r   r   )!r:   Úbinasciir   ÚloggingÚ	getLoggerr7   ÚlogÚwarningsr   Úpasslib.utilsr   r   Úpasslib.utils.compatr   rd   r   Úconstr	   Úpasslib.utils.handlersÚutilsÚhandlersr=   Ú__all__ÚTruncateMixinÚHasEncodingContextÚStaticHandlerr
   r   ÚPrefixWrapperr   ÚHasUserContextr   r   rC   r   r   ú<module>rw      sÎ  ðØ AÐ Að
 Ð Ð Ð Ð Ð Ø €€€Ð'�gÔ'¨Ñ1Ô1�Ø Ð Ð Ð Ð Ð ð 7Ð 6Ð 6Ð 6Ð 6Ð 6Ð 6Ð 6Ø (Ð (Ð (Ð (Ð (Ð (Ø -Ð -Ð -Ð -Ð -Ð -Ø€k�%ÑÔÔ€Ø #Ð #Ð #Ð #Ð #Ð #Ð #Ð #Ð #ðð ð €ðk6ð k6ð k6ð k6ð k6ˆRÔ˜rÔ4°bÔ6Fñ k6ô k6ð k6ðh-<ð -<ð -<ð -<ð -<ˆRÔñ -<ô -<ð -<ðf ˆRÔ˜l¨F¸6Èð	ð	ñ 	ô 	€
ðT+9ð +9ð +9ð +9ð +9ˆBÔ˜rÔ/ñ +9ô +9ð +9ð`-9ð -9ð -9ð -9ð -9ˆRÔ Ô 0ñ -9ô -9ð -9ð -9ð -9r   