MySQL 8.0.39
Source Code Documentation
|
#include "my_config.h"
#include <memory>
#include <sys/types.h>
#include <openssl/evp.h>
#include <openssl/rand.h>
#include <openssl/sha.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include "crypt_genhash_impl.h"
#include "m_string.h"
#include <errno.h>
Macros | |
#define | DIGEST_CTX EVP_MD_CTX |
#define | DIGEST_LEN SHA256_DIGEST_LENGTH |
#define | MAX(a, b) (((a) > (b)) ? (a) : (b)) |
#define | MIN(a, b) (((a) < (b)) ? (a) : (b)) |
#define | b64_from_24bit(B2, B1, B0, N) |
#define | ROUNDS "rounds=" |
#define | ROUNDSLEN (sizeof(ROUNDS) - 1) |
Functions | |
static void | DIGESTCreate (DIGEST_CTX **ctx) |
static void | DIGESTInit (DIGEST_CTX *ctx) |
static void | DIGESTUpdate (DIGEST_CTX *ctx, const void *plaintext, int len) |
static void | DIGESTFinal (void *txt, DIGEST_CTX *ctx) |
static void | DIGESTDestroy (DIGEST_CTX **ctx) |
static size_t | strlcat (char *dst, const char *src, size_t siz) |
Size-bounded string copying and concatenation This is a replacement for STRLCPY(3) More... | |
static uint | getrounds (const char *s) |
Get the integer value after rounds= where ever it occurs in the string. More... | |
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 **, unsigned int *num_rounds) |
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) |
Variables | |
static const char | crypt_alg_magic [] = "$5" |
static const int | crypt_alg_magic_len = sizeof(crypt_alg_magic) - 1 |
static unsigned char | b64t [] |
#define b64_from_24bit | ( | B2, | |
B1, | |||
B0, | |||
N | |||
) |
#define DIGEST_CTX EVP_MD_CTX |
#define DIGEST_LEN SHA256_DIGEST_LENGTH |
#define MAX | ( | a, | |
b | |||
) | (((a) > (b)) ? (a) : (b)) |
#define MIN | ( | a, | |
b | |||
) | (((a) < (b)) ? (a) : (b)) |
#define ROUNDS "rounds=" |
#define ROUNDSLEN (sizeof(ROUNDS) - 1) |
|
static |
|
static |
|
static |
|
static |
|
static |
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.
[in,out] | salt_begin | As input, pointer to start of crypt passwd, as output, pointer to first byte of the salt |
[in,out] | salt_end | As input, pointer to the last byte in passwd, as output, pointer to the byte immediately following the 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.
|
static |
Get the integer value after rounds= where ever it occurs in the string.
if the last char after the int is a , or $ that is fine anything else is an error.
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 | ||
) |
|
static |
Size-bounded string copying and concatenation This is a replacement for STRLCPY(3)
void xor_string | ( | char * | to, |
int | to_len, | ||
char * | pattern, | ||
int | pattern_len | ||
) |
|
static |
|
static |
|
static |