Skip to content

Commit e580cf7

Browse files
FooBarriorsanja-byelkin
authored andcommitted
MDEV-32618 new auth plugin
PARSEC: Password Authentication using Response Signed with Elliptic Curve new authentication plugin that uses salted passwords, key derivation, extensible password storage format, and both server- and client-side scrambles. It signs the response with ed25519, but it uses stock unmodified ed25519 as provided by OpenSSL/WolfSSL/GnuTLS. Edited by: Sergei Golubchik
1 parent 68e369e commit e580cf7

File tree

14 files changed

+445
-20
lines changed

14 files changed

+445
-20
lines changed

cmake/mariadb_connector_c.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ ENDIF()
77
SET(CONC_WITH_SIGNCODE ${SIGNCODE})
88
SET(SIGN_OPTIONS ${SIGNTOOL_PARAMETERS})
99
SET(CONC_WITH_EXTERNAL_ZLIB ON)
10+
SET(CLIENT_PLUGIN_PARSEC DYNAMIC)
1011

1112
IF(SSL_DEFINES MATCHES "WOLFSSL")
1213
IF(WIN32)

cmake/ssl.cmake

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,8 @@ MACRO (MYSQL_USE_BUNDLED_SSL)
5454
SET(HAVE_EncryptAes128Ctr ON CACHE INTERNAL "wolfssl does support AES-CTR")
5555
SET(HAVE_EncryptAes128Gcm OFF CACHE INTERNAL "wolfssl does not support AES-GCM")
5656
SET(HAVE_des ON CACHE INTERNAL "wolfssl does support DES API")
57-
SET(HAVE_hkdf ON CACHE INTERNAL "wolfssl does support EVP_PKEY API")
57+
SET(HAVE_evp_pkey ON CACHE INTERNAL "wolfssl does support EVP_PKEY API")
58+
SET(HAVE_hkdf ON CACHE INTERNAL "wolfssl does support EVP_PKEY_HKDF API")
5859
CHANGE_SSL_SETTINGS("bundled")
5960
ADD_SUBDIRECTORY(extra/wolfssl)
6061
MESSAGE_ONCE(SSL_LIBRARIES "SSL_LIBRARIES = ${SSL_LIBRARIES}")
@@ -137,6 +138,8 @@ MACRO (MYSQL_CHECK_SSL)
137138
HAVE_EncryptAes128Gcm)
138139
CHECK_SYMBOL_EXISTS(DES_set_key_unchecked "openssl/des.h"
139140
HAVE_des)
141+
CHECK_SYMBOL_EXISTS(EVP_PKEY_get_raw_public_key "openssl/evp.h"
142+
HAVE_evp_pkey)
140143
CHECK_SYMBOL_EXISTS(EVP_PKEY_CTX_set_hkdf_md "string.h;stdarg.h;openssl/kdf.h"
141144
HAVE_hkdf)
142145
SET(CMAKE_REQUIRED_INCLUDES)

