
    Dh                     ~    d Z ddlZddlm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&Native Password Authentication Plugin.    N)sha1)TYPE_CHECKINGAnyOptional)InterfaceError)logger   )MySQLAuthPlugin   )MySQLSocketMySQLNativePasswordAuthPluginc                   ~    e Zd ZdZde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   zBClass implementing the MySQL Native Password authentication plugin	auth_datareturnc                    |st        d      | j                  syd}	 t        | j                  j                               j	                         }t        |      j	                         }t        ||z         j	                         }t        ||      D cg c]
  \  }}||z   }}}t        j                  dg| }|S c c}}w # t        j                  t        f$ r}	t        d|	       |	d}	~	ww xY w)z;Prepares and returns password as native MySQL 4.1+ passwordz"Missing authentication data (seed)    N20BzFailed scrambling password; )
r   	_passwordr   encodedigestzipstructpackerror	TypeError)
selfr   hash4hash1hash2hash3h1h3xorederrs
             C:\Users\Erick Rodrigues\AppData\Local\Programs\Python\Python312\Lib\site-packages\mysql/connector/aio/plugins/mysql_native_password.py_prepare_passwordz/MySQLNativePasswordAuthPlugin._prepare_password2   s     !EFF~~	P..0188:EK&&(EU*+224E-0->?"bR"W?E?KK..E  @i( 	P #?u!EFCO	Ps*   A5C B="C =C C0C++C0c                      y)zPlugin official name.mysql_native_password r   s    r%   namez"MySQLNativePasswordAuthPlugin.nameF   s     'r   c                      y)z'Signals whether or not SSL is required.Fr)   r*   s    r%   requires_sslz*MySQLNativePasswordAuthPlugin.requires_sslK   s     r   kwargsc                 $    | j                  |      S )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.
        )r&   )r   r   r.   s      r%   auth_responsez+MySQLNativePasswordAuthPlugin.auth_responseP   s     %%i00r   sockr   c                 6  K    | j                   |fi |}|t        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)r0   r   r   debuglenwritebytesread)r   r1   r   r.   responsepkts         r%   auth_switch_responsez2MySQLNativePasswordAuthPlugin.auth_switch_response^   s     " &4%%i:6: !;<<-xXGjj"""$))+%&3S9
 	#%s$   ABBB4B5!BBN)__name__
__module____qualname____doc__r6   r&   propertystrr+   boolr-   r   r   r0   r:   r)   r   r%   r   r   /   s    L5 U ( 'c ' ' d  1u 1 1 1!.3?B	r   )r>   r   hashlibr   typingr   r   r   mysql.connector.errorsr   mysql.connector.loggerr    r
   networkr   AUTHENTICATION_PLUGIN_CLASSr   r)   r   r%   <module>rI      s9   : -   / / 1 ) %= JO Jr   