From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 4108BA04F0 for ; Mon, 13 Jan 2020 12:51:22 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 220D31C436; Mon, 13 Jan 2020 12:51:22 +0100 (CET) Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by dpdk.org (Postfix) with ESMTP id F34241C436 for ; Mon, 13 Jan 2020 12:51:19 +0100 (CET) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga106.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 13 Jan 2020 03:51:18 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.69,428,1571727600"; d="scan'208";a="304821008" Received: from akusztax-mobl.ger.corp.intel.com ([10.103.104.121]) by orsmga001.jf.intel.com with ESMTP; 13 Jan 2020 03:51:17 -0800 From: Arek Kusztal To: stable@dpdk.org Cc: fiona.trahe@intel.com, Arek Kusztal Date: Mon, 13 Jan 2020 12:51:14 +0100 Message-Id: <20200113115114.9832-1-arkadiuszx.kusztal@intel.com> X-Mailer: git-send-email 2.19.1.windows.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-stable] [PATCH 18.11] test/crypto: fix checks for null digest in null auth X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org Sender: "stable" [ upstream 3c60756c736a4439e3ee75a29cdf5d35fb58c8d3 ] This patch fixes checks in null auth algorithm tests. Fixes: 3c60756c736a ("test/crypto: improve NULL authentication validation") Signed-off-by: Arek Kusztal --- 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