Skip to content

Commit a604479

Browse files
harinvadodariajankowsk
authored andcommitted
PS-11392 [8.4] Backport PBKDF2 from 9.7
WL#17160: Support PBKDF2 storage format with Caching_sha2_password Description: - Added PBKDF2 storage format support for plugin caching_sha2_password - Added option caching_sha2_password_storage_format to control password storage format - Added option caching_sha2_password_enforce_storage_format to control behavior in case password is hashed using format other than the one specified by caching_sha2_password_storage_format - Made caching_sha2_password_digest_rounds dynamic - Added unit and functional tests
1 parent b6d91cf commit a604479

25 files changed

Lines changed: 2713 additions & 381 deletions

include/crypt_genhash_impl.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,17 @@
2727

2828
#ifndef CRYPT_HASHGEN_IMPL_H
2929
#define CRYPT_HASHGEN_IMPL_H
30+
31+
// sha256 rounds
3032
#define ROUNDS_DEFAULT 5000
3133
#define ROUNDS_MIN ROUNDS_DEFAULT
3234
#define ROUNDS_MAX (0xFFF * 1000)
35+
36+
// caching_sha2 rounds
37+
#define SHA2_ROUNDS_DEFAULT 10000
38+
#define SHA2_ROUNDS_MIN 5000
39+
#define SHA2_ROUNDS_MAX (0xFFF * 1000)
40+
3341
#define MIXCHARS 32
3442
#define CRYPT_SALT_LENGTH 20
3543
#define CRYPT_MAGIC_LENGTH 3

