You need to sign in or sign up before continuing.
提交 19e74032 编写于 作者: Y Yu'an Wang 提交者: Yang Yingliang

hpre: optimize key process before free

driver inclusion
category: bugfix
bugzilla: NA
CVE: NA

In this patch, we try to optimize key process before free of hpre
module.
1、for DH algorithm, we use para g to compute public key, para g is
public, so we need not clear it before free.
2、for RSA algorithm, we should use memzero_explicit to clear prikey.
It will be optimized, when memset follows free.
3、For standard RSA algorithm, we use one buf to store public and
prikey, to consider performance, we just clear prikey buf.
Signed-off-by: NYu'an Wang <wangyuan46@huawei.com>
Reviewed-by: NCheng Hu <hucheng.hu@huawei.com>
Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
上级 ebb0518c
...@@ -559,7 +559,6 @@ static void hpre_dh_clear_ctx(struct hpre_ctx *ctx, bool is_clear_all) ...@@ -559,7 +559,6 @@ static void hpre_dh_clear_ctx(struct hpre_ctx *ctx, bool is_clear_all)
hisi_qm_stop_qp(ctx->qp); hisi_qm_stop_qp(ctx->qp);
if (ctx->dh.g) { if (ctx->dh.g) {
memzero_explicit(ctx->dh.g, sz);
dma_free_coherent(dev, sz, ctx->dh.g, ctx->dh.dma_g); dma_free_coherent(dev, sz, ctx->dh.g, ctx->dh.dma_g);
ctx->dh.g = NULL; ctx->dh.g = NULL;
} }
...@@ -893,7 +892,7 @@ static int hpre_rsa_setkey_crt(struct hpre_ctx *ctx, struct rsa_key *rsa_key) ...@@ -893,7 +892,7 @@ static int hpre_rsa_setkey_crt(struct hpre_ctx *ctx, struct rsa_key *rsa_key)
free_key: free_key:
offset = hlf_ksz * HPRE_CRT_PRMS; offset = hlf_ksz * HPRE_CRT_PRMS;
memset(ctx->rsa.crt_prikey, 0, offset); memzero_explicit(ctx->rsa.crt_prikey, offset);
dma_free_coherent(dev, hlf_ksz * HPRE_CRT_PRMS, ctx->rsa.crt_prikey, dma_free_coherent(dev, hlf_ksz * HPRE_CRT_PRMS, ctx->rsa.crt_prikey,
ctx->rsa.dma_crt_prikey); ctx->rsa.dma_crt_prikey);
ctx->rsa.crt_prikey = NULL; ctx->rsa.crt_prikey = NULL;
...@@ -926,7 +925,7 @@ static void hpre_rsa_clear_ctx(struct hpre_ctx *ctx, bool is_clear_all) ...@@ -926,7 +925,7 @@ static void hpre_rsa_clear_ctx(struct hpre_ctx *ctx, bool is_clear_all)
} }
if (ctx->rsa.prikey) { if (ctx->rsa.prikey) {
memzero_explicit(ctx->rsa.prikey, ctx->key_sz << 1); memzero_explicit(ctx->rsa.prikey, ctx->key_sz);
dma_free_coherent(dev, ctx->key_sz << 1, ctx->rsa.prikey, dma_free_coherent(dev, ctx->key_sz << 1, ctx->rsa.prikey,
ctx->rsa.dma_prikey); ctx->rsa.dma_prikey);
ctx->rsa.prikey = NULL; ctx->rsa.prikey = NULL;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册