Skip to content

Commit

Permalink
test/crypto: fix data lengths
Browse files Browse the repository at this point in the history
[ upstream commit f52b75c ]

This patch fixes incorrect data lengths computation in cryptodev
unit test. Previously some data lengths were incorrectly set, which
was insensitive for crypto op unit tets but is critical for raw data
path API unit tests. The patch addressed the issue by setting the
correct data lengths for some tests.

Fixes: 681f540 ("cryptodev: do not use AAD in wireless algorithms")
Fixes: e847fc5 ("test/crypto: add encrypted digest case for AES-CTR-CMAC")
Fixes: b1c1df4 ("test/crypto: add ZUC test cases for auth-cipher")

Signed-off-by: Kai Ji <kai.ji@intel.com>
Acked-by: Anoob Joseph <anoobj@marvell.com>
  • Loading branch information
KaiJiIntel authored and cpaelzer committed Nov 30, 2021
1 parent 6bf2029 commit 3cf7745
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions app/test/test_cryptodev.c
Expand Up @@ -3957,9 +3957,9 @@ test_kasumi_decryption(const struct kasumi_test_data *tdata)

/* Create KASUMI operation */
retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
tdata->cipher_iv.len,
tdata->ciphertext.len,
tdata->validCipherOffsetInBits.len);
tdata->cipher_iv.len,
RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
tdata->validCipherOffsetInBits.len);
if (retval < 0)
return retval;

Expand Down Expand Up @@ -5717,20 +5717,20 @@ test_zuc_auth_cipher(const struct wireless_test_data *tdata,
ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
ciphertext_pad_len);
memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
if (op_mode == OUT_OF_PLACE)
rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
debug_hexdump(stdout, "ciphertext:", ciphertext,
ciphertext_len);
} else {
/* make sure enough space to cover partial digest verify case */
plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
plaintext_pad_len);
ciphertext_pad_len);
memcpy(plaintext, tdata->plaintext.data, plaintext_len);
if (op_mode == OUT_OF_PLACE)
rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
debug_hexdump(stdout, "plaintext:", plaintext,
plaintext_len);
}

if (op_mode == OUT_OF_PLACE)
rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);

/* Create ZUC operation */
retval = create_wireless_algo_auth_cipher_operation(
tdata->digest.data, tdata->digest.len,
Expand Down Expand Up @@ -6704,19 +6704,19 @@ test_mixed_auth_cipher(const struct mixed_cipher_auth_test_data *tdata,
ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
ciphertext_pad_len);
memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
if (op_mode == OUT_OF_PLACE)
rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
debug_hexdump(stdout, "ciphertext:", ciphertext,
ciphertext_len);
} else {
/* make sure enough space to cover partial digest verify case */
plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
plaintext_pad_len);
ciphertext_pad_len);
memcpy(plaintext, tdata->plaintext.data, plaintext_len);
if (op_mode == OUT_OF_PLACE)
rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
}

if (op_mode == OUT_OF_PLACE)
rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);

/* Create the operation */
retval = create_wireless_algo_auth_cipher_operation(
tdata->digest_enc.data, tdata->digest_enc.len,
Expand Down

0 comments on commit 3cf7745

Please sign in to comment.