HEX
Server: Apache
System: Linux 185.122.168.184.host.secureserver.net 5.14.0-570.60.1.el9_6.x86_64 #1 SMP PREEMPT_DYNAMIC Wed Nov 5 05:00:59 EST 2025 x86_64
User: barbeatleanalyti (1024)
PHP: 8.1.33
Disabled: NONE
Upload Files
File: //var/opt/nydus/ops/mysql/connector/plugins/__pycache__/caching_sha2_password.cpython-39.pyc
a

�,�h��@sxdZddlZddlmZddlmZmZmZddlm	Z	ddl
m
Z
dd	lmZer`dd
l
mZdZGdd�de�ZdS)
z,Caching SHA2 Password Authentication Plugin.�N)�sha256)�
TYPE_CHECKING�Any�Optional�)�InterfaceError)�logger�)�MySQLAuthPlugin)�MySQLSocket�"MySQLCachingSHA2PasswordAuthPluginc@s�eZdZUdZdZeed<eed�dd�Ze	e
d�dd	��Ze	ed�d
d��Z
eeeed�d
d�Zdeeed�dd�Zdeeed�dd�ZdS)rz�Class implementing the MySQL caching_sha2_password authentication plugin

    Note that encrypting using RSA is not supported since the Python
    Standard Library does not provide this OpenSSL functionality.
    ��perform_full_authentication)�	auth_data�returncCs||std��|jsdSt|j�����}t�}|�t|����|�|�|��}dd�t||�D�}tjdg|�R�}|S)z�Return a scramble of the password using a Nonce sent by the
        server.

        The scramble is of the form:
        XOR(SHA2(password), SHA2(SHA2(SHA2(password)), Nonce))
        z"Missing authentication data (seed)�cSsg|]\}}||A�qS�r)�.0�h1�h2rr�`/opt/nydus/tmp/pip-target-wkfpz8uv/lib64/python/mysql/connector/plugins/caching_sha2_password.py�
<listcomp>Irz@MySQLCachingSHA2PasswordAuthPlugin._scramble.<locals>.<listcomp>Z32B)	r�	_passwordr�encode�digest�update�zip�struct�pack)�selfrZhash1Zhash2Zhash2_digestZxoredZhash3rrr�	_scramble7s
z,MySQLCachingSHA2PasswordAuthPlugin._scramble)rcCsdS)zPlugin official name.Zcaching_sha2_passwordr�rrrr�nameMsz'MySQLCachingSHA2PasswordAuthPlugin.namecCsdS)z'Signals whether or not SSL is required.Frr!rrr�requires_sslRsz/MySQLCachingSHA2PasswordAuthPlugin.requires_ssl)r�kwargsrcKs>|sdSt|�dkr|�|�S|d|jkr:|j��dSdS)a�Make the client's authorization response.

        Args:
            auth_data: Authorization data.
            kwargs: Custom configuration to be passed to the auth plugin
                    when invoked. The parameters defined here will override the ones
                    defined in the auth plugin itself.

        Returns:
            packet: Client's authorization response.
        Nr	r�)�lenr rrr)rrr$rrr�
auth_responseWs
z0MySQLCachingSHA2PasswordAuthPlugin.auth_responser)�sockrr$rcKs,|j|fi|��}|r |�|�t|���S)aEHandles server's `auth more data` response.

        Args:
            sock: Pointer to the socket connection.
            auth_data: Authentication method data (from a packet representing
                       an `auth more data` response).
            kwargs: Custom configuration to be passed to the auth plugin
                    when invoked. The parameters defined here will override the ones
                    defined in the auth plugin itself.

        Returns:
            packet: Last server's response after back-and-forth
                    communication.
        )r'�send�bytes�recv)rr(rr$�responserrr�auth_more_responsems
z5MySQLCachingSHA2PasswordAuthPlugin.auth_more_responsecKsZ|j|fi|��}|dur"td��t�d|t|��|�|�t|���}t�d|�|S)aSHandles server's `auth switch request` response.

        Args:
            sock: Pointer to the socket connection.
            auth_data: Plugin provided data (extracted from a packet
                       representing an `auth switch request` response).
            kwargs: Custom configuration to be passed to the auth plugin
                    when invoked. The parameters defined here will override the ones
                    defined in the auth plugin itself.

        Returns:
            packet: Last server's response after back-and-forth
                    communication.
        NzGot a NULL auth responsez# request: %s size: %sz# server response packet: %s)r'rr�debugr&r)r*r+)rr(rr$r,Zpktrrr�auth_switch_response�s
z7MySQLCachingSHA2PasswordAuthPlugin.auth_switch_responseN)�__name__�
__module__�__qualname__�__doc__r�int�__annotations__r*r �property�strr"�boolr#rrr'r-r/rrrrr.s
��)r3r�hashlibr�typingrrr�errorsrr�r
�networkrZAUTHENTICATION_PLUGIN_CLASSrrrrr�<module>s