Skip to content

Commit 5e30f0a

Browse files
gmuthukrishnAkhil Goyal
authored andcommitted
app/crypto-perf: support EDDSA
Added support for EDDSA 25519 curve SIGN and VERIFY operations. Signed-off-by: Gowrishankar Muthukrishnan <[email protected]> Acked-by: Brian Dooley <[email protected]> Acked-by: Akhil Goyal <[email protected]>
1 parent 98e66f5 commit 5e30f0a

File tree

8 files changed

+138
-2
lines changed

8 files changed

+138
-2
lines changed

app/test-crypto-perf/cperf_ops.c

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,36 @@ cperf_set_ops_asym_ecdsa(struct rte_crypto_op **ops,
6767
}
6868
}
6969

70+
static void
71+
cperf_set_ops_asym_eddsa(struct rte_crypto_op **ops,
72+
uint32_t src_buf_offset __rte_unused,
73+
uint32_t dst_buf_offset __rte_unused, uint16_t nb_ops,
74+
void *sess,
75+
const struct cperf_options *options,
76+
const struct cperf_test_vector *test_vector __rte_unused,
77+
uint16_t iv_offset __rte_unused,
78+
uint32_t *imix_idx __rte_unused,
79+
uint64_t *tsc_start __rte_unused)
80+
{
81+
uint16_t i;
82+
83+
for (i = 0; i < nb_ops; i++) {
84+
struct rte_crypto_asym_op *asym_op = ops[i]->asym;
85+
86+
ops[i]->status = RTE_CRYPTO_OP_STATUS_NOT_PROCESSED;
87+
rte_crypto_op_attach_asym_session(ops[i], sess);
88+
89+
asym_op->eddsa.op_type = options->asym_op_type;
90+
asym_op->eddsa.message.data = options->eddsa_data->message.data;
91+
asym_op->eddsa.message.length = options->eddsa_data->message.length;
92+
93+
asym_op->eddsa.instance = options->eddsa_data->instance;
94+
95+
asym_op->eddsa.sign.data = options->eddsa_data->sign.data;
96+
asym_op->eddsa.sign.length = options->eddsa_data->sign.length;
97+
}
98+
}
99+
70100
static void
71101
cperf_set_ops_asym_sm2(struct rte_crypto_op **ops,
72102
uint32_t src_buf_offset __rte_unused,
@@ -1031,6 +1061,25 @@ cperf_create_session(struct rte_mempool *sess_mp,
10311061
return asym_sess;
10321062
}
10331063

1064+
if (options->op_type == CPERF_ASYM_ED25519) {
1065+
xform.next = NULL;
1066+
xform.xform_type = RTE_CRYPTO_ASYM_XFORM_EDDSA;
1067+
xform.ec.curve_id = options->eddsa_data->curve;
1068+
xform.ec.pkey.data = options->eddsa_data->pkey.data;
1069+
xform.ec.pkey.length = options->eddsa_data->pkey.length;
1070+
xform.ec.q.x.data = options->eddsa_data->pubkey.data;
1071+
xform.ec.q.x.length = options->eddsa_data->pubkey.length;
1072+
1073+
ret = rte_cryptodev_asym_session_create(dev_id, &xform,
1074+
sess_mp, &asym_sess);
1075+
if (ret < 0) {
1076+
RTE_LOG(ERR, USER1, "EDDSA Asym session create failed\n");
1077+
return NULL;
1078+
}
1079+
1080+
return asym_sess;
1081+
}
1082+
10341083
if (options->op_type == CPERF_ASYM_SM2) {
10351084
xform.next = NULL;
10361085
xform.xform_type = RTE_CRYPTO_ASYM_XFORM_SM2;
@@ -1354,6 +1403,9 @@ cperf_get_op_functions(const struct cperf_options *options,
13541403
case CPERF_ASYM_SECP256R1:
13551404
op_fns->populate_ops = cperf_set_ops_asym_ecdsa;
13561405
break;
1406+
case CPERF_ASYM_ED25519:
1407+
op_fns->populate_ops = cperf_set_ops_asym_eddsa;
1408+
break;
13571409
case CPERF_ASYM_SM2:
13581410
op_fns->populate_ops = cperf_set_ops_asym_sm2;
13591411
break;

app/test-crypto-perf/cperf_options.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ enum cperf_op_type {
9191
CPERF_IPSEC,
9292
CPERF_ASYM_MODEX,
9393
CPERF_ASYM_SECP256R1,
94+
CPERF_ASYM_ED25519,
9495
CPERF_ASYM_SM2,
9596
CPERF_TLS,
9697
};
@@ -172,6 +173,7 @@ struct cperf_options {
172173
struct cperf_modex_test_data *modex_data;
173174
uint16_t modex_len;
174175
struct cperf_ecdsa_test_data *secp256r1_data;
176+
struct cperf_eddsa_test_data *eddsa_data;
175177
struct cperf_sm2_test_data *sm2_data;
176178
enum rte_crypto_asym_op_type asym_op_type;
177179
enum rte_crypto_auth_algorithm asym_hash_alg;

app/test-crypto-perf/cperf_options_parsing.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ usage(char *progname)
3939
" --devtype TYPE: set crypto device type to use\n"
4040
" --low-prio-qp-mask mask: set low priority for queues set in mask(hex)\n"
4141
" --optype cipher-only / auth-only / cipher-then-auth / auth-then-cipher /\n"
42-
" aead / pdcp / docsis / ipsec / modex / secp256r1 / sm2 / tls-record : set operation type\n"
42+
" aead / pdcp / docsis / ipsec / modex / secp256r1 / eddsa / sm2 / tls-record : set operation type\n"
4343
" --sessionless: enable session-less crypto operations\n"
4444
" --shared-session: share 1 session across all queue pairs on crypto device\n"
4545
" --out-of-place: enable out-of-place crypto operations\n"
@@ -490,6 +490,10 @@ parse_op_type(struct cperf_options *opts, const char *arg)
490490
cperf_op_type_strs[CPERF_ASYM_SECP256R1],
491491
CPERF_ASYM_SECP256R1
492492
},
493+
{
494+
cperf_op_type_strs[CPERF_ASYM_ED25519],
495+
CPERF_ASYM_ED25519
496+
},
493497
{
494498
cperf_op_type_strs[CPERF_ASYM_SM2],
495499
CPERF_ASYM_SM2
@@ -1099,6 +1103,7 @@ cperf_options_default(struct cperf_options *opts)
10991103
opts->modex_data = (struct cperf_modex_test_data *)&modex_perf_data[0];
11001104

11011105
opts->secp256r1_data = &secp256r1_perf_data;
1106+
opts->eddsa_data = &ed25519_perf_data;
11021107
opts->sm2_data = &sm2_perf_data;
11031108
opts->asym_op_type = RTE_CRYPTO_ASYM_OP_SIGN;
11041109
}
@@ -1533,7 +1538,7 @@ cperf_options_dump(struct cperf_options *opts)
15331538
printf("#\n");
15341539
printf("# number of queue pairs per device: %u\n", opts->nb_qps);
15351540
printf("# crypto operation: %s\n", cperf_op_type_strs[opts->op_type]);
1536-
if (opts->op_type == CPERF_ASYM_SM2 || opts->op_type == CPERF_ASYM_SECP256R1)
1541+
if (cperf_is_asym_test(opts))
15371542
printf("# asym operation type: %s\n",
15381543
rte_crypto_asym_op_strings[opts->asym_op_type]);
15391544
printf("# sessionless: %s\n", opts->sessionless ? "yes" : "no");

app/test-crypto-perf/cperf_test_common.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -307,6 +307,7 @@ cperf_is_asym_test(const struct cperf_options *options)
307307
{
308308
if (options->op_type == CPERF_ASYM_MODEX ||
309309
options->op_type == CPERF_ASYM_SECP256R1 ||
310+
options->op_type == CPERF_ASYM_ED25519 ||
310311
options->op_type == CPERF_ASYM_SM2)
311312
return true;
312313

app/test-crypto-perf/cperf_test_vectors.c

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -853,6 +853,35 @@ static uint8_t secp256r1_message[] = {
853853
0xdb, 0xc4, 0xe7, 0xa6, 0xa1, 0x33, 0xec, 0x56
854854
};
855855

856+
static uint8_t ed25519_pkey[] = {
857+
0x4c, 0xcd, 0x08, 0x9b, 0x28, 0xff, 0x96, 0xda,
858+
0x9d, 0xb6, 0xc3, 0x46, 0xec, 0x11, 0x4e, 0x0f,
859+
0x5b, 0x8a, 0x31, 0x9f, 0x35, 0xab, 0xa6, 0x24,
860+
0xda, 0x8c, 0xf6, 0xed, 0x4f, 0xb8, 0xa6, 0xfb,
861+
};
862+
863+
static uint8_t ed25519_pubkey[] = {
864+
0x3d, 0x40, 0x17, 0xc3, 0xe8, 0x43, 0x89, 0x5a,
865+
0x92, 0xb7, 0x0a, 0xa7, 0x4d, 0x1b, 0x7e, 0xbc,
866+
0x9c, 0x98, 0x2c, 0xcf, 0x2e, 0xc4, 0x96, 0x8c,
867+
0xc0, 0xcd, 0x55, 0xf1, 0x2a, 0xf4, 0x66, 0x0c,
868+
};
869+
870+
static uint8_t ed25519_sign[] = {
871+
0x92, 0xa0, 0x09, 0xa9, 0xf0, 0xd4, 0xca, 0xb8,
872+
0x72, 0x0e, 0x82, 0x0b, 0x5f, 0x64, 0x25, 0x40,
873+
0xa2, 0xb2, 0x7b, 0x54, 0x16, 0x50, 0x3f, 0x8f,
874+
0xb3, 0x76, 0x22, 0x23, 0xeb, 0xdb, 0x69, 0xda,
875+
0x08, 0x5a, 0xc1, 0xe4, 0x3e, 0x15, 0x99, 0x6e,
876+
0x45, 0x8f, 0x36, 0x13, 0xd0, 0xf1, 0x1d, 0x8c,
877+
0x38, 0x7b, 0x2e, 0xae, 0xb4, 0x30, 0x2a, 0xee,
878+
0xb0, 0x0d, 0x29, 0x16, 0x12, 0xbb, 0x0c, 0x00,
879+
};
880+
881+
static uint8_t ed25519_message[] = {
882+
0x72
883+
};
884+
856885
static uint8_t fp256_pkey[] = {
857886
0x77, 0x84, 0x35, 0x65, 0x4c, 0x7a, 0x6d, 0xb1,
858887
0x1e, 0x63, 0x0b, 0x41, 0x97, 0x36, 0x04, 0xf4,
@@ -1365,6 +1394,29 @@ cperf_ecdsa_test_data secp256r1_perf_data = {
13651394
.curve = RTE_CRYPTO_EC_GROUP_SECP256R1
13661395
};
13671396

1397+
/** EDDSA 25519 elliptic curve test params */
1398+
struct
1399+
cperf_eddsa_test_data ed25519_perf_data = {
1400+
.pubkey = {
1401+
.data = ed25519_pubkey,
1402+
.length = sizeof(ed25519_pubkey),
1403+
},
1404+
.pkey = {
1405+
.data = ed25519_pkey,
1406+
.length = sizeof(ed25519_pkey),
1407+
},
1408+
.sign = {
1409+
.data = ed25519_sign,
1410+
.length = sizeof(ed25519_sign),
1411+
},
1412+
.message = {
1413+
.data = ed25519_message,
1414+
.length = sizeof(ed25519_message),
1415+
},
1416+
.curve = RTE_CRYPTO_EC_GROUP_ED25519,
1417+
.instance = RTE_CRYPTO_EDCURVE_25519
1418+
};
1419+
13681420
/** SM2 Fp256 elliptic curve test params */
13691421
struct
13701422
cperf_sm2_test_data sm2_perf_data = {

app/test-crypto-perf/cperf_test_vectors.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,15 @@ struct cperf_ecdsa_test_data {
118118
int curve;
119119
};
120120

121+
struct cperf_eddsa_test_data {
122+
rte_crypto_param pubkey;
123+
rte_crypto_param pkey;
124+
rte_crypto_param sign;
125+
rte_crypto_param message;
126+
int curve;
127+
int instance;
128+
};
129+
121130
struct cperf_sm2_test_data {
122131
rte_crypto_param pubkey_qx;
123132
rte_crypto_param pubkey_qy;
@@ -147,6 +156,7 @@ extern uint8_t digest[2048];
147156

148157
extern struct cperf_modex_test_data modex_perf_data[10];
149158
extern struct cperf_ecdsa_test_data secp256r1_perf_data;
159+
extern struct cperf_eddsa_test_data ed25519_perf_data;
150160
extern struct cperf_sm2_test_data sm2_perf_data;
151161

152162
#endif

app/test-crypto-perf/main.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ const char *cperf_op_type_strs[] = {
4646
[CPERF_IPSEC] = "ipsec",
4747
[CPERF_ASYM_MODEX] = "modex",
4848
[CPERF_ASYM_SECP256R1] = "ecdsa_p256r1",
49+
[CPERF_ASYM_ED25519] = "eddsa_25519",
4950
[CPERF_ASYM_SM2] = "sm2",
5051
[CPERF_TLS] = "tls-record"
5152
};
@@ -227,6 +228,7 @@ cperf_initialize_cryptodev(struct cperf_options *opts, uint8_t *enabled_cdevs)
227228

228229
switch (opts->op_type) {
229230
case CPERF_ASYM_SECP256R1:
231+
case CPERF_ASYM_ED25519:
230232
case CPERF_ASYM_SM2:
231233
case CPERF_ASYM_MODEX:
232234
conf.ff_disable |= (RTE_CRYPTODEV_FF_SECURITY |
@@ -386,6 +388,17 @@ cperf_verify_devices_capabilities(struct cperf_options *opts,
386388
}
387389
}
388390

391+
if (opts->op_type == CPERF_ASYM_ED25519) {
392+
asym_cap_idx.type = RTE_CRYPTO_ASYM_XFORM_EDDSA;
393+
asym_capability = rte_cryptodev_asym_capability_get(cdev_id, &asym_cap_idx);
394+
if (asym_capability == NULL)
395+
return -1;
396+
397+
if (!rte_cryptodev_asym_xform_capability_check_optype(asym_capability,
398+
opts->asym_op_type))
399+
return -1;
400+
}
401+
389402
if (opts->op_type == CPERF_ASYM_SM2) {
390403
asym_cap_idx.type = RTE_CRYPTO_ASYM_XFORM_SM2;
391404
asym_capability = rte_cryptodev_asym_capability_get(cdev_id, &asym_cap_idx);

doc/guides/tools/cryptoperf.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,7 @@ The following are the application command-line options:
176176
docsis
177177
modex
178178
ecdsa_p256r1
179+
eddsa_25519
179180
sm2
180181
ipsec
181182
tls-record

0 commit comments

Comments
 (0)