§
    HŠtjù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j!        ej"        ¦  «        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*d„ eD ¦   «         Z+d„ Z, e,¦   «          dS )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                   óH   — e Zd ZdZdZdZdZej        Z	e
d„ ¦   «         Zd„ ZdS )Ú_Base64DigestHelperzhelper for ldap_md5 / ldap_sha1Nc                 ó   — | j         S )z/tell StaticHandler to strip ident from checksum)Úident©Úclss    ú[/var/www/html/CA-Chatbot/venv/lib/python3.11/site-packages/passlib/handlers/ldap_digests.pyÚ_hash_prefixz _Base64DigestHelper._hash_prefix2   s   € ð ŒyÐó    c                 óè   — t          |t          ¦  «        r|                     d¦  «        }|                      |¦  «                             ¦   «         }t          |¦  «                             d¦  «        S )Núutf-8Úascii)Ú
isinstancer   ÚencodeÚ
_hash_funcÚdigestr   Údecode)ÚselfÚsecretÚchks      r$   Ú_calc_checksumz"_Base64DigestHelper._calc_checksum7   s\   € Ý�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   )   s[   € € € € € Ø)Ð)ð €EØ€JØ€KØÔ+€Nàðð ñ „]ðð.ð .ð .ð .ð .r&   r   c                   óf   — 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dS )	Ú_SaltedBase64DigestHelperz-helper for ldap_salted_md5 / ldap_salted_sha1)ÚsaltÚ	salt_sizeNé   é   c                 ó²  — t          |dd¦  «        }| j                             |¦  «        }|st          j                             | ¦  «        ‚	 t          |                     d¦  «                             d¦  «        ¦  «        }n-# t          $ r  t          j         
                    | ¦  «        ‚w xY w| j        }|sJ ‚ | |d |…         ||d …         ¬¦  «        S )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Ô0ˆØŒO×!Ò! $Ñ'Ô'ˆØð 	/Ý”&×)Ò)¨#Ñ.Ô.Ð.ð	1Ý˜QŸWšW U™^œ^×2Ò2°7Ñ;Ô;Ñ<Ô<ˆDˆDøÝð 	1ð 	1ð 	1Ý”&×+Ò+¨CÑ0Ô0Ð0ð	1øøøàÔˆØˆ	ˆ	ˆrØˆs˜D  " œI¨D°°°¬IÐ6Ñ6Ô6Ð6s   Á5B Â*B.c                 ó’   — | j         | j        z   }| j        t          |¦  «                             d¦  «        z   }t          |¦  «        S )Nr)   )rE   r>   r!   r   r.   r   )r/   rN   rC   s      r$   Ú	to_stringz#_SaltedBase64DigestHelper.to_string\   s>   € ØŒ}˜tœyÑ(ˆØŒz�I d™OœO×2Ò2°7Ñ;Ô;Ñ;ˆÝ˜TÑ"Ô"Ð"r&   c                 ó´   — t          |t          ¦  «        r|                     d¦  «        }|                      || j        z   ¦  «                             ¦   «         S )Nr(   )r*   r   r+   r,   r>   r-   )r/   r0   s     r$   r2   z(_SaltedBase64DigestHelper._calc_checksuma   sJ   € Ý�f�gÑ&Ô&ð 	,Ø—]’] 7Ñ+Ô+ˆFØ�Š˜v¨¬	Ñ1Ñ2Ô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Ð7Ø(€LØÔ+€Nà€EØ€JØ€KØ$%Ð%€M�Mð
 €MØÐØ€Màð7ð 7ñ „[ð7ð#ð #ð #ð
<ð <ð <ð <ð <r&   r=   c                   ób   — e Zd ZdZd Z ed¦  «        ZeZ e	j
         ed¦  «        ¦  «        ZdS )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   sM   € € € € € ðð ð €DØˆAˆg‰JŒJ€EØ€JØ�"”*˜Q˜QÐGÑHÔHÑIÔI€K€K€Kr&   r   c                   ób   — e Zd ZdZd Z ed¦  «        ZeZ e	j
         ed¦  «        ¦  «        ZdS )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   sM   € € € € € ðð ð €DØˆAˆg‰JŒJ€EØ€JØ�"”*˜Q˜QÐFÑGÔGÑHÔH€K€K€Kr&   r   c                   óf   — e Zd ZdZd Z ed¦  «        ZdZeZ	 e
