
    Aah                     r    d Z ddlmZmZmZ ddlmZ ddlmZ ddlmZ erddl	m
Z
 d	Z G d
 d	e          ZdS )z&SHA256 Password Authentication Plugin.    )TYPE_CHECKINGAnyOptional   )errors)logger   )MySQLAuthPlugin)MySQLSocketMySQLSHA256PasswordAuthPluginc                       e Zd ZdZdefdZedefd            Zede	fd            Z
dededee         fdZd	d
dededefdZdS )r   zClass implementing the MySQL SHA256 authentication plugin

    Note that encrypting using RSA is not supported since the Python
    Standard Library does not provide this OpenSSL functionality.
    returnc                 :    | j                                         dz   S )zyPrepare and return password as as clear text.

        Returns:
            password (bytes): Prepared password.
            )	_passwordencodeselfs    Y/var/www/lms/venv/lib/python3.11/site-packages/mysql/connector/plugins/sha256_password.py_prepare_passwordz/MySQLSHA256PasswordAuthPlugin._prepare_password2   s     ~$$&&00    c                     dS )zPlugin official name.sha256_password r   s    r   namez"MySQLSHA256PasswordAuthPlugin.name:   s
     ! r   c                     dS )z'Signals whether or not SSL is required.Tr   r   s    r   requires_sslz*MySQLSHA256PasswordAuthPlugin.requires_ssl?   s	     tr   	auth_datakwargsc                 ~    | j         r#| j        st          j        | j         d          |                                 S )zReturn the prepared password to send to MySQL.

        Raises:
            InterfaceError: When SSL is required by not enabled.

        Returns:
            str: The prepared password.
        z requires SSL)r   ssl_enabledr   InterfaceErrorr   r   )r   r   r   s      r   auth_responsez+MySQLSHA256PasswordAuthPlugin.auth_responseD   sI      	ET%5 	E'49(C(C(CDDD%%'''r   sockr   c                 *    | j         |fi |}|t          j        d          t          j        d|t          |                     |                    |           t          |                                          }t          j        d|           |S )aS  Handles 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.
        NzGot a NULL auth responsez# request: %s size: %sz# server response packet: %s)	r#   r   r"   r   debuglensendbytesrecv)r   r$   r   r   responsepkts         r   auth_switch_responsez2MySQLSHA256PasswordAuthPlugin.auth_switch_responseQ   s    " &4%i::6::'(BCCC-xXGGG		(DIIKK  3S999
r   N)__name__
__module____qualname____doc__r)   r   propertystrr   boolr   r   r   r#   r-   r   r   r   r   r   +   s         15 1 1 1 1 !c ! ! ! X! d    X(u ( ( ( ( ( (!.3?B	     r   N)r1   typingr   r   r    r   r   r
   networkr   AUTHENTICATION_PLUGIN_CLASSr   r   r   r   <module>r9      s   : - , / / / / / / / / / /                   &%%%%%%= A A A A AO A A A A Ar   