Skip to contentSkip to conversation

app/crypto-perf: support ML KEM

PATCH Superseded Pratik Senapati 2 participants 5 messages Jun 9 – Jun 24

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/2 app/crypto-perf: support ML KEM

Add ML-KEM512 support to test-crypto-perf.

---
 app/test-crypto-perf/cperf_ops.c             |  61 +++
 app/test-crypto-perf/cperf_options.h         |   2 +
 app/test-crypto-perf/cperf_options_parsing.c |  20 +
 app/test-crypto-perf/cperf_test_common.c     |   3 +-
 app/test-crypto-perf/cperf_test_vectors.c    | 470 +++++++++++++++++++
 app/test-crypto-perf/cperf_test_vectors.h    |  27 ++
 app/test-crypto-perf/main.c                  |  21 +-
 doc/guides/tools/cryptoperf.rst              |   1 +
 8 files changed, 603 insertions(+), 2 deletions(-)
app/test-crypto-perf/cperf_ops.c +61 -0
index 9297b4a3d3..806265f7bf 100644
@@ -208,6 +208,49 @@ cperf_set_ops_asym_sm2(struct rte_crypto_op **ops,
 	}
 }
 
+static void
+cperf_set_ops_asym_mlkem(struct rte_crypto_op **ops,
+		uint32_t src_buf_offset __rte_unused,
+		uint32_t dst_buf_offset __rte_unused, uint16_t nb_ops,
+		void *sess,
+		const struct cperf_options *options,
+		const struct cperf_test_vector *test_vector __rte_unused,
+		uint16_t iv_offset __rte_unused,
+		uint32_t *imix_idx __rte_unused,
+		uint64_t *tsc_start __rte_unused)
+{
+	uint16_t i;
+
+	for (i = 0; i < nb_ops; i++) {
+		struct rte_crypto_asym_op *asym_op = ops[i]->asym;
+
+		ops[i]->status = RTE_CRYPTO_OP_STATUS_NOT_PROCESSED;
+		rte_crypto_op_attach_asym_session(ops[i], sess);
+
+		if (options->asym_op_type == RTE_CRYPTO_ASYM_OP_ENCRYPT) {
+			asym_op->mlkem.op = RTE_CRYPTO_ML_KEM_OP_ENCAP;
+			asym_op->mlkem.encap.ek.data = options->mlkem_data->ek.data;
+			asym_op->mlkem.encap.ek.length = options->mlkem_data->ek.length;
+			asym_op->mlkem.encap.cipher.data = options->mlkem_data->cipher.data;
+			asym_op->mlkem.encap.cipher.length = options->mlkem_data->cipher.length;
+			asym_op->mlkem.encap.sk.data = options->mlkem_data->sk.data;
+			asym_op->mlkem.encap.sk.length = options->mlkem_data->sk.length;
+			asym_op->mlkem.encap.message.data = options->mlkem_data->message.data;
+			asym_op->mlkem.encap.message.length = options->mlkem_data->message.length;
+		} else if (options->asym_op_type == RTE_CRYPTO_ASYM_OP_DECRYPT) {
+			asym_op->mlkem.op = RTE_CRYPTO_ML_KEM_OP_DECAP;
+			asym_op->mlkem.decap.dk.data = options->mlkem_data->dk.data;
+			asym_op->mlkem.decap.dk.length = options->mlkem_data->dk.length;
+			asym_op->mlkem.decap.cipher.data = options->mlkem_data->cipher.data;
+			asym_op->mlkem.decap.cipher.length = options->mlkem_data->cipher.length;
+			asym_op->mlkem.decap.sk.data = options->mlkem_data->sk.data;
+			asym_op->mlkem.decap.sk.length = options->mlkem_data->sk.length;
+		} else {
+			rte_panic("Unsupported ML-KEM operation type %d\n", options->asym_op_type);
+		}
+	}
+}
+
 
 #ifdef RTE_LIB_SECURITY
 static void
@@ -1226,6 +1269,21 @@ cperf_create_session(struct rte_mempool *sess_mp,
 
 		return asym_sess;
 	}