j         ed¦  «        ¦  «        ZdS )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   }   sS   € € € € € ðð ð@ €DØˆAˆh‰KŒK€EØ€MØ€JØ�"”*˜Q˜QÐMÑNÔNÑOÔO€K€K€Kr&   r   c                   óf   — e Zd ZdZd Z ed¦  «        ZdZeZ	 e
j         ed¦  «        ¦  «        ZdS )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   ¤   sS   € € € € € ð!ð !ðD €DØˆAˆh‰KŒK€EØ€MØ€Jà�"”*˜Q˜QÐMÑNÔNÑOÔO€K€K€Kr&   r   c                   ój   — e Zd ZdZd Z ed¦  «        ZdZdZe	Z
 ej         ed¦  «        ¦  «        ZdS )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   Ð   óX   € € € € € ðð ð<  €DØˆAˆk‰NŒN€EØ€MØÐØ€Jà�"”*˜Q˜QÐPÑQÔQÑRÔR€K€K€Kr&   r   c                   ój   — e Zd ZdZd Z ed¦  «        ZdZdZe	Z
 ej         ed¦  «        ¦  «        ZdS )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dS )	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                 ó   — dS )Nú!r;   r"   s    r$   Ú	genconfigzldap_plaintext.genconfig:  s	   € ð
 ˆsr&   c                 ó€   — t          j        |¦  «        }t          |¦  «        o| j                             |¦  «        d u S )N)r8   Úto_unicode_for_identifyÚboolÚ	_2307_patrF   )r#   rC   s     r$   Úidentifyzldap_plaintext.identifyA  s:   € õ Ô)¨$Ñ/Ô/ˆÝ�D‰zŒzÐ?˜cœm×1Ò1°$Ñ7Ô7¸4Ð?Ð?r&   N)r3   r4   r5   r6   rZ   r[   r\   r   rp   r8   Údeprecated_methodrX   rl   rq   r;   r&   r$   r   r      s–   € € € € € ðð ð, €DØ�”
˜1˜1˜^Ñ,Ô,Ñ-Ô-€Ià€RÔ U°EÐ:Ñ:Ô:Øðð ñ „[ñ ;Ô:ðð
 ð@ð @ñ „[ð@ð @ð @r&   r   c                 ó   — g | ]}d |z   ‘ŒS )Úldap_r;   )Ú.0rZ   s     r$   ú
<listcomp>rv   L  s   € ÐFÐFÐF¨$�w ‘~ÐFÐFÐFr&   c                  ó’   — t          ¦   «         } t          D ]/}d|z   }t          j        ||t	          d¦  «        d¬¦  «        | |<   Œ0~ d S )Nrt   z{CRYPT}T)ÚprefixÚlazy)Úglobalsr
   r8   ÚPrefixWrapperr   )ÚgÚwnamerZ   s      r$   Ú_init_ldap_crypt_handlersr~   N  sS   € õ 	‰	Œ	€AÝ#ð Pð PˆØ˜‰ˆÝÔ" 4¨µq¸±|´|È$ÐOÑOÔ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~   r;   r&   r$   ú<module>r‘      s  ððð ð (Ð 'Ð 'Ð 'Ð 'Ð 'Ð 'Ð 'Ø -Ð -Ð -Ð -Ð -Ð -Ð -Ð -Ð -Ð -Ð -Ð -Ø €€€Ð'�gÔ'¨Ñ1Ô1�Ø 	€	€	€	ð ,Ð +Ð +Ð +Ð +Ð +Ø 8Ð 8Ð 8Ð 8Ð 8Ð 8Ð 8Ð 8Ø :Ð :Ð :Ð :Ð :Ð :Ð :Ð :Ð :Ð :Ø -Ð -Ð -Ð -Ð -Ð -Ø #Ð #Ð #Ð #Ð #Ð #Ð #Ð #Ð #ðð ð €ð,.ð .ð .ð .ð .˜"Ô*ñ .ô .ð .ð('<ð '<ð '<ð '<ð '< ¤¨rÔ/@À"ÔBSñ '<ô '<ð '<ðXJð Jð Jð Jð JÐ"ñ Jô Jð JðIð Ið Ið Ið IÐ#ñ Iô Ið Ið%Pð %Pð %Pð %Pð %PÐ/ñ %Pô %Pð %PðN(Pð (Pð (Pð (Pð (PÐ0ñ (Pô (Pð (PðX%Sð %Sð %Sð %Sð %SÐ2ñ %Sô %Sð %SðP%Sð %Sð %Sð %Sð %SÐ2ñ %Sô %Sð %SðP%@ð %@ð %@ð %@ð %@�Yñ %@ô %@ð %@ðX GÐFÐ2DÐFÑFÔFÐ ð
ð 
ð 
ð Ð Ñ Ô Ð Ð Ð r&   