diff options
author | Petr Gotthard <petr.gotthard@centrum.cz> | 2020-12-26 21:32:14 +0100 |
---|---|---|
committer | Pauli <ppzgs1@gmail.com> | 2021-02-05 10:24:04 +1000 |
commit | 7dc67708c8ae6ec06c7fec34781225ed60b5e68d (patch) | |
tree | c48ecd0e6c3a24a5837a09a7e7497c458052d4c6 /apps/pkeyutl.c | |
parent | 88444854affe31ce08a5daaf4b6afc86e6972c63 (diff) |
apps/openssl: add -propquery command line option
Fixes #13656. Right now all openssl commands use a NULL propq. This
patch adds a possibility to specify a custom propq.
The implementation follows the example of set_nameopt/get_nameopt.
Various tools had to be modified to call app_get0_propq after it has
been populated. Otherwise the -propquery has no effect.
The tests then verify the -propquery affects the tool behaviour by
requesting a non-existing property.
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/13707)
Diffstat (limited to 'apps/pkeyutl.c')
-rw-r--r-- | apps/pkeyutl.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/apps/pkeyutl.c b/apps/pkeyutl.c index a88a6ca7a3..4eb15c30f4 100644 --- a/apps/pkeyutl.c +++ b/apps/pkeyutl.c @@ -24,7 +24,7 @@ static EVP_PKEY_CTX *init_ctx(const char *kdfalg, int *pkeysize, const char *keyfile, int keyform, int key_type, char *passinarg, int pkey_op, ENGINE *e, const int impl, int rawin, EVP_PKEY **ppkey, - OSSL_LIB_CTX *libctx, const char *propq); + OSSL_LIB_CTX *libctx); static int setup_peer(EVP_PKEY_CTX *ctx, int peerform, const char *file, ENGINE *e); @@ -125,7 +125,6 @@ int pkeyutl_main(int argc, char **argv) const EVP_MD *md = NULL; int filesize = -1; OSSL_LIB_CTX *libctx = app_get0_libctx(); - const char *propq = NULL; prog = opt_init(argc, argv, pkeyutl_options); while ((o = opt_next()) != OPT_EOF) { @@ -293,7 +292,7 @@ int pkeyutl_main(int argc, char **argv) } ctx = init_ctx(kdfalg, &keysize, inkey, keyform, key_type, passinarg, pkey_op, e, engine_impl, rawin, &pkey, - libctx, propq); + libctx); if (ctx == NULL) { BIO_printf(bio_err, "%s: Error initializing context\n", prog); ERR_print_errors(bio_err); @@ -514,7 +513,7 @@ static EVP_PKEY_CTX *init_ctx(const char *kdfalg, int *pkeysize, char *passinarg, int pkey_op, ENGINE *e, const int engine_impl, int rawin, EVP_PKEY **ppkey, - OSSL_LIB_CTX *libctx, const char *propq) + OSSL_LIB_CTX *libctx) { EVP_PKEY *pkey = NULL; EVP_PKEY_CTX *ctx = NULL; @@ -522,6 +521,7 @@ static EVP_PKEY_CTX *init_ctx(const char *kdfalg, int *pkeysize, char *passin = NULL; int rv = -1; X509 *x; + if (((pkey_op == EVP_PKEY_OP_SIGN) || (pkey_op == EVP_PKEY_OP_DECRYPT) || (pkey_op == EVP_PKEY_OP_DERIVE)) && (key_type != KEY_PRIVKEY && kdfalg == NULL)) { @@ -573,7 +573,7 @@ static EVP_PKEY_CTX *init_ctx(const char *kdfalg, int *pkeysize, if (impl != NULL) ctx = EVP_PKEY_CTX_new_id(kdfnid, impl); else - ctx = EVP_PKEY_CTX_new_from_name(libctx, kdfalg, propq); + ctx = EVP_PKEY_CTX_new_from_name(libctx, kdfalg, app_get0_propq()); } else { if (pkey == NULL) goto end; @@ -582,7 +582,7 @@ static EVP_PKEY_CTX *init_ctx(const char *kdfalg, int *pkeysize, if (impl != NULL) ctx = EVP_PKEY_CTX_new(pkey, impl); else - ctx = EVP_PKEY_CTX_new_from_pkey(libctx, pkey, propq); + ctx = EVP_PKEY_CTX_new_from_pkey(libctx, pkey, app_get0_propq()); if (ppkey != NULL) *ppkey = pkey; EVP_PKEY_free(pkey); |