+
+	if (options->op_type == CPERF_ASYM_MLKEM512) {
+		xform.next = NULL;
+		xform.xform_type = RTE_CRYPTO_ASYM_XFORM_ML_KEM;
+		xform.mlkem.type = RTE_CRYPTO_ML_KEM_512;
+
+		ret = rte_cryptodev_asym_session_create(dev_id, &xform, sess_mp, &asym_sess);
+		if (ret < 0) {
+			RTE_LOG(ERR, USER1, "ML-KEM Asym session create failed\n");
+			return NULL;
+		}
+		return asym_sess;
+	}
+
+
 #ifdef RTE_LIB_SECURITY
 	/*
 	 * security only
@@ -1542,6 +1600,9 @@ cperf_get_op_functions(const struct cperf_options *options,
 	case CPERF_ASYM_SM2:
 		op_fns->populate_ops = cperf_set_ops_asym_sm2;
 		break;
+	case CPERF_ASYM_MLKEM512:
+		op_fns->populate_ops = cperf_set_ops_asym_mlkem;
+		break;
 #ifdef RTE_LIB_SECURITY
 	case CPERF_PDCP:
 	case CPERF_DOCSIS:
app/test-crypto-perf/cperf_options.h +2 -0
index 428e8cb4f1..98b8eeec3e 100644
@@ -101,6 +101,7 @@ enum cperf_op_type {
 	CPERF_ASYM_SECP521R1,
 	CPERF_ASYM_ED25519,
 	CPERF_ASYM_SM2,
+	CPERF_ASYM_MLKEM512,
 	CPERF_TLS,
 };
 
@@ -187,6 +188,7 @@ struct cperf_options {
 	struct cperf_ecdsa_test_data *secp521r1_data;
 	struct cperf_eddsa_test_data *eddsa_data;
 	struct cperf_sm2_test_data *sm2_data;
+	struct cperf_mlkem_test_data *mlkem_data;
 	enum rte_crypto_asym_op_type asym_op_type;
 	enum rte_crypto_auth_algorithm asym_hash_alg;
 	struct cperf_rsa_test_data *rsa_data;
app/test-crypto-perf/cperf_options_parsing.c +20 -0
index 14e731586b..34afa938c8 100644
@@ -41,6 +41,7 @@ usage(char *progname)
 		" --optype cipher-only / auth-only / cipher-then-auth / auth-then-cipher /\n"
 		"        aead / pdcp / docsis / ipsec / modex / rsa / secp192r1 /\n"
 		"        secp224r1 / secp256r1 / secp384r1 / secp521r1 / eddsa / sm2 /\n"
+		"        mlkem_512 /\n"
 		"        tls-record : set operation type\n"
 		" --sessionless: enable session-less crypto operations\n"
 		" --shared-session: share 1 session across all queue pairs on crypto device\n"
@@ -559,6 +560,10 @@ parse_op_type(struct cperf_options *opts, const char *arg)
 			cperf_op_type_strs[CPERF_ASYM_SM2],
 			CPERF_ASYM_SM2
 		},
+		{
+			cperf_op_type_strs[CPERF_ASYM_MLKEM512],
+			CPERF_ASYM_MLKEM512
+		},
 		{
 			cperf_op_type_strs[CPERF_TLS],
 			CPERF_TLS
@@ -1174,6 +1179,7 @@ cperf_options_default(struct cperf_options *opts)
 	opts->secp521r1_data = &secp521r1_perf_data;
 	opts->eddsa_data = &ed25519_perf_data;
 	opts->sm2_data = &sm2_perf_data;
+	opts->mlkem_data = &mlkem_encap_perf_data[0];
 	opts->asym_op_type = RTE_CRYPTO_ASYM_OP_ENCRYPT;
 }
 
@@ -1669,6 +1675,18 @@ cperf_options_check(struct cperf_options *options)
 		}
 	}
 
+	if (options->op_type == CPERF_ASYM_MLKEM512) {
+		if (options->asym_op_type == RTE_CRYPTO_ASYM_OP_ENCRYPT)
+			options->mlkem_data = &mlkem_encap_perf_data[0];
+		else if (options->asym_op_type == RTE_CRYPTO_ASYM_OP_DECRYPT)
+			options->mlkem_data = &mlkem_decap_perf_data[0];
+		else {
+			RTE_LOG(ERR, USER1,
+				"ML-KEM operations only support encrypt (encapsulate) and decrypt (decapsulate)\n");
+			return -EINVAL;
+		}
+	}
+
 #ifdef RTE_LIB_SECURITY
 	if (options->op_type == CPERF_DOCSIS) {
 		if (check_docsis_buffer_length(options) < 0)
@@ -1741,6 +1759,8 @@ cperf_options_dump(struct cperf_options *opts)
 				   rte_crypto_asym_op_strings[opts->asym_op_type]);
 		if (opts->op_type == CPERF_ASYM_RSA)
 			printf("# rsa test name: %s\n", opts->rsa_data->name);
+		if (opts->op_type == CPERF_ASYM_MLKEM512)
+			printf("# mlkem test name: %s\n", opts->mlkem_data->name);
 	}
 	printf("# sessionless: %s\n", opts->sessionless ? "yes" : "no");
 	printf("# shared session: %s\n", opts->shared_session ? "yes" : "no");
app/test-crypto-perf/cperf_test_common.c +2 -1
index caf429b4d9..383d4bd940 100644
@@ -313,7 +313,8 @@ cperf_is_asym_test(const struct cperf_options *options)
 	    options->op_type == CPERF_ASYM_SECP384R1 ||
 	    options->op_type == CPERF_ASYM_SECP521R1 ||
 	    options->op_type == CPERF_ASYM_ED25519 ||
-	    options->op_type == CPERF_ASYM_SM2)
+	    options->op_type == CPERF_ASYM_SM2 ||
+		options->op_type == CPERF_ASYM_MLKEM512)
 		return true;
 
 	return false;
app/test-crypto-perf/cperf_test_vectors.c +470 -0

482 lines not on this page · raw message

app/test-crypto-perf/cperf_test_vectors.h +27 -0
index d6f18268c4..e498196ae3 100644
@@ -107,6 +107,31 @@ struct cperf_modex_test_data {
 	} result;
 };
 
+struct cperf_mlkem_test_data {
+	const char *name;
+	enum rte_crypto_ml_kem_type type;
+	struct {
+		uint8_t *data;
+		uint32_t length;
+	} dk;
+	struct {
+		uint8_t *data;
+		uint32_t length;
+	} ek;
+	struct {
+		uint8_t *data;
+		uint32_t length;
+	} message;
+	struct {
+		uint8_t *data;
+		uint32_t length;
+	} cipher;
+	struct {
+		uint8_t *data;
+		uint32_t length;
+	} sk;
+};
+
 #define TEST_DATA_SIZE 4096
 struct cperf_rsa_plaintext {
 	uint8_t data[TEST_DATA_SIZE];
@@ -188,5 +213,7 @@ extern struct cperf_rsa_test_data rsa_pub_perf_data[4];
 extern struct cperf_rsa_test_data rsa_exp_perf_data[4];
 extern struct cperf_rsa_test_data rsa_qt_perf_data[4];
 extern struct cperf_rsa_plaintext rsa_plaintext;
+extern struct cperf_mlkem_test_data mlkem_encap_perf_data[];
+extern struct cperf_mlkem_test_data mlkem_decap_perf_data[];
 
 #endif
app/test-crypto-perf/main.c +20 -1
index f63e892413..2e228201ab 100644
@@ -53,7 +53,8 @@ const char *cperf_op_type_strs[] = {
 	[CPERF_ASYM_SECP521R1] = "ecdsa_p521r1",
 	[CPERF_ASYM_ED25519] = "eddsa_25519",
 	[CPERF_ASYM_SM2] = "sm2",
-	[CPERF_TLS] = "tls-record"
+	[CPERF_TLS] = "tls-record",
+	[CPERF_ASYM_MLKEM512] = "mlkem_512",
 };
 
 const char *cperf_rsa_priv_keytype_strs[] = {
@@ -245,6 +246,7 @@ cperf_initialize_cryptodev(struct cperf_options *opts, uint8_t *enabled_cdevs)
 		case CPERF_ASYM_ED25519:
 		case CPERF_ASYM_SM2:
 		case CPERF_ASYM_RSA:
+		case CPERF_ASYM_MLKEM512:
 		case CPERF_ASYM_MODEX:
 			conf.ff_disable |= (RTE_CRYPTODEV_FF_SECURITY |
 					    RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO);
@@ -515,6 +517,23 @@ cperf_verify_devices_capabilities(struct cperf_options *opts,
 			}
 		}
 
+		if (opts->op_type == CPERF_ASYM_MLKEM512) {
+			asym_cap_idx.type = RTE_CRYPTO_ASYM_XFORM_ML_KEM;
+			asym_capability = rte_cryptodev_asym_capability_get(cdev_id, &asym_cap_idx);
+			if (asym_capability == NULL)
+				return -1;
+
+			if (opts->asym_op_type == RTE_CRYPTO_ASYM_OP_ENCRYPT)
+				opts->mlkem_data = &mlkem_encap_perf_data[0];
+			else if (opts->asym_op_type == RTE_CRYPTO_ASYM_OP_DECRYPT)
+				opts->mlkem_data = &mlkem_decap_perf_data[0];
+			else {
+				RTE_LOG(ERR, USER1, "Unsupported MLKEM operation type\n");
+				return -ENOTSUP;
+			}
+
+		}
+
 		if (opts->op_type == CPERF_AUTH_ONLY ||
 				opts->op_type == CPERF_CIPHER_THEN_AUTH ||
 				opts->op_type == CPERF_AUTH_THEN_CIPHER) {
doc/guides/tools/cryptoperf.rst +1 -0
index d7ee468e17..13f9db66f4 100644
@@ -183,6 +183,7 @@ The following are the application command-line options:
            eddsa_25519
            rsa
            sm2
+           mlkem_512
            ipsec
            tls-record
 
Signature · 1 line
2.43.0
#1 lore raw

PATCH v2 2/2 app/crypto-perf: support ML DSA

Add ML-DSA44 support to test-crypto-perf.

---
 app/test-crypto-perf/cperf_ops.c             |   70 +
 app/test-crypto-perf/cperf_options.h         |    2 +
 app/test-crypto-perf/cperf_options_parsing.c |   20 +-
 app/test-crypto-perf/cperf_test_common.c     |    3 +-
 app/test-crypto-perf/cperf_test_vectors.c    | 1661 ++++++++++++++++++
 app/test-crypto-perf/cperf_test_vectors.h    |   37 +
 app/test-crypto-perf/main.c                  |   17 +
 doc/guides/tools/cryptoperf.rst              |    1 +
 8 files changed, 1809 insertions(+), 2 deletions(-)
app/test-crypto-perf/cperf_ops.c +70 -0
index 806265f7bf..7d3a74b505 100644
@@ -251,6 +251,58 @@ cperf_set_ops_asym_mlkem(struct rte_crypto_op **ops,
 	}
 }
 
+static void
+cperf_set_ops_asym_mldsa(struct rte_crypto_op **ops,
+		uint32_t src_buf_offset __rte_unused,
+		uint32_t dst_buf_offset __rte_unused, uint16_t nb_ops,
+		void *sess,
+		const struct cperf_options *options,
+		const struct cperf_test_vector *test_vector __rte_unused,
+		uint16_t iv_offset __rte_unused,
+		uint32_t *imix_idx __rte_unused,
+		uint64_t *tsc_start __rte_unused)
+{
+	uint16_t i;
+
+	for (i = 0; i < nb_ops; i++) {
+		struct rte_crypto_asym_op *asym_op = ops[i]->asym;
+
+		ops[i]->status = RTE_CRYPTO_OP_STATUS_NOT_PROCESSED;
+		rte_crypto_op_attach_asym_session(ops[i], sess);
+
+		if (options->asym_op_type == RTE_CRYPTO_ASYM_OP_SIGN) {
+			asym_op->mldsa.op = RTE_CRYPTO_ML_DSA_OP_SIGN;
+			asym_op->mldsa.siggen.privkey.data = options->mldsa_data->privkey.data;
+			asym_op->mldsa.siggen.privkey.length = options->mldsa_data->privkey.length;
+			asym_op->mldsa.siggen.message.data = options->mldsa_data->message.data;
+			asym_op->mldsa.siggen.message.length = options->mldsa_data->message.length;
+			asym_op->mldsa.siggen.sign.data = options->mldsa_data->sign.data;
+			asym_op->mldsa.siggen.sign.length = options->mldsa_data->sign.length;
+			asym_op->mldsa.siggen.ctx.data = options->mldsa_data->ctx.data;
+			asym_op->mldsa.siggen.ctx.length = options->mldsa_data->ctx.length;
+			asym_op->mldsa.siggen.seed.data = options->mldsa_data->seed.data;
+			asym_op->mldsa.siggen.seed.length = options->mldsa_data->seed.length;
+			asym_op->mldsa.siggen.mu.data = options->mldsa_data->mu.data;
+			asym_op->mldsa.siggen.mu.length = options->mldsa_data->mu.length;
+			asym_op->mldsa.siggen.hash = options->mldsa_data->hash;
+		} else if (options->asym_op_type == RTE_CRYPTO_ASYM_OP_VERIFY) {
+			asym_op->mldsa.op = RTE_CRYPTO_ML_DSA_OP_VERIFY;
+			asym_op->mldsa.sigver.pubkey.data = options->mldsa_data->pubkey.data;
+			asym_op->mldsa.sigver.pubkey.length = options->mldsa_data->pubkey.length;
+			asym_op->mldsa.sigver.message.data = options->mldsa_data->message.data;
+			asym_op->mldsa.sigver.message.length = options->mldsa_data->message.length;
+			asym_op->mldsa.sigver.sign.data = options->mldsa_data->sign.data;
+			asym_op->mldsa.sigver.sign.length = options->mldsa_data->sign.length;
+			asym_op->mldsa.sigver.ctx.data = options->mldsa_data->ctx.data;
+			asym_op->mldsa.sigver.ctx.length = options->mldsa_data->ctx.length;
+			asym_op->mldsa.sigver.mu.data = options->mldsa_data->mu.data;
+			asym_op->mldsa.sigver.mu.length = options->mldsa_data->mu.length;
+			asym_op->mldsa.sigver.hash = options->mldsa_data->hash;
+		} else {
+			rte_panic("Unsupported ML-DSA operation type %d\n", options->asym_op_type);
+		}
+	}
+}
 
 #ifdef RTE_LIB_SECURITY
 static void
@@ -1269,6 +1321,21 @@ cperf_create_session(struct rte_mempool *sess_mp,
 
 		return asym_sess;
 	}
+	if (options->op_type == CPERF_ASYM_MLDSA44) {
+		xform.next = NULL;
+		xform.xform_type = RTE_CRYPTO_ASYM_XFORM_ML_DSA;
+		xform.mldsa.type = RTE_CRYPTO_ML_DSA_44;
+		xform.mldsa.sign_deterministic =
+		   options->mldsa_data->sign_deterministic;
+		xform.mldsa.sign_prehash = false;
+
+		ret = rte_cryptodev_asym_session_create(dev_id, &xform, sess_mp, &asym_sess);
+		if (ret < 0) {
+			RTE_LOG(ERR, USER1, "ML-DSA Asym session create failed\n");
+			return NULL;
+		}
+		return asym_sess;
+	}
 
 	if (options->op_type == CPERF_ASYM_MLKEM512) {
 		xform.next = NULL;
@@ -1600,6 +1667,9 @@ cperf_get_op_functions(const struct cperf_options *options,
 	case CPERF_ASYM_SM2:
 		op_fns->populate_ops = cperf_set_ops_asym_sm2;
 		break;
+	case CPERF_ASYM_MLDSA44:
+		op_fns->populate_ops = cperf_set_ops_asym_mldsa;
+		break;
 	case CPERF_ASYM_MLKEM512:
 		op_fns->populate_ops = cperf_set_ops_asym_mlkem;
 		break;
app/test-crypto-perf/cperf_options.h +2 -0
index 98b8eeec3e..d8ceca2424 100644
@@ -101,6 +101,7 @@ enum cperf_op_type {
 	CPERF_ASYM_SECP521R1,
 	CPERF_ASYM_ED25519,
 	CPERF_ASYM_SM2,
+	CPERF_ASYM_MLDSA44,
 	CPERF_ASYM_MLKEM512,
 	CPERF_TLS,
 };
@@ -189,6 +190,7 @@ struct cperf_options {
 	struct cperf_eddsa_test_data *eddsa_data;
 	struct cperf_sm2_test_data *sm2_data;
 	struct cperf_mlkem_test_data *mlkem_data;
+	struct cperf_mldsa_test_data *mldsa_data;
 	enum rte_crypto_asym_op_type asym_op_type;
 	enum rte_crypto_auth_algorithm asym_hash_alg;
 	struct cperf_rsa_test_data *rsa_data;
app/test-crypto-perf/cperf_options_parsing.c +19 -1
index 34afa938c8..44c2a7173a 100644
@@ -41,7 +41,7 @@ usage(char *progname)
 		" --optype cipher-only / auth-only / cipher-then-auth / auth-then-cipher /\n"
 		"        aead / pdcp / docsis / ipsec / modex / rsa / secp192r1 /\n"
 		"        secp224r1 / secp256r1 / secp384r1 / secp521r1 / eddsa / sm2 /\n"
-		"        mlkem_512 /\n"
+		"        mlkem_512 / mldsa_44 /\n"
 		"        tls-record : set operation type\n"
 		" --sessionless: enable session-less crypto operations\n"
 		" --shared-session: share 1 session across all queue pairs on crypto device\n"
@@ -560,6 +560,10 @@ parse_op_type(struct cperf_options *opts, const char *arg)
 			cperf_op_type_strs[CPERF_ASYM_SM2],
 			CPERF_ASYM_SM2
 		},
+		{
+			cperf_op_type_strs[CPERF_ASYM_MLDSA44],
+			CPERF_ASYM_MLDSA44
+		},
 		{
 			cperf_op_type_strs[CPERF_ASYM_MLKEM512],
 			CPERF_ASYM_MLKEM512
@@ -1180,6 +1184,7 @@ cperf_options_default(struct cperf_options *opts)
 	opts->eddsa_data = &ed25519_perf_data;
 	opts->sm2_data = &sm2_perf_data;
 	opts->mlkem_data = &mlkem_encap_perf_data[0];
+	opts->mldsa_data = &mldsa_sign_perf_data[0];
 	opts->asym_op_type = RTE_CRYPTO_ASYM_OP_ENCRYPT;
 }
 
@@ -1709,6 +1714,17 @@ cperf_options_check(struct cperf_options *options)
 	}
 #endif
 
+	if (options->op_type == CPERF_ASYM_MLDSA44) {
+		if (options->asym_op_type == RTE_CRYPTO_ASYM_OP_SIGN)
+			options->mldsa_data = &mldsa_sign_perf_data[0];
+		else if (options->asym_op_type == RTE_CRYPTO_ASYM_OP_VERIFY)
+			options->mldsa_data = &mldsa_verify_perf_data[0];
+		else {
+			RTE_LOG(ERR, USER1, "ML-DSA only supports sign and verify operations\n");
+			return -EINVAL;
+		}
+	}
+
 	return 0;
 }
 
@@ -1759,6 +1775,8 @@ cperf_options_dump(struct cperf_options *opts)
 				   rte_crypto_asym_op_strings[opts->asym_op_type]);
 		if (opts->op_type == CPERF_ASYM_RSA)
 			printf("# rsa test name: %s\n", opts->rsa_data->name);
+		if (opts->op_type == CPERF_ASYM_MLDSA44)
+			printf("# mldsa test name: %s\n", opts->mldsa_data->name);
 		if (opts->op_type == CPERF_ASYM_MLKEM512)
 			printf("# mlkem test name: %s\n", opts->mlkem_data->name);
 	}
app/test-crypto-perf/cperf_test_common.c +2 -1
index 383d4bd940..0bcaa6dfd8 100644
@@ -314,7 +314,8 @@ cperf_is_asym_test(const struct cperf_options *options)
 	    options->op_type == CPERF_ASYM_SECP521R1 ||
 	    options->op_type == CPERF_ASYM_ED25519 ||
 	    options->op_type == CPERF_ASYM_SM2 ||
-		options->op_type == CPERF_ASYM_MLKEM512)
+		options->op_type == CPERF_ASYM_MLKEM512 ||
+		options->op_type == CPERF_ASYM_MLDSA44)
 		return true;
 
 	return false;
app/test-crypto-perf/cperf_test_vectors.c +1661 -0

1,673 lines not on this page · raw message

app/test-crypto-perf/cperf_test_vectors.h +37 -0
index e498196ae3..6b4b4f22b4 100644
@@ -188,6 +188,41 @@ struct cperf_sm2_test_data {
 	int curve;
 };
 
+struct cperf_mldsa_test_data {
+	const char *name;
+	enum rte_crypto_ml_dsa_type type;
+	struct {
+		uint8_t *data;
+		uint32_t length;
+	} privkey;
+	struct {
+		uint8_t *data;
+		uint32_t length;
+	} pubkey;
+	struct {
+		uint8_t *data;
+		uint32_t length;
+	} message;
+	struct {
+		uint8_t *data;
+		uint32_t length;
+	} sign;
+	struct {
+		uint8_t *data;
+		uint32_t length;
+	} ctx;
+	struct {
+		uint8_t *data;
+		uint32_t length;
+	} seed;
+	struct {
+		uint8_t *data;
+		uint32_t length;
+	} mu;
+	enum rte_crypto_auth_algorithm hash;
+	bool sign_deterministic;
+};
+
 struct cperf_test_vector*
 cperf_test_vector_get_dummy(struct cperf_options *options);
 
@@ -215,5 +250,7 @@ extern struct cperf_rsa_test_data rsa_qt_perf_data[4];
 extern struct cperf_rsa_plaintext rsa_plaintext;
 extern struct cperf_mlkem_test_data mlkem_encap_perf_data[];
 extern struct cperf_mlkem_test_data mlkem_decap_perf_data[];
+extern struct cperf_mldsa_test_data mldsa_sign_perf_data[];
+extern struct cperf_mldsa_test_data mldsa_verify_perf_data[];
 
 #endif
app/test-crypto-perf/main.c +17 -0
index 2e228201ab..c4d844d225 100644
@@ -55,6 +55,7 @@ const char *cperf_op_type_strs[] = {
 	[CPERF_ASYM_SM2] = "sm2",
 	[CPERF_TLS] = "tls-record",
 	[CPERF_ASYM_MLKEM512] = "mlkem_512",
+	[CPERF_ASYM_MLDSA44] = "mldsa_44",
 };
 
 const char *cperf_rsa_priv_keytype_strs[] = {
@@ -247,6 +248,7 @@ cperf_initialize_cryptodev(struct cperf_options *opts, uint8_t *enabled_cdevs)
 		case CPERF_ASYM_SM2:
 		case CPERF_ASYM_RSA:
 		case CPERF_ASYM_MLKEM512:
+		case CPERF_ASYM_MLDSA44:
 		case CPERF_ASYM_MODEX:
 			conf.ff_disable |= (RTE_CRYPTODEV_FF_SECURITY |
 					    RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO);
@@ -516,6 +518,21 @@ cperf_verify_devices_capabilities(struct cperf_options *opts,
 				opts->sm2_data->sign_s.length = sm2_perf_data.sign_s.length;
 			}
 		}
+		if (opts->op_type == CPERF_ASYM_MLDSA44) {
+			asym_cap_idx.type = RTE_CRYPTO_ASYM_XFORM_ML_DSA;
+			asym_capability = rte_cryptodev_asym_capability_get(cdev_id, &asym_cap_idx);
+			if (asym_capability == NULL)
+				return -1;
+
+			if (opts->asym_op_type == RTE_CRYPTO_ASYM_OP_SIGN)
+				opts->mldsa_data = &mldsa_sign_perf_data[0];
+			else if (opts->asym_op_type == RTE_CRYPTO_ASYM_OP_VERIFY)
+				opts->mldsa_data = &mldsa_verify_perf_data[0];
+			else {
+				RTE_LOG(ERR, USER1, "Unsupported MLDSA operation type\n");
+				return -ENOTSUP;
+			}
+		}
 
 		if (opts->op_type == CPERF_ASYM_MLKEM512) {
 			asym_cap_idx.type = RTE_CRYPTO_ASYM_XFORM_ML_KEM;
doc/guides/tools/cryptoperf.rst +1 -0
index 13f9db66f4..7a7ee5c884 100644
@@ -184,6 +184,7 @@ The following are the application command-line options:
            rsa
            sm2
            mlkem_512
+           mldsa_44
            ipsec
            tls-record
 
Signature · 1 line
2.43.0
#2 lore raw

PATCH v3 1/2 app/crypto-perf: support ML KEM

In reply to Pratik Senapati

Add ML-KEM512 support to test-crypto-perf.

---
 app/test-crypto-perf/cperf_ops.c             |  61 +++
 app/test-crypto-perf/cperf_options.h         |   2 +
 app/test-crypto-perf/cperf_options_parsing.c |  20 +
 app/test-crypto-perf/cperf_test_common.c     |   3 +-
 app/test-crypto-perf/cperf_test_vectors.c    | 470 +++++++++++++++++++
 app/test-crypto-perf/cperf_test_vectors.h    |  27 ++
 app/test-crypto-perf/main.c                  |  21 +-
 doc/guides/tools/cryptoperf.rst              |   1 +
 8 files changed, 603 insertions(+), 2 deletions(-)
app/test-crypto-perf/cperf_ops.c +61 -0
index 9297b4a3d3..c30ffc3476 100644
@@ -208,6 +208,49 @@ cperf_set_ops_asym_sm2(struct rte_crypto_op **ops,
 	}
 }
 
+static void
+cperf_set_ops_asym_mlkem(struct rte_crypto_op **ops,
+		uint32_t src_buf_offset __rte_unused,
+		uint32_t dst_buf_offset __rte_unused, uint16_t nb_ops,
+		void *sess,
+		const struct cperf_options *options,
+		const struct cperf_test_vector *test_vector __rte_unused,
+		uint16_t iv_offset __rte_unused,
+		uint32_t *imix_idx __rte_unused,
+		uint64_t *tsc_start __rte_unused)
+{
+	uint16_t i;
+
+	for (i = 0; i < nb_ops; i++) {
+		struct rte_crypto_asym_op *asym_op = ops[i]->asym;
+
+		ops[i]->status = RTE_CRYPTO_OP_STATUS_NOT_PROCESSED;
+		rte_crypto_op_attach_asym_session(ops[i], sess);
+
+		if (options->asym_op_type == RTE_CRYPTO_ASYM_OP_ENCRYPT) {
+			asym_op->mlkem.op = RTE_CRYPTO_ML_KEM_OP_ENCAP;
+			asym_op->mlkem.encap.ek.data = options->mlkem_data->ek.data;
+			asym_op->mlkem.encap.ek.length = options->mlkem_data->ek.length;
+			asym_op->mlkem.encap.cipher.data = options->mlkem_data->cipher.data;
+			asym_op->mlkem.encap.cipher.length = options->mlkem_data->cipher.length;
+			asym_op->mlkem.encap.sk.data = options->mlkem_data->sk.data;
+			asym_op->mlkem.encap.sk.length = options->mlkem_data->sk.length;
+			asym_op->mlkem.encap.message.data = options->mlkem_data->message.data;
+			asym_op->mlkem.encap.message.length = options->mlkem_data->message.length;
+		} else if (options->asym_op_type == RTE_CRYPTO_ASYM_OP_DECRYPT) {
+			asym_op->mlkem.op = RTE_CRYPTO_ML_KEM_OP_DECAP;
+			asym_op->mlkem.decap.dk.data = options->mlkem_data->dk.data;
+			asym_op->mlkem.decap.dk.length = options->mlkem_data->dk.length;
+			asym_op->mlkem.decap.cipher.data = options->mlkem_data->cipher.data;
+			asym_op->mlkem.decap.cipher.length = options->mlkem_data->cipher.length;
+			asym_op->mlkem.decap.sk.data = options->mlkem_data->sk.data;
+			asym_op->mlkem.decap.sk.length = options->mlkem_data->sk.length;
+		} else {
+			rte_panic("Unsupported ML-KEM operation type %d\n", options->asym_op_type);
+		}
+	}
+}
+
 
 #ifdef RTE_LIB_SECURITY
 static void
@@ -1226,6 +1269,21 @@ cperf_create_session(struct rte_mempool *sess_mp,
 
 		return asym_sess;
 	}
+
+	if (options->op_type == CPERF_ASYM_MLKEM512) {
+		xform.next = NULL;
+		xform.xform_type = RTE_CRYPTO_ASYM_XFORM_ML_KEM;
+		xform.mlkem.type = RTE_CRYPTO_ML_KEM_512;
+
+		ret = rte_cryptodev_asym_session_create(dev_id, &xform, sess_mp, &asym_sess);
+		if (ret < 0 || asym_sess == NULL) {
+			RTE_LOG(ERR, USER1, "ML-KEM Asym session create failed\n");
+			return NULL;
+		}
+		return asym_sess;
+	}
+
+
 #ifdef RTE_LIB_SECURITY
 	/*
 	 * security only
@@ -1542,6 +1600,9 @@ cperf_get_op_functions(const struct cperf_options *options,
 	case CPERF_ASYM_SM2:
 		op_fns->populate_ops = cperf_set_ops_asym_sm2;
 		break;
+	case CPERF_ASYM_MLKEM512:
+		op_fns->populate_ops = cperf_set_ops_asym_mlkem;
+		break;
 #ifdef RTE_LIB_SECURITY
 	case CPERF_PDCP:
 	case CPERF_DOCSIS:
app/test-crypto-perf/cperf_options.h +2 -0
index 428e8cb4f1..98b8eeec3e 100644
@@ -101,6 +101,7 @@ enum cperf_op_type {
 	CPERF_ASYM_SECP521R1,
 	CPERF_ASYM_ED25519,
 	CPERF_ASYM_SM2,
+	CPERF_ASYM_MLKEM512,
 	CPERF_TLS,
 };
 
@@ -187,6 +188,7 @@ struct cperf_options {
 	struct cperf_ecdsa_test_data *secp521r1_data;
 	struct cperf_eddsa_test_data *eddsa_data;
 	struct cperf_sm2_test_data *sm2_data;
+	struct cperf_mlkem_test_data *mlkem_data;
 	enum rte_crypto_asym_op_type asym_op_type;
 	enum rte_crypto_auth_algorithm asym_hash_alg;
 	struct cperf_rsa_test_data *rsa_data;
app/test-crypto-perf/cperf_options_parsing.c +20 -0
index 14e731586b..34afa938c8 100644
@@ -41,6 +41,7 @@ usage(char *progname)
 		" --optype cipher-only / auth-only / cipher-then-auth / auth-then-cipher /\n"
 		"        aead / pdcp / docsis / ipsec / modex / rsa / secp192r1 /\n"
 		"        secp224r1 / secp256r1 / secp384r1 / secp521r1 / eddsa / sm2 /\n"
+		"        mlkem_512 /\n"
 		"        tls-record : set operation type\n"
 		" --sessionless: enable session-less crypto operations\n"
 		" --shared-session: share 1 session across all queue pairs on crypto device\n"
@@ -559,6 +560,10 @@ parse_op_type(struct cperf_options *opts, const char *arg)
 			cperf_op_type_strs[CPERF_ASYM_SM2],
 			CPERF_ASYM_SM2
 		},
+		{
+			cperf_op_type_strs[CPERF_ASYM_MLKEM512],
+			CPERF_ASYM_MLKEM512
+		},
 		{
 			cperf_op_type_strs[CPERF_TLS],
 			CPERF_TLS
@@ -1174,6 +1179,7 @@ cperf_options_default(struct cperf_options *opts)
 	opts->secp521r1_data = &secp521r1_perf_data;
 	opts->eddsa_data = &ed25519_perf_data;
 	opts->sm2_data = &sm2_perf_data;
+	opts->mlkem_data = &mlkem_encap_perf_data[0];
 	opts->asym_op_type = RTE_CRYPTO_ASYM_OP_ENCRYPT;
 }
 
@@ -1669,6 +1675,18 @@ cperf_options_check(struct cperf_options *options)
 		}
 	}
 
+	if (options->op_type == CPERF_ASYM_MLKEM512) {
+		if (options->asym_op_type == RTE_CRYPTO_ASYM_OP_ENCRYPT)
+			options->mlkem_data = &mlkem_encap_perf_data[0];
+		else if (options->asym_op_type == RTE_CRYPTO_ASYM_OP_DECRYPT)
+			options->mlkem_data = &mlkem_decap_perf_data[0];
+		else {
+			RTE_LOG(ERR, USER1,
+				"ML-KEM operations only support encrypt (encapsulate) and decrypt (decapsulate)\n");
+			return -EINVAL;
+		}
+	}
+
 #ifdef RTE_LIB_SECURITY
 	if (options->op_type == CPERF_DOCSIS) {
 		if (check_docsis_buffer_length(options) < 0)
@@ -1741,6 +1759,8 @@ cperf_options_dump(struct cperf_options *opts)
 				   rte_crypto_asym_op_strings[opts->asym_op_type]);
 		if (opts->op_type == CPERF_ASYM_RSA)
 			printf("# rsa test name: %s\n", opts->rsa_data->name);
+		if (opts->op_type == CPERF_ASYM_MLKEM512)
+			printf("# mlkem test name: %s\n", opts->mlkem_data->name);
 	}
 	printf("# sessionless: %s\n", opts->sessionless ? "yes" : "no");
 	printf("# shared session: %s\n", opts->shared_session ? "yes" : "no");
app/test-crypto-perf/cperf_test_common.c +2 -1
index caf429b4d9..383d4bd940 100644
@@ -313,7 +313,8 @@ cperf_is_asym_test(const struct cperf_options *options)
 	    options->op_type == CPERF_ASYM_SECP384R1 ||
 	    options->op_type == CPERF_ASYM_SECP521R1 ||
 	    options->op_type == CPERF_ASYM_ED25519 ||
-	    options->op_type == CPERF_ASYM_SM2)
+	    options->op_type == CPERF_ASYM_SM2 ||
+		options->op_type == CPERF_ASYM_MLKEM512)
 		return true;
 
 	return false;
app/test-crypto-perf/cperf_test_vectors.c +470 -0

482 lines not on this page · raw message

app/test-crypto-perf/cperf_test_vectors.h +27 -0
index d6f18268c4..e498196ae3 100644
@@ -107,6 +107,31 @@ struct cperf_modex_test_data {
 	} result;
 };
 
+struct cperf_mlkem_test_data {
+	const char *name;
+	enum rte_crypto_ml_kem_type type;
+	struct {
+		uint8_t *data;
+		uint32_t length;
+	} dk;
+	struct {
+		uint8_t *data;
+		uint32_t length;
+	} ek;
+	struct {
+		uint8_t *data;
+		uint32_t length;
+	} message;
+	struct {
+		uint8_t *data;
+		uint32_t length;
+	} cipher;
+	struct {
+		uint8_t *data;
+		uint32_t length;
+	} sk;
+};
+
 #define TEST_DATA_SIZE 4096
 struct cperf_rsa_plaintext {
 	uint8_t data[TEST_DATA_SIZE];
@@ -188,5 +213,7 @@ extern struct cperf_rsa_test_data rsa_pub_perf_data[4];
 extern struct cperf_rsa_test_data rsa_exp_perf_data[4];
 extern struct cperf_rsa_test_data rsa_qt_perf_data[4];
 extern struct cperf_rsa_plaintext rsa_plaintext;
+extern struct cperf_mlkem_test_data mlkem_encap_perf_data[];
+extern struct cperf_mlkem_test_data mlkem_decap_perf_data[];
 
 #endif
app/test-crypto-perf/main.c +20 -1
index f63e892413..2e228201ab 100644
@@ -53,7 +53,8 @@ const char *cperf_op_type_strs[] = {
 	[CPERF_ASYM_SECP521R1] = "ecdsa_p521r1",
 	[CPERF_ASYM_ED25519] = "eddsa_25519",
 	[CPERF_ASYM_SM2] = "sm2",
-	[CPERF_TLS] = "tls-record"
+	[CPERF_TLS] = "tls-record",
+	[CPERF_ASYM_MLKEM512] = "mlkem_512",
 };
 
 const char *cperf_rsa_priv_keytype_strs[] = {
@@ -245,6 +246,7 @@ cperf_initialize_cryptodev(struct cperf_options *opts, uint8_t *enabled_cdevs)
 		case CPERF_ASYM_ED25519:
 		case CPERF_ASYM_SM2:
 		case CPERF_ASYM_RSA:
+		case CPERF_ASYM_MLKEM512:
 		case CPERF_ASYM_MODEX:
 			conf.ff_disable |= (RTE_CRYPTODEV_FF_SECURITY |
 					    RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO);
@@ -515,6 +517,23 @@ cperf_verify_devices_capabilities(struct cperf_options *opts,
 			}
 		}
 
+		if (opts->op_type == CPERF_ASYM_MLKEM512) {
+			asym_cap_idx.type = RTE_CRYPTO_ASYM_XFORM_ML_KEM;
+			asym_capability = rte_cryptodev_asym_capability_get(cdev_id, &asym_cap_idx);
+			if (asym_capability == NULL)
+				return -1;
+
+			if (opts->asym_op_type == RTE_CRYPTO_ASYM_OP_ENCRYPT)
+				opts->mlkem_data = &mlkem_encap_perf_data[0];
+			else if (opts->asym_op_type == RTE_CRYPTO_ASYM_OP_DECRYPT)
+				opts->mlkem_data = &mlkem_decap_perf_data[0];
+			else {
+				RTE_LOG(ERR, USER1, "Unsupported MLKEM operation type\n");
+				return -ENOTSUP;
+			}
+
+		}
+
 		if (opts->op_type == CPERF_AUTH_ONLY ||
 				opts->op_type == CPERF_CIPHER_THEN_AUTH ||
 				opts->op_type == CPERF_AUTH_THEN_CIPHER) {
doc/guides/tools/cryptoperf.rst +1 -0
index d7ee468e17..13f9db66f4 100644
@@ -183,6 +183,7 @@ The following are the application command-line options:
            eddsa_25519
            rsa
            sm2
+           mlkem_512
            ipsec
            tls-record
 
Signature · 1 line
2.43.0
#3 lore raw

PATCH v3 2/2 app/crypto-perf: support ML DSA

Add ML-DSA44 support to test-crypto-perf.

---
 app/test-crypto-perf/cperf_ops.c             |   70 +
 app/test-crypto-perf/cperf_options.h         |    2 +
 app/test-crypto-perf/cperf_options_parsing.c |   20 +-
 app/test-crypto-perf/cperf_test_common.c     |    3 +-
 app/test-crypto-perf/cperf_test_vectors.c    | 1661 ++++++++++++++++++
 app/test-crypto-perf/cperf_test_vectors.h    |   37 +
 app/test-crypto-perf/main.c                  |   17 +
 doc/guides/tools/cryptoperf.rst              |    1 +
 8 files changed, 1809 insertions(+), 2 deletions(-)
app/test-crypto-perf/cperf_ops.c +70 -0
index c30ffc3476..873fa3b59f 100644
@@ -251,6 +251,58 @@ cperf_set_ops_asym_mlkem(struct rte_crypto_op **ops,
 	}
 }
 
+static void
+cperf_set_ops_asym_mldsa(struct rte_crypto_op **ops,
+		uint32_t src_buf_offset __rte_unused,
+		uint32_t dst_buf_offset __rte_unused, uint16_t nb_ops,
+		void *sess,
+		const struct cperf_options *options,
+		const struct cperf_test_vector *test_vector __rte_unused,
+		uint16_t iv_offset __rte_unused,
+		uint32_t *imix_idx __rte_unused,
+		uint64_t *tsc_start __rte_unused)
+{
+	uint16_t i;
+
+	for (i = 0; i < nb_ops; i++) {
+		struct rte_crypto_asym_op *asym_op = ops[i]->asym;
+
+		ops[i]->status = RTE_CRYPTO_OP_STATUS_NOT_PROCESSED;
+		rte_crypto_op_attach_asym_session(ops[i], sess);
+
+		if (options->asym_op_type == RTE_CRYPTO_ASYM_OP_SIGN) {
+			asym_op->mldsa.op = RTE_CRYPTO_ML_DSA_OP_SIGN;
+			asym_op->mldsa.siggen.privkey.data = options->mldsa_data->privkey.data;
+			asym_op->mldsa.siggen.privkey.length = options->mldsa_data->privkey.length;
+			asym_op->mldsa.siggen.message.data = options->mldsa_data->message.data;
+			asym_op->mldsa.siggen.message.length = options->mldsa_data->message.length;
+			asym_op->mldsa.siggen.sign.data = options->mldsa_data->sign.data;
+			asym_op->mldsa.siggen.sign.length = options->mldsa_data->sign.length;
+			asym_op->mldsa.siggen.ctx.data = options->mldsa_data->ctx.data;
+			asym_op->mldsa.siggen.ctx.length = options->mldsa_data->ctx.length;
+			asym_op->mldsa.siggen.seed.data = options->mldsa_data->seed.data;
+			asym_op->mldsa.siggen.seed.length = options->mldsa_data->seed.length;
+			asym_op->mldsa.siggen.mu.data = options->mldsa_data->mu.data;
+			asym_op->mldsa.siggen.mu.length = options->mldsa_data->mu.length;
+			asym_op->mldsa.siggen.hash = options->mldsa_data->hash;
+		} else if (options->asym_op_type == RTE_CRYPTO_ASYM_OP_VERIFY) {
+			asym_op->mldsa.op = RTE_CRYPTO_ML_DSA_OP_VERIFY;
+			asym_op->mldsa.sigver.pubkey.data = options->mldsa_data->pubkey.data;
+			asym_op->mldsa.sigver.pubkey.length = options->mldsa_data->pubkey.length;
+			asym_op->mldsa.sigver.message.data = options->mldsa_data->message.data;
+			asym_op->mldsa.sigver.message.length = options->mldsa_data->message.length;
+			asym_op->mldsa.sigver.sign.data = options->mldsa_data->sign.data;
+			asym_op->mldsa.sigver.sign.length = options->mldsa_data->sign.length;
+			asym_op->mldsa.sigver.ctx.data = options->mldsa_data->ctx.data;
+			asym_op->mldsa.sigver.ctx.length = options->mldsa_data->ctx.length;
+			asym_op->mldsa.sigver.mu.data = options->mldsa_data->mu.data;
+			asym_op->mldsa.sigver.mu.length = options->mldsa_data->mu.length;
+			asym_op->mldsa.sigver.hash = options->mldsa_data->hash;
+		} else {
+			rte_panic("Unsupported ML-DSA operation type %d\n", options->asym_op_type);
+		}
+	}
+}
 
 #ifdef RTE_LIB_SECURITY
 static void
@@ -1269,6 +1321,21 @@ cperf_create_session(struct rte_mempool *sess_mp,
 
 		return asym_sess;
 	}
+	if (options->op_type == CPERF_ASYM_MLDSA44) {
+		xform.next = NULL;
+		xform.xform_type = RTE_CRYPTO_ASYM_XFORM_ML_DSA;
+		xform.mldsa.type = RTE_CRYPTO_ML_DSA_44;
+		xform.mldsa.sign_deterministic =
+		   options->mldsa_data->sign_deterministic;
+		xform.mldsa.sign_prehash = false;
+
+		ret = rte_cryptodev_asym_session_create(dev_id, &xform, sess_mp, &asym_sess);
+		if (ret < 0 || asym_sess == NULL) {
+			RTE_LOG(ERR, USER1, "ML-DSA Asym session create failed\n");
+			return NULL;
+		}
+		return asym_sess;
+	}
 
 	if (options->op_type == CPERF_ASYM_MLKEM512) {
 		xform.next = NULL;
@@ -1600,6 +1667,9 @@ cperf_get_op_functions(const struct cperf_options *options,
 	case CPERF_ASYM_SM2:
 		op_fns->populate_ops = cperf_set_ops_asym_sm2;
 		break;
+	case CPERF_ASYM_MLDSA44:
+		op_fns->populate_ops = cperf_set_ops_asym_mldsa;
+		break;
 	case CPERF_ASYM_MLKEM512:
 		op_fns->populate_ops = cperf_set_ops_asym_mlkem;
 		break;
app/test-crypto-perf/cperf_options.h +2 -0
index 98b8eeec3e..d8ceca2424 100644
@@ -101,6 +101,7 @@ enum cperf_op_type {
 	CPERF_ASYM_SECP521R1,
 	CPERF_ASYM_ED25519,
 	CPERF_ASYM_SM2,
+	CPERF_ASYM_MLDSA44,
 	CPERF_ASYM_MLKEM512,
 	CPERF_TLS,
 };
@@ -189,6 +190,7 @@ struct cperf_options {
 	struct cperf_eddsa_test_data *eddsa_data;
 	struct cperf_sm2_test_data *sm2_data;
 	struct cperf_mlkem_test_data *mlkem_data;
+	struct cperf_mldsa_test_data *mldsa_data;
 	enum rte_crypto_asym_op_type asym_op_type;
 	enum rte_crypto_auth_algorithm asym_hash_alg;
 	struct cperf_rsa_test_data *rsa_data;
app/test-crypto-perf/cperf_options_parsing.c +19 -1
index 34afa938c8..44c2a7173a 100644
@@ -41,7 +41,7 @@ usage(char *progname)
 		" --optype cipher-only / auth-only / cipher-then-auth / auth-then-cipher /\n"
 		"        aead / pdcp / docsis / ipsec / modex / rsa / secp192r1 /\n"
 		"        secp224r1 / secp256r1 / secp384r1 / secp521r1 / eddsa / sm2 /\n"
-		"        mlkem_512 /\n"
+		"        mlkem_512 / mldsa_44 /\n"
 		"        tls-record : set operation type\n"
 		" --sessionless: enable session-less crypto operations\n"
 		" --shared-session: share 1 session across all queue pairs on crypto device\n"
@@ -560,6 +560,10 @@ parse_op_type(struct cperf_options *opts, const char *arg)
 			cperf_op_type_strs[CPERF_ASYM_SM2],
 			CPERF_ASYM_SM2
 		},
+		{
+			cperf_op_type_strs[CPERF_ASYM_MLDSA44],
+			CPERF_ASYM_MLDSA44
+		},
 		{
 			cperf_op_type_strs[CPERF_ASYM_MLKEM512],
 			CPERF_ASYM_MLKEM512
@@ -1180,6 +1184,7 @@ cperf_options_default(struct cperf_options *opts)
 	opts->eddsa_data = &ed25519_perf_data;
 	opts->sm2_data = &sm2_perf_data;
 	opts->mlkem_data = &mlkem_encap_perf_data[0];
+	opts->mldsa_data = &mldsa_sign_perf_data[0];
 	opts->asym_op_type = RTE_CRYPTO_ASYM_OP_ENCRYPT;
 }
 
@@ -1709,6 +1714,17 @@ cperf_options_check(struct cperf_options *options)
 	}
 #endif
 
+	if (options->op_type == CPERF_ASYM_MLDSA44) {
+		if (options->asym_op_type == RTE_CRYPTO_ASYM_OP_SIGN)
+			options->mldsa_data = &mldsa_sign_perf_data[0];
+		else if (options->asym_op_type == RTE_CRYPTO_ASYM_OP_VERIFY)
+			options->mldsa_data = &mldsa_verify_perf_data[0];
+		else {
+			RTE_LOG(ERR, USER1, "ML-DSA only supports sign and verify operations\n");
+			return -EINVAL;
+		}
+	}
+
 	return 0;
 }
 
@@ -1759,6 +1775,8 @@ cperf_options_dump(struct cperf_options *opts)
 				   rte_crypto_asym_op_strings[opts->asym_op_type]);
 		if (opts->op_type == CPERF_ASYM_RSA)
 			printf("# rsa test name: %s\n", opts->rsa_data->name);
+		if (opts->op_type == CPERF_ASYM_MLDSA44)
+			printf("# mldsa test name: %s\n", opts->mldsa_data->name);
 		if (opts->op_type == CPERF_ASYM_MLKEM512)
 			printf("# mlkem test name: %s\n", opts->mlkem_data->name);
 	}
app/test-crypto-perf/cperf_test_common.c +2 -1
index 383d4bd940..0bcaa6dfd8 100644
@@ -314,7 +314,8 @@ cperf_is_asym_test(const struct cperf_options *options)
 	    options->op_type == CPERF_ASYM_SECP521R1 ||
 	    options->op_type == CPERF_ASYM_ED25519 ||
 	    options->op_type == CPERF_ASYM_SM2 ||
-		options->op_type == CPERF_ASYM_MLKEM512)
+		options->op_type == CPERF_ASYM_MLKEM512 ||
+		options->op_type == CPERF_ASYM_MLDSA44)
 		return true;
 
 	return false;
app/test-crypto-perf/cperf_test_vectors.c +1661 -0

1,673 lines not on this page · raw message

app/test-crypto-perf/cperf_test_vectors.h +37 -0
index e498196ae3..6b4b4f22b4 100644
@@ -188,6 +188,41 @@ struct cperf_sm2_test_data {
 	int curve;
 };
 
+struct cperf_mldsa_test_data {
+	const char *name;
+	enum rte_crypto_ml_dsa_type type;
+	struct {
+		uint8_t *data;
+		uint32_t length;
+	} privkey;
+	struct {
+		uint8_t *data;
+		uint32_t length;
+	} pubkey;
+	struct {
+		uint8_t *data;
+		uint32_t length;
+	} message;
+	struct {
+		uint8_t *data;
+		uint32_t length;
+	} sign;
+	struct {
+		uint8_t *data;
+		uint32_t length;
+	} ctx;
+	struct {
+		uint8_t *data;
+		uint32_t length;
+	} seed;
+	struct {
+		uint8_t *data;
+		uint32_t length;
+	} mu;
+	enum rte_crypto_auth_algorithm hash;
+	bool sign_deterministic;
+};
+
 struct cperf_test_vector*
 cperf_test_vector_get_dummy(struct cperf_options *options);
 
@@ -215,5 +250,7 @@ extern struct cperf_rsa_test_data rsa_qt_perf_data[4];
 extern struct cperf_rsa_plaintext rsa_plaintext;
 extern struct cperf_mlkem_test_data mlkem_encap_perf_data[];
 extern struct cperf_mlkem_test_data mlkem_decap_perf_data[];
+extern struct cperf_mldsa_test_data mldsa_sign_perf_data[];
+extern struct cperf_mldsa_test_data mldsa_verify_perf_data[];
 
 #endif
app/test-crypto-perf/main.c +17 -0
index 2e228201ab..c4d844d225 100644
@@ -55,6 +55,7 @@ const char *cperf_op_type_strs[] = {
 	[CPERF_ASYM_SM2] = "sm2",
 	[CPERF_TLS] = "tls-record",
 	[CPERF_ASYM_MLKEM512] = "mlkem_512",
+	[CPERF_ASYM_MLDSA44] = "mldsa_44",
 };
 
 const char *cperf_rsa_priv_keytype_strs[] = {
@@ -247,6 +248,7 @@ cperf_initialize_cryptodev(struct cperf_options *opts, uint8_t *enabled_cdevs)
 		case CPERF_ASYM_SM2:
 		case CPERF_ASYM_RSA:
 		case CPERF_ASYM_MLKEM512:
+		case CPERF_ASYM_MLDSA44:
 		case CPERF_ASYM_MODEX:
 			conf.ff_disable |= (RTE_CRYPTODEV_FF_SECURITY |
 					    RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO);
@@ -516,6 +518,21 @@ cperf_verify_devices_capabilities(struct cperf_options *opts,
 				opts->sm2_data->sign_s.length = sm2_perf_data.sign_s.length;
 			}
 		}
+		if (opts->op_type == CPERF_ASYM_MLDSA44) {
+			asym_cap_idx.type = RTE_CRYPTO_ASYM_XFORM_ML_DSA;
+			asym_capability = rte_cryptodev_asym_capability_get(cdev_id, &asym_cap_idx);
+			if (asym_capability == NULL)
+				return -1;
+
+			if (opts->asym_op_type == RTE_CRYPTO_ASYM_OP_SIGN)
+				opts->mldsa_data = &mldsa_sign_perf_data[0];
+			else if (opts->asym_op_type == RTE_CRYPTO_ASYM_OP_VERIFY)
+				opts->mldsa_data = &mldsa_verify_perf_data[0];
+			else {
+				RTE_LOG(ERR, USER1, "Unsupported MLDSA operation type\n");
+				return -ENOTSUP;
+			}
+		}
 
 		if (opts->op_type == CPERF_ASYM_MLKEM512) {
 			asym_cap_idx.type = RTE_CRYPTO_ASYM_XFORM_ML_KEM;
doc/guides/tools/cryptoperf.rst +1 -0
index 13f9db66f4..7a7ee5c884 100644
@@ -184,6 +184,7 @@ The following are the application command-line options:
            rsa
            sm2
            mlkem_512
+           mldsa_44
            ipsec
            tls-record
 
Signature · 1 line
2.43.0
Applied
#4 lore raw
In reply to Pratik Senapati
Quoted 5 lines

Subject: [PATCH v3 1/2] app/crypto-perf: support ML KEM

Add ML-KEM512 support to test-crypto-perf.

Quoted 10 lines
---
 app/test-crypto-perf/cperf_ops.c             |  61 +++
 app/test-crypto-perf/cperf_options.h         |   2 +
 app/test-crypto-perf/cperf_options_parsing.c |  20 +
 app/test-crypto-perf/cperf_test_common.c     |   3 +-
 app/test-crypto-perf/cperf_test_vectors.c    | 470 +++++++++++++++++++
 app/test-crypto-perf/cperf_test_vectors.h    |  27 ++
 app/test-crypto-perf/main.c                  |  21 +-
 doc/guides/tools/cryptoperf.rst              |   1 +
 8 files changed, 603 insertions(+), 2 deletions(-)

Series Acked-by: Akhil Goyal <[email protected]>

Applied to dpdk-next-crypto