From: Matt Caswell Date: Mon, 31 Jul 2023 11:32:16 +0000 (+0100) Subject: The PEM_read_bio_Parameters() function should not ask for a password X-Git-Tag: openssl-3.1.3~78 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5ac7a04471370da6010bd653af83fec5559ca202;p=thirdparty%2Fopenssl.git The PEM_read_bio_Parameters() function should not ask for a password The PEM_read_bio_Parameters[_ex] function does not have the capability of specifying a password callback. We should not use the fallback password callback in this case because it will attempt to send a prompt for the password which might not be the correct thing to do. We should just not use a password in that case. Fixes #21588 Reviewed-by: Tim Hudson Reviewed-by: Tomas Mraz (Merged from https://github.com/openssl/openssl/pull/21603) (cherry picked from commit 0d0791eedff7f0747503d816184810aa093f523e) --- diff --git a/crypto/pem/pem_pkey.c b/crypto/pem/pem_pkey.c index 75a8bb3c15b..7822b8b00b6 100644 --- a/crypto/pem/pem_pkey.c +++ b/crypto/pem/pem_pkey.c @@ -366,10 +366,19 @@ int PEM_write_bio_PrivateKey_traditional(BIO *bp, const EVP_PKEY *x, return ret; } +static int no_password_cb(char *buf, int num, int rwflag, void *userdata) +{ + return -1; +} + EVP_PKEY *PEM_read_bio_Parameters_ex(BIO *bp, EVP_PKEY **x, OSSL_LIB_CTX *libctx, const char *propq) { - return pem_read_bio_key(bp, x, NULL, NULL, libctx, propq, + /* + * PEM_read_bio_Parameters(_ex) should never ask for a password. Any attempt + * to get a password just fails. + */ + return pem_read_bio_key(bp, x, no_password_cb, NULL, libctx, propq, EVP_PKEY_KEY_PARAMETERS); }