[1/6] test/crypto: add asserts to validate test lengths
Checks
Commit Message
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(-)
@@ -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,
@@ -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 */
@@ -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] = {