zmc
2023-12-22 9fdbf60165db0400c2e8e6be2dc6e88138ac719a
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
U
£ý°dCã@sTdZddlZddlmZddlmZddlmZddlm    Z    d    Z
Gd
d    „d    e    ƒZ dS) z,Caching SHA2 Password Authentication Plugin.éN)Úsha256)ÚOptionalé)ÚInterfaceErroré)ÚBaseAuthPluginÚ"MySQLCachingSHA2PasswordAuthPlugincsxeZdZUdZdZeed<dZeed<dZ    e
ed<dZ e
ed    <e d
œd d „Z e d
œ‡fd d„ Zee d
œdd„Z‡ZS)rzÕ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.
    FÚ requires_sslZcaching_sha2_passwordÚ plugin_nameéÚperform_full_authenticationéÚfast_auth_success)ÚreturncCs˜|jstdƒ‚|jsdSt|jtƒr0|j d¡n|j}|j}t|ƒ ¡}tƒ}| t|ƒ ¡¡| |¡| ¡}dd„t    ||ƒDƒ}t
j d|žŽ}|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)ózutf-8cSsg|]\}}||A‘qS©r)Ú.0Úh1Úh2rrúdd:\z\workplace\vscode\pyvenv\venv\Lib\site-packages\mysql/connector/plugins/caching_sha2_password.pyÚ
<listcomp>Osz@MySQLCachingSHA2PasswordAuthPlugin._scramble.<locals>.<listcomp>Ú32B)r) Ú
_auth_datarZ    _passwordÚ
isinstanceÚstrÚencoderÚdigestÚupdateÚzipÚstructÚpack)ÚselfÚpasswordZ    auth_dataZhash1Zhash2Z hash2_digestZxoredZhash3rrrÚ    _scramble6s"
ÿý 
z,MySQLCachingSHA2PasswordAuthPlugin._scramblecs |jst|j›dƒ‚tƒ ¡S)z!Returns password as as clear textz  requires SSL)Z _ssl_enabledrr
ÚsuperÚprepare_password©r!©Ú    __class__rrÚ_full_authenticationSsz7MySQLCachingSHA2PasswordAuthPlugin._full_authenticationcCs<|js
dSt|jƒdkr | ¡S|jd|jkr8| ¡SdS)z]Prepare and return password.
 
        Returns:
            bytes: Prepared password.
        Nrr)rÚlenr#r r)r&rrrr%Ysz3MySQLCachingSHA2PasswordAuthPlugin.prepare_password)Ú__name__Ú
__module__Ú __qualname__Ú__doc__r    ÚboolÚ__annotations__r
rr ÚintrÚbytesr#r)rr%Ú __classcell__rrr'rr*s
    ) r.rÚhashlibrÚtypingrÚerrorsrÚrZAUTHENTICATION_PLUGIN_CLASSrrrrrÚ<module>s