diff options
author | Richard Levitte <levitte@openssl.org> | 2019-08-12 14:56:18 +0200 |
---|---|---|
committer | Richard Levitte <levitte@openssl.org> | 2019-08-15 10:49:56 +0200 |
commit | ae3ff60e7bea6fb7510b5c0c2b9599d8430cf001 (patch) | |
tree | a6cef6a574ebeac091b9bdb57ba6aff5c257becf /crypto/evp/evp_enc.c | |
parent | aee6e29f0e88df18ebc21dbcf9d4d5794d7511e0 (diff) | |
download | openssl-new-ae3ff60e7bea6fb7510b5c0c2b9599d8430cf001.tar.gz |
Add missing EVP param utility functions
These functions were missing for a completes API:
EVP_MD_get_params(), EVP_CIPHER_get_params(), EVP_CIPHER_CTX_set_params(),
and EVP_CIPHER_CTX_get_params
Additionally, we also add all the corresponding parameter descriptor
returning functions, along the correspoding provider dispatches:
EVP_MD_gettable_params(), EVP_MD_CTX_settable_params(),
EVP_MD_CTX_gettable_params(), EVP_CIPHER_gettable_params(),
EVP_CIPHER_CTX_settable_params(), and EVP_CIPHER_CTX_gettable_params()
Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/9576)
Diffstat (limited to 'crypto/evp/evp_enc.c')
-rw-r--r-- | crypto/evp/evp_enc.c | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/crypto/evp/evp_enc.c b/crypto/evp/evp_enc.c index 31e15a63c2..9e0c01aff9 100644 --- a/crypto/evp/evp_enc.c +++ b/crypto/evp/evp_enc.c @@ -1051,6 +1051,48 @@ legacy: return ret; } +int EVP_CIPHER_get_params(EVP_CIPHER *cipher, OSSL_PARAM params[]) +{ + if (cipher != NULL && cipher->get_params != NULL) + return cipher->get_params(params); + return 0; +} + +int EVP_CIPHER_CTX_set_params(EVP_CIPHER_CTX *ctx, const OSSL_PARAM params[]) +{ + if (ctx->cipher != NULL && ctx->cipher->ctx_set_params != NULL) + return ctx->cipher->ctx_set_params(ctx->provctx, params); + return 0; +} + +int EVP_CIPHER_CTX_get_params(EVP_CIPHER_CTX *ctx, OSSL_PARAM params[]) +{ + if (ctx->cipher != NULL && ctx->cipher->ctx_get_params != NULL) + return ctx->cipher->ctx_get_params(ctx->provctx, params); + return 0; +} + +const OSSL_PARAM *EVP_CIPHER_gettable_params(const EVP_CIPHER *cipher) +{ + if (cipher != NULL && cipher->gettable_params != NULL) + return cipher->gettable_params(); + return NULL; +} + +const OSSL_PARAM *EVP_CIPHER_CTX_settable_params(const EVP_CIPHER *cipher) +{ + if (cipher != NULL && cipher->settable_ctx_params != NULL) + return cipher->settable_ctx_params(); + return NULL; +} + +const OSSL_PARAM *EVP_CIPHER_CTX_gettable_params(const EVP_CIPHER *cipher) +{ + if (cipher != NULL && cipher->gettable_ctx_params != NULL) + return cipher->gettable_ctx_params(); + return NULL; +} + #if !defined(FIPS_MODE) /* TODO(3.0): No support for RAND yet in the FIPS module */ int EVP_CIPHER_CTX_rand_key(EVP_CIPHER_CTX *ctx, unsigned char *key) @@ -1212,6 +1254,23 @@ static void *evp_cipher_from_dispatch(const char *name, break; cipher->ctx_set_params = OSSL_get_OP_cipher_ctx_set_params(fns); break; + case OSSL_FUNC_CIPHER_GETTABLE_PARAMS: + if (cipher->gettable_params != NULL) + break; + cipher->gettable_params = OSSL_get_OP_cipher_gettable_params(fns); + break; + case OSSL_FUNC_CIPHER_GETTABLE_CTX_PARAMS: + if (cipher->gettable_ctx_params != NULL) + break; + cipher->gettable_ctx_params = + OSSL_get_OP_cipher_gettable_ctx_params(fns); + break; + case OSSL_FUNC_CIPHER_SETTABLE_CTX_PARAMS: + if (cipher->settable_ctx_params != NULL) + break; + cipher->settable_ctx_params = + OSSL_get_OP_cipher_settable_ctx_params(fns); + break; } } if ((fnciphcnt != 0 && fnciphcnt != 3 && fnciphcnt != 4) |