MySQL 8.4.3
Source Code Documentation
crypt_genhash_impl.h File Reference
#include <stddef.h>
#include "my_macros.h"

Go to the source code of this file.

Macros

#define ROUNDS_DEFAULT   5000
 
#define ROUNDS_MIN   ROUNDS_DEFAULT
 
#define ROUNDS_MAX   (0xFFF * 1000)
 
#define MIXCHARS   32
 
#define CRYPT_SALT_LENGTH   20
 
#define CRYPT_MAGIC_LENGTH   3
 
#define CRYPT_PARAM_LENGTH   13
 
#define SHA256_HASH_LENGTH   43
 
#define CRYPT_MAX_PASSWORD_SIZE
 
#define MAX_PLAINTEXT_LENGTH   256
 

Functions

int extract_user_salt (const char **salt_begin, const char **salt_end)
 Finds the interval which envelopes the user salt in a crypt password The crypt format is assumed to be $a$bbbb$cccccc\0 and the salt is found by counting the delimiters and marking begin and end. More...
 
char * my_crypt_genhash (char *ctbuffer, size_t ctbufflen, const char *plaintext, size_t plaintext_len, const char *switchsalt, const char **params, unsigned int *num_rounds=nullptr)
 
void generate_user_salt (char *buffer, int buffer_len)
 Generate a random string using ASCII characters but avoid separator character. More...
 
void xor_string (char *to, int to_len, char *pattern, int pattern_len)
 
void my_make_scrambled_password (char *to, const char *password, size_t pass_len)
 

Macro Definition Documentation

◆ CRYPT_MAGIC_LENGTH

#define CRYPT_MAGIC_LENGTH   3

◆ CRYPT_MAX_PASSWORD_SIZE

#define CRYPT_MAX_PASSWORD_SIZE
Value:
CRYPT_PARAM_LENGTH)
#define CRYPT_SALT_LENGTH
Definition: crypt_genhash_impl.h:34
#define SHA256_HASH_LENGTH
Definition: crypt_genhash_impl.h:37
#define CRYPT_MAGIC_LENGTH
Definition: crypt_genhash_impl.h:35

◆ CRYPT_PARAM_LENGTH

#define CRYPT_PARAM_LENGTH   13

◆ CRYPT_SALT_LENGTH

#define CRYPT_SALT_LENGTH   20

◆ MAX_PLAINTEXT_LENGTH

#define MAX_PLAINTEXT_LENGTH   256

◆ MIXCHARS

#define MIXCHARS   32

◆ ROUNDS_DEFAULT

#define ROUNDS_DEFAULT   5000

◆ ROUNDS_MAX

#define ROUNDS_MAX   (0xFFF * 1000)

◆ ROUNDS_MIN

#define ROUNDS_MIN   ROUNDS_DEFAULT

◆ SHA256_HASH_LENGTH

#define SHA256_HASH_LENGTH   43

Function Documentation

◆ extract_user_salt()

int extract_user_salt ( const char **  salt_begin,
const char **  salt_end 
)

Finds the interval which envelopes the user salt in a crypt password The crypt format is assumed to be $a$bbbb$cccccc\0 and the salt is found by counting the delimiters and marking begin and end.

Parameters
[in,out]salt_beginAs input, pointer to start of crypt passwd, as output, pointer to first byte of the salt
[in,out]salt_endAs input, pointer to the last byte in passwd, as output, pointer to the byte immediately following the salt ($)
Returns
The size of the salt identified

◆ generate_user_salt()

void generate_user_salt ( char *  buffer,
int  buffer_len 
)

Generate a random string using ASCII characters but avoid separator character.

Stdlib rand and srand are used to produce pseudo random numbers between with about 7 bit worth of entropty between 1-127.

◆ my_crypt_genhash()

char * my_crypt_genhash ( char *  ctbuffer,
size_t  ctbufflen,
const char *  plaintext,
size_t  plaintext_len,
const char *  switchsalt,
const char **  params,
unsigned int *  num_rounds = nullptr 
)

◆ my_make_scrambled_password()

void my_make_scrambled_password ( char *  to,
const char *  password,
size_t  pass_len 
)

◆ xor_string()

void xor_string ( char *  to,
int  to_len,
char *  pattern,
int  pattern_len 
)