Skip to content

Commit cb666bd

Browse files
rupesh-chiluka-marvellAkhil Goyal
authored andcommitted
app/crypto-perf: support ECDSA P192/P224/P521
Add support for ECDSA SECP192R1, SECP224R1, SECP521R1 curve SIGN and VERIFY operations Signed-off-by: Rupesh Chiluka <[email protected]> Acked-by: Akhil Goyal <[email protected]>
1 parent 78c0791 commit cb666bd

File tree

8 files changed

+420
-61
lines changed

8 files changed

+420
-61
lines changed

app/test-crypto-perf/cperf_ops.c

Lines changed: 63 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -95,36 +95,46 @@ cperf_set_ops_asym_ecdsa(struct rte_crypto_op **ops,
9595
uint16_t i;
9696

9797
for (i = 0; i < nb_ops; i++) {
98+
const struct cperf_ecdsa_test_data *ecdsa_curve_data = NULL;
9899
struct rte_crypto_asym_op *asym_op = ops[i]->asym;
99100

100101
ops[i]->status = RTE_CRYPTO_OP_STATUS_NOT_PROCESSED;
101102
rte_crypto_op_attach_asym_session(ops[i], sess);
102103

103104
asym_op->ecdsa.op_type = options->asym_op_type;
104-
if (options->op_type == CPERF_ASYM_SECP256R1) {
105-
asym_op->ecdsa.message.data = options->secp256r1_data->message.data;
106-
asym_op->ecdsa.message.length = options->secp256r1_data->message.length;
107-
108-
asym_op->ecdsa.k.data = options->secp256r1_data->k.data;
109-
asym_op->ecdsa.k.length = options->secp256r1_data->k.length;
110-
111-
asym_op->ecdsa.r.data = options->secp256r1_data->sign_r.data;
112-
asym_op->ecdsa.r.length = options->secp256r1_data->sign_r.length;
113-
asym_op->ecdsa.s.data = options->secp256r1_data->sign_s.data;
114-
asym_op->ecdsa.s.length = options->secp256r1_data->sign_s.length;
115-
} else if (options->op_type == CPERF_ASYM_SECP384R1) {
116-
asym_op->ecdsa.message.data = options->secp384r1_data->message.data;
117-
asym_op->ecdsa.message.length = options->secp384r1_data->message.length;
118-
119-
asym_op->ecdsa.k.data = options->secp384r1_data->k.data;
120-
asym_op->ecdsa.k.length = options->secp384r1_data->k.length;
121-
122-
asym_op->ecdsa.r.data = options->secp384r1_data->sign_r.data;
123-
asym_op->ecdsa.r.length = options->secp384r1_data->sign_r.length;
124-
asym_op->ecdsa.s.data = options->secp384r1_data->sign_s.data;
125-
asym_op->ecdsa.s.length = options->secp384r1_data->sign_s.length;
105+
106+
switch (options->op_type) {
107+
case CPERF_ASYM_SECP192R1:
108+
ecdsa_curve_data = options->secp192r1_data;
109+
break;
110+
case CPERF_ASYM_SECP224R1:
111+
ecdsa_curve_data = options->secp224r1_data;
112+
break;
113+
case CPERF_ASYM_SECP256R1:
114+
ecdsa_curve_data = options->secp256r1_data;
115+
break;
116+
case CPERF_ASYM_SECP384R1:
117+
ecdsa_curve_data = options->secp384r1_data;
118+
break;
119+
case CPERF_ASYM_SECP521R1:
120+
ecdsa_curve_data = options->secp521r1_data;
121+
break;
122+
default:
123+
rte_panic("Unsupported ECDSA operation type %d\n",
124+
options->op_type);
125+
break;
126126
}
127127

128+
asym_op->ecdsa.message.data = ecdsa_curve_data->message.data;
129+
asym_op->ecdsa.message.length = ecdsa_curve_data->message.length;
130+
131+
asym_op->ecdsa.k.data = ecdsa_curve_data->k.data;
132+
asym_op->ecdsa.k.length = ecdsa_curve_data->k.length;
133+
134+
asym_op->ecdsa.r.data = ecdsa_curve_data->sign_r.data;
135+
asym_op->ecdsa.r.length = ecdsa_curve_data->sign_r.length;
136+
asym_op->ecdsa.s.data = ecdsa_curve_data->sign_s.data;
137+
asym_op->ecdsa.s.length = ecdsa_curve_data->sign_s.length;
128138
}
129139
}
130140

@@ -1078,6 +1088,7 @@ cperf_create_session(struct rte_mempool *sess_mp,
10781088
const struct cperf_test_vector *test_vector,
10791089
uint16_t iv_offset)
10801090
{
1091+
const struct cperf_ecdsa_test_data *ecdsa_curve_data = NULL;
10811092
struct rte_crypto_sym_xform cipher_xform;
10821093
struct rte_crypto_sym_xform auth_xform;
10831094
struct rte_crypto_sym_xform aead_xform;
@@ -1135,42 +1146,41 @@ cperf_create_session(struct rte_mempool *sess_mp,
11351146
return asym_sess;
11361147
}
11371148

1138-
if (options->op_type == CPERF_ASYM_SECP256R1) {
1139-
xform.next = NULL;
1140-
xform.xform_type = RTE_CRYPTO_ASYM_XFORM_ECDSA;
1141-
xform.ec.curve_id = options->secp256r1_data->curve;
1142-
xform.ec.pkey.data = options->secp256r1_data->pkey.data;
1143-
xform.ec.pkey.length = options->secp256r1_data->pkey.length;
1144-
xform.ec.q.x.data = options->secp256r1_data->pubkey_qx.data;
1145-
xform.ec.q.x.length = options->secp256r1_data->pubkey_qx.length;
1146-
xform.ec.q.y.data = options->secp256r1_data->pubkey_qy.data;
1147-
xform.ec.q.y.length = options->secp256r1_data->pubkey_qy.length;
1148-
1149-
ret = rte_cryptodev_asym_session_create(dev_id, &xform,
1150-
sess_mp, &asym_sess);
1151-
if (ret < 0) {
1152-
RTE_LOG(ERR, USER1, "ECDSA P256 Asym session create failed\n");
1153-
return NULL;
1154-
}
1155-
1156-
return asym_sess;
1149+
switch (options->op_type) {
1150+
case CPERF_ASYM_SECP192R1:
1151+
ecdsa_curve_data = options->secp192r1_data;
1152+
break;
1153+
case CPERF_ASYM_SECP224R1:
1154+
ecdsa_curve_data = options->secp224r1_data;
1155+
break;
1156+
case CPERF_ASYM_SECP256R1:
1157+
ecdsa_curve_data = options->secp256r1_data;
1158+
break;
1159+
case CPERF_ASYM_SECP384R1:
1160+
ecdsa_curve_data = options->secp384r1_data;
1161+
break;
1162+
case CPERF_ASYM_SECP521R1:
1163+
ecdsa_curve_data = options->secp521r1_data;
1164+
break;
1165+
default:
1166+
break;
11571167
}
11581168

1159-
if (options->op_type == CPERF_ASYM_SECP384R1) {
1169+
if (ecdsa_curve_data) {
11601170
xform.next = NULL;
11611171
xform.xform_type = RTE_CRYPTO_ASYM_XFORM_ECDSA;
1162-
xform.ec.curve_id = options->secp384r1_data->curve;
1163-
xform.ec.pkey.data = options->secp384r1_data->pkey.data;
1164-
xform.ec.pkey.length = options->secp384r1_data->pkey.length;
1165-
xform.ec.q.x.data = options->secp384r1_data->pubkey_qx.data;
1166-
xform.ec.q.x.length = options->secp384r1_data->pubkey_qx.length;
1167-
xform.ec.q.y.data = options->secp384r1_data->pubkey_qy.data;
1168-
xform.ec.q.y.length = options->secp384r1_data->pubkey_qy.length;
1172+
xform.ec.curve_id = ecdsa_curve_data->curve;
1173+
xform.ec.pkey.data = ecdsa_curve_data->pkey.data;
1174+
xform.ec.pkey.length = ecdsa_curve_data->pkey.length;
1175+
xform.ec.q.x.data = ecdsa_curve_data->pubkey_qx.data;
1176+
xform.ec.q.x.length = ecdsa_curve_data->pubkey_qx.length;
1177+
xform.ec.q.y.data = ecdsa_curve_data->pubkey_qy.data;
1178+
xform.ec.q.y.length = ecdsa_curve_data->pubkey_qy.length;
11691179

11701180
ret = rte_cryptodev_asym_session_create(dev_id, &xform,
11711181
sess_mp, &asym_sess);
11721182
if (ret < 0) {
1173-
RTE_LOG(ERR, USER1, "ECDSA P384 Asym session create failed\n");
1183+
RTE_LOG(ERR, USER1, "ECDSA Asym session create failed\n");
11741184
return NULL;
11751185
}
11761186

@@ -1519,10 +1529,11 @@ cperf_get_op_functions(const struct cperf_options *options,
15191529
case CPERF_ASYM_RSA:
15201530
op_fns->populate_ops = cperf_set_ops_asym_rsa;
15211531
break;
1532+
case CPERF_ASYM_SECP192R1:
1533+
case CPERF_ASYM_SECP224R1:
15221534
case CPERF_ASYM_SECP256R1:
1523-
op_fns->populate_ops = cperf_set_ops_asym_ecdsa;
1524-
break;
15251535
case CPERF_ASYM_SECP384R1:
1536+
case CPERF_ASYM_SECP521R1:
15261537
op_fns->populate_ops = cperf_set_ops_asym_ecdsa;
15271538
break;
15281539
case CPERF_ASYM_ED25519:

app/test-crypto-perf/cperf_options.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,11 @@ enum cperf_op_type {
9494
CPERF_IPSEC,
9595
CPERF_ASYM_MODEX,
9696
CPERF_ASYM_RSA,
97+
CPERF_ASYM_SECP192R1,
98+
CPERF_ASYM_SECP224R1,
9799
CPERF_ASYM_SECP256R1,
98100
CPERF_ASYM_SECP384R1,
101+
CPERF_ASYM_SECP521R1,
99102
CPERF_ASYM_ED25519,
100103
CPERF_ASYM_SM2,
101104
CPERF_TLS,
@@ -177,8 +180,11 @@ struct cperf_options {
177180
uint8_t imix_distribution_count;
178181
struct cperf_modex_test_data *modex_data;
179182
uint16_t modex_len;
183+
struct cperf_ecdsa_test_data *secp192r1_data;
184+
struct cperf_ecdsa_test_data *secp224r1_data;
180185
struct cperf_ecdsa_test_data *secp256r1_data;
181186
struct cperf_ecdsa_test_data *secp384r1_data;
187+
struct cperf_ecdsa_test_data *secp521r1_data;
182188
struct cperf_eddsa_test_data *eddsa_data;
183189
struct cperf_sm2_test_data *sm2_data;
184190
enum rte_crypto_asym_op_type asym_op_type;

app/test-crypto-perf/cperf_options_parsing.c

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,9 @@ 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 / rsa / secp256r1 / secp384r1 / eddsa / sm2 / tls-record : set operation type\n"
42+
" aead / pdcp / docsis / ipsec / modex / rsa / secp192r1 /\n"
43+
" secp224r1 / secp256r1 / secp384r1 / secp521r1 / eddsa / sm2 /\n"
44+
" tls-record : set operation type\n"
4345
" --sessionless: enable session-less crypto operations\n"
4446
" --shared-session: share 1 session across all queue pairs on crypto device\n"
4547
" --out-of-place: enable out-of-place crypto operations\n"
@@ -529,6 +531,14 @@ parse_op_type(struct cperf_options *opts, const char *arg)
529531
cperf_op_type_strs[CPERF_ASYM_RSA],
530532
CPERF_ASYM_RSA
531533
},
534+
{
535+
cperf_op_type_strs[CPERF_ASYM_SECP192R1],
536+
CPERF_ASYM_SECP192R1
537+
},
538+
{
539+
cperf_op_type_strs[CPERF_ASYM_SECP224R1],
540+
CPERF_ASYM_SECP224R1
541+
},
532542
{
533543
cperf_op_type_strs[CPERF_ASYM_SECP256R1],
534544
CPERF_ASYM_SECP256R1
@@ -537,6 +547,10 @@ parse_op_type(struct cperf_options *opts, const char *arg)
537547
cperf_op_type_strs[CPERF_ASYM_SECP384R1],
538548
CPERF_ASYM_SECP384R1
539549
},
550+
{
551+
cperf_op_type_strs[CPERF_ASYM_SECP521R1],
552+
CPERF_ASYM_SECP521R1
553+
},
540554
{
541555
cperf_op_type_strs[CPERF_ASYM_ED25519],
542556
CPERF_ASYM_ED25519
@@ -1153,8 +1167,11 @@ cperf_options_default(struct cperf_options *opts)
11531167
opts->rsa_data = &rsa_pub_perf_data[0];
11541168
opts->rsa_keytype = UINT8_MAX;
11551169

1170+
opts->secp192r1_data = &secp192r1_perf_data;
1171+
opts->secp224r1_data = &secp224r1_perf_data;
11561172
opts->secp256r1_data = &secp256r1_perf_data;
11571173
opts->secp384r1_data = &secp384r1_perf_data;
1174+
opts->secp521r1_data = &secp521r1_perf_data;
11581175
opts->eddsa_data = &ed25519_perf_data;
11591176
opts->sm2_data = &sm2_perf_data;
11601177
opts->asym_op_type = RTE_CRYPTO_ASYM_OP_ENCRYPT;
@@ -1639,6 +1656,19 @@ cperf_options_check(struct cperf_options *options)
16391656
}
16401657
}
16411658

1659+
if (options->op_type == CPERF_ASYM_SECP192R1 ||
1660+
options->op_type == CPERF_ASYM_SECP224R1 ||
1661+
options->op_type == CPERF_ASYM_SECP256R1 ||
1662+
options->op_type == CPERF_ASYM_SECP384R1 ||
1663+
options->op_type == CPERF_ASYM_SECP521R1) {
1664+
1665+
if (options->asym_op_type != RTE_CRYPTO_ASYM_OP_SIGN &&
1666+
options->asym_op_type != RTE_CRYPTO_ASYM_OP_VERIFY) {
1667+
RTE_LOG(ERR, USER1, "ECDSA operations only support sign and verify\n");
1668+
return -EINVAL;
1669+
}
1670+
}
1671+
16421672
#ifdef RTE_LIB_SECURITY
16431673
if (options->op_type == CPERF_DOCSIS) {
16441674
if (check_docsis_buffer_length(options) < 0)

app/test-crypto-perf/cperf_test_common.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -307,8 +307,11 @@ cperf_is_asym_test(const struct cperf_options *options)
307307
{
308308
if (options->op_type == CPERF_ASYM_MODEX ||
309309
options->op_type == CPERF_ASYM_RSA ||
310+
options->op_type == CPERF_ASYM_SECP192R1 ||
311+
options->op_type == CPERF_ASYM_SECP224R1 ||
310312
options->op_type == CPERF_ASYM_SECP256R1 ||
311313
options->op_type == CPERF_ASYM_SECP384R1 ||
314+
options->op_type == CPERF_ASYM_SECP521R1 ||
312315
options->op_type == CPERF_ASYM_ED25519 ||
313316
options->op_type == CPERF_ASYM_SM2)
314317
return true;

0 commit comments

Comments
 (0)