From: Arek Kusztal <arkadiuszx.kusztal@intel.com>
To: stable@dpdk.org
Cc: fiona.trahe@intel.com, Arek Kusztal <arkadiuszx.kusztal@intel.com>
Subject: [dpdk-stable] [PATCH 18.11] test/crypto: fix checks for null digest in null auth
Date: Mon, 13 Jan 2020 12:51:14 +0100 [thread overview]
Message-ID: <20200113115114.9832-1-arkadiuszx.kusztal@intel.com> (raw)
[ upstream 3c60756c736a4439e3ee75a29cdf5d35fb58c8d3 ]
This patch fixes checks in null auth algorithm tests.
Fixes: 3c60756c736a ("test/crypto: improve NULL authentication validation")
Signed-off-by: Arek Kusztal <arkadiuszx.kusztal@intel.com>
---
test/test/test_cryptodev.c | 61 +++++++++++++++++++---------------------------
1 file changed, 25 insertions(+), 36 deletions(-)
diff --git a/test/test/test_cryptodev.c b/test/test/test_cryptodev.c
index 5ddd257..7b654f3 100644
--- a/test/test/test_cryptodev.c
+++ b/test/test/test_cryptodev.c
@@ -6978,28 +6978,23 @@ test_null_cipher_only_operation(void)
return TEST_SUCCESS;
}
-uint8_t orig_data[] = {0xab, 0xab, 0xab, 0xab,
- 0xab, 0xab, 0xab, 0xab,
- 0xab, 0xab, 0xab, 0xab,
- 0xab, 0xab, 0xab, 0xab};
+
+#define CRYPTO_NULL_DIGEST_LEN 4
+
static int
test_null_auth_only_operation(void)
{
struct crypto_testsuite_params *ts_params = &testsuite_params;
struct crypto_unittest_params *ut_params = &unittest_params;
+ const char ver_vector[CRYPTO_NULL_DIGEST_LEN] = { 0 };
uint8_t *digest;
/* Generate test mbuf data and space for digest */
ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
catch_22_quote, QUOTE_512_BYTES, 0);
-
- /* create a pointer for digest, but don't expect anything to be written
- * here in a NULL auth algo so no mbuf append done.
- */
- digest = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
- QUOTE_512_BYTES);
- /* prefill the memory pointed to by digest */
- memcpy(digest, orig_data, sizeof(orig_data));
+ digest = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf, CRYPTO_NULL_DIGEST_LEN);
+ memset(digest, 0, CRYPTO_NULL_DIGEST_LEN);
+ ut_params->auth_xform.auth.digest_length = CRYPTO_NULL_DIGEST_LEN;
/* Setup HMAC Parameters */
ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
@@ -7045,10 +7040,10 @@ test_null_auth_only_operation(void)
"crypto operation processing failed");
/* Make sure memory pointed to by digest hasn't been overwritten */
TEST_ASSERT_BUFFERS_ARE_EQUAL(
- orig_data,
+ ver_vector,
digest,
- sizeof(orig_data),
- "Memory at digest ptr overwritten unexpectedly");
+ CRYPTO_NULL_DIGEST_LEN,
+ "Digest not as expected");
return TEST_SUCCESS;
}
@@ -7059,19 +7054,16 @@ test_null_cipher_auth_operation(void)
{
struct crypto_testsuite_params *ts_params = &testsuite_params;
struct crypto_unittest_params *ut_params = &unittest_params;
+ const char ver_vector[CRYPTO_NULL_DIGEST_LEN] = { 0 };
uint8_t *digest;
/* Generate test mbuf data and space for digest */
ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
catch_22_quote, QUOTE_512_BYTES, 0);
- /* create a pointer for digest, but don't expect anything to be written
- * here in a NULL auth algo so no mbuf append done.
- */
- digest = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
- QUOTE_512_BYTES);
- /* prefill the memory pointed to by digest */
- memcpy(digest, orig_data, sizeof(orig_data));
+ digest = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf, CRYPTO_NULL_DIGEST_LEN);
+ memset(digest, 0, CRYPTO_NULL_DIGEST_LEN);
+ ut_params->auth_xform.auth.digest_length = CRYPTO_NULL_DIGEST_LEN;
/* Setup Cipher Parameters */
ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
@@ -7134,10 +7126,10 @@ test_null_cipher_auth_operation(void)
"Ciphertext data not as expected");
/* Make sure memory pointed to by digest hasn't been overwritten */
TEST_ASSERT_BUFFERS_ARE_EQUAL(
- orig_data,
+ ver_vector,
digest,
- sizeof(orig_data),
- "Memory at digest ptr overwritten unexpectedly");
+ CRYPTO_NULL_DIGEST_LEN,
+ "Digest not as expected");
return TEST_SUCCESS;
}
@@ -7147,19 +7139,16 @@ test_null_auth_cipher_operation(void)
{
struct crypto_testsuite_params *ts_params = &testsuite_params;
struct crypto_unittest_params *ut_params = &unittest_params;
+ const char ver_vector[CRYPTO_NULL_DIGEST_LEN] = { 0 };
uint8_t *digest;
- /* Generate test mbuf data */
+ /* Generate test mbuf data and space for digest */
ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
catch_22_quote, QUOTE_512_BYTES, 0);
- /* create a pointer for digest, but don't expect anything to be written
- * here in a NULL auth algo so no mbuf append done.
- */
- digest = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
- QUOTE_512_BYTES);
- /* prefill the memory pointed to by digest */
- memcpy(digest, orig_data, sizeof(orig_data));
+ digest = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf, CRYPTO_NULL_DIGEST_LEN);
+ memset(digest, 0, CRYPTO_NULL_DIGEST_LEN);
+ ut_params->auth_xform.auth.digest_length = CRYPTO_NULL_DIGEST_LEN;
/* Setup Cipher Parameters */
ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
@@ -7222,10 +7211,10 @@ test_null_auth_cipher_operation(void)
"Ciphertext data not as expected");
/* Make sure memory pointed to by digest hasn't been overwritten */
TEST_ASSERT_BUFFERS_ARE_EQUAL(
- orig_data,
+ ver_vector,
digest,
- sizeof(orig_data),
- "Memory at digest ptr overwritten unexpectedly");
+ CRYPTO_NULL_DIGEST_LEN,
+ "Digest not as expected");
return TEST_SUCCESS;
}
--
2.1.0
next reply other threads:[~2020-01-13 11:51 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-01-13 11:51 Arek Kusztal [this message]
2020-01-14 14:28 ` Kevin Traynor
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200113115114.9832-1-arkadiuszx.kusztal@intel.com \
--to=arkadiuszx.kusztal@intel.com \
--cc=fiona.trahe@intel.com \
--cc=stable@dpdk.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).