Route ML-KEM and ML-DSA ops through the cperf_test_vector mechanism
instead of accessing options->mlkem_data/mldsa_data directly in the
per-op setup functions.

Allocate writable rte_malloc'd buffers in cperf_test_vectors.c to
hold copies of the input data for each field.

Use rte_zmalloc for the test vector struct so unset pointer fields
are NULL-initialized; rte_free(NULL) is a defined no-op in DPDK.

Skip allocation for optional zero-length fields (ML-DSA privkey,
pubkey; ML-KEM ek, dk, message, sk) which are absent depending on
operation type.

Use a single err_free label with free_test_vector() to clean up on
any allocation failure.

Pre-allocate output buffers (ML-DSA sign, ML-KEM cipher and sk) as
a pool of nb_descriptors slots so each in-flight op gets its own
writable slice, preventing cross-op clobbering in burst mode.

Use rte_free_sensitive() for ML-KEM dk/sk and ML-DSA privkey to
zero private key material before freeing.

Validate op type before the per-op loop with an explicit panic on
unsupported types.

Signed-off-by: Pratik Senapati <[email protected]>
---
 app/test-crypto-perf/cperf_ops.c              | 154 ++++++-----------
 .../cperf_test_vector_parsing.c               |  12 ++
 app/test-crypto-perf/cperf_test_vectors.c     | 159 ++++++++++++++----
 app/test-crypto-perf/cperf_test_vectors.h     |  78 +++++++--
 4 files changed, 256 insertions(+), 147 deletions(-)

diff --git a/app/test-crypto-perf/cperf_ops.c b/app/test-crypto-perf/cperf_ops.c
index af30cb8359..01047ca76a 100644
--- a/app/test-crypto-perf/cperf_ops.c
+++ b/app/test-crypto-perf/cperf_ops.c
@@ -214,31 +214,17 @@ cperf_set_ops_asym_mlkem(struct rte_crypto_op **ops,
                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,
+               const struct cperf_test_vector *test_vector,
                uint16_t iv_offset __rte_unused,
                uint32_t *imix_idx __rte_unused,
                uint64_t *tsc_start __rte_unused)
 {
-       /* Intermediate writable buffers for static const test vectors */
-       static uint8_t ek_buf[1568];     /* ML-KEM-1024 ek max */
-       static uint8_t dk_buf[3168];     /* ML-KEM-1024 dk max */
-       static uint8_t msg_buf[32];      /* ML-KEM message (32 bytes) */
-       static uint8_t cipher_buf[1568]; /* ML-KEM-1024 cipher max */
-       static uint8_t sk_buf[32];       /* shared key (32 bytes) */
        uint16_t i;
 
-       if (options->asym_op_type == RTE_CRYPTO_ASYM_OP_ENCRYPT) {
-               memcpy(ek_buf, options->mlkem_data->ek.data,
-                      options->mlkem_data->ek.length);
-               if (options->mlkem_data->message.length)
-                       memcpy(msg_buf, options->mlkem_data->message.data,
-                              options->mlkem_data->message.length);
-       } else {
-               memcpy(dk_buf, options->mlkem_data->dk.data,
-                      options->mlkem_data->dk.length);
-               memcpy(cipher_buf, options->mlkem_data->cipher.data,
-                      options->mlkem_data->cipher.length);
-       }
+       if (options->asym_op_type != RTE_CRYPTO_ASYM_OP_ENCRYPT &&
+                       options->asym_op_type != RTE_CRYPTO_ASYM_OP_DECRYPT)
+               rte_panic("Unsupported ML-KEM operation type %d\n",
+                         options->asym_op_type);
 
        for (i = 0; i < nb_ops; i++) {
                struct rte_crypto_asym_op *asym_op = ops[i]->asym;
@@ -248,25 +234,25 @@ cperf_set_ops_asym_mlkem(struct rte_crypto_op **ops,
 
                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 = ek_buf;
-                       asym_op->mlkem.encap.ek.length = 
options->mlkem_data->ek.length;
-                       asym_op->mlkem.encap.cipher.data = cipher_buf;
-                       asym_op->mlkem.encap.cipher.length = 
options->mlkem_data->cipher.length;
-                       asym_op->mlkem.encap.sk.data = sk_buf;
-                       asym_op->mlkem.encap.sk.length = 
options->mlkem_data->sk.length;
-                       asym_op->mlkem.encap.message.data = msg_buf;
-                       asym_op->mlkem.encap.message.length = 
options->mlkem_data->message.length;
+                       asym_op->mlkem.encap.ek.data = 
test_vector->mlkem.ek.data;
+                       asym_op->mlkem.encap.ek.length = 
test_vector->mlkem.ek.length;
+                       asym_op->mlkem.encap.cipher.data = 
test_vector->mlkem.cipher.data +
+                                       (i * test_vector->mlkem.cipher.length);
+                       asym_op->mlkem.encap.cipher.length = 
test_vector->mlkem.cipher.length;
+                       asym_op->mlkem.encap.sk.data = 
test_vector->mlkem.sk.data +
+                                       (i * test_vector->mlkem.sk.length);
+                       asym_op->mlkem.encap.sk.length = 
test_vector->mlkem.sk.length;
+                       asym_op->mlkem.encap.message.data = 
test_vector->mlkem.message.data;
+                       asym_op->mlkem.encap.message.length = 
test_vector->mlkem.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 = dk_buf;
-                       asym_op->mlkem.decap.dk.length = 
options->mlkem_data->dk.length;
-                       asym_op->mlkem.decap.cipher.data = cipher_buf;
-                       asym_op->mlkem.decap.cipher.length = 
options->mlkem_data->cipher.length;
-                       asym_op->mlkem.decap.sk.data = sk_buf;
-                       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);
+                       asym_op->mlkem.decap.dk.data = 
test_vector->mlkem.dk.data;
+                       asym_op->mlkem.decap.dk.length = 
test_vector->mlkem.dk.length;
+                       asym_op->mlkem.decap.cipher.data = 
test_vector->mlkem.cipher.data;
+                       asym_op->mlkem.decap.cipher.length = 
test_vector->mlkem.cipher.length;
+                       asym_op->mlkem.decap.sk.data = 
test_vector->mlkem.sk.data +
+                                       (i * test_vector->mlkem.sk.length);
+                       asym_op->mlkem.decap.sk.length = 
test_vector->mlkem.sk.length;
                }
        }
 }