include/mysql/plugin_auth_common.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,12 @@
105105
authentication with very limited operations ALTER USER to do registration.
106106
*/
107107
#define CR_OK_AUTH_IN_SANDBOX_MODE -3
108+
/**
109+
Authentication was successful with limited operations.
110+
User should change the password.
111+
*/
112+
#define CR_OK_FORCE_PASSWORD_CHANGE -4
113+
108114
/**
109115
Flag to be passed back to server from authentication plugins via
110116
authenticated_as when proxy mapping should be done by the server.

mysql-test/r/mysqld--help-notwin.result

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,12 +252,28 @@ The following options may be given as the first argument:
252252
--caching-sha2-password-digest-rounds=#
253253
Number of SHA2 rounds to be done when storing a password
254254
hash onto disk.
255+
--caching-sha2-password-enforce-storage-format
256+
Enforce storage format for credentials. If set to TRUE,
257+
then accounts that are using caching_sha2_password and
258+
have password transformation stored in format other than
259+
what is specified by
260+
--caching_sha2_password_storage_format, will be forced to
261+
change their password upon login.
255262
--caching-sha2-password-private-key-path=name
256263
A fully qualified path to the private RSA key used for
257264
authentication.
265+
--caching-sha2-password-proxy-users
266+
If set to FALSE (the default), then the caching_sha2
267+
authentication plugin will not signal for authenticated
268+
users to be checked for mapping to proxy users. If set to
269+
TRUE, the plugin will flag associated authenticated
270+
accounts to be mapped to proxy users when the server
271+
option check_proxy_users is enabled.
258272
--caching-sha2-password-public-key-path=name
259273
A fully qualified path to the public RSA key used for
260274
authentication.
275+
--caching-sha2-password-storage-format=name
276+
Storage format for credentials.
261277
--character-set-filesystem=name
262278
Set the filesystem character set.
263279
-C, --character-set-server=name
@@ -1808,8 +1824,11 @@ buffered-error-log-filename
18081824
buffered-error-log-size 0
18091825
bulk-insert-buffer-size 8388608
18101826
caching-sha2-password-digest-rounds 5000
1827+
caching-sha2-password-enforce-storage-format FALSE
18111828
caching-sha2-password-private-key-path private_key.pem
1829+
caching-sha2-password-proxy-users FALSE
18121830
caching-sha2-password-public-key-path public_key.pem
1831+
caching-sha2-password-storage-format CRYPT5
18131832
character-set-filesystem binary
18141833
character-set-server utf8mb4
18151834
character-sets-dir MYSQL_CHARSETSDIR/

mysql-test/r/mysqld--help-win.result

Lines changed: 31 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -239,13 +239,29 @@ The following options may be given as the first argument:
239239
--caching-sha2-password-digest-rounds=#
240240
Number of SHA2 rounds to be done when storing a password
241241
hash onto disk.
242-
--caching-sha2-password-private-key-path=name
242+
--caching-sha2-password-enforce-storage-format
243+
Enforce storage format for credentials. If set to TRUE,
244+
then accounts that are using caching_sha2_password and
245+
have password transformation stored in format other than
246+
what is specified by
247+
--caching_sha2_password_storage_format, will be forced to
248+
change their password upon login.
249+
--caching-sha2-password-private-key-path=name
243250
A fully qualified path to the private RSA key used for
244251
authentication.
252+
--caching-sha2-password-proxy-users
253+
If set to FALSE (the default), then the caching_sha2
254+
authentication plugin will not signal for authenticated
255+
users to be checked for mapping to proxy users. If set to
256+
TRUE, the plugin will flag associated authenticated
257+
accounts to be mapped to proxy users when the server
258+
option check_proxy_users is enabled.
245259
--caching-sha2-password-public-key-path=name
246260
A fully qualified path to the public RSA key used for
247261
authentication.
248-
--character-set-filesystem=name
262+
--caching-sha2-password-storage-format=name
263+
Storage format for credentials.
264+
--character-set-filesystem=name
249265
Set the filesystem character set.
250266
-C, --character-set-server=name
251267
Set the default character set.
@@ -721,11 +737,11 @@ The following options may be given as the first argument:
721737
NULLS_UNEQUAL (default behavior for 4.1 and later),
722738
NULLS_EQUAL (emulate 4.0 behavior), and NULLS_IGNORED
723739
--myisam-use-mmap Use memory mapping for reading and writing MyISAM tables
724-
--mysql-native-password[=name]
740+
--mysql-native-password[=name]
725741
Enable or disable mysql_native_password plugin. Possible
726742
values are ON, OFF, FORCE (don't start if the plugin
727743
fails to load).
728-
--mysql-native-password-proxy-users
744+
--mysql-native-password-proxy-users
729745
If set to FALSE (the default), then the
730746
mysql_native_password plugin will not signal for
731747
authenticated users to be checked for mapping to proxy
@@ -1144,15 +1160,15 @@ The following options may be given as the first argument:
11441160
--replica-net-timeout=#
11451161
Number of seconds to wait for more data from a
11461162
replication connection before aborting the read.
1147-
--replica-parallel-type=name
1163+
--replica-parallel-type=name
11481164
The method used by the replication applier to parallelize
11491165
transactions. DATABASE, indicates that it may apply
11501166
transactions in parallel in case they update different
11511167
databases. LOGICAL_CLOCK, which is the default, indicates
11521168
that it decides whether two transactions can be applied
11531169
in parallel using the logical timestamps computed by the
11541170
source.
1155-
--replica-parallel-workers=#
1171+
--replica-parallel-workers=#
11561172
Number of worker threads for executing events in parallel
11571173
--replica-pending-jobs-size-max=#
11581174
Soft limit on the size, in bytes, of per-worker queues of
@@ -1410,10 +1426,10 @@ The following options may be given as the first argument:
14101426
--slave-net-timeout=#
14111427
This option is deprecated. Use replica_net_timeout
14121428
instead.
1413-
--slave-parallel-type=name
1429+
--slave-parallel-type=name
14141430
This option is deprecated. Use replica_parallel_type
14151431
instead.
1416-
--slave-parallel-workers=#
1432+
--slave-parallel-workers=#
14171433
This option is deprecated. Use replica_parallel_workers
14181434
instead.
14191435
--slave-pending-jobs-size-max=#
@@ -1534,10 +1550,10 @@ The following options may be given as the first argument:
15341550
Maximum amount of memory (in bytes) the TempTable storage
15351551
engine is allowed to allocate from the main memory (RAM)
15361552
before starting to store data on disk.
1537-
--temptable-use-mmap
1553+
--temptable-use-mmap
15381554
Use mmap files for temptables. This variable is
15391555
deprecated and will be removed in a future release.
1540-
--terminology-use-previous=name
1556+
--terminology-use-previous=name
15411557
Make monitoring tables and statements use the identifiers
15421558
that were in use before they were changed in a given
15431559
release. That includes names for mutexes, read/write
@@ -1629,6 +1645,7 @@ The following options may be given as the first argument:
16291645

16301646
Variables (--variable-name=value)
16311647
activate-all-roles-on-login FALSE
1648+
activate-mandatory-roles TRUE
16321649
admin-address (No default value)
16331650
admin-port 33062
16341651
admin-ssl-ca (No default value)
@@ -1673,9 +1690,12 @@ binlog-transaction-compression-level-zstd 3
16731690
binlog-transaction-dependency-history-size 25000
16741691
block-encryption-mode aes-128-ecb
16751692
bulk-insert-buffer-size 8388608
1676-
caching-sha2-password-digest-rounds 5000
1693+
caching-sha2-password-digest-rounds 10000
1694+
caching-sha2-password-enforce-storage-format FALSE
16771695
caching-sha2-password-private-key-path private_key.pem
1696+
caching-sha2-password-proxy-users FALSE
16781697
caching-sha2-password-public-key-path public_key.pem
1698+
caching-sha2-password-storage-format CRYPT5
16791699
character-set-filesystem binary
16801700
character-set-server utf8mb4
16811701
character-sets-dir MYSQL_CHARSETSDIR/

0 commit comments

Comments
 (0)