diff options
author | Richard Levitte <levitte@openssl.org> | 2021-05-03 08:48:17 +0200 |
---|---|---|
committer | Richard Levitte <levitte@openssl.org> | 2021-05-04 11:40:31 +0200 |
commit | 5432d827ec2cffa2e75bf8dd0bc570288cba19f6 (patch) | |
tree | 29468b741d428db2ebaecde697f36aace8df3360 | |
parent | 49ce00374030c74f527c9916bff7c2c7268f4318 (diff) | |
download | openssl-new-5432d827ec2cffa2e75bf8dd0bc570288cba19f6.tar.gz |
APPS: Add passphrase handling in the "rsa" and "dsa" commands
They completely ignored any passphrase related setting.
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/15119)
-rw-r--r-- | apps/dsa.c | 14 | ||||
-rw-r--r-- | apps/rsa.c | 14 |
2 files changed, 28 insertions, 0 deletions
diff --git a/apps/dsa.c b/apps/dsa.c index 9ea1098514..9a7bf04adb 100644 --- a/apps/dsa.c +++ b/apps/dsa.c @@ -267,6 +267,20 @@ int dsa_main(int argc, char **argv) goto end; } + /* Passphrase setup */ + if (enc != NULL) + OSSL_ENCODER_CTX_set_cipher(ectx, EVP_CIPHER_name(enc), NULL); + + /* Default passphrase prompter */ + if (enc != NULL || outformat == FORMAT_PVK) { + OSSL_ENCODER_CTX_set_passphrase_ui(ectx, get_ui_method(), NULL); + if (passout != NULL) + /* When passout given, override the passphrase prompter */ + OSSL_ENCODER_CTX_set_passphrase(ectx, + (const unsigned char *)passout, + strlen(passout)); + } + /* PVK requires a bit more */ if (outformat == FORMAT_PVK) { OSSL_PARAM params[2] = { OSSL_PARAM_END, OSSL_PARAM_END }; diff --git a/apps/rsa.c b/apps/rsa.c index fc1db506d7..47316757d5 100644 --- a/apps/rsa.c +++ b/apps/rsa.c @@ -335,6 +335,20 @@ int rsa_main(int argc, char **argv) goto end; } + /* Passphrase setup */ + if (enc != NULL) + OSSL_ENCODER_CTX_set_cipher(ectx, EVP_CIPHER_name(enc), NULL); + + /* Default passphrase prompter */ + if (enc != NULL || outformat == FORMAT_PVK) { + OSSL_ENCODER_CTX_set_passphrase_ui(ectx, get_ui_method(), NULL); + if (passout != NULL) + /* When passout given, override the passphrase prompter */ + OSSL_ENCODER_CTX_set_passphrase(ectx, + (const unsigned char *)passout, + strlen(passout)); + } + /* PVK is a bit special... */ if (outformat == FORMAT_PVK) { OSSL_PARAM params[2] = { OSSL_PARAM_END, OSSL_PARAM_END }; |