DPDK patches and discussions
 help / color / mirror / Atom feed
From: Anoob Joseph <anoobj@marvell.com>
To: Akhil Goyal <gakhil@marvell.com>, Fan Zhang <fanzhang.oss@gmail.com>
Cc: Hemant Agrawal <hemant.agrawal@nxp.com>,
	Jerin Jacob <jerinj@marvell.com>,
	 Aakash Sasidharan <asasidharan@marvell.com>,
	Tejasree Kondoj <ktejasree@marvell.com>,
	Vidya Sagar Velumuri <vvelumuri@marvell.com>, <dev@dpdk.org>
Subject: [PATCH 1/6] test/crypto: add asserts to validate test lengths
Date: Thu, 22 Aug 2024 07:16:29 +0000	[thread overview]
Message-ID: <20240822071651.2403105-2-anoobj@marvell.com> (raw)
In-Reply-To: <20240822071651.2403105-1-anoobj@marvell.com>

Add asserts to validate the max lengths set.

Signed-off-by: Anoob Joseph <anoobj@marvell.com>
---
 app/test/test_cryptodev.c                   |  2 +-
 app/test/test_cryptodev.h                   |  2 ++
 app/test/test_cryptodev_aead_test_vectors.h | 14 +++++++++++++-
 3 files changed, 16 insertions(+), 2 deletions(-)

diff --git a/app/test/test_cryptodev.c b/app/test/test_cryptodev.c
index 0c445f9eae..9d8ca8f616 100644
--- a/app/test/test_cryptodev.c
+++ b/app/test/test_cryptodev.c
@@ -665,7 +665,7 @@ testsuite_setup(void)
 		/* Not already created so create */
 		ts_params->large_mbuf_pool = rte_pktmbuf_pool_create(
 				"CRYPTO_LARGE_MBUFPOOL",
-				1, 0, 0, UINT16_MAX,
+				1, 0, 0, LARGE_MBUF_SIZE,
 				rte_socket_id());
 		if (ts_params->large_mbuf_pool == NULL) {
 			RTE_LOG(ERR, USER1,
diff --git a/app/test/test_cryptodev.h b/app/test/test_cryptodev.h
index fd9ea0dd81..af56145cdd 100644
--- a/app/test/test_cryptodev.h
+++ b/app/test/test_cryptodev.h
@@ -24,6 +24,8 @@
 #define MBUF_DATAPAYLOAD_SIZE		(4096 + DIGEST_BYTE_LENGTH_SHA512)
 #define MBUF_SIZE			(sizeof(struct rte_mbuf) + \
 		RTE_PKTMBUF_HEADROOM + MBUF_DATAPAYLOAD_SIZE)
+#define LARGE_MBUF_DATAPAYLOAD_SIZE	(UINT16_MAX - RTE_PKTMBUF_HEADROOM)
+#define LARGE_MBUF_SIZE			(RTE_PKTMBUF_HEADROOM + LARGE_MBUF_DATAPAYLOAD_SIZE)
 
 #define BYTE_LENGTH(x)				(x/8)
 /* HASH DIGEST LENGTHS */
diff --git a/app/test/test_cryptodev_aead_test_vectors.h b/app/test/test_cryptodev_aead_test_vectors.h
index e9b0590048..73bfb8dad4 100644
--- a/app/test/test_cryptodev_aead_test_vectors.h
+++ b/app/test/test_cryptodev_aead_test_vectors.h
@@ -5,11 +5,23 @@
 #ifndef TEST_CRYPTODEV_AEAD_TEST_VECTORS_H_
 #define TEST_CRYPTODEV_AEAD_TEST_VECTORS_H_
 
+#include "test_cryptodev.h"
+
 #define GMAC_LARGE_PLAINTEXT_LENGTH		65344
-#define MAX_AAD_LENGTH				65536
+#define MAX_AAD_LENGTH				(65535 - RTE_PKTMBUF_HEADROOM)
 #define GCM_LARGE_AAD_LENGTH			65296
 #define AEAD_TEXT_MAX_LENGTH			8096
 
+static_assert(GMAC_LARGE_PLAINTEXT_LENGTH <= LARGE_MBUF_DATAPAYLOAD_SIZE,
+	      "GMAC_LARGE_PLAINTEXT_LENGTH should not be greater than LARGE_MBUF_DATAPAYLOAD_SIZE");
+static_assert(MAX_AAD_LENGTH <= LARGE_MBUF_DATAPAYLOAD_SIZE,
+	      "MAX_AAD_LENGTH should not be greater than LARGE_MBUF_DATAPAYLOAD_SIZE");
+static_assert(GCM_LARGE_AAD_LENGTH <= LARGE_MBUF_DATAPAYLOAD_SIZE,
+	      "GCM_LARGE_AAD_LENGTH should not be greater than LARGE_MBUF_DATAPAYLOAD_SIZE");
+static_assert(AEAD_TEXT_MAX_LENGTH <= LARGE_MBUF_DATAPAYLOAD_SIZE,
+	      "AEAD_TEXT_MAX_LENGTH should not be greater than LARGE_MBUF_DATAPAYLOAD_SIZE");
+
+
 static uint8_t gcm_aad_zero_text[MAX_AAD_LENGTH] = { 0 };
 
 static uint8_t gcm_aad_text[MAX_AAD_LENGTH] = {
-- 
2.45.2


  reply	other threads:[~2024-08-22  7:41 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-08-22  7:16 [PATCH 0/6] Fixes and improvements in crypto unit tests Anoob Joseph
2024-08-22  7:16 ` Anoob Joseph [this message]
2024-08-22  7:16 ` [PATCH 2/6] test/crypto: enable larger packet sizes with TLS Anoob Joseph
2024-08-22  7:16 ` [PATCH 3/6] test/crypto: remove redefinition Anoob Joseph
2024-08-22  7:16 ` [PATCH 4/6] test/crypto: remove unused macros Anoob Joseph
2024-08-22  7:16 ` [PATCH 5/6] test/crypto: start opening brace in new line Anoob Joseph
2024-08-22  7:16 ` [PATCH 6/6] test/crypto: free pools in teardown Anoob Joseph
2024-09-18  5:36 ` [PATCH 0/6] Fixes and improvements in crypto unit tests Akhil Goyal

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=20240822071651.2403105-2-anoobj@marvell.com \
    --to=anoobj@marvell.com \
    --cc=asasidharan@marvell.com \
    --cc=dev@dpdk.org \
    --cc=fanzhang.oss@gmail.com \
    --cc=gakhil@marvell.com \
    --cc=hemant.agrawal@nxp.com \
    --cc=jerinj@marvell.com \
    --cc=ktejasree@marvell.com \
    --cc=vvelumuri@marvell.com \
    /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).