MySQL 8.1.0
Source Code Documentation
crypt_genhash_impl.h
Go to the documentation of this file.
1/* Copyright (c) 2012, 2023, 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 also distributed 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 included with MySQL.
13
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License, version 2.0, for more details.
18
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software
21 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
22
23/**
24 @file include/crypt_genhash_impl.h
25*/
26
27#ifndef CRYPT_HASHGEN_IMPL_H
28#define CRYPT_HASHGEN_IMPL_H
29#define ROUNDS_DEFAULT 5000
30#define ROUNDS_MIN ROUNDS_DEFAULT
31#define ROUNDS_MAX (0xFFF * 1000)
32#define MIXCHARS 32
33#define CRYPT_SALT_LENGTH 20
34#define CRYPT_MAGIC_LENGTH 3
35#define CRYPT_PARAM_LENGTH 13
36#define SHA256_HASH_LENGTH 43
37#define CRYPT_MAX_PASSWORD_SIZE \
38 (CRYPT_SALT_LENGTH + SHA256_HASH_LENGTH + CRYPT_MAGIC_LENGTH + \
39 CRYPT_PARAM_LENGTH)
40#define MAX_PLAINTEXT_LENGTH 256
41
42#include <stddef.h>
43
44#include "my_macros.h"
45
46int extract_user_salt(const char **salt_begin, const char **salt_end);
47char *my_crypt_genhash(char *ctbuffer, size_t ctbufflen, const char *plaintext,
48 size_t plaintext_len, const char *switchsalt,
49 const char **params, unsigned int *num_rounds = nullptr);
50void generate_user_salt(char *buffer, int buffer_len);
51void xor_string(char *to, int to_len, char *pattern, int pattern_len);
52
53#endif
void xor_string(char *to, int to_len, char *pattern, int pattern_len)
Definition: crypt_genhash_impl.cc:435
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:422
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:235
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:187
Some common macros.
mutable_buffer buffer(void *p, size_t n) noexcept
Definition: buffer.h:419