MySQL 8.4.2
Source Code Documentation
|
#include "mysql_native_authentication_client.h"
#include "client_async_authentication.h"
#include "config.h"
#include "crypt_genhash_impl.h"
#include "my_compiler.h"
#include "my_dbug.h"
#include "my_inttypes.h"
#include "mysql.h"
#include "mysql/plugin_auth_common.h"
#include "sha1.h"
#include "sql_common.h"
Macros | |
#define | PVERSION41_CHAR '*' |
Functions | |
static uint8 | char_val (uint8 X) |
static void | hex2octet (uint8 *to, const char *str, uint len) |
static void | my_crypt (char *to, const uchar *s1, const uchar *s2, uint len) |
static 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 | my_make_scrambled_password_sha1 (char *to, const char *password, size_t pass_len) |
void | make_scrambled_password (char *to, const char *password) |
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 bool | check_scramble_sha1 (const uchar *scramble_arg, const char *message, const uint8 *hash_stage2) |
Check that scrambled message corresponds to the password. More... | |
bool | check_scramble (const uchar *scramble_arg, const char *message, const uint8 *hash_stage2) |
void | get_salt_from_password (uint8 *hash_stage2, const char *password) |
void | make_password_from_salt (char *to, const uint8 *hash_stage2) |
Convert scrambled password from binary form to asciiz hex string. 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... | |
static net_async_status | native_password_auth_client_nonblocking (MYSQL_PLUGIN_VIO *vio, MYSQL *mysql, int *result) |
Client authentication plugin that does native MySQL authentication in a nonblocking way. More... | |
Variables | |
auth_plugin_t | native_password_client_plugin |
#define PVERSION41_CHAR '*' |
|
static |
Check that scrambled message corresponds to the password.
The function is used by server to check that received reply is authentic. This function does not check lengths of given strings: message must be null-terminated, reply and hash_stage2 must be at least SHA1_HASH_SIZE long (if not, something fishy is going on).
scramble_arg | clients' reply, presumably produced by scramble() |
message | original random string, previously sent to client (presumably second argument of scramble()), must be exactly SCRAMBLE_LENGTH long and NULL-terminated. |
hash_stage2 | hex2octet-decoded database entry |
false | password is correct Wretval true password is invalid |
|
inlinestatic |
Compute two stage SHA1 hash of the password :
hash_stage1=sha1("password") hash_stage2=sha1(hash_stage1)
[in] | password | Password string. |
[in] | pass_len | Length of the password. |
[out] | hash_stage1 | sha1(password) |
[out] | hash_stage2 | sha1(hash_stage1) |
void get_salt_from_password | ( | uint8 * | hash_stage2, |
const char * | password | ||
) |
|
static |
void make_password_from_salt | ( | char * | to, |
const uint8 * | hash_stage2 | ||
) |
Convert scrambled password from binary form to asciiz hex string.
[out] | to | store resulting string here, 2*SHA1_HASH_SIZE+2 bytes |
hash_stage2 | password in salt format |
void make_scrambled_password | ( | char * | to, |
const char * | password | ||
) |
void my_make_scrambled_password_sha1 | ( | char * | to, |
const char * | password, | ||
size_t | pass_len | ||
) |
|
static |
Client authentication plugin that does native MySQL authentication using a 20-byte (4.1+) scramble.
vio | the channel to operate on |
mysql | the MYSQL structure to operate on |
-1 | CR_OK : Success |
1 | CR_ERROR : error reading |
2012 | CR_SERVER_HANDSHAKE_ERR : malformed handshake data |
|
static |
Client authentication plugin that does native MySQL authentication in a nonblocking way.
[in] | vio | the channel to operate on |
[in] | mysql | the MYSQL structure to operate on |
[out] | result | CR_OK : Success, CR_ERROR : error reading, CR_SERVER_HANDSHAKE_ERR : malformed handshake data |
NET_ASYNC_NOT_READY | authentication not yet complete |
NET_ASYNC_COMPLETE | authentication done |
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.
[out] | to | store scrambled string here. The buf must be at least SHA1_HASH_SIZE bytes long. |
message | random message, must be exactly SCRAMBLE_LENGTH long and NULL-terminated. | |
password | users' password, NULL-terminated |
auth_plugin_t native_password_client_plugin |