@@ -277,52 +263,17 @@ cperf_set_ops_asym_mldsa(struct rte_crypto_op **ops,
                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,
+               const struct cperf_test_vector *test_vector,
                uint16_t iv_offset __rte_unused,
                uint32_t *imix_idx __rte_unused,
                uint64_t *tsc_start __rte_unused)
 {
-       /* Intermediate writable buffers for static const test vectors */
-       static uint8_t privkey_buf[4896]; /* ML-DSA-87 privkey max */
-       static uint8_t pubkey_buf[2592];  /* ML-DSA-87 pubkey max */
-       static uint8_t msg_buf[256];      /* message */
-       static uint8_t sign_buf[4627];    /* ML-DSA-87 sign max */
-       static uint8_t ctx_buf[256];      /* context */
-       static uint8_t seed_buf[32];      /* seed */
-       static uint8_t mu_buf[64];        /* mu */
        uint16_t i;
 
-       if (options->asym_op_type == RTE_CRYPTO_ASYM_OP_SIGN) {
-               memcpy(privkey_buf, options->mldsa_data->privkey.data,
-                      options->mldsa_data->privkey.length);
-               if (options->mldsa_data->message.length)
-                       memcpy(msg_buf, options->mldsa_data->message.data,
-                              options->mldsa_data->message.length);
-               if (options->mldsa_data->ctx.length)
-                       memcpy(ctx_buf, options->mldsa_data->ctx.data,
-                              options->mldsa_data->ctx.length);
-               if (options->mldsa_data->seed.length)
-                       memcpy(seed_buf, options->mldsa_data->seed.data,
-                              options->mldsa_data->seed.length);
-               if (options->mldsa_data->mu.length)
-                       memcpy(mu_buf, options->mldsa_data->mu.data,
-                              options->mldsa_data->mu.length);
-       } else {
-               memcpy(pubkey_buf, options->mldsa_data->pubkey.data,
-                      options->mldsa_data->pubkey.length);
-               if (options->mldsa_data->message.length)
-                       memcpy(msg_buf, options->mldsa_data->message.data,
-                              options->mldsa_data->message.length);
-               if (options->mldsa_data->sign.length)
-                       memcpy(sign_buf, options->mldsa_data->sign.data,
-                              options->mldsa_data->sign.length);
-               if (options->mldsa_data->ctx.length)
-                       memcpy(ctx_buf, options->mldsa_data->ctx.data,
-                              options->mldsa_data->ctx.length);
-               if (options->mldsa_data->mu.length)
-                       memcpy(mu_buf, options->mldsa_data->mu.data,
-                              options->mldsa_data->mu.length);
-       }
+       if (options->asym_op_type != RTE_CRYPTO_ASYM_OP_SIGN &&
+                       options->asym_op_type != RTE_CRYPTO_ASYM_OP_VERIFY)
+               rte_panic("Unsupported ML-DSA operation type %d\n",
+                         options->asym_op_type);
 
        for (i = 0; i < nb_ops; i++) {
                struct rte_crypto_asym_op *asym_op = ops[i]->asym;
@@ -332,35 +283,33 @@ cperf_set_ops_asym_mldsa(struct rte_crypto_op **ops,
 
                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 = privkey_buf;
-                       asym_op->mldsa.siggen.privkey.length = 
options->mldsa_data->privkey.length;
-                       asym_op->mldsa.siggen.message.data = msg_buf;
-                       asym_op->mldsa.siggen.message.length = 
options->mldsa_data->message.length;
-                       asym_op->mldsa.siggen.sign.data = sign_buf;
-                       asym_op->mldsa.siggen.sign.length = 
options->mldsa_data->sign.length;
-                       asym_op->mldsa.siggen.ctx.data = ctx_buf;
-                       asym_op->mldsa.siggen.ctx.length = 
options->mldsa_data->ctx.length;
-                       asym_op->mldsa.siggen.seed.data = seed_buf;
-                       asym_op->mldsa.siggen.seed.length = 
options->mldsa_data->seed.length;
-                       asym_op->mldsa.siggen.mu.data = mu_buf;
-                       asym_op->mldsa.siggen.mu.length = 
options->mldsa_data->mu.length;
+                       asym_op->mldsa.siggen.privkey.data = 
test_vector->mldsa.privkey.data;
+                       asym_op->mldsa.siggen.privkey.length = 
test_vector->mldsa.privkey.length;
+                       asym_op->mldsa.siggen.message.data = 
test_vector->mldsa.message.data;
+                       asym_op->mldsa.siggen.message.length = 
test_vector->mldsa.message.length;
+                       asym_op->mldsa.siggen.sign.data = 
test_vector->mldsa.sign.data +
+                                       (i * test_vector->mldsa.sign.length);
+                       asym_op->mldsa.siggen.sign.length = 
test_vector->mldsa.sign.length;
+                       asym_op->mldsa.siggen.ctx.data = 
test_vector->mldsa.ctx.data;
+                       asym_op->mldsa.siggen.ctx.length = 
test_vector->mldsa.ctx.length;
+                       asym_op->mldsa.siggen.seed.data = 
test_vector->mldsa.seed.data;
+                       asym_op->mldsa.siggen.seed.length = 
test_vector->mldsa.seed.length;
+                       asym_op->mldsa.siggen.mu.data = 
test_vector->mldsa.mu.data;
+                       asym_op->mldsa.siggen.mu.length = 
test_vector->mldsa.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 = pubkey_buf;
-                       asym_op->mldsa.sigver.pubkey.length = 
options->mldsa_data->pubkey.length;
-                       asym_op->mldsa.sigver.message.data = msg_buf;
-                       asym_op->mldsa.sigver.message.length = 
options->mldsa_data->message.length;
-                       asym_op->mldsa.sigver.sign.data = sign_buf;
-                       asym_op->mldsa.sigver.sign.length = 
options->mldsa_data->sign.length;
-                       asym_op->mldsa.sigver.ctx.data = ctx_buf;
-                       asym_op->mldsa.sigver.ctx.length = 
options->mldsa_data->ctx.length;
-                       asym_op->mldsa.sigver.mu.data = mu_buf;
-                       asym_op->mldsa.sigver.mu.length = 
options->mldsa_data->mu.length;
+                       asym_op->mldsa.sigver.pubkey.data = 
test_vector->mldsa.pubkey.data;
+                       asym_op->mldsa.sigver.pubkey.length = 
test_vector->mldsa.pubkey.length;
+                       asym_op->mldsa.sigver.message.data = 
test_vector->mldsa.message.data;
+                       asym_op->mldsa.sigver.message.length = 
test_vector->mldsa.message.length;
+                       asym_op->mldsa.sigver.sign.data = 
test_vector->mldsa.sign.data;
+                       asym_op->mldsa.sigver.sign.length = 
test_vector->mldsa.sign.length;
+                       asym_op->mldsa.sigver.ctx.data = 
test_vector->mldsa.ctx.data;
+                       asym_op->mldsa.sigver.ctx.length = 
test_vector->mldsa.ctx.length;
+                       asym_op->mldsa.sigver.mu.data = 
test_vector->mldsa.mu.data;
+                       asym_op->mldsa.sigver.mu.length = 
test_vector->mldsa.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);
                }
        }
 }
