Initialize the algorithm type again to prevent the algorithm type from being changed.
Signed-off-by: taoqi taoqi10@huawei.com --- src/uadk_cipher.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-)
diff --git a/src/uadk_cipher.c b/src/uadk_cipher.c index 2c1d87b..0a7518b 100644 --- a/src/uadk_cipher.c +++ b/src/uadk_cipher.c @@ -848,8 +848,10 @@ static int do_cipher_async(struct cipher_priv_ctx *priv, struct async_op *op)
static void uadk_e_ctx_init(EVP_CIPHER_CTX *ctx, struct cipher_priv_ctx *priv) { + __u32 cipher_counts = ARRAY_SIZE(cipher_info_table); struct sched_params params = {0}; - int ret; + int nid, ret; + __u32 i;
priv->req.iv_bytes = EVP_CIPHER_CTX_iv_length(ctx); priv->req.iv = priv->iv; @@ -877,7 +879,23 @@ static void uadk_e_ctx_init(EVP_CIPHER_CTX *ctx, struct cipher_priv_ctx *priv) /* Use the default numa parameters */ params.numa_id = -1; priv->setup.sched_param = ¶ms; + if (!priv->sess) { + nid = EVP_CIPHER_CTX_nid(ctx); + + for (i = 0; i < cipher_counts; i++) { + if (nid == cipher_info_table[i].nid) { + cipher_priv_ctx_setup(priv, cipher_info_table[i].alg, + cipher_info_table[i].mode, cipher_info_table[i].out_bytes); + break; + } + } + + if (i == cipher_counts) { + fprintf(stderr, "failed to setup the private ctx.\n"); + return; + } + priv->sess = wd_cipher_alloc_sess(&priv->setup); if (!priv->sess) { fprintf(stderr, "uadk failed to alloc session!\n");