MySQL 9.1.0
Source Code Documentation
mysql_native_password.cc File Reference
#include "my_dbug.h"
#include "my_sys.h"
#include "sha1.h"
#include "sql_common.h"

Macros

#define MYSQL_NATIVE_PASSWORD_PLUGIN_NAME   "mysql_native_password"
 

Functions

static void my_crypt (char *to, const uchar *s1, const uchar *s2, uint len)
 
void compute_two_stage_sha1_hash (const char *password, size_t pass_len, uint8 *hash_stage1, uint8 *hash_stage2)
 Compute two stage SHA1 hash of the password : More...
 
void scramble (char *to, const char *message, const char *password)
 Produce an obscure octet sequence from password and random string, received from the server. More...
 
static int native_password_auth_client (MYSQL_PLUGIN_VIO *vio, MYSQL *mysql)
 Client authentication plugin that does native MySQL authentication using a 20-byte (4.1+) scramble. More...
 
 mysql_declare_client_plugin (AUTHENTICATION) MYSQL_NATIVE_PASSWORD_PLUGIN_NAME
 

Variables

 MYSQL_CLIENT_PLUGIN_AUTHOR_ORACLE
 
MySQL Native Authentication Client
 
MySQL Native Authentication GPL
 
MySQL Native Authentication nullptr
 
MySQL Native Authentication native_password_auth_client
 
MySQL Native Authentication mysql_end_client_plugin
 

Macro Definition Documentation

◆ MYSQL_NATIVE_PASSWORD_PLUGIN_NAME

#define MYSQL_NATIVE_PASSWORD_PLUGIN_NAME   "mysql_native_password"

Function Documentation

◆ compute_two_stage_sha1_hash()

void compute_two_stage_sha1_hash ( const char *  password,
size_t  pass_len,
uint8 hash_stage1,
uint8 hash_stage2 
)
inline

Compute two stage SHA1 hash of the password :

hash_stage1=sha1("password") hash_stage2=sha1(hash_stage1)

Parameters
[in]passwordPassword string.
[in]pass_lenLength of the password.
[out]hash_stage1sha1(password)
[out]hash_stage2sha1(hash_stage1)

◆ my_crypt()

static void my_crypt ( char *  to,
const uchar s1,
const uchar s2,
uint  len 
)
static

◆ mysql_declare_client_plugin()

mysql_declare_client_plugin ( AUTHENTICATION  )

◆ native_password_auth_client()

static int native_password_auth_client ( MYSQL_PLUGIN_VIO vio,
MYSQL mysql 
)
static

Client authentication plugin that does native MySQL authentication using a 20-byte (4.1+) scramble.

Parameters
viothe channel to operate on
mysqlthe MYSQL structure to operate on
Return values
-1CR_OK : Success
1CR_ERROR : error reading
2012CR_SERVER_HANDSHAKE_ERR : malformed handshake data

◆ scramble()

void scramble ( char *  to,
const char *  message,
const char *  password 
)

Produce an obscure octet sequence from password and random string, received from the server.

This sequence corresponds to the password, but password can not be easily restored from it. The sequence is then sent to the server for validation. Trailing zero is not stored in the buf as it is not needed. This function is used by client to create authenticated reply to the server's greeting.

Parameters
[out]tostore scrambled string here. The buf must be at least SHA1_HASH_SIZE bytes long.
messagerandom message, must be exactly SCRAMBLE_LENGTH long and NULL-terminated.
passwordusers' password, NULL-terminated

Variable Documentation

◆ Client

MySQL Native Authentication Client

◆ GPL

MySQL Native Authentication GPL

◆ MYSQL_CLIENT_PLUGIN_AUTHOR_ORACLE

MYSQL_CLIENT_PLUGIN_AUTHOR_ORACLE

◆ mysql_end_client_plugin

MySQL Native Authentication mysql_end_client_plugin

◆ native_password_auth_client

MySQL Native Authentication native_password_auth_client

◆ nullptr

MySQL Native Authentication nullptr