@@ -470,8 +419,6 @@ cperf_set_ops_security_ipsec(struct rte_crypto_op **ops,
                ops[i]->status = RTE_CRYPTO_OP_STATUS_NOT_PROCESSED;
                rte_security_attach_session(ops[i], sess);
                sym_op->m_src = (struct rte_mbuf *)((uint8_t *)ops[i] + 
src_buf_offset);
-               if (options->is_outbound)
-                       rte_pktmbuf_reset(sym_op->m_src);
                sym_op->m_src->pkt_len = test_buffer_size;
 
                while ((m->next != NULL) && (offset >= m->data_len)) {
@@ -1384,6 +1331,7 @@ cperf_create_session(struct rte_mempool *sess_mp,
 
                return asym_sess;
        }
+
        switch (options->op_type) {
        case CPERF_ASYM_MLDSA44:
        case CPERF_ASYM_MLDSA65:
diff --git a/app/test-crypto-perf/cperf_test_vector_parsing.c 
b/app/test-crypto-perf/cperf_test_vector_parsing.c
index 5665fb425b..3d6df873cc 100644
--- a/app/test-crypto-perf/cperf_test_vector_parsing.c
+++ b/app/test-crypto-perf/cperf_test_vector_parsing.c
@@ -24,6 +24,18 @@ free_test_vector(struct cperf_test_vector *vector, struct 
cperf_options *opts)
        rte_free(vector->auth_iv.data);
        rte_free(vector->aad.data);
        rte_free(vector->digest.data);
+       rte_free(vector->mlkem.ek.data);
+       rte_free_sensitive(vector->mlkem.dk.data);
+       rte_free(vector->mlkem.message.data);
+       rte_free(vector->mlkem.cipher.data);
+       rte_free_sensitive(vector->mlkem.sk.data);
+       rte_free_sensitive(vector->mldsa.privkey.data);
+       rte_free(vector->mldsa.pubkey.data);
+       rte_free(vector->mldsa.message.data);
+       rte_free(vector->mldsa.sign.data);
+       rte_free(vector->mldsa.ctx.data);
+       rte_free(vector->mldsa.seed.data);
+       rte_free(vector->mldsa.mu.data);
 
        if (opts->test_file != NULL) {
                rte_free(vector->plaintext.data);
diff --git a/app/test-crypto-perf/cperf_test_vectors.c 
b/app/test-crypto-perf/cperf_test_vectors.c
index 09e65476ea..2c8a1c82ce 100644
--- a/app/test-crypto-perf/cperf_test_vectors.c
+++ b/app/test-crypto-perf/cperf_test_vectors.c
@@ -6,6 +6,7 @@
 #include <rte_malloc.h>
 
 #include "cperf_test_vectors.h"
+#include "cperf_test_vector_parsing.h"
 
 struct
 cperf_modex_test_data modex_perf_data[10] = {
@@ -5552,7 +5553,7 @@ uint8_t mldsa_44_extmu[] = {
        0xF5, 0x2E, 0x4B, 0x7C, 0xD6, 0x2A, 0xF4, 0x2E,
 };
 
-static const uint8_t mldsa_44_message_5_iter[] = {
+uint8_t mldsa_44_message_5_iter[] = {
        0x5E, 0x42, 0x43, 0x44, 0x99, 0x76, 0x99, 0x99,
        0xA3, 0x7F, 0x2B, 0xE1, 0x54, 0xC8, 0x0D, 0x6E,
        0x31, 0xBB, 0x85, 0x92, 0xF0, 0x5A, 0xD7, 0x23,
@@ -5568,7 +5569,7 @@ static const uint8_t mldsa_44_message_5_iter[] = {
        0x99, 0x99, 0x99, 0x9D, 0xAC, 0x48, 0x59, 0x77,
 };
 
-static const uint8_t mldsa_44_message_10_iter[] = {
+uint8_t mldsa_44_message_10_iter[] = {
        0x3F, 0x42, 0x43, 0x44, 0x99, 0x76, 0x99, 0x99,
        0xA3, 0x7F, 0x2B, 0xE1, 0x54, 0xC8, 0x0D, 0x6E,
        0x31, 0xBB, 0x85, 0x92, 0xF0, 0x5A, 0xD7, 0x23,
@@ -5584,7 +5585,7 @@ static const uint8_t mldsa_44_message_10_iter[] = {
        0x99, 0x99, 0x99, 0x9D, 0xAC, 0x48, 0x59, 0x77,
 };
 
-static const uint8_t mldsa_44_sign_1_iter[] = {
+uint8_t mldsa_44_sign_1_iter[] = {
        0xFD, 0x1F, 0x49, 0x0A, 0xFF, 0x04, 0x28, 0x4A,
        0xEF, 0xDE, 0x2F, 0xD2, 0x6E, 0x4B, 0x20, 0x12,
        0xCC, 0xF1, 0x6C, 0x35, 0x02, 0xE0, 0xE6, 0xE6,
@@ -5890,7 +5891,7 @@ static const uint8_t mldsa_44_sign_1_iter[] = {
        0x0F, 0x1E, 0x31, 0x43,
 };
 
-static const uint8_t mldsa_44_sign_5_iter[] = {
+uint8_t mldsa_44_sign_5_iter[] = {
        0x96, 0x98, 0xF9, 0xE6, 0x22, 0xEF, 0x58, 0xF4,
        0x57, 0x82, 0xF7, 0x40, 0x95, 0x1A, 0xE7, 0x9C,
        0x0E, 0x95, 0x77, 0xEA, 0x32, 0x86, 0xAE, 0x81,
@@ -6197,7 +6198,7 @@ static const uint8_t mldsa_44_sign_5_iter[] = {
 
 };
 
-static const uint8_t mldsa_44_sign_10_iter[] = {
+uint8_t mldsa_44_sign_10_iter[] = {
        0x21, 0x06, 0x63, 0xCE, 0xA8, 0xAA, 0x3A, 0x78,
        0xD9, 0xF1, 0x8E, 0x75, 0xF8, 0xA0, 0xC9, 0x89,
        0xD7, 0x85, 0xBF, 0xE4, 0x5C, 0xEB, 0x99, 0x45,
@@ -6504,7 +6505,7 @@ static const uint8_t mldsa_44_sign_10_iter[] = {
 
 };
 
-static const uint8_t mlkem_768_dk[] = {
+uint8_t mlkem_768_dk[] = {
        0x29, 0x18, 0xA0, 0x56, 0x30, 0x51, 0x93, 0xF1,
        0x80, 0xB9, 0xCB, 0xAE, 0xD3, 0x97, 0x02, 0x73,
        0xAB, 0x7D, 0x7C, 0xEB, 0x44, 0x03, 0x60, 0x06,
@@ -6807,7 +6808,7 @@ static const uint8_t mlkem_768_dk[] = {
        0xBB, 0x2B, 0x37, 0x59, 0x85, 0x84, 0xE0, 0xF9,
 };
 
-static const uint8_t mlkem_768_ek[] = {
+uint8_t mlkem_768_ek[] = {
        0x7B, 0x15, 0x44, 0x17, 0xF9, 0x85, 0xAB, 0xF3,
        0xCE, 0xDE, 0x04, 0x8A, 0xF1, 0xCA, 0x3A, 0x63,
        0xB7, 0x79, 0xFA, 0x00, 0xAD, 0x20, 0x62, 0x31,
@@ -6958,14 +6959,14 @@ static const uint8_t mlkem_768_ek[] = {
        0x1D, 0x85, 0xA8, 0x04, 0xD6, 0xCD, 0x32, 0x5F,
 };
 
-static const uint8_t mlkem_768_message[] = {
+uint8_t mlkem_768_message[] = {
        0x16, 0x20, 0x03, 0x2E, 0xBD, 0xB3, 0x08, 0xF2,
        0xBE, 0xF4, 0x07, 0x03, 0x06, 0xAF, 0x29, 0xFD,
        0x2D, 0x30, 0x73, 0xA0, 0xE5, 0x79, 0xCF, 0x90,
        0x78, 0x7C, 0xCE, 0xC8, 0x9C, 0x4D, 0x9F, 0x16,
 };
 
-static const uint8_t mlkem_768_cipher[] = {
+uint8_t mlkem_768_cipher[] = {
        0x0E, 0x0C, 0x21, 0xA5, 0x33, 0x7A, 0xFC, 0x3C,
        0x76, 0x9A, 0x80, 0x14, 0xD7, 0x82, 0x8E, 0x7A,
        0xBC, 0xCF, 0xF0, 0xA9, 0x77, 0xD7, 0x92, 0x9E,
@@ -7104,14 +7105,14 @@ static const uint8_t mlkem_768_cipher[] = {
        0xD3, 0xC9, 0xB5, 0x2A, 0x6C, 0xE8, 0x1F, 0xE1,
 };
 
-static const uint8_t mlkem_768_sk[] = {
+uint8_t mlkem_768_sk[] = {
        0x21, 0xA7, 0x5C, 0x6A, 0x1B, 0xC9, 0xA1, 0x0B,
        0x3D, 0x99, 0x03, 0xBE, 0xE5, 0x5C, 0x26, 0x18,
        0x0D, 0xF3, 0x1D, 0x21, 0x66, 0x1E, 0x39, 0x7B,
        0x64, 0x6A, 0x57, 0x54, 0xAE, 0x70, 0xFB, 0x69,
 };
 
-static const uint8_t mlkem_1024_dk[] = {
+uint8_t mlkem_1024_dk[] = {
        0xBA, 0x60, 0x87, 0x43, 0x75, 0x8A, 0xB6, 0xCA,
        0xCD, 0xFD, 0xAA, 0x89, 0xD3, 0x54, 0xA0, 0x21,
        0x61, 0xCF, 0x3A, 0xCB, 0x62, 0x86, 0x5A, 0x11,
@@ -7510,7 +7511,7 @@ static const uint8_t mlkem_1024_dk[] = {
        0x58, 0x0B, 0xBB, 0x61, 0x45, 0x9C, 0xA3, 0xE1,
 };
 
-static const uint8_t mlkem_1024_ek[] = {
+uint8_t mlkem_1024_ek[] = {
        0x8E, 0x4B, 0xB1, 0x60, 0xF4, 0x62, 0xE1, 0xE9,
        0xBA, 0xF9, 0x5C, 0x65, 0x4F, 0x00, 0x60, 0xBB,
        0x94, 0x8C, 0xEF, 0x14, 0x87, 0x7B, 0x52, 0x2F,
@@ -7709,14 +7710,14 @@ static const uint8_t mlkem_1024_ek[] = {
        0x27, 0xF1, 0xC7, 0x3F, 0xD5, 0x54, 0x61, 0xF2,
 };
 
-static const uint8_t mlkem_1024_message[] = {
+uint8_t mlkem_1024_message[] = {
        0xA9, 0x91, 0x84, 0x52, 0x12, 0x42, 0xC8, 0xF4,
        0x6C, 0x5D, 0x0F, 0x04, 0xCD, 0x9E, 0x82, 0x14,
        0x15, 0x74, 0xDA, 0xD5, 0xF9, 0xF4, 0xF5, 0x9A,
        0x6B, 0x17, 0x9B, 0xF8, 0x54, 0xF8, 0xFA, 0x9C,
 };
 
-static const uint8_t mlkem_1024_cipher[] = {
+uint8_t mlkem_1024_cipher[] = {
        0xCE, 0xE7, 0x81, 0x3D, 0x95, 0x80, 0x18, 0x33,
        0x48, 0xC0, 0x05, 0xD1, 0x34, 0x69, 0x8E, 0x0B,
        0xA9, 0x3E, 0xEC, 0x60, 0xE5, 0xBC, 0x55, 0x3B,
@@ -7915,21 +7916,21 @@ static const uint8_t mlkem_1024_cipher[] = {
        0xB3, 0x89, 0x73, 0xBA, 0x02, 0x76, 0x64, 0x24,
 };
 
-static const uint8_t mlkem_1024_sk[] = {
+uint8_t mlkem_1024_sk[] = {
        0x14, 0x0F, 0x5E, 0x1F, 0x11, 0x85, 0x16, 0x26,
        0xE4, 0x65, 0x6C, 0x09, 0x7C, 0xE1, 0x9A, 0x32,
        0x28, 0x4E, 0x31, 0x64, 0x58, 0xA5, 0xE6, 0x90,
        0xDD, 0x06, 0xD9, 0x38, 0x10, 0x34, 0xC6, 0xB4,
 };
 
-const uint8_t mldsa_65_seed[] = {
+uint8_t mldsa_65_seed[] = {
        0xAF, 0xB4, 0x7E, 0x7A, 0x2B, 0x5C, 0x6B, 0xF9,
        0xE7, 0x3E, 0xFE, 0xD6, 0x4B, 0x27, 0x90, 0x48,
        0xD3, 0xA2, 0x35, 0x42, 0x11, 0xD2, 0xCA, 0x31,
        0xE1, 0xA7, 0xA6, 0xC2, 0xD8, 0x28, 0xCF, 0xCF,
 };
 
-static const uint8_t mldsa_65_privkey_noseed[] = {
+uint8_t mldsa_65_privkey_noseed[] = {
        0x1D, 0x6D, 0xB9, 0x95, 0x3A, 0xB9, 0x93, 0x6C,
        0x2B, 0x7D, 0xB2, 0xF6, 0xEE, 0x16, 0x69, 0x8C,
        0x49, 0xF3, 0x74, 0xB1, 0x42, 0xE8, 0x88, 0x07,
@@ -8436,7 +8437,7 @@ static const uint8_t mldsa_65_privkey_noseed[] = {
        0xD3, 0x5D, 0x50, 0x2F, 0x70, 0x03, 0xE7, 0xDE,
 };
 
-static const uint8_t mldsa_65_pubkey_noseed[] = {
+uint8_t mldsa_65_pubkey_noseed[] = {
        0x1D, 0x6D, 0xB9, 0x95, 0x3A, 0xB9, 0x93, 0x6C,
        0x2B, 0x7D, 0xB2, 0xF6, 0xEE, 0x16, 0x69, 0x8C,
        0x49, 0xF3, 0x74, 0xB1, 0x42, 0xE8, 0x88, 0x07,
@@ -8683,14 +8684,14 @@ static const uint8_t mldsa_65_pubkey_noseed[] = {
        0xAD, 0x5C, 0x6C, 0xEF, 0x33, 0x13, 0x4D, 0x61,
 };
 
-static const uint8_t mldsa_65_message[] = {
+uint8_t mldsa_65_message[] = {
        0x1C, 0x00, 0x00, 0x00, 0x61, 0x6D, 0xB0, 0xB6,
        0x0F, 0x54, 0x96, 0x5F, 0xDB, 0x21, 0x40, 0xB5,
        0x33, 0xA3, 0x85, 0xFE, 0xA3, 0xCC, 0x76, 0x5C,
        0x8C, 0xB0, 0xC0, 0x71, 0xE5, 0x6D, 0xFB, 0xDD,
 };
 
-static const uint8_t mldsa_65_sign_dtrm[] = {
+uint8_t mldsa_65_sign_dtrm[] = {
        0xD1, 0x54, 0x6B, 0x32, 0x93, 0xC2, 0xFE, 0xA1,
        0x5F, 0x8D, 0x6C, 0xF4, 0x2A, 0x86, 0xFA, 0x5D,
        0xAB, 0xFA, 0x0C, 0x42, 0x49, 0x48, 0x7E, 0x77,
@@ -9107,14 +9108,14 @@ static const uint8_t mldsa_65_sign_dtrm[] = {
        0x10, 0x14, 0x1C, 0x24, 0x2F,
 };
 
-const uint8_t mldsa_87_seed[] = {
+uint8_t mldsa_87_seed[] = {
        0x2F, 0xA5, 0xF2, 0x15, 0xFE, 0x26, 0x93, 0x2F,
        0xF4, 0x7C, 0xF3, 0x03, 0x6F, 0xC4, 0x0F, 0x4A,
        0x4B, 0x43, 0xA2, 0x70, 0xB3, 0x2A, 0xAD, 0xB0,
        0x9D, 0x74, 0x8D, 0xFE, 0xD2, 0x07, 0x52, 0x8B,
 };
 
-static const uint8_t mldsa_87_privkey_noseed[] = {
+uint8_t mldsa_87_privkey_noseed[] = {
        0xD4, 0xFF, 0xA6, 0x98, 0xD8, 0x54, 0x53, 0xB6,
        0xEE, 0xA1, 0xB2, 0x2C, 0xA3, 0xCB, 0xE1, 0x95,
        0xA1, 0x92, 0x92, 0x54, 0x4B, 0xED, 0x50, 0x89,
@@ -9729,7 +9730,7 @@ static const uint8_t mldsa_87_privkey_noseed[] = {
        0x1A, 0x6E, 0xD8, 0x73, 0xC3, 0xDC, 0xF7, 0xDB,
 };
 
-static const uint8_t mldsa_87_pubkey_noseed[] = {
+uint8_t mldsa_87_pubkey_noseed[] = {
        0xD4, 0xFF, 0xA6, 0x98, 0xD8, 0x54, 0x53, 0xB6,
        0xEE, 0xA1, 0xB2, 0x2C, 0xA3, 0xCB, 0xE1, 0x95,
        0xA1, 0x92, 0x92, 0x54, 0x4B, 0xED, 0x50, 0x89,
@@ -10056,14 +10057,14 @@ static const uint8_t mldsa_87_pubkey_noseed[] = {
        0x62, 0x5A, 0x7D, 0x2F, 0xE2, 0xEC, 0xE8, 0xD5,
 };
 
-static const uint8_t mldsa_87_message[] = {
+uint8_t mldsa_87_message[] = {
        0x75, 0x35, 0x3E, 0x04, 0xF4, 0xB3, 0xD4, 0x7F,
        0xD2, 0x7E, 0x02, 0xA5, 0x93, 0x80, 0x26, 0x90,
        0xB6, 0xE9, 0xC3, 0xBC, 0xB0, 0xB9, 0x03, 0xC1,
        0x36, 0xB4, 0x5B, 0xEF, 0xA5, 0x80, 0x50, 0xDD,
 };
 
-static const uint8_t mldsa_87_sign_dtrm[] = {
+uint8_t mldsa_87_sign_dtrm[] = {
        0x55, 0x63, 0x52, 0x72, 0xAA, 0xFF, 0x4C, 0xEC,
        0x2F, 0x28, 0x5C, 0x59, 0x13, 0xAD, 0xFC, 0xA0,
        0xBC, 0xDC, 0x96, 0x49, 0xFA, 0xDB, 0x7B, 0x57,
@@ -10645,42 +10646,42 @@ static const uint8_t mldsa_87_sign_dtrm[] = {
        0x28, 0x30, 0x3C,
 };
 
-static const uint8_t mldsa_65_message_1_iter[] = {
+uint8_t mldsa_65_message_1_iter[] = {
        0x13, 0xCD, 0x8C, 0x83, 0x61, 0x6D, 0xB0, 0xB6,
        0x0F, 0x54, 0x96, 0x5F, 0xDB, 0x21, 0x40, 0xB5,
        0x33, 0xA3, 0x85, 0xFE, 0xA3, 0xCC, 0x76, 0x5C,
        0x8C, 0xB0, 0xC0, 0x71, 0xE5, 0x6D, 0xFB, 0xDD,
 };
 
-static const uint8_t mldsa_65_message_5_iter[] = {
+uint8_t mldsa_65_message_5_iter[] = {
        0xE3, 0xB3, 0xF1, 0x9F, 0x61, 0x6D, 0xB0, 0xB6,
        0x0F, 0x54, 0x96, 0x5F, 0xDB, 0x21, 0x40, 0xB5,
        0x33, 0xA3, 0x85, 0xFE, 0xA3, 0xCC, 0x76, 0x5C,
        0x8C, 0xB0, 0xC0, 0x71, 0xE5, 0x6D, 0xFB, 0xDD,
 };
 
-static const uint8_t mldsa_65_message_10_iter[] = {
+uint8_t mldsa_65_message_10_iter[] = {
        0x83, 0x81, 0xBB, 0xD8, 0x61, 0x6D, 0xB0, 0xB6,
        0x0F, 0x54, 0x96, 0x5F, 0xDB, 0x21, 0x40, 0xB5,
        0x33, 0xA3, 0x85, 0xFE, 0xA3, 0xCC, 0x76, 0x5C,
        0x8C, 0xB0, 0xC0, 0x71, 0xE5, 0x6D, 0xFB, 0xDD,
 };
 
-static const uint8_t mldsa_87_message_1_iter[] = {
+uint8_t mldsa_87_message_1_iter[] = {
        0x80, 0x1B, 0x53, 0xC5, 0xF4, 0xB3, 0xD4, 0x7F,
        0xD2, 0x7E, 0x02, 0xA5, 0x93, 0x80, 0x26, 0x90,
        0xB6, 0xE9, 0xC3, 0xBC, 0xB0, 0xB9, 0x03, 0xC1,
        0x36, 0xB4, 0x5B, 0xEF, 0xA5, 0x80, 0x50, 0xDD,
 };
 
-static const uint8_t mldsa_87_message_5_iter[] = {
+uint8_t mldsa_87_message_5_iter[] = {
        0x50, 0x02, 0xB8, 0xE1, 0xF4, 0xB3, 0xD4, 0x7F,
        0xD2, 0x7E, 0x02, 0xA5, 0x93, 0x80, 0x26, 0x90,
        0xB6, 0xE9, 0xC3, 0xBC, 0xB0, 0xB9, 0x03, 0xC1,
        0x36, 0xB4, 0x5B, 0xEF, 0xA5, 0x80, 0x50, 0xDD,
 };
 
-static const uint8_t mldsa_87_message_10_iter[] = {
+uint8_t mldsa_87_message_10_iter[] = {
        0xD2, 0xAD, 0x0A, 0xE5, 0xF4, 0xB3, 0xD4, 0x7F,
        0xD2, 0x7E, 0x02, 0xA5, 0x93, 0x80, 0x26, 0x90,
        0xB6, 0xE9, 0xC3, 0xBC, 0xB0, 0xB9, 0x03, 0xC1,
@@ -11445,7 +11446,7 @@ cperf_test_vector_get_dummy(struct cperf_options 
*options)
 {
        struct cperf_test_vector *t_vec;
 
-       t_vec = (struct cperf_test_vector *)rte_malloc(NULL,
+       t_vec = (struct cperf_test_vector *)rte_zmalloc(NULL,
                        sizeof(struct cperf_test_vector), 0);
        if (t_vec == NULL)
                return t_vec;
@@ -11458,6 +11459,97 @@ cperf_test_vector_get_dummy(struct cperf_options 
*options)
                t_vec->modex.exp = options->modex_data->exponent.data;
                t_vec->modex.mlen = options->modex_data->modulus.len;
                t_vec->modex.elen = options->modex_data->exponent.len;
+
+       } else if (options->op_type == CPERF_ASYM_MLKEM512 ||
+                       options->op_type == CPERF_ASYM_MLKEM768 ||
+                       options->op_type == CPERF_ASYM_MLKEM1024) {
+               const struct cperf_mlkem_test_data *d = options->mlkem_data;
+
+               if (d->ek.length > 0) {
+                       t_vec->mlkem.ek.data = rte_malloc(NULL, d->ek.length, 
0);
+                       if (t_vec->mlkem.ek.data == NULL)
+                               goto err_free;
+                       memcpy(t_vec->mlkem.ek.data, d->ek.data, d->ek.length);
+                       t_vec->mlkem.ek.length = d->ek.length;
+               }
+               if (d->dk.length > 0) {
+                       t_vec->mlkem.dk.data = rte_malloc(NULL, d->dk.length, 
0);
+                       if (t_vec->mlkem.dk.data == NULL)
+                               goto err_free;
+                       memcpy(t_vec->mlkem.dk.data, d->dk.data, d->dk.length);
+                       t_vec->mlkem.dk.length = d->dk.length;
+               }
+               if (d->message.length > 0) {
+                       t_vec->mlkem.message.data = rte_malloc(NULL, 
d->message.length, 0);
+                       if (t_vec->mlkem.message.data == NULL)
+                               goto err_free;
+                       memcpy(t_vec->mlkem.message.data, d->message.data, 
d->message.length);
+                       t_vec->mlkem.message.length = d->message.length;
+               }
+               t_vec->mlkem.cipher.data = rte_malloc(NULL,
+                               (size_t)d->cipher.length * 
options->nb_descriptors, 0);
+               if (t_vec->mlkem.cipher.data == NULL)
+                       goto err_free;
+               memcpy(t_vec->mlkem.cipher.data, d->cipher.data, 
d->cipher.length);
+               t_vec->mlkem.cipher.length = d->cipher.length;
+               if (d->sk.length > 0) {
+                       t_vec->mlkem.sk.data = rte_malloc(NULL,
+                                       (size_t)d->sk.length * 
options->nb_descriptors, 0);
+                       if (t_vec->mlkem.sk.data == NULL)
+                               goto err_free;
+                       t_vec->mlkem.sk.length = d->sk.length;
+               }
+
+       } else if (options->op_type == CPERF_ASYM_MLDSA44 ||
+                       options->op_type == CPERF_ASYM_MLDSA65 ||
+                       options->op_type == CPERF_ASYM_MLDSA87) {
+               const struct cperf_mldsa_test_data *d = options->mldsa_data;
+
+               if (d->privkey.length > 0) {
+                       t_vec->mldsa.privkey.data = rte_malloc(NULL, 
d->privkey.length, 0);
+                       if (t_vec->mldsa.privkey.data == NULL)
+                               goto err_free;
+                       memcpy(t_vec->mldsa.privkey.data, d->privkey.data, 
d->privkey.length);
+                       t_vec->mldsa.privkey.length = d->privkey.length;
+               }
+               if (d->pubkey.length > 0) {
+                       t_vec->mldsa.pubkey.data = rte_malloc(NULL, 
d->pubkey.length, 0);
+                       if (t_vec->mldsa.pubkey.data == NULL)
+                               goto err_free;
+                       memcpy(t_vec->mldsa.pubkey.data, d->pubkey.data, 
d->pubkey.length);
+                       t_vec->mldsa.pubkey.length = d->pubkey.length;
+               }
+               t_vec->mldsa.message.data = rte_malloc(NULL, d->message.length, 
0);
+               if (t_vec->mldsa.message.data == NULL)
+                       goto err_free;
+               memcpy(t_vec->mldsa.message.data, d->message.data, 
d->message.length);
+               t_vec->mldsa.message.length = d->message.length;
+               t_vec->mldsa.sign.data = rte_malloc(NULL,
+                               (size_t)d->sign.length * 
options->nb_descriptors, 0);
+               if (t_vec->mldsa.sign.data == NULL)
+                       goto err_free;
+               t_vec->mldsa.sign.length = d->sign.length;
+               if (d->ctx.length > 0) {
+                       t_vec->mldsa.ctx.data = rte_malloc(NULL, d->ctx.length, 
0);
+                       if (t_vec->mldsa.ctx.data == NULL)
+                               goto err_free;
+                       memcpy(t_vec->mldsa.ctx.data, d->ctx.data, 
d->ctx.length);
+                       t_vec->mldsa.ctx.length = d->ctx.length;
+               }
+               if (d->seed.length > 0) {
+                       t_vec->mldsa.seed.data = rte_malloc(NULL, 
d->seed.length, 0);
+                       if (t_vec->mldsa.seed.data == NULL)
+                               goto err_free;
+                       memcpy(t_vec->mldsa.seed.data, d->seed.data, 
d->seed.length);
+                       t_vec->mldsa.seed.length = d->seed.length;
+               }
+               if (d->mu.length > 0) {
+                       t_vec->mldsa.mu.data = rte_malloc(NULL, d->mu.length, 
0);
+                       if (t_vec->mldsa.mu.data == NULL)
+                               goto err_free;
+                       memcpy(t_vec->mldsa.mu.data, d->mu.data, d->mu.length);
+                       t_vec->mldsa.mu.length = d->mu.length;
+               }
        }
 
        if (options->op_type == CPERF_PDCP || options->op_type == CPERF_TLS ||
@@ -11646,4 +11738,7 @@ cperf_test_vector_get_dummy(struct cperf_options 
*options)
                t_vec->aead_iv.length = options->aead_iv_sz;
        }
        return t_vec;
+err_free:
+       free_test_vector(t_vec, options);
+       return NULL;
 }
diff --git a/app/test-crypto-perf/cperf_test_vectors.h 
b/app/test-crypto-perf/cperf_test_vectors.h
index c6ad7fdcb3..a11f0dfa42 100644
--- a/app/test-crypto-perf/cperf_test_vectors.h
+++ b/app/test-crypto-perf/cperf_test_vectors.h
@@ -85,6 +85,60 @@ struct cperf_test_vector {
                uint32_t msg_len;
                uint32_t cipher_len;
        } sm2;
+
+       struct {
+               struct {
+                       uint8_t *data;
+                       uint32_t length;
+               } ek;
+               struct {
+                       uint8_t *data;
+                       uint32_t length;
+               } dk;
+               struct {
+                       uint8_t *data;
+                       uint32_t length;
+               } message;
+               struct {
+                       uint8_t *data;
+                       uint32_t length;
+               } cipher;
+               struct {
+                       uint8_t *data;
+                       uint32_t length;
+               } sk;
+       } mlkem;
+
+       struct {
+               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;
+       } mldsa;
 };
 
 struct cperf_modex_test_data {
@@ -111,23 +165,23 @@ struct cperf_mlkem_test_data {
        const char *name;
        enum rte_crypto_ml_kem_type type;
        struct {
-               const uint8_t *data;
+               uint8_t *data;
                uint32_t length;
        } dk;
        struct {
-               const uint8_t *data;
+               uint8_t *data;
                uint32_t length;
        } ek;
        struct {
-               const uint8_t *data;
+               uint8_t *data;
                uint32_t length;
        } message;
        struct {
-               const uint8_t *data;
+               uint8_t *data;
                uint32_t length;
        } cipher;
        struct {
-               const uint8_t *data;
+               uint8_t *data;
                uint32_t length;
        } sk;
 };
@@ -192,31 +246,31 @@ struct cperf_mldsa_test_data {
        const char *name;
        enum rte_crypto_ml_dsa_type type;
        struct {
-               const uint8_t *data;
+               uint8_t *data;
                uint32_t length;
        } privkey;
        struct {
-               const uint8_t *data;
+               uint8_t *data;
                uint32_t length;
        } pubkey;
        struct {
-               const uint8_t *data;
+               uint8_t *data;
                uint32_t length;
        } message;
        struct {
-               const uint8_t *data;
+               uint8_t *data;
                uint32_t length;
        } sign;
        struct {
-               const uint8_t *data;
+               uint8_t *data;
                uint32_t length;
        } ctx;
        struct {
-               const uint8_t *data;
+               uint8_t *data;
                uint32_t length;
        } seed;
        struct {
-               const uint8_t *data;
+               uint8_t *data;
                uint32_t length;
        } mu;
        enum rte_crypto_auth_algorithm hash;
-- 
2.43.0

Reply via email to