
    3i                     j    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y)z&SHA256 Password Authentication Plugin.    )TYPE_CHECKINGAnyOptional)errors)logger   )MySQLAuthPlugin   )MySQLSocketMySQLSHA256PasswordAuthPluginc                   z    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y)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                   j                         dz   S )zyPrepare and return password as as clear text.

        Returns:
            password (bytes): Prepared password.
            )	_passwordencodeselfs    PD:\jyotish\venv\Lib\site-packages\mysql/connector/aio/plugins/sha256_password.py_prepare_passwordz/MySQLSHA256PasswordAuthPlugin._prepare_password3   s     ~~$$&00    c                      y)zPlugin official name.sha256_password r   s    r   namez"MySQLSHA256PasswordAuthPlugin.name;   s     !r   c                      y)z'Signals whether or not SSL is required.Tr   r   s    r   requires_sslz*MySQLSHA256PasswordAuthPlugin.requires_ssl@   s     r   	auth_datakwargsc                     | j                   r.| j                  s"t        j                  | j                   d      | j                         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_responseE   s@     T%5%5''499+](CDD%%''r   sockr   c                 J  K    | j                   |fi |}|t        j                  d      t        j                  d|t        |             |j                  |       d{    t        |j                          d{         }t        j                  d|       |S 7 =7 "w)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writebytesread)r   r$   r   r   responsepkts         r   auth_switch_responsez2MySQLSHA256PasswordAuthPlugin.auth_switch_responseR   s     " &4%%i:6:''(BCC-xXGjj"""$))+%&3S9
 	#%s$   AB#!B"B#>B!?!B#!B#N)__name__
__module____qualname____doc__r)   r   propertystrr   boolr   r   r   r#   r-   r   r   r   r   r   ,   s    15 1 !c ! ! d  (u ( ( (!.3?B	r   N)r1   typingr   r   r   mysql.connectorr   mysql.connector.loggerr    r	   networkr   AUTHENTICATION_PLUGIN_CLASSr   r   r   r   <module>r;      s3   : - / / " ) %= AO Ar   