MySQL 8.0.39
Source Code Documentation
|
#include <string.h>
#include <sys/types.h>
#include "crypt_genhash_impl.h"
#include "m_string.h"
#include "my_inttypes.h"
#include "my_macros.h"
#include "mysql_com.h"
#include "sha1.h"
Macros | |
#define | PVERSION41_CHAR '*' |
Functions | |
void | randominit (struct rand_struct *rand_st, ulong seed1, ulong seed2) |
void | hash_password (ulong *result, const char *password, uint password_len) |
static uint8 | char_val (uint8 X) |
char * | octet2hex (char *to, const char *str, uint len) |
static void | hex2octet (uint8 *to, const char *str, uint len) |
static void | my_crypt (char *to, const uchar *s1, const uchar *s2, uint len) |
void | my_make_scrambled_password (char *to, const char *password, size_t pass_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... | |
#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 | ||
) |
void hash_password | ( | ulong * | result, |
const char * | password, | ||
uint | password_len | ||
) |
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 | ( | char * | to, |
const char * | password, | ||
size_t | pass_len | ||
) |
void my_make_scrambled_password_sha1 | ( | char * | to, |
const char * | password, | ||
size_t | pass_len | ||
) |
char * octet2hex | ( | char * | to, |
const char * | str, | ||
uint | len | ||
) |
void randominit | ( | struct rand_struct * | rand_st, |
ulong | seed1, | ||
ulong | seed2 | ||
) |
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 |