§
    HŠtj#  ã                   ó  — d Z ddlmZmZ ddlmZ ddlZddlZ ej        e	¦  «        Z
ddlmZmZ ddlmZmZmZmZmZ ddlmZ ddlmc mZ dd	gZdd„ZdZ G d„ dej        ej        ¦  «        Z G d„ dej         ej!        ¦  «        Z"dS )z3passlib.handlers.oracle - Oracle DB Password Hashesé    )ÚhexlifyÚ	unhexlify)Úsha1N)Ú
to_unicodeÚ	xor_bytes)ÚirangeÚuÚuascii_to_strÚunicodeÚstr_to_uascii)Údes_encrypt_blockÚ	oracle10gÚ	oracle11gó           ó    c                 óÔ   — ||t          |¦  «         dz  z  z  }|}t          dt          |¦  «        d¦  «        D ]-}t          ||||dz   …         ¦  «        }t          | |¦  «        }Œ.|S )aé  performs des-cbc encryption, returns only last block.

    this performs a specific DES-CBC encryption implementation
    as needed by the Oracle10 hash. it probably won't be useful for
    other purposes as-is.

    input value is null-padded to multiple of 8 bytes.

    :arg key: des key as bytes
    :arg value: value to encrypt, as bytes.
    :param iv: optional IV
    :param pad: optional pad byte

    :returns: last block of DES-CBC encryption of all ``value``'s byte blocks.
    é   r   )Úlenr   r   r   )ÚkeyÚvalueÚivÚpadÚhashÚoffsetÚchunks          úU/var/www/html/CA-Chatbot/venv/lib/python3.11/site-packages/passlib/handlers/oracle.pyÚdes_cbc_encryptr      sw   € ð  
ˆS•S˜‘Z”Z�K !‘OÑ$Ñ$€EØ€DÝ˜�3˜u™:œ: aÑ(Ô(ð -ð -ˆÝ˜$  f¨V°A©X oÔ 6Ñ7Ô7ˆÝ   eÑ,Ô,ˆˆØ€Kó    s   #Eg‰«Íïc                   óD   — e Zd ZdZd Zej        ZdZe	d„ ¦   «         Z
d„ ZdS )Úoracle10aû  This class implements the password hash used by Oracle up to version 10g, and follows the :ref:`password-hash-api`.

    It does a single round of hashing, and relies on the username as the salt.

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

    :type user: str
    :param user: name of oracle user account this password is associated with.
    é   c                 ó*   — |                      ¦   «         S )N)Úupper)Úclsr   s     r   Ú
