From: Chenghai Huang huangchenghai2@huawei.com
The ivlen param setting function is added.
In addition, the pad param is missing in the ctx param table. As a result, users cannot set this parameter. This param is added.
Signed-off-by: Chenghai Huang huangchenghai2@huawei.com Signed-off-by: JiangShui Yang yangjiangshui@h-partners.com --- src/uadk_prov_cipher.c | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-)
diff --git a/src/uadk_prov_cipher.c b/src/uadk_prov_cipher.c index 53ff589..8c17d98 100644 --- a/src/uadk_prov_cipher.c +++ b/src/uadk_prov_cipher.c @@ -983,6 +983,8 @@ static int uadk_prov_cipher_dinit(void *vctx, const unsigned char *key, size_t k
static const OSSL_PARAM uadk_prov_settable_ctx_params[] = { OSSL_PARAM_size_t(OSSL_CIPHER_PARAM_KEYLEN, NULL), + OSSL_PARAM_size_t(OSSL_CIPHER_PARAM_IVLEN, NULL), + OSSL_PARAM_uint(OSSL_CIPHER_PARAM_PADDING, NULL), OSSL_PARAM_END };
@@ -996,7 +998,6 @@ static int uadk_prov_cipher_set_ctx_params(void *vctx, const OSSL_PARAM params[] { struct cipher_priv_ctx *priv = (struct cipher_priv_ctx *)vctx; const OSSL_PARAM *p; - int ret = 1;
if (!vctx) return UADK_E_FAIL; @@ -1027,7 +1028,21 @@ static int uadk_prov_cipher_set_ctx_params(void *vctx, const OSSL_PARAM params[] } }
- return ret; + p = OSSL_PARAM_locate_const(params, OSSL_CIPHER_PARAM_IVLEN); + if (p != NULL) { + size_t ivlen; + + if (!OSSL_PARAM_get_size_t(p, &ivlen)) { + ERR_raise(ERR_LIB_PROV, PROV_R_FAILED_TO_GET_PARAMETER); + return UADK_E_FAIL; + } + if (priv->ivlen != ivlen) { + ERR_raise(ERR_LIB_PROV, PROV_R_INVALID_IV_LENGTH); + return UADK_E_FAIL; + } + } + + return UADK_E_SUCCESS; }
static int uadk_prov_cipher_get_ctx_params(void *vctx, OSSL_PARAM params[]) @@ -1071,6 +1086,7 @@ static int uadk_prov_cipher_get_ctx_params(void *vctx, OSSL_PARAM params[]) static const OSSL_PARAM uadk_prov_default_ctx_params[] = { OSSL_PARAM_size_t(OSSL_CIPHER_PARAM_KEYLEN, NULL), OSSL_PARAM_size_t(OSSL_CIPHER_PARAM_IVLEN, NULL), + OSSL_PARAM_uint(OSSL_CIPHER_PARAM_PADDING, NULL), OSSL_PARAM_octet_string(OSSL_CIPHER_PARAM_IV, NULL, 0), OSSL_PARAM_octet_string(OSSL_CIPHER_PARAM_UPDATED_IV, NULL, 0), OSSL_PARAM_END