summaryrefslogtreecommitdiffstats
path: root/crypto/passphrase.c
diff options
context:
space:
mode:
authorTomas Mraz <tomas@openssl.org>2021-12-02 22:04:21 +0100
committerTomas Mraz <tomas@openssl.org>2021-12-06 16:38:03 +0100
commitbaa88d9d170b95fd6f177b3e5f8d8818e024a55d (patch)
tree15409ac507a2527785f4ef593aacfd8e5d2af804 /crypto/passphrase.c
parent3dbf82438004b31258627f324841476c4f586c19 (diff)
Fix pvk encoder to properly query for the passphrase
The passphrase callback data was not properly initialized. Fixes #17054 Reviewed-by: Tim Hudson <tjh@openssl.org> Reviewed-by: Richard Levitte <levitte@openssl.org> Reviewed-by: Paul Dale <pauli@openssl.org> (Merged from https://github.com/openssl/openssl/pull/17181)
Diffstat (limited to 'crypto/passphrase.c')
-rw-r--r--crypto/passphrase.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/crypto/passphrase.c b/crypto/passphrase.c
index fb8ea1deb1..d61e249440 100644
--- a/crypto/passphrase.c
+++ b/crypto/passphrase.c
@@ -296,7 +296,8 @@ int ossl_pw_get_passphrase(char *pass, size_t pass_size, size_t *pass_len,
return ret;
}
-int ossl_pw_pem_password(char *buf, int size, int rwflag, void *userdata)
+static int ossl_pw_get_password(char *buf, int size, int rwflag,
+ void *userdata, const char *info)
{
size_t password_len = 0;
OSSL_PARAM params[] = {
@@ -304,13 +305,23 @@ int ossl_pw_pem_password(char *buf, int size, int rwflag, void *userdata)
OSSL_PARAM_END
};
- params[0].data = "PEM";
+ params[0].data = (void *)info;
if (ossl_pw_get_passphrase(buf, (size_t)size, &password_len, params,
rwflag, userdata))
return (int)password_len;
return -1;
}
+int ossl_pw_pem_password(char *buf, int size, int rwflag, void *userdata)
+{
+ return ossl_pw_get_password(buf, size, rwflag, userdata, "PEM");
+}
+
+int ossl_pw_pvk_password(char *buf, int size, int rwflag, void *userdata)
+{
+ return ossl_pw_get_password(buf, size, rwflag, userdata, "PVK");
+}
+
int ossl_pw_passphrase_callback_enc(char *pass, size_t pass_size,
size_t *pass_len,
const OSSL_PARAM params[], void *arg)