_norm_hashzoracle10._norm_hashI   s   € à�zŠz‰|Œ|Ðr   c                 óŠ  — t          |t          ¦  «        r|                     d¦  «        }t          | j        dd¬¦  «        }||z                        ¦   «                              d¦  «        }t          t          |¦  «        }t          ||¦  «        }t          |¦  «                             d¦  «                             ¦   «         S )Núutf-8Úuser)Úparamz	utf-16-beÚascii)
Ú
isinstanceÚbytesÚdecoder   r(   r#   Úencoder   ÚORACLE10_MAGICr   )ÚselfÚsecretr(   Úinputr   s        r   Ú_calc_checksumzoracle10._calc_checksumM   s¤   € õ �f�eÑ$Ô$ð 	,Ø—]’] 7Ñ+Ô+ˆFÝ˜$œ) W°FÐ;Ñ;Ô;ˆØ�f‘×#Ò#Ñ%Ô%×,Ò,¨[Ñ9Ô9ˆÝ�~¨uÑ5Ô5ˆÝ˜t UÑ+Ô+ˆÝ�t‰}Œ}×#Ò# GÑ,Ô,×2Ò2Ñ4Ô4Ð4r   N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__ÚnameÚuhÚ	HEX_CHARSÚchecksum_charsÚchecksum_sizeÚclassmethodr%   r3   © r   r   r    r    4   s[   € € € € € ð	ð 	ð €DØ”\€NØ€Mð
 ðð ñ „[ðð5ð 5ð 5ð 5ð 5r   r    c                   ó¢   — e Zd ZdZd ZdZdZej        Z	dxZ
Zej        Z ej         ed¦  «        ej        ¦  «        Zed„ ¦   «         Zd„ Zd„ Zd	S )
Úoracle11aE  This class implements the Oracle11g password hash, and follows the :ref:`password-hash-api`.

    It supports a fixed-length salt.

    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 20 hexadecimal characters.

    :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
    )Úsalté(   é   z/^S:(?P<chk>[0-9a-f]{40})(?P<salt>[0-9a-f]{20})$c                 ó
  — t          |dd¦  «        }| j                             |¦  «        }|st          j                             | ¦  «        ‚|                     dd¦  «        \  }} | ||                     ¦   «         ¬¦  «        S )Nr*   r   rA   Úchk)rA   Úchecksum)r   Ú_hash_regexÚmatchr9   ÚexcÚInvalidHashErrorÚgroupr#   )r$   r   ÚmrA   rE   s        r   Úfrom_stringzoracle11.from_string’   sz   € å˜$ ¨Ñ0Ô0ˆØŒO×!Ò! $Ñ'Ô'ˆØð 	/Ý”&×)Ò)¨#Ñ.Ô.Ð.Ø—G’G˜F EÑ*Ô*‰	ˆˆcØˆs˜ s§y¢y¡{¤{Ð3Ñ3Ô3Ð3r   c                 ó¨   — | j         }t          d¦  «        |                     ¦   «         | j                             ¦   «         fz  }t	          |¦  «        S )NzS:%s%s)rF   r	   r#   rA   r
   )r0   rE   r   s      r   Ú	to_stringzoracle11.to_string›   s@   € ØŒmˆÝ�‰{Œ{˜cŸiši™kœk¨4¬9¯?ª?Ñ+<Ô+<Ð=Ñ=ˆÝ˜TÑ"Ô"Ð"r   c                 ó*  — t          |t          ¦  «        r|                     d¦  «        }t          |t	          | j                             d¦  «        ¦  «        z   ¦  «                             ¦   «         }t          |¦  «                             ¦   «         S )Nr'   r*   )	r+   r   r.   r   r   rA   Ú	hexdigestr   r#   )r0   r1   rE   s      r   r3   zoracle11._calc_checksum    su   € Ý�f�gÑ&Ô&ð 	,Ø—]’] 7Ñ+Ô+ˆFÝ�6�I d¤i×&6Ò&6°wÑ&?Ô&?Ñ@Ô@Ñ@ÑAÔA×KÒKÑMÔMˆÝ˜SÑ!Ô!×'Ò'Ñ)Ô)Ð)r   N)r4   r5   r6   r7   r8   Úsetting_kwdsr<   r9   ÚUPPER_HEX_CHARSr;   Úmin_salt_sizeÚmax_salt_sizeÚ
salt_charsÚreÚcompiler	   ÚIrG   r=   rM   rO   r3   r>   r   r   r@   r@   h   s¦   € € € € € ðð ð4 €DØ€LØ€MØÔ'€Nð %'Ð&€M�MØÔ#€Jð �"”*˜Q˜QÐPÑQÔQÐSUÔSWÑXÔX€Kàð4ð 4ñ „[ð4ð#ð #ð #ð
*ð *ð *ð *ð *r   r@   )r   r   )#r7   Úbinasciir   r   Úhashlibr   rW   ÚloggingÚ	getLoggerr4   ÚlogÚpasslib.utilsr   r   Úpasslib.utils.compatr   r	   r
   r   r   Úpasslib.crypto.desr   Úpasslib.utils.handlersÚutilsÚhandlersr9   Ú__all__r   r/   ÚHasUserContextÚStaticHandlerr    ÚHasSaltÚGenericHandlerr@   r>   r   r   ú<module>rj      sŽ  ðØ 9Ð 9ð
 (Ð 'Ð 'Ð 'Ð 'Ð 'Ð 'Ð 'Ø Ð Ð Ð Ð Ð Ø 	€	€	€	Ø €€€Ð'�gÔ'¨Ñ1Ô1�ð 0Ð /Ð /Ð /Ð /Ð /Ð /Ð /ðGð Gð Gð Gð Gð Gð Gð Gð Gð Gð Gð Gð Gð Gà 0Ð 0Ð 0Ð 0Ð 0Ð 0Ø #Ð #Ð #Ð #Ð #Ð #Ð #Ð #Ð #ð Øð€ðð ð ð ð0 5€ð+5ð +5ð +5ð +5ð +5ˆrÔ  "Ô"2ñ +5ô +5ð +5ðh<*ð <*ð <*ð <*ð <*ˆrŒz˜2Ô,ñ <*ô <*ð <*ð <*ð <*r   