From 044d8c50c67f9cb15eda93fb6f85a458de3d270b Mon Sep 17 00:00:00 2001 From: Nikita Malyavin Date: Mon, 28 Oct 2024 22:41:41 +0100 Subject: [PATCH] ed25519: support empty password --- mysql-test/suite/plugins/r/auth_ed25519.result | 14 ++++++++++++++ mysql-test/suite/plugins/t/auth_ed25519.test | 12 ++++++++++++ plugin/auth_ed25519/server_ed25519.c | 2 +- 3 files changed, 27 insertions(+), 1 deletion(-) diff --git a/mysql-test/suite/plugins/r/auth_ed25519.result b/mysql-test/suite/plugins/r/auth_ed25519.result index f5d1ce2497d..70208f5adab 100644 --- a/mysql-test/suite/plugins/r/auth_ed25519.result +++ b/mysql-test/suite/plugins/r/auth_ed25519.result @@ -70,6 +70,20 @@ current_user() test1@localhost disconnect con1; connection default; +create user test2@localhost identified via ed25519 using PASSWORD(''); +show grants for test2@localhost; +Grants for test2@localhost +GRANT USAGE ON *.* TO `test2`@`localhost` IDENTIFIED VIA ed25519 USING '4LH+dBF+G5W2CKTyId8xR3SyDqZoQjUNUVNxx8aWbG4' +connect con2, localhost, test2,; +select current_user(); +current_user() +test2@localhost +disconnect con2; +connect(localhost,test2,wrong_pwd,test,MASTER_MYPORT,MASTER_MYSOCK); +connect con3, localhost, test2, "wrong_pwd"; +ERROR 28000: Access denied for user 'test2'@'localhost' (using password: YES) +connection default; +drop user test2@localhost; drop user test1@localhost; uninstall plugin ed25519; select ed25519_password("foo"); diff --git a/mysql-test/suite/plugins/t/auth_ed25519.test b/mysql-test/suite/plugins/t/auth_ed25519.test index 8e0bdd1d460..ccd54c36ed1 100644 --- a/mysql-test/suite/plugins/t/auth_ed25519.test +++ b/mysql-test/suite/plugins/t/auth_ed25519.test @@ -50,6 +50,18 @@ select current_user(); disconnect con1; connection default; +create user test2@localhost identified via ed25519 using PASSWORD(''); +show grants for test2@localhost; +connect con2, localhost, test2,; +select current_user(); +disconnect con2; + +replace_result $MASTER_MYSOCK MASTER_MYSOCK $MASTER_MYPORT MASTER_MYPORT; +error ER_ACCESS_DENIED_ERROR; +connect con3, localhost, test2, "wrong_pwd"; +connection default; +drop user test2@localhost; + drop user test1@localhost; uninstall plugin ed25519; error ER_CANT_INITIALIZE_UDF; diff --git a/plugin/auth_ed25519/server_ed25519.c b/plugin/auth_ed25519/server_ed25519.c index b789bd34ca4..f4d37f4f77b 100644 --- a/plugin/auth_ed25519/server_ed25519.c +++ b/plugin/auth_ed25519/server_ed25519.c @@ -64,7 +64,7 @@ static int compute_password_digest(const char *pw, size_t pwlen, char *d, size_t *dlen) { unsigned char pk[CRYPTO_PUBLICKEYBYTES]; - if (*dlen < PASSWORD_LEN || pwlen == 0) + if (*dlen < PASSWORD_LEN) return 1; *dlen= PASSWORD_LEN; crypto_sign_keypair(pk, (unsigned char*)pw, pwlen);