diff options
author | Richard Levitte <levitte@openssl.org> | 2021-07-13 10:40:45 +0200 |
---|---|---|
committer | Richard Levitte <levitte@openssl.org> | 2021-07-26 12:11:54 +0200 |
commit | ad0a2c011020268a242737820bc50549e76cd6b8 (patch) | |
tree | c5b1a6ab6cef59978f3591c9a63757af13258a7e /crypto/evp/pmeth_lib.c | |
parent | 4d4de19e9c77f36cc5ab71df77a6eb1253031d4c (diff) |
EVP: Add EVP_PKEY_get0_provider() and EVP_PKEY_CTX_get0_provider()
Fixes #16058
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/16063)
Diffstat (limited to 'crypto/evp/pmeth_lib.c')
-rw-r--r-- | crypto/evp/pmeth_lib.c | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/crypto/evp/pmeth_lib.c b/crypto/evp/pmeth_lib.c index e5975081e1..7b835a5eb6 100644 --- a/crypto/evp/pmeth_lib.c +++ b/crypto/evp/pmeth_lib.c @@ -1531,11 +1531,33 @@ OSSL_LIB_CTX *EVP_PKEY_CTX_get0_libctx(EVP_PKEY_CTX *ctx) return ctx->libctx; } -const char *EVP_PKEY_CTX_get0_propq(EVP_PKEY_CTX *ctx) +const char *EVP_PKEY_CTX_get0_propq(const EVP_PKEY_CTX *ctx) { return ctx->propquery; } +const OSSL_PROVIDER *EVP_PKEY_CTX_get0_provider(const EVP_PKEY_CTX *ctx) +{ + if (EVP_PKEY_CTX_IS_SIGNATURE_OP(ctx)) { + if (ctx->op.sig.signature != NULL) + return EVP_SIGNATURE_get0_provider(ctx->op.sig.signature); + } else if (EVP_PKEY_CTX_IS_DERIVE_OP(ctx)) { + if (ctx->op.kex.exchange != NULL) + return EVP_KEYEXCH_get0_provider(ctx->op.kex.exchange); + } else if (EVP_PKEY_CTX_IS_KEM_OP(ctx)) { + if (ctx->op.encap.kem != NULL) + return EVP_KEM_get0_provider(ctx->op.encap.kem); + } else if (EVP_PKEY_CTX_IS_ASYM_CIPHER_OP(ctx)) { + if (ctx->op.ciph.cipher != NULL) + return EVP_ASYM_CIPHER_get0_provider(ctx->op.ciph.cipher); + } else if (EVP_PKEY_CTX_IS_GEN_OP(ctx)) { + if (ctx->keymgmt != NULL) + return EVP_KEYMGMT_get0_provider(ctx->keymgmt); + } + + return NULL; +} + /* Utility functions to send a string of hex string to a ctrl */ int EVP_PKEY_CTX_str2ctrl(EVP_PKEY_CTX *ctx, int cmd, const char *str) |