diff options
author | Pauli <ppzgs1@gmail.com> | 2021-03-02 22:44:53 +1000 |
---|---|---|
committer | Pauli <ppzgs1@gmail.com> | 2021-03-12 08:27:21 +1000 |
commit | f336f98dbf80af632ea142ea3d43fe1e9d727e14 (patch) | |
tree | b0c72865f12f902ab8d93447ba2e1b51613d3de3 /providers/implementations/ciphers/cipher_chacha20.c | |
parent | 8f42380a21e7732cc0931be1921e24d360285278 (diff) |
prov: support params argument to CHACHA20 ciphers
Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/14383)
Diffstat (limited to 'providers/implementations/ciphers/cipher_chacha20.c')
-rw-r--r-- | providers/implementations/ciphers/cipher_chacha20.c | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/providers/implementations/ciphers/cipher_chacha20.c b/providers/implementations/ciphers/cipher_chacha20.c index 9bce5b0914..386c865d83 100644 --- a/providers/implementations/ciphers/cipher_chacha20.c +++ b/providers/implementations/ciphers/cipher_chacha20.c @@ -106,6 +106,9 @@ static int chacha20_set_ctx_params(void *vctx, const OSSL_PARAM params[]) const OSSL_PARAM *p; size_t len; + if (params == NULL) + return 1; + p = OSSL_PARAM_locate_const(params, OSSL_CIPHER_PARAM_KEYLEN); if (p != NULL) { if (!OSSL_PARAM_get_size_t(p, &len)) { @@ -143,34 +146,40 @@ const OSSL_PARAM *chacha20_settable_ctx_params(ossl_unused void *cctx, } int ossl_chacha20_einit(void *vctx, const unsigned char *key, size_t keylen, - const unsigned char *iv, size_t ivlen) + const unsigned char *iv, size_t ivlen, + const OSSL_PARAM params[]) { int ret; /* The generic function checks for ossl_prov_is_running() */ - ret= ossl_cipher_generic_einit(vctx, key, keylen, iv, ivlen); + ret = ossl_cipher_generic_einit(vctx, key, keylen, iv, ivlen, NULL); if (ret && iv != NULL) { PROV_CIPHER_CTX *ctx = (PROV_CIPHER_CTX *)vctx; PROV_CIPHER_HW_CHACHA20 *hw = (PROV_CIPHER_HW_CHACHA20 *)ctx->hw; hw->initiv(ctx); } + if (ret && !chacha20_set_ctx_params(vctx, params)) + ret = 0; return ret; } int ossl_chacha20_dinit(void *vctx, const unsigned char *key, size_t keylen, - const unsigned char *iv, size_t ivlen) + const unsigned char *iv, size_t ivlen, + const OSSL_PARAM params[]) { int ret; /* The generic function checks for ossl_prov_is_running() */ - ret= ossl_cipher_generic_dinit(vctx, key, keylen, iv, ivlen); + ret = ossl_cipher_generic_dinit(vctx, key, keylen, iv, ivlen, NULL); if (ret && iv != NULL) { PROV_CIPHER_CTX *ctx = (PROV_CIPHER_CTX *)vctx; PROV_CIPHER_HW_CHACHA20 *hw = (PROV_CIPHER_HW_CHACHA20 *)ctx->hw; hw->initiv(ctx); } + if (ret && !chacha20_set_ctx_params(vctx, params)) + ret = 0; return ret; } |