Skip to content

Commit

Permalink
app/crypto-perf: fix data comparison
Browse files Browse the repository at this point in the history
[ upstream commit ddec2a39bae12da2817392239ddce19f3953fd53 ]

The function memcmp() returns an integer less than, equal to,
or greater than zero. In current code, if the first memcmp()
returns less than zero and the second memcmp() returns greater
than zero, the sum of results may still be 0 and indicates
verify successed.

This commit converts the return value to be zero or greater
than zero. That will make sure the sum of results be correct.

Fixes: df52cb3 ("app/crypto-perf: move verify as single test type")

Signed-off-by: Suanming Mou <suanmingm@nvidia.com>
Acked-by: Anoob Joseph <anoobj@marvell.com>
Acked-by: Ciara Power <ciara.power@intel.com>
  • Loading branch information
smou-mlnx authored and kevintraynor committed Mar 5, 2024
1 parent fa23c86 commit 4fe2036
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions app/test-crypto-perf/cperf_test_verify.c
Original file line number Diff line number Diff line change
Expand Up @@ -175,18 +175,18 @@ cperf_verify_op(struct rte_crypto_op *op,

if (cipher == 1) {
if (options->cipher_op == RTE_CRYPTO_CIPHER_OP_ENCRYPT)
res += memcmp(data + cipher_offset,
res += !!memcmp(data + cipher_offset,
vector->ciphertext.data,
options->test_buffer_size);
else
res += memcmp(data + cipher_offset,
res += !!memcmp(data + cipher_offset,
vector->plaintext.data,
options->test_buffer_size);
}

if (auth == 1) {
if (options->auth_op == RTE_CRYPTO_AUTH_OP_GENERATE)
res += memcmp(data + auth_offset,
res += !!memcmp(data + auth_offset,
vector->digest.data,
options->digest_sz);
}
Expand Down

0 comments on commit 4fe2036

Please sign in to comment.