From: Arek Kusztal <arkadiuszx.kusztal@intel.com>
To: dev@dpdk.org
Cc: gakhil@marvell.com, kai.ji@intel.com,
Arek Kusztal <arkadiuszx.kusztal@intel.com>
Subject: [PATCH v2 2/4] crypto/qat: improve freeing of asym cookies
Date: Thu, 20 Oct 2022 16:09:38 +0100 [thread overview]
Message-ID: <20221020150940.62465-3-arkadiuszx.kusztal@intel.com> (raw)
In-Reply-To: <20221020150940.62465-1-arkadiuszx.kusztal@intel.com>
Improve the way that cookies are freed and cleared.
Signed-off-by: Arek Kusztal <arkadiuszx.kusztal@intel.com>
---
drivers/crypto/qat/qat_asym.c | 73 ++++++++++++++++++++-----------------------
1 file changed, 34 insertions(+), 39 deletions(-)
diff --git a/drivers/crypto/qat/qat_asym.c b/drivers/crypto/qat/qat_asym.c
index 6a079424b9..a77f7bfcd0 100644
--- a/drivers/crypto/qat/qat_asym.c
+++ b/drivers/crypto/qat/qat_asym.c
@@ -70,27 +70,33 @@ static const struct rte_driver cryptodev_qat_asym_driver = {
} while (0)
#define SET_PKE_LN(what, how, idx) \
- rte_memcpy(cookie->input_array[idx] + how - \
- what.length, \
- what.data, \
- what.length)
+ rte_memcpy(cookie->input_array[idx] + how - \
+ what.length, \
+ what.data, \
+ what.length)
#define SET_PKE_LN_EC(curve, p, idx) \
- rte_memcpy(cookie->input_array[idx] + \
- qat_func_alignsize - curve.bytesize, \
- curve.p.data, curve.bytesize)
+ rte_memcpy(cookie->input_array[idx] + \
+ qat_func_alignsize - curve.bytesize, \
+ curve.p.data, curve.bytesize)
#define SET_PKE_9A_IN(what, idx) \
- rte_memcpy(&cookie->input_buffer[idx * \
- qat_func_alignsize] + \
- qat_func_alignsize - what.length, \
- what.data, what.length)
+ rte_memcpy(&cookie->input_buffer[idx * \
+ qat_func_alignsize] + \
+ qat_func_alignsize - what.length, \
+ what.data, what.length)
#define SET_PKE_9A_EC(curve, p, idx) \
- rte_memcpy(&cookie->input_buffer[idx * \
- qat_func_alignsize] + \
- qat_func_alignsize - curve.bytesize, \
- curve.p.data, curve.bytesize)
+ rte_memcpy(&cookie->input_buffer[idx * \
+ qat_func_alignsize] + \
+ qat_func_alignsize - curve.bytesize, \
+ curve.p.data, curve.bytesize)
+
+#define PARAM_CLR(what) \
+ do { \
+ memset(what.data, 0, what.length); \
+ rte_free(what.data); \
+ } while (0)
static void
request_init(struct icp_qat_fw_pke_request *qat_req)
@@ -98,8 +104,8 @@ request_init(struct icp_qat_fw_pke_request *qat_req)
memset(qat_req, 0, sizeof(*qat_req));
qat_req->pke_hdr.service_type = ICP_QAT_FW_COMN_REQ_CPM_FW_PKE;
qat_req->pke_hdr.hdr_flags =
- ICP_QAT_FW_COMN_HDR_FLAGS_BUILD
- (ICP_QAT_FW_COMN_REQ_FLAG_SET);
+ ICP_QAT_FW_COMN_HDR_FLAGS_BUILD
+ (ICP_QAT_FW_COMN_REQ_FLAG_SET);
}
static void
@@ -1146,40 +1152,29 @@ qat_asym_session_get_private_size(struct rte_cryptodev *dev __rte_unused)
static void
session_clear_modexp(struct rte_crypto_modex_xform *modex)
{
- memset(modex->modulus.data, 0, modex->modulus.length);
- rte_free(modex->modulus.data);
- memset(modex->exponent.data, 0, modex->exponent.length);
- rte_free(modex->exponent.data);
+ PARAM_CLR(modex->modulus);
+ PARAM_CLR(modex->exponent);
}
static void
session_clear_modinv(struct rte_crypto_modinv_xform *modinv)
{
- memset(modinv->modulus.data, 0, modinv->modulus.length);
- rte_free(modinv->modulus.data);
+ PARAM_CLR(modinv->modulus);
}
static void
session_clear_rsa(struct rte_crypto_rsa_xform *rsa)
{
- memset(rsa->n.data, 0, rsa->n.length);
- rte_free(rsa->n.data);
- memset(rsa->e.data, 0, rsa->e.length);
- rte_free(rsa->e.data);
+ PARAM_CLR(rsa->n);
+ PARAM_CLR(rsa->e);
if (rsa->key_type == RTE_RSA_KEY_TYPE_EXP) {
- memset(rsa->d.data, 0, rsa->d.length);
- rte_free(rsa->d.data);
+ PARAM_CLR(rsa->d);
} else {
- memset(rsa->qt.p.data, 0, rsa->qt.p.length);
- rte_free(rsa->qt.p.data);
- memset(rsa->qt.q.data, 0, rsa->qt.q.length);
- rte_free(rsa->qt.q.data);
- memset(rsa->qt.dP.data, 0, rsa->qt.dP.length);
- rte_free(rsa->qt.dP.data);
- memset(rsa->qt.dQ.data, 0, rsa->qt.dQ.length);
- rte_free(rsa->qt.dQ.data);
- memset(rsa->qt.qInv.data, 0, rsa->qt.qInv.length);
- rte_free(rsa->qt.qInv.data);
+ PARAM_CLR(rsa->qt.p);
+ PARAM_CLR(rsa->qt.q);
+ PARAM_CLR(rsa->qt.dP);
+ PARAM_CLR(rsa->qt.dQ);
+ PARAM_CLR(rsa->qt.qInv);
}
}
--
2.13.6
next prev parent reply other threads:[~2022-10-20 16:18 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-20 15:09 [PATCH v2 0/4] crypto/qat: extend asymmetric crypto pmd Arek Kusztal
2022-10-20 15:09 ` [PATCH v2 1/4] crypto/qat: make immutable parameters constant Arek Kusztal
2022-10-20 21:55 ` Ji, Kai
2022-10-20 15:09 ` Arek Kusztal [this message]
2022-10-20 21:57 ` [PATCH v2 2/4] crypto/qat: improve freeing of asym cookies Ji, Kai
2022-10-20 15:09 ` [PATCH v2 3/4] crypto/qat: add ecdh key exchange algorithm Arek Kusztal
2022-10-24 11:11 ` Ji, Kai
2022-10-20 15:09 ` [PATCH v2 4/4] crypto/qat: add ecdh public key verification Arek Kusztal
2022-10-24 11:26 ` Ji, Kai
2022-10-27 9:48 ` [EXT] [PATCH v2 0/4] crypto/qat: extend asymmetric crypto pmd Akhil Goyal
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20221020150940.62465-3-arkadiuszx.kusztal@intel.com \
--to=arkadiuszx.kusztal@intel.com \
--cc=dev@dpdk.org \
--cc=gakhil@marvell.com \
--cc=kai.ji@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).