diff mbox series

[2/3] crypto/cnxk: update asym ECDSA messages in sync with ucode

Message ID 20210726044853.2232433-2-kirankumark@marvell.com (mailing list archive)
State Accepted, archived
Delegated to: akhil goyal
Headers show
Series [1/3] common/cnxk: add const values to ec groups | expand

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Kiran Kumar Kokkilagadda July 26, 2021, 4:48 a.m. UTC
From: Kiran Kumar K <kirankumark@marvell.com>

Adding changes to asymmetric ECDSA messages to align with
the new ucode for cnxk device.

Signed-off-by: Kiran Kumar K <kirankumark@marvell.com>
---
 drivers/crypto/cnxk/cnxk_ae.h        | 24 ++++++++++++++++++++----
 drivers/crypto/cnxk/cnxk_cryptodev.h |  2 +-
 2 files changed, 21 insertions(+), 5 deletions(-)
diff mbox series

Patch

diff --git a/drivers/crypto/cnxk/cnxk_ae.h b/drivers/crypto/cnxk/cnxk_ae.h
index c752e62ea5..174a940ab8 100644
--- a/drivers/crypto/cnxk/cnxk_ae.h
+++ b/drivers/crypto/cnxk/cnxk_ae.h
@@ -439,7 +439,7 @@  cnxk_ae_ecdsa_sign_prep(struct rte_crypto_ecdsa_op_param *ecdsa,
 	 * Please note, private key, order cannot exceed prime
 	 * length i.e 3 * p_align.
 	 */
-	dlen = sizeof(fpm_table_iova) + k_align + m_align + p_align * 3;
+	dlen = sizeof(fpm_table_iova) + k_align + m_align + p_align * 5;
 
 	memset(dptr, 0, dlen);
 
@@ -461,12 +461,18 @@  cnxk_ae_ecdsa_sign_prep(struct rte_crypto_ecdsa_op_param *ecdsa,
 	memcpy(dptr, ecdsa->message.data, message_len);
 	dptr += m_align;
 
+	memcpy(dptr, ec_grp->consta.data, prime_len);
+	dptr += p_align;
+
+	memcpy(dptr, ec_grp->constb.data, prime_len);
+	dptr += p_align;
+
 	/* Setup opcodes */
 	w4.s.opcode_major = ROC_AE_MAJOR_OP_ECDSA;
 	w4.s.opcode_minor = ROC_AE_MINOR_OP_ECDSA_SIGN;
 
 	w4.s.param1 = curveid | (message_len << 8);
-	w4.s.param2 = k_len;
+	w4.s.param2 = (pkey_len << 8) | k_len;
 	w4.s.dlen = dlen;
 
 	inst->w4.u64 = w4.u64;
@@ -521,7 +527,7 @@  cnxk_ae_ecdsa_verify_prep(struct rte_crypto_ecdsa_op_param *ecdsa,
 	 * Please note sign, public key and order can not exceed prime length
 	 * i.e. 6 * p_align
 	 */
-	dlen = sizeof(fpm_table_iova) + m_align + (6 * p_align);
+	dlen = sizeof(fpm_table_iova) + m_align + (8 * p_align);
 
 	memset(dptr, 0, dlen);
 
@@ -549,6 +555,12 @@  cnxk_ae_ecdsa_verify_prep(struct rte_crypto_ecdsa_op_param *ecdsa,
 	memcpy(dptr + qy_offset, ecdsa->q.y.data, qy_len);
 	dptr += p_align;
 
+	memcpy(dptr, ec_grp->consta.data, prime_len);
+	dptr += p_align;
+
+	memcpy(dptr, ec_grp->constb.data, prime_len);
+	dptr += p_align;
+
 	/* Setup opcodes */
 	w4.s.opcode_major = ROC_AE_MAJOR_OP_ECDSA;
 	w4.s.opcode_minor = ROC_AE_MINOR_OP_ECDSA_VERIFY;
@@ -612,7 +624,7 @@  cnxk_ae_ecpm_prep(struct rte_crypto_ecpm_op_param *ecpm,
 	 * scalar length),
 	 * Please note point length is equivalent to prime of the curve
 	 */
-	dlen = 3 * p_align + scalar_align;
+	dlen = 5 * p_align + scalar_align;
 
 	x1_offset = prime_len - x1_len;
 	y1_offset = prime_len - y1_len;
@@ -628,6 +640,10 @@  cnxk_ae_ecpm_prep(struct rte_crypto_ecpm_op_param *ecpm,
 	dptr += scalar_align;
 	memcpy(dptr, ec_grp->prime.data, ec_grp->prime.length);
 	dptr += p_align;
+	memcpy(dptr, ec_grp->consta.data, ec_grp->consta.length);
+	dptr += p_align;
+	memcpy(dptr, ec_grp->constb.data, ec_grp->constb.length);
+	dptr += p_align;
 
 	/* Setup opcodes */
 	w4.s.opcode_major = ROC_AE_MAJOR_OP_ECC;
diff --git a/drivers/crypto/cnxk/cnxk_cryptodev.h b/drivers/crypto/cnxk/cnxk_cryptodev.h
index ff46d16e58..b3856f7eaa 100644
--- a/drivers/crypto/cnxk/cnxk_cryptodev.h
+++ b/drivers/crypto/cnxk/cnxk_cryptodev.h
@@ -13,7 +13,7 @@ 
 #define CNXK_CPT_MAX_CAPS	 34
 #define CNXK_SEC_CRYPTO_MAX_CAPS 4
 #define CNXK_SEC_MAX_CAPS	 3
-#define CNXK_AE_EC_ID_MAX	 5
+#define CNXK_AE_EC_ID_MAX	 8
 /**
  * Device private data
  */