1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2019 Intel Corporation
8 #include "icp_qat_fw_pke.h"
9 #include "icp_qat_fw.h"
10 #include "qat_pke_functionality_arrays.h"
12 #define qat_asym_sz_2param(arg) (arg, sizeof(arg)/sizeof(*arg))
14 static int qat_asym_get_sz_and_func_id(const uint32_t arr[][2],
15 size_t arr_sz, size_t *size, uint32_t *func_id)
19 for (i = 0; i < arr_sz; i++) {
20 if (*size <= arr[i][0]) {
29 static inline void qat_fill_req_tmpl(struct icp_qat_fw_pke_request *qat_req)
31 memset(qat_req, 0, sizeof(*qat_req));
32 qat_req->pke_hdr.service_type = ICP_QAT_FW_COMN_REQ_CPM_FW_PKE;
34 qat_req->pke_hdr.hdr_flags =
35 ICP_QAT_FW_COMN_HDR_FLAGS_BUILD
36 (ICP_QAT_FW_COMN_REQ_FLAG_SET);
39 static inline void qat_asym_build_req_tmpl(void *sess_private_data)
41 struct icp_qat_fw_pke_request *qat_req;
42 struct qat_asym_session *session = sess_private_data;
44 qat_req = &session->req_tmpl;
45 qat_fill_req_tmpl(qat_req);
48 static size_t max_of(int n, ...)
55 len = va_arg(args, size_t);
57 for (i = 0; i < n - 1; i++) {
58 num = va_arg(args, size_t);
67 static void qat_clear_arrays(struct qat_asym_op_cookie *cookie,
68 int in_count, int out_count, int in_size, int out_size)
72 for (i = 0; i < in_count; i++)
73 memset(cookie->input_array[i], 0x0, in_size);
74 for (i = 0; i < out_count; i++)
75 memset(cookie->output_array[i], 0x0, out_size);
78 static void qat_clear_arrays_by_alg(struct qat_asym_op_cookie *cookie,
79 enum rte_crypto_asym_xform_type alg, int in_size, int out_size)
81 if (alg == RTE_CRYPTO_ASYM_XFORM_MODEX)
82 qat_clear_arrays(cookie, QAT_ASYM_MODEXP_NUM_IN_PARAMS,
83 QAT_ASYM_MODEXP_NUM_OUT_PARAMS, in_size,
85 else if (alg == RTE_CRYPTO_ASYM_XFORM_MODINV)
86 qat_clear_arrays(cookie, QAT_ASYM_MODINV_NUM_IN_PARAMS,
87 QAT_ASYM_MODINV_NUM_OUT_PARAMS, in_size,
91 static int qat_asym_check_nonzero(rte_crypto_param n)
94 /* Not a case for any cryptograpic function except for DH
95 * generator which very often can be of one byte length
99 if (n.data[n.length - 1] == 0x0) {
100 for (i = 0; i < n.length - 1; i++)
101 if (n.data[i] != 0x0)
103 if (i == n.length - 1)
106 } else if (*(uint64_t *)&n.data[
107 n.length - 8] == 0) {
108 /* Very likely it is zeroed modulus */
111 for (i = 0; i < n.length - 8; i++)
112 if (n.data[i] != 0x0)
114 if (i == n.length - 8)
122 qat_asym_fill_arrays(struct rte_crypto_asym_op *asym_op,
123 struct icp_qat_fw_pke_request *qat_req,
124 struct qat_asym_op_cookie *cookie,
125 struct rte_crypto_asym_xform *xform)
129 size_t alg_size_in_bytes;
130 uint32_t func_id = 0;
132 if (xform->xform_type == RTE_CRYPTO_ASYM_XFORM_MODEX) {
133 err = qat_asym_check_nonzero(xform->modex.modulus);
135 QAT_LOG(ERR, "Empty modulus in modular exponentiation,"
136 " aborting this operation");
140 alg_size_in_bytes = max_of(3, asym_op->modex.base.length,
141 xform->modex.exponent.length,
142 xform->modex.modulus.length);
143 alg_size = alg_size_in_bytes << 3;
145 if (qat_asym_get_sz_and_func_id(MOD_EXP_SIZE,
146 sizeof(MOD_EXP_SIZE)/sizeof(*MOD_EXP_SIZE),
147 &alg_size, &func_id)) {
151 alg_size_in_bytes = alg_size >> 3;
152 rte_memcpy(cookie->input_array[0] + alg_size_in_bytes -
153 asym_op->modex.base.length
154 , asym_op->modex.base.data,
155 asym_op->modex.base.length);
156 rte_memcpy(cookie->input_array[1] + alg_size_in_bytes -
157 xform->modex.exponent.length
158 , xform->modex.exponent.data,
159 xform->modex.exponent.length);
160 rte_memcpy(cookie->input_array[2] + alg_size_in_bytes -
161 xform->modex.modulus.length,
162 xform->modex.modulus.data,
163 xform->modex.modulus.length);
164 cookie->alg_size = alg_size;
165 qat_req->pke_hdr.cd_pars.func_id = func_id;
166 qat_req->input_param_count = QAT_ASYM_MODEXP_NUM_IN_PARAMS;
167 qat_req->output_param_count = QAT_ASYM_MODEXP_NUM_OUT_PARAMS;
168 #if RTE_LOG_DP_LEVEL >= RTE_LOG_DEBUG
169 QAT_DP_HEXDUMP_LOG(DEBUG, "ModExp base",
170 cookie->input_array[0],
172 QAT_DP_HEXDUMP_LOG(DEBUG, "ModExp exponent",
173 cookie->input_array[1],
175 QAT_DP_HEXDUMP_LOG(DEBUG, " ModExpmodulus",
176 cookie->input_array[2],
179 } else if (xform->xform_type == RTE_CRYPTO_ASYM_XFORM_MODINV) {
180 err = qat_asym_check_nonzero(xform->modinv.modulus);
182 QAT_LOG(ERR, "Empty modulus in modular multiplicative"
183 " inverse, aborting this operation");
187 alg_size_in_bytes = max_of(2, asym_op->modinv.base.length,
188 xform->modinv.modulus.length);
189 alg_size = alg_size_in_bytes << 3;
191 if (xform->modinv.modulus.data[
192 xform->modinv.modulus.length - 1] & 0x01) {
193 if (qat_asym_get_sz_and_func_id(MOD_INV_IDS_ODD,
194 sizeof(MOD_INV_IDS_ODD)/
195 sizeof(*MOD_INV_IDS_ODD),
196 &alg_size, &func_id)) {
200 if (qat_asym_get_sz_and_func_id(MOD_INV_IDS_EVEN,
201 sizeof(MOD_INV_IDS_EVEN)/
202 sizeof(*MOD_INV_IDS_EVEN),
203 &alg_size, &func_id)) {
208 alg_size_in_bytes = alg_size >> 3;
209 rte_memcpy(cookie->input_array[0] + alg_size_in_bytes -
210 asym_op->modinv.base.length
211 , asym_op->modinv.base.data,
212 asym_op->modinv.base.length);
213 rte_memcpy(cookie->input_array[1] + alg_size_in_bytes -
214 xform->modinv.modulus.length
215 , xform->modinv.modulus.data,
216 xform->modinv.modulus.length);
217 cookie->alg_size = alg_size;
218 qat_req->pke_hdr.cd_pars.func_id = func_id;
219 qat_req->input_param_count =
220 QAT_ASYM_MODINV_NUM_IN_PARAMS;
221 qat_req->output_param_count =
222 QAT_ASYM_MODINV_NUM_OUT_PARAMS;
223 #if RTE_LOG_DP_LEVEL >= RTE_LOG_DEBUG
224 QAT_DP_HEXDUMP_LOG(DEBUG, "ModInv base",
225 cookie->input_array[0],
227 QAT_DP_HEXDUMP_LOG(DEBUG, "ModInv modulus",
228 cookie->input_array[1],
231 } else if (xform->xform_type == RTE_CRYPTO_ASYM_XFORM_RSA) {
232 err = qat_asym_check_nonzero(xform->rsa.n);
234 QAT_LOG(ERR, "Empty modulus in RSA"
235 " inverse, aborting this operation");
239 alg_size_in_bytes = xform->rsa.n.length;
240 alg_size = alg_size_in_bytes << 3;
242 qat_req->input_param_count =
243 QAT_ASYM_RSA_NUM_IN_PARAMS;
244 qat_req->output_param_count =
245 QAT_ASYM_RSA_NUM_OUT_PARAMS;
247 if (asym_op->rsa.op_type == RTE_CRYPTO_ASYM_OP_ENCRYPT ||
248 asym_op->rsa.op_type ==
249 RTE_CRYPTO_ASYM_OP_VERIFY) {
251 if (qat_asym_get_sz_and_func_id(RSA_ENC_IDS,
253 sizeof(*RSA_ENC_IDS),
254 &alg_size, &func_id)) {
257 "Not supported RSA parameter size (key)");
260 alg_size_in_bytes = alg_size >> 3;
261 if (asym_op->rsa.op_type == RTE_CRYPTO_ASYM_OP_ENCRYPT) {
262 switch (asym_op->rsa.pad) {
263 case RTE_CRYPTO_RSA_PADDING_NONE:
264 rte_memcpy(cookie->input_array[0] +
266 asym_op->rsa.message.length
267 , asym_op->rsa.message.data,
268 asym_op->rsa.message.length);
273 "Invalid RSA padding (Encryption)");
276 #if RTE_LOG_DP_LEVEL >= RTE_LOG_DEBUG
277 QAT_DP_HEXDUMP_LOG(DEBUG, "RSA Message",
278 cookie->input_array[0],
282 switch (asym_op->rsa.pad) {
283 case RTE_CRYPTO_RSA_PADDING_NONE:
284 rte_memcpy(cookie->input_array[0],
285 asym_op->rsa.sign.data,
291 "Invalid RSA padding (Verify)");
295 #if RTE_LOG_DP_LEVEL >= RTE_LOG_DEBUG
296 QAT_DP_HEXDUMP_LOG(DEBUG, " RSA Signature",
297 cookie->input_array[0],
302 rte_memcpy(cookie->input_array[1] +
306 xform->rsa.e.length);
307 rte_memcpy(cookie->input_array[2] +
311 xform->rsa.n.length);
313 cookie->alg_size = alg_size;
314 qat_req->pke_hdr.cd_pars.func_id = func_id;
316 #if RTE_LOG_DP_LEVEL >= RTE_LOG_DEBUG
317 QAT_DP_HEXDUMP_LOG(DEBUG, "RSA Public Key",
318 cookie->input_array[1], alg_size_in_bytes);
319 QAT_DP_HEXDUMP_LOG(DEBUG, "RSA Modulus",
320 cookie->input_array[2], alg_size_in_bytes);
323 if (asym_op->rsa.op_type ==
324 RTE_CRYPTO_ASYM_OP_DECRYPT) {
325 switch (asym_op->rsa.pad) {
326 case RTE_CRYPTO_RSA_PADDING_NONE:
327 rte_memcpy(cookie->input_array[0]
328 + alg_size_in_bytes -
329 asym_op->rsa.cipher.length,
330 asym_op->rsa.cipher.data,
331 asym_op->rsa.cipher.length);
335 "Invalid padding of RSA (Decrypt)");
339 } else if (asym_op->rsa.op_type ==
340 RTE_CRYPTO_ASYM_OP_SIGN) {
341 switch (asym_op->rsa.pad) {
342 case RTE_CRYPTO_RSA_PADDING_NONE:
343 rte_memcpy(cookie->input_array[0]
344 + alg_size_in_bytes -
345 asym_op->rsa.message.length,
346 asym_op->rsa.message.data,
347 asym_op->rsa.message.length);
351 "Invalid padding of RSA (Signature)");
356 if (xform->rsa.key_type == RTE_RSA_KET_TYPE_QT) {
357 QAT_LOG(ERR, "RSA CRT not implemented");
359 } else if (xform->rsa.key_type ==
360 RTE_RSA_KEY_TYPE_EXP) {
361 if (qat_asym_get_sz_and_func_id(
364 sizeof(*RSA_DEC_IDS),
365 &alg_size, &func_id)) {
368 alg_size_in_bytes = alg_size >> 3;
369 rte_memcpy(cookie->input_array[1] +
373 xform->rsa.d.length);
374 rte_memcpy(cookie->input_array[2] +
378 xform->rsa.n.length);
379 #if RTE_LOG_DP_LEVEL >= RTE_LOG_DEBUG
380 QAT_DP_HEXDUMP_LOG(DEBUG, "RSA ciphertext",
381 cookie->input_array[0],
383 QAT_DP_HEXDUMP_LOG(DEBUG, "RSA d", cookie->input_array[1],
385 QAT_DP_HEXDUMP_LOG(DEBUG, "RSA n", cookie->input_array[2],
389 cookie->alg_size = alg_size;
390 qat_req->pke_hdr.cd_pars.func_id = func_id;
392 QAT_LOG(ERR, "Invalid RSA key type");
397 QAT_LOG(ERR, "Invalid asymmetric crypto xform");
404 qat_asym_build_request(void *in_op,
407 __rte_unused enum qat_device_gen qat_dev_gen)
409 struct qat_asym_session *ctx;
410 struct rte_crypto_op *op = (struct rte_crypto_op *)in_op;
411 struct rte_crypto_asym_op *asym_op = op->asym;
412 struct icp_qat_fw_pke_request *qat_req =
413 (struct icp_qat_fw_pke_request *)out_msg;
414 struct qat_asym_op_cookie *cookie =
415 (struct qat_asym_op_cookie *)op_cookie;
418 op->status = RTE_CRYPTO_OP_STATUS_NOT_PROCESSED;
419 if (op->sess_type == RTE_CRYPTO_OP_WITH_SESSION) {
420 ctx = (struct qat_asym_session *)
421 get_asym_session_private_data(
422 op->asym->session, cryptodev_qat_asym_driver_id);
423 if (unlikely(ctx == NULL)) {
424 QAT_LOG(ERR, "Session has not been created for this device");
427 rte_mov64((uint8_t *)qat_req, (const uint8_t *)&(ctx->req_tmpl));
428 err = qat_asym_fill_arrays(asym_op, qat_req, cookie, ctx->xform);
430 op->status = RTE_CRYPTO_OP_STATUS_INVALID_ARGS;
433 } else if (op->sess_type == RTE_CRYPTO_OP_SESSIONLESS) {
434 qat_fill_req_tmpl(qat_req);
435 err = qat_asym_fill_arrays(asym_op, qat_req, cookie,
438 op->status = RTE_CRYPTO_OP_STATUS_INVALID_ARGS;
442 QAT_DP_LOG(ERR, "Invalid session/xform settings");
443 op->status = RTE_CRYPTO_OP_STATUS_INVALID_SESSION;
447 qat_req->pke_mid.opaque = (uint64_t)(uintptr_t)op;
448 qat_req->pke_mid.src_data_addr = cookie->input_addr;
449 qat_req->pke_mid.dest_data_addr = cookie->output_addr;
451 #if RTE_LOG_DP_LEVEL >= RTE_LOG_DEBUG
452 QAT_DP_HEXDUMP_LOG(DEBUG, "qat_req:", qat_req,
453 sizeof(struct icp_qat_fw_pke_request));
459 qat_req->pke_mid.opaque = (uint64_t)(uintptr_t)op;
461 #if RTE_LOG_DP_LEVEL >= RTE_LOG_DEBUG
462 QAT_DP_HEXDUMP_LOG(DEBUG, "qat_req:", qat_req,
463 sizeof(struct icp_qat_fw_pke_request));
466 qat_req->output_param_count = 0;
467 qat_req->input_param_count = 0;
468 qat_req->pke_hdr.service_type = ICP_QAT_FW_COMN_REQ_NULL;
469 cookie->error |= err;
474 static void qat_asym_collect_response(struct rte_crypto_op *rx_op,
475 struct qat_asym_op_cookie *cookie,
476 struct rte_crypto_asym_xform *xform)
478 size_t alg_size, alg_size_in_bytes = 0;
479 struct rte_crypto_asym_op *asym_op = rx_op->asym;
481 if (xform->xform_type == RTE_CRYPTO_ASYM_XFORM_MODEX) {
482 rte_crypto_param n = xform->modex.modulus;
484 alg_size = cookie->alg_size;
485 alg_size_in_bytes = alg_size >> 3;
486 uint8_t *modexp_result = asym_op->modex.result.data;
488 if (rx_op->status == RTE_CRYPTO_OP_STATUS_NOT_PROCESSED) {
489 rte_memcpy(modexp_result +
490 (asym_op->modex.result.length -
492 cookie->output_array[0] + alg_size_in_bytes
495 rx_op->status = RTE_CRYPTO_OP_STATUS_SUCCESS;
496 #if RTE_LOG_DP_LEVEL >= RTE_LOG_DEBUG
497 QAT_DP_HEXDUMP_LOG(DEBUG, "ModExp result",
498 cookie->output_array[0],
503 } else if (xform->xform_type == RTE_CRYPTO_ASYM_XFORM_MODINV) {
504 rte_crypto_param n = xform->modinv.modulus;
506 alg_size = cookie->alg_size;
507 alg_size_in_bytes = alg_size >> 3;
508 uint8_t *modinv_result = asym_op->modinv.result.data;
510 if (rx_op->status == RTE_CRYPTO_OP_STATUS_NOT_PROCESSED) {
511 rte_memcpy(modinv_result + (asym_op->modinv.result.length
513 cookie->output_array[0] + alg_size_in_bytes
514 - n.length, n.length);
515 rx_op->status = RTE_CRYPTO_OP_STATUS_SUCCESS;
516 #if RTE_LOG_DP_LEVEL >= RTE_LOG_DEBUG
517 QAT_DP_HEXDUMP_LOG(DEBUG, "ModInv result",
518 cookie->output_array[0],
522 } else if (xform->xform_type == RTE_CRYPTO_ASYM_XFORM_RSA) {
524 alg_size = cookie->alg_size;
525 alg_size_in_bytes = alg_size >> 3;
526 if (asym_op->rsa.op_type == RTE_CRYPTO_ASYM_OP_ENCRYPT ||
527 asym_op->rsa.op_type ==
528 RTE_CRYPTO_ASYM_OP_VERIFY) {
529 if (asym_op->rsa.op_type ==
530 RTE_CRYPTO_ASYM_OP_ENCRYPT) {
531 uint8_t *rsa_result = asym_op->rsa.cipher.data;
533 rte_memcpy(rsa_result,
534 cookie->output_array[0],
536 rx_op->status = RTE_CRYPTO_OP_STATUS_SUCCESS;
537 #if RTE_LOG_DP_LEVEL >= RTE_LOG_DEBUG
538 QAT_DP_HEXDUMP_LOG(DEBUG, "RSA Encrypted data",
539 cookie->output_array[0],
542 } else if (asym_op->rsa.op_type ==
543 RTE_CRYPTO_ASYM_OP_VERIFY) {
544 uint8_t *rsa_result = asym_op->rsa.cipher.data;
546 switch (asym_op->rsa.pad) {
547 case RTE_CRYPTO_RSA_PADDING_NONE:
548 rte_memcpy(rsa_result,
549 cookie->output_array[0],
552 RTE_CRYPTO_OP_STATUS_SUCCESS;
553 #if RTE_LOG_DP_LEVEL >= RTE_LOG_DEBUG
554 QAT_DP_HEXDUMP_LOG(DEBUG, "RSA Signature",
555 cookie->output_array[0],
560 QAT_LOG(ERR, "Padding not supported");
562 RTE_CRYPTO_OP_STATUS_ERROR;
567 if (asym_op->rsa.op_type ==
568 RTE_CRYPTO_ASYM_OP_DECRYPT) {
569 uint8_t *rsa_result = asym_op->rsa.message.data;
571 switch (asym_op->rsa.pad) {
572 case RTE_CRYPTO_RSA_PADDING_NONE:
573 rte_memcpy(rsa_result,
574 cookie->output_array[0],
578 QAT_LOG(ERR, "Padding not supported");
580 RTE_CRYPTO_OP_STATUS_ERROR;
583 #if RTE_LOG_DP_LEVEL >= RTE_LOG_DEBUG
584 QAT_DP_HEXDUMP_LOG(DEBUG, "RSA Decrypted Message",
585 rsa_result, alg_size_in_bytes);
587 } else if (asym_op->rsa.op_type == RTE_CRYPTO_ASYM_OP_SIGN) {
588 uint8_t *rsa_result = asym_op->rsa.sign.data;
590 rte_memcpy(rsa_result,
591 cookie->output_array[0],
593 rx_op->status = RTE_CRYPTO_OP_STATUS_SUCCESS;
594 #if RTE_LOG_DP_LEVEL >= RTE_LOG_DEBUG
595 QAT_DP_HEXDUMP_LOG(DEBUG, "RSA Signature",
596 cookie->output_array[0],
602 qat_clear_arrays_by_alg(cookie, xform->xform_type, alg_size_in_bytes,
607 qat_asym_process_response(void **op, uint8_t *resp,
610 struct qat_asym_session *ctx;
611 struct icp_qat_fw_pke_resp *resp_msg =
612 (struct icp_qat_fw_pke_resp *)resp;
613 struct rte_crypto_op *rx_op = (struct rte_crypto_op *)(uintptr_t)
615 struct qat_asym_op_cookie *cookie = op_cookie;
619 if (rx_op->status == RTE_CRYPTO_OP_STATUS_NOT_PROCESSED)
620 rx_op->status = RTE_CRYPTO_OP_STATUS_ERROR;
621 QAT_DP_LOG(ERR, "Cookie status returned error");
623 if (ICP_QAT_FW_PKE_RESP_PKE_STAT_GET(
624 resp_msg->pke_resp_hdr.resp_status.pke_resp_flags)) {
625 if (rx_op->status == RTE_CRYPTO_OP_STATUS_NOT_PROCESSED)
626 rx_op->status = RTE_CRYPTO_OP_STATUS_ERROR;
627 QAT_DP_LOG(ERR, "Asymmetric response status"
630 if (resp_msg->pke_resp_hdr.resp_status.comn_err_code) {
631 if (rx_op->status == RTE_CRYPTO_OP_STATUS_NOT_PROCESSED)
632 rx_op->status = RTE_CRYPTO_OP_STATUS_ERROR;
633 QAT_DP_LOG(ERR, "Asymmetric common status"
638 if (rx_op->sess_type == RTE_CRYPTO_OP_WITH_SESSION) {
639 ctx = (struct qat_asym_session *)get_asym_session_private_data(
640 rx_op->asym->session, cryptodev_qat_asym_driver_id);
641 qat_asym_collect_response(rx_op, cookie, ctx->xform);
642 } else if (rx_op->sess_type == RTE_CRYPTO_OP_SESSIONLESS) {
643 qat_asym_collect_response(rx_op, cookie, rx_op->asym->xform);
647 #if RTE_LOG_DP_LEVEL >= RTE_LOG_DEBUG
648 QAT_DP_HEXDUMP_LOG(DEBUG, "resp_msg:", resp_msg,
649 sizeof(struct icp_qat_fw_pke_resp));
654 qat_asym_session_configure(struct rte_cryptodev *dev,
655 struct rte_crypto_asym_xform *xform,
656 struct rte_cryptodev_asym_session *sess,
657 struct rte_mempool *mempool)
660 void *sess_private_data;
661 struct qat_asym_session *session;
663 if (rte_mempool_get(mempool, &sess_private_data)) {
665 "Couldn't get object from session mempool");
669 session = sess_private_data;
670 if (xform->xform_type == RTE_CRYPTO_ASYM_XFORM_MODEX) {
671 if (xform->modex.exponent.length == 0 ||
672 xform->modex.modulus.length == 0) {
673 QAT_LOG(ERR, "Invalid mod exp input parameter");
677 } else if (xform->xform_type == RTE_CRYPTO_ASYM_XFORM_MODINV) {
678 if (xform->modinv.modulus.length == 0) {
679 QAT_LOG(ERR, "Invalid mod inv input parameter");
683 } else if (xform->xform_type == RTE_CRYPTO_ASYM_XFORM_RSA) {
684 if (xform->rsa.n.length == 0) {
685 QAT_LOG(ERR, "Invalid rsa input parameter");
689 } else if (xform->xform_type >= RTE_CRYPTO_ASYM_XFORM_TYPE_LIST_END
690 || xform->xform_type <= RTE_CRYPTO_ASYM_XFORM_NONE) {
691 QAT_LOG(ERR, "Invalid asymmetric crypto xform");
695 QAT_LOG(ERR, "Asymmetric crypto xform not implemented");
700 session->xform = xform;
701 qat_asym_build_req_tmpl(sess_private_data);
702 set_asym_session_private_data(sess, dev->driver_id,
707 rte_mempool_put(mempool, sess_private_data);
711 unsigned int qat_asym_session_get_private_size(
712 struct rte_cryptodev *dev __rte_unused)
714 return RTE_ALIGN_CEIL(sizeof(struct qat_asym_session), 8);
718 qat_asym_session_clear(struct rte_cryptodev *dev,
719 struct rte_cryptodev_asym_session *sess)
721 uint8_t index = dev->driver_id;
722 void *sess_priv = get_asym_session_private_data(sess, index);
723 struct qat_asym_session *s = (struct qat_asym_session *)sess_priv;
726 memset(s, 0, qat_asym_session_get_private_size(dev));
727 struct rte_mempool *sess_mp = rte_mempool_from_obj(sess_priv);
729 set_asym_session_private_data(sess, index, NULL);
730 rte_mempool_put(sess_mp, sess_priv);