Skip to content

Commit 7d55ca1

Browse files
smou-mlnxAkhil Goyal
authored andcommitted
app/crypto-perf: fix encrypt operation verification
AEAD uses RTE_CRYPTO_AEAD_OP_* with aead_op and CIPHER uses RTE_CRYPTO_CIPHER_OP_* with cipher_op in current code. This commit aligns aead_op and cipher_op operation to fix incorrect AEAD verification. Fixes: df52cb3 ("app/crypto-perf: move verify as single test type") Cc: [email protected] Signed-off-by: Suanming Mou <[email protected]> Acked-by: Anoob Joseph <[email protected]>
1 parent ddec2a3 commit 7d55ca1

File tree

1 file changed

+27
-28
lines changed

1 file changed

+27
-28
lines changed

app/test-crypto-perf/cperf_test_verify.c

Lines changed: 27 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,10 @@ cperf_verify_op(struct rte_crypto_op *op,
111111
uint32_t len;
112112
uint16_t nb_segs;
113113
uint8_t *data;
114-
uint32_t cipher_offset, auth_offset;
115-
uint8_t cipher, auth;
114+
uint32_t cipher_offset, auth_offset = 0;
115+
bool cipher = false;
116+
bool digest_verify = false;
117+
bool is_encrypt = false;
116118
int res = 0;
117119

118120
if (op->status != RTE_CRYPTO_OP_STATUS_SUCCESS)
@@ -150,42 +152,43 @@ cperf_verify_op(struct rte_crypto_op *op,
150152

151153
switch (options->op_type) {
152154
case CPERF_CIPHER_ONLY:
153-
cipher = 1;
155+
cipher = true;
154156
cipher_offset = 0;
155-
auth = 0;
156-
auth_offset = 0;
157-
break;
158-
case CPERF_CIPHER_THEN_AUTH:
159-
cipher = 1;
160-
cipher_offset = 0;
161-
auth = 1;
162-
auth_offset = options->test_buffer_size;
157+
is_encrypt = options->cipher_op == RTE_CRYPTO_CIPHER_OP_ENCRYPT;
163158
break;
164159
case CPERF_AUTH_ONLY:
165-
cipher = 0;
166160
cipher_offset = 0;
167-
auth = 1;
168-
auth_offset = options->test_buffer_size;
161+
if (options->auth_op == RTE_CRYPTO_AUTH_OP_GENERATE) {
162+
auth_offset = options->test_buffer_size;
163+
digest_verify = true;
164+
}
169165
break;
166+
case CPERF_CIPHER_THEN_AUTH:
170167
case CPERF_AUTH_THEN_CIPHER:
171-
cipher = 1;
168+
cipher = true;
172169
cipher_offset = 0;
173-
auth = 1;
174-
auth_offset = options->test_buffer_size;
170+
if (options->cipher_op == RTE_CRYPTO_CIPHER_OP_ENCRYPT) {
171+
auth_offset = options->test_buffer_size;
172+
digest_verify = true;
173+
is_encrypt = true;
174+
}
175175
break;
176176
case CPERF_AEAD:
177-
cipher = 1;
177+
cipher = true;
178178
cipher_offset = 0;
179-
auth = 1;
180-
auth_offset = options->test_buffer_size;
179+
if (options->aead_op == RTE_CRYPTO_AEAD_OP_ENCRYPT) {
180+
auth_offset = options->test_buffer_size;
181+
digest_verify = true;
182+
is_encrypt = true;
183+
}
181184
break;
182185
default:
183186
res = 1;
184187
goto out;
185188
}
186189

187-
if (cipher == 1) {
188-
if (options->cipher_op == RTE_CRYPTO_CIPHER_OP_ENCRYPT)
190+
if (cipher) {
191+
if (is_encrypt)
189192
res += !!memcmp(data + cipher_offset,
190193
vector->ciphertext.data,
191194
options->test_buffer_size);
@@ -195,12 +198,8 @@ cperf_verify_op(struct rte_crypto_op *op,
195198
options->test_buffer_size);
196199
}
197200

198-
if (auth == 1) {
199-
if (options->auth_op == RTE_CRYPTO_AUTH_OP_GENERATE)
200-
res += !!memcmp(data + auth_offset,
201-
vector->digest.data,
202-
options->digest_sz);
203-
}
201+
if (digest_verify)
202+
res += !!memcmp(data + auth_offset, vector->digest.data, options->digest_sz);
204203

205204
out:
206205
rte_free(data);

0 commit comments

Comments
 (0)