MySQL 8.4.3
Source Code Documentation
crypt_genhash_impl.h
Go to the documentation of this file.
1/* Copyright (c) 2012, 2024, Oracle and/or its affiliates.
2
3 This program is free software; you can redistribute it and/or modify
4 it under the terms of the GNU General Public License, version 2.0,
5 as published by the Free Software Foundation.
6
7 This program is designed to work with certain software (including
8 but not limited to OpenSSL) that is licensed under separate terms,
9 as designated in a particular file or component or in included license
10 documentation. The authors of MySQL hereby grant you an additional
11 permission to link the program and your derivative works with the
12 separately licensed software that they have either included with
13 the program or referenced in the documentation.
14
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License, version 2.0, for more details.
19
20 You should have received a copy of the GNU General Public License
21 along with this program; if not, write to the Free Software
22 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
23
24/**
25 @file include/crypt_genhash_impl.h
26*/
27
28#ifndef CRYPT_HASHGEN_IMPL_H
29#define CRYPT_HASHGEN_IMPL_H
30#define ROUNDS_DEFAULT 5000
31#define ROUNDS_MIN ROUNDS_DEFAULT
32#define ROUNDS_MAX (0xFFF * 1000)
33#define MIXCHARS 32
34#define CRYPT_SALT_LENGTH 20
35#define CRYPT_MAGIC_LENGTH 3
36#define CRYPT_PARAM_LENGTH 13
37#define SHA256_HASH_LENGTH 43
38#define CRYPT_MAX_PASSWORD_SIZE \
39 (CRYPT_SALT_LENGTH + SHA256_HASH_LENGTH + CRYPT_MAGIC_LENGTH + \
40 CRYPT_PARAM_LENGTH)
41#define MAX_PLAINTEXT_LENGTH 256
42
43#include <stddef.h>
44
45#include "my_macros.h"
46
47int extract_user_salt(const char **salt_begin, const char **salt_end);
48char *my_crypt_genhash(char *ctbuffer, size_t ctbufflen, const char *plaintext,
49 size_t plaintext_len, const char *switchsalt,
50 const char **params, unsigned int *num_rounds = nullptr);
51void generate_user_salt(char *buffer, int buffer_len);
52void xor_string(char *to, int to_len, char *pattern, int pattern_len);
53
54// extern "C" since it is an (undocumented) part of the libmysql ABI.
55extern "C" void my_make_scrambled_password(char *to, const char *password,
56 size_t pass_len);
57
58#endif
void my_make_scrambled_password(char *to, const char *password, size_t pass_len)
Definition: crypt_genhash_impl.cc:445
void xor_string(char *to, int to_len, char *pattern, int pattern_len)
Definition: crypt_genhash_impl.cc:436
void generate_user_salt(char *buffer, int buffer_len)
Generate a random string using ASCII characters but avoid separator character.
Definition: crypt_genhash_impl.cc:423
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)
Definition: crypt_genhash_impl.cc:236
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 b...
Definition: crypt_genhash_impl.cc:188
Some common macros.
static char * password
Definition: mysql_secure_installation.cc:58
mutable_buffer buffer(void *p, size_t n) noexcept
Definition: buffer.h:418