Ë
    àU.j#  ã                   ó6  — 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jB                  «      Z"y)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Ú	oracle11gc                 ó¦   — ||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          úYC:\xampp\htdocs\tradingbinance\backend\.venv\Lib\site-packages\passlib/handlers/oracle.pyÚdes_cbc_encryptr      sc   € ð  
ˆS”S˜“Z�K !‘OÑ$Ñ$€EØ€DÜ˜œ3˜u›: aÖ(ˆÜ˜$  f¨V°A©XÐ 6Ó7ˆÜ   eÓ,‰ð )ð €Kó    s   #Eg‰«Íïc                   óF   — e Zd ZdZd Zej                  ZdZe	d„ «       Z
d„ Zy)Ú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                 ó"   — |j                  «       S )N)Úupper)Úclsr   s     r   Ú
_norm_hashzoracle10._norm_hashI   s   € à�z‰z‹|Ðr   c                 ó@  — t        |t        «      r|j                  d«      }t        | j                  dd¬«      }||z   j                  «       j                  d«      }t        t        |«      }t        ||«      }t        |«      j                  d«      j                  «       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ˆÜœ~¨uÓ5ˆÜ˜t UÓ+ˆÜ�t‹}×#Ñ# GÓ,×2Ñ2Ó4Ð4r   N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__ÚnameÚuhÚ	HEX_CHARSÚchecksum_charsÚchecksum_sizeÚclassmethodr#   r1   © r   r   r   r   4   s5   „ ñ	ð €DØ—\‘\€NØ€Mð
 ñó ðó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y	)
Ú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                  j                  |«      }|st        j                  j                  | «      ‚|j                  dd«      \  }} | ||j                  «       ¬«      S )Nr(   r   r?   Úchk)r?   Úchecksum)r   Ú_hash_regexÚmatchr7   ÚexcÚInvalidHashErrorÚgroupr!   )r"   r   Úmr?   rC   s        r   Úfrom_stringzoracle11.from_string’   sc   € ä˜$ ¨Ó0ˆØ�O‰O×!Ñ! $Ó'ˆÙÜ—&‘&×)Ñ)¨#Ó.Ð.Ø—G‘G˜F EÓ*‰	ˆˆcÙ˜ s§y¡y£{Ô3Ð3r   c                 óœ   — | j                   }t        d«      |j                  «       | j                  j                  «       fz  }t	        |«      S )NzS:%s%s)rD   r	   r!   r?   r
   )r.   rC   r   s      r   Ú	to_stringzoracle11.to_string›   s:   € Ø�m‰mˆÜ�‹{˜cŸi™i›k¨4¯9©9¯?©?Ó+<Ð=Ñ=ˆÜ˜TÓ"Ð"r   c                 óò   — t        |t        «      r|j                  d«      }t        |t	        | j
                  j                  d«      «      z   «      j                  «       }t        |«      j                  «       S )Nr%   r(   )	r)   r   r,   r   r   r?   Ú	hexdigestr   r!   )r.   r/   rC   s      r   r1   zoracle11._calc_checksum    sZ   € Ü�fœgÔ&Ø—]‘] 7Ó+ˆFÜ�6œI d§i¡i×&6Ñ&6°wÓ&?Ó@Ñ@ÓA×KÑKÓMˆÜ˜SÓ!×'Ñ'Ó)Ð)r   N)r2   r3   r4   r5   r6   Úsetting_kwdsr:   r7   ÚUPPER_HEX_CHARSr9   Úmin_salt_sizeÚmax_salt_sizeÚ
salt_charsÚreÚcompiler	   ÚIrE   r;   rK   rM   r1   r<   r   r   r>   r>   h   sw   „ ñð4 €DØ€LØ€MØ×'Ñ'€Nð %'Ð&€M�MØ×#Ñ#€Jð �"—*‘*™QÐPÓQÐSU×SWÑSWÓX€Kàñ4ó ð4ò#ó
*r   r>   )s           ó    )#r5   Úbinasciir   r   Úhashlibr   rU   ÚloggingÚ	getLoggerr2   ÚlogÚpasslib.utilsr   r   Úpasslib.utils.compatr   r	   r
   r   r   Úpasslib.crypto.desr   Úpasslib.utils.handlersÚutilsÚhandlersr7   Ú__all__r   r-   ÚHasUserContextÚStaticHandlerr   ÚHasSaltÚGenericHandlerr>   r<   r   r   Ú<module>ri      s�   ðÙ 9÷
 (Ý Û 	Û Ð'�g×'Ñ'¨Ó1�÷ 0÷Gõ Gå 0ß #Ð #ð Øð€óð0 5€ô+5ˆr× Ñ  "×"2Ñ"2ô +5ôh<*ˆr�z‰z˜2×,Ñ,õ <*r   