debian/libmariadb3.install

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@ usr/lib/*/libmariadb3/plugin/client_ed25519.so
44
usr/lib/*/libmariadb3/plugin/dialog.so
55
usr/lib/*/libmariadb3/plugin/mysql_clear_password.so
66
usr/lib/*/libmariadb3/plugin/sha256_password.so
7+
usr/lib/*/libmariadb3/plugin/parsec.so

debian/mariadb-server.install

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ usr/lib/mysql/plugin/auth_ed25519.so
3939
usr/lib/mysql/plugin/auth_pam.so
4040
usr/lib/mysql/plugin/auth_pam_tool_dir/auth_pam_tool
4141
usr/lib/mysql/plugin/auth_pam_v1.so
42+
usr/lib/mysql/plugin/auth_parsec.so
4243
usr/lib/mysql/plugin/disks.so
4344
usr/lib/mysql/plugin/file_key_management.so
4445
usr/lib/mysql/plugin/ha_archive.so

extra/wolfssl/CMakeLists.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,10 @@ ${WOLFCRYPT_SRCDIR}/des3.c
6060
${WOLFCRYPT_SRCDIR}/dh.c
6161
${WOLFCRYPT_SRCDIR}/dsa.c
6262
${WOLFCRYPT_SRCDIR}/ecc.c
63+
${WOLFCRYPT_SRCDIR}/ed25519.c
6364
${WOLFCRYPT_SRCDIR}/error.c
65+
${WOLFCRYPT_SRCDIR}/fe_operations.c
66+
${WOLFCRYPT_SRCDIR}/ge_operations.c
6467
${WOLFCRYPT_SRCDIR}/hmac.c
6568
${WOLFCRYPT_SRCDIR}/logging.c
6669
${WOLFCRYPT_SRCDIR}/md4.c
@@ -112,6 +115,7 @@ if(WOLFSSL_INTELASM)
112115
${WOLFCRYPT_SRCDIR}/aes_asm.S
113116
${WOLFCRYPT_SRCDIR}/aes_gcm_asm.S
114117
${WOLFCRYPT_SRCDIR}/chacha_asm.S
118+
${WOLFCRYPT_SRCDIR}/fe_x25519_asm.S
115119
${WOLFCRYPT_SRCDIR}/poly1305_asm.S
116120
${WOLFCRYPT_SRCDIR}/sha512_asm.S
117121
${WOLFCRYPT_SRCDIR}/sha256_asm.S
@@ -132,5 +136,7 @@ if(MSVC)
132136
endif()
133137
endif()
134138

139+
set_property(TARGET wolfssl PROPERTY POSITION_INDEPENDENT_CODE ON)
140+
135141
CONFIGURE_FILE(user_settings.h.in user_settings.h)
136142

extra/wolfssl/user_settings.h.in

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,4 +69,6 @@
6969
#cmakedefine WOLFSSL_SP_X86_64
7070
#cmakedefine WOLFSSL_SP_X86_64_ASM
7171

72+
#define HAVE_ED25519
73+
7274
#endif /* WOLFSSL_USER_SETTINGS_H */
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
install soname 'auth_parsec';
2+
create user test1@'%' identified via parsec using 'pwd';
3+
ERROR HY000: Operation CREATE USER failed for 'test1'@'%'
4+
create user test1@'%' identified via parsec using PASSWORD('pwd');
5+
show grants for test1@'%';
6+
Grants for test1@%
7+
GRANT USAGE ON *.* TO `test1`@`%` IDENTIFIED VIA parsec USING 'P0:salt:password'
8+
connect con1, localhost, test1, pwd;
9+
select 1, USER(), CURRENT_USER();
10+
1 USER() CURRENT_USER()
11+
1 test1@localhost test1@%
12+
disconnect con1;
13+
connect con2, localhost, test1, pwd;
14+
select 2, USER(), CURRENT_USER();
15+
2 USER() CURRENT_USER()
16+
2 test1@localhost test1@%
17+
disconnect con2;
18+
connect(localhost,test1,wrong_pwd,test,MASTER_MYPORT,MASTER_MYSOCK);
19+
connect con3, localhost, test1, wrong_pwd;
20+
ERROR 28000: Access denied for user 'test1'@'localhost' (using password: NO)
21+
connection default;
22+
create function have_ssl() returns char(3)
23+
return (select if(variable_value > '','yes','no') as 'have_ssl'
24+
from information_schema.session_status
25+
where variable_name='ssl_cipher');
26+
grant execute on test.* to test1@'%';
27+
# mysql -utest1 -ppwd --ssl-verify-server-cert -e "select test.have_ssl()"
28+
test.have_ssl()
29+
yes
30+
drop function have_ssl;
31+
drop user test1@'%';
32+
uninstall soname 'auth_parsec';
Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
install soname 'client_ed25519';
1+
install soname 'CLIENT_PLUGIN';
22
Got one of the listed errors
33
include/master-slave.inc
44
[connection master]
55
connection slave;
6-
install soname 'auth_ed25519';
6+
install soname 'auth_PLUGIN';
77
connection master;
8-
install soname 'auth_ed25519';
9-
create user rpluser@'%' identified via ed25519 using PASSWORD('rpl_pass');
8+
install soname 'auth_plugin';
9+
create user rpluser@'%' identified via PLUGIN using PASSWORD('rpl_pass');
1010
grant replication slave on *.* to rpluser@'%';
1111
connection master;
1212
connection slave;
@@ -19,7 +19,7 @@ change master to master_user='root', master_password='';
1919
include/start_slave.inc
2020
include/stop_slave.inc
2121
drop user rpluser@'%';
22-
uninstall soname 'auth_ed25519';
22+
uninstall soname 'auth_plugin';
2323
connection master;
2424
drop user rpluser@'%';
25-
uninstall soname 'auth_ed25519';
25+
uninstall soname 'auth_plugin';

mysql-test/suite/plugins/t/parsec.opt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
--ssl-key=
2+
--ssl-cert=
3+
--ssl-ca=
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
source include/platform.inc;
2+
source include/not_embedded.inc;
3+
4+
if (!$AUTH_PARSEC_SO) {
5+
skip No auth_parsec plugin;
6+
}
7+
if (!$PARSEC_SO) {
8+
skip No auth_parsec plugin;
9+
}
10+
install soname 'auth_parsec';
11+
--error ER_CANNOT_USER
12+
create user test1@'%' identified via parsec using 'pwd';
13+
create user test1@'%' identified via parsec using PASSWORD('pwd');
14+
--replace_regex /:[A-Za-z0-9+\/]{43}'/:password'/ /:[A-Za-z0-9+\/]{24}:/:salt:/
15+
show grants for test1@'%';
16+
connect con1, localhost, test1, pwd;
17+
select 1, USER(), CURRENT_USER();
18+
disconnect con1;
19+
connect con2, localhost, test1, pwd;
20+
select 2, USER(), CURRENT_USER();
21+
disconnect con2;
22+
--replace_result $MASTER_MYSOCK MASTER_MYSOCK $MASTER_MYPORT MASTER_MYPORT
23+
--error ER_ACCESS_DENIED_ERROR
24+
connect con3, localhost, test1, wrong_pwd;
25+
26+
connection default;
27+
28+
create function have_ssl() returns char(3)
29+
return (select if(variable_value > '','yes','no') as 'have_ssl'
30+
from information_schema.session_status
31+
where variable_name='ssl_cipher');
32+
grant execute on test.* to test1@'%';
33+
34+
let host=;
35+
if ($MTR_COMBINATION_WIN) {
36+
# see ssl_autoverify.test
37+
let host=--host=127.0.0.2;
38+
}
39+
40+
--echo # mysql -utest1 -ppwd --ssl-verify-server-cert -e "select test.have_ssl()"
41+
--exec $MYSQL --protocol tcp $host -utest1 -ppwd --ssl-verify-server-cert -e "select test.have_ssl()" 2>&1
42+
43+
drop function have_ssl;
44+
drop user test1@'%';
45+
uninstall soname 'auth_parsec';

0 commit comments

Comments
 (0)