aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnoob Joseph <anoobj@marvell.com>2020-11-03 11:43:07 +0000
committerMatias Elo <matias.elo@nokia.com>2020-12-22 10:28:19 +0200
commit0f90f1788f15b7d2c41c23eaf969ac1c23738b6a (patch)
tree4a7c1af4cae4fc5d581c4aa2f346a21b4357bc56
parentd043c0e5c953528e85e1e7a18eb27a37236798e6 (diff)
validation: ipsec: move combined mode algos to generic suite
Extend current unit test validating all algo combinations to cover combined mode algos (like AES GCM) and remove individual tests. Signed-off-by: Anoob Joseph <anoobj@marvell.com> Reviewed-by: Janne Peltonen <janne.peltonen@nokia.com>
-rw-r--r--test/validation/api/ipsec/ipsec.c25
-rw-r--r--test/validation/api/ipsec/ipsec.h5
-rw-r--r--test/validation/api/ipsec/ipsec_test_out.c159
3 files changed, 57 insertions, 132 deletions
diff --git a/test/validation/api/ipsec/ipsec.c b/test/validation/api/ipsec/ipsec.c
index dccce2813..4a62dedb8 100644
--- a/test/validation/api/ipsec/ipsec.c
+++ b/test/validation/api/ipsec/ipsec.c
@@ -1,5 +1,6 @@
/* Copyright (c) 2017-2018, Linaro Limited
* Copyright (c) 2019-2020, Nokia
+ * Copyright (c) 2020, Marvell
* All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
@@ -332,12 +333,6 @@ int ipsec_check_esp_aes_gcm_128(void)
ODP_AUTH_ALG_AES_GCM, 0);
}
-int ipsec_check_esp_aes_gcm_192(void)
-{
- return ipsec_check_esp(ODP_CIPHER_ALG_AES_GCM, 192,
- ODP_AUTH_ALG_AES_GCM, 0);
-}
-
int ipsec_check_esp_aes_gcm_256(void)
{
return ipsec_check_esp(ODP_CIPHER_ALG_AES_GCM, 256,
@@ -380,24 +375,6 @@ int ipsec_check_esp_null_aes_gmac_256(void)
ODP_AUTH_ALG_AES_GMAC, 256);
}
-int ipsec_check_esp_aes_ccm_128(void)
-{
- return ipsec_check_esp(ODP_CIPHER_ALG_AES_CCM, 128,
- ODP_AUTH_ALG_AES_CCM, 0);
-}
-
-int ipsec_check_esp_aes_ccm_192(void)
-{
- return ipsec_check_esp(ODP_CIPHER_ALG_AES_CCM, 192,
- ODP_AUTH_ALG_AES_CCM, 0);
-}
-
-int ipsec_check_esp_aes_ccm_256(void)
-{
- return ipsec_check_esp(ODP_CIPHER_ALG_AES_CCM, 256,
- ODP_AUTH_ALG_AES_CCM, 0);
-}
-
int ipsec_check_esp_chacha20_poly1305(void)
{
return ipsec_check_esp(ODP_CIPHER_ALG_CHACHA20_POLY1305, 256,
diff --git a/test/validation/api/ipsec/ipsec.h b/test/validation/api/ipsec/ipsec.h
index 46b52d880..8ced8d97e 100644
--- a/test/validation/api/ipsec/ipsec.h
+++ b/test/validation/api/ipsec/ipsec.h
@@ -1,4 +1,5 @@
/* Copyright (c) 2017-2018, Linaro Limited
+ * Copyright (c) 2020, Marvell
* Copyright (c) 2020, Nokia
* All rights reserved.
*
@@ -96,7 +97,6 @@ int ipsec_check_esp_aes_cbc_128_sha1(void);
int ipsec_check_esp_aes_cbc_128_sha256(void);
int ipsec_check_esp_aes_ctr_128_null(void);
int ipsec_check_esp_aes_gcm_128(void);
-int ipsec_check_esp_aes_gcm_192(void);
int ipsec_check_esp_aes_gcm_256(void);
int ipsec_check_ah_aes_gmac_128(void);
int ipsec_check_ah_aes_gmac_192(void);
@@ -104,9 +104,6 @@ int ipsec_check_ah_aes_gmac_256(void);
int ipsec_check_esp_null_aes_gmac_128(void);
int ipsec_check_esp_null_aes_gmac_192(void);
int ipsec_check_esp_null_aes_gmac_256(void);
-int ipsec_check_esp_aes_ccm_128(void);
-int ipsec_check_esp_aes_ccm_192(void);
-int ipsec_check_esp_aes_ccm_256(void);
int ipsec_check_esp_chacha20_poly1305(void);
#endif
diff --git a/test/validation/api/ipsec/ipsec_test_out.c b/test/validation/api/ipsec/ipsec_test_out.c
index 9a3ba2bd3..0546656c3 100644
--- a/test/validation/api/ipsec/ipsec_test_out.c
+++ b/test/validation/api/ipsec/ipsec_test_out.c
@@ -1,4 +1,5 @@
/* Copyright (c) 2017-2018, Linaro Limited
+ * Copyright (c) 2020, Marvell
* Copyright (c) 2020, Nokia
* All rights reserved.
*
@@ -55,6 +56,54 @@ static struct auth_param auths[] = {
ALG(ODP_AUTH_ALG_AES_XCBC_MAC, &key_5a_128, NULL)
};
+struct cipher_auth_comb_param {
+ struct cipher_param cipher;
+ struct auth_param auth;
+};
+
+static struct cipher_auth_comb_param cipher_auth_comb[] = {
+ {
+ ALG(ODP_CIPHER_ALG_AES_GCM, &key_a5_128, &key_mcgrew_gcm_salt_2),
+ ALG(ODP_AUTH_ALG_AES_GCM, NULL, NULL),
+ },
+ {
+ ALG(ODP_CIPHER_ALG_AES_GCM, &key_a5_192, &key_mcgrew_gcm_salt_2),
+ ALG(ODP_AUTH_ALG_AES_GCM, NULL, NULL),
+ },
+ {
+ ALG(ODP_CIPHER_ALG_AES_GCM, &key_a5_256, &key_mcgrew_gcm_salt_2),
+ ALG(ODP_AUTH_ALG_AES_GCM, NULL, NULL),
+ },
+ {
+ ALG(ODP_CIPHER_ALG_NULL, NULL, NULL),
+ ALG(ODP_AUTH_ALG_AES_GMAC, &key_a5_128, &key_mcgrew_gcm_salt_2),
+ },
+ {
+ ALG(ODP_CIPHER_ALG_NULL, NULL, NULL),
+ ALG(ODP_AUTH_ALG_AES_GMAC, &key_a5_192, &key_mcgrew_gcm_salt_2),
+ },
+ {
+ ALG(ODP_CIPHER_ALG_NULL, NULL, NULL),
+ ALG(ODP_AUTH_ALG_AES_GMAC, &key_a5_256, &key_mcgrew_gcm_salt_2),
+ },
+ {
+ ALG(ODP_CIPHER_ALG_AES_CCM, &key_a5_128, &key_3byte_salt),
+ ALG(ODP_AUTH_ALG_AES_CCM, NULL, NULL),
+ },
+ {
+ ALG(ODP_CIPHER_ALG_AES_CCM, &key_a5_192, &key_3byte_salt),
+ ALG(ODP_AUTH_ALG_AES_CCM, NULL, NULL),
+ },
+ {
+ ALG(ODP_CIPHER_ALG_AES_CCM, &key_a5_256, &key_3byte_salt),
+ ALG(ODP_AUTH_ALG_AES_CCM, NULL, NULL),
+ },
+ {
+ ALG(ODP_CIPHER_ALG_CHACHA20_POLY1305, &key_rfc7634, &key_rfc7634_salt),
+ ALG(ODP_AUTH_ALG_CHACHA20_POLY1305, NULL, NULL),
+ },
+};
+
#define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0]))
static void test_out_ipv4_ah_sha256(void)
@@ -362,10 +411,8 @@ static void test_esp_out_in(struct cipher_param *cipher,
}
/*
- * Test ESP output followed by input with all combinations of normal
- * mode (not combined mode) ciphers and integrity algorithms.
- *
- * Combined mode algorithms are tested one-by-one in their own test cases.
+ * Test ESP output followed by input with all combinations of ciphers and
+ * integrity algorithms.
*/
static void test_esp_out_in_all(void)
{
@@ -375,6 +422,10 @@ static void test_esp_out_in_all(void)
for (c = 0; c < ARRAY_SIZE(ciphers); c++)
for (a = 0; a < ARRAY_SIZE(auths); a++)
test_esp_out_in(&ciphers[c], &auths[a]);
+
+ for (c = 0; c < ARRAY_SIZE(cipher_auth_comb); c++)
+ test_esp_out_in(&cipher_auth_comb[c].cipher,
+ &cipher_auth_comb[c].auth);
printf("\n ");
}
@@ -433,30 +484,6 @@ static void test_out_ipv4_esp_udp_null_sha256(void)
ipsec_sa_destroy(sa);
}
-static void test_out_ipv4_esp_aes_gcm128(void)
-{
- test_out_in_common(false,
- ODP_CIPHER_ALG_AES_GCM, &key_a5_128,
- ODP_AUTH_ALG_AES_GCM, NULL,
- &key_mcgrew_gcm_salt_2, NULL);
-}
-
-static void test_out_ipv4_esp_aes_gcm192(void)
-{
- test_out_in_common(false,
- ODP_CIPHER_ALG_AES_GCM, &key_a5_192,
- ODP_AUTH_ALG_AES_GCM, NULL,
- &key_mcgrew_gcm_salt_2, NULL);
-}
-
-static void test_out_ipv4_esp_aes_gcm256(void)
-{
- test_out_in_common(false,
- ODP_CIPHER_ALG_AES_GCM, &key_a5_256,
- ODP_AUTH_ALG_AES_GCM, NULL,
- &key_mcgrew_gcm_salt_2, NULL);
-}
-
static void test_out_ipv4_ah_aes_gmac_128(void)
{
test_out_in_common(true,
@@ -481,62 +508,6 @@ static void test_out_ipv4_ah_aes_gmac_256(void)
NULL, &key_mcgrew_gcm_salt_2);
}
-static void test_out_ipv4_esp_null_aes_gmac_128(void)
-{
- test_out_in_common(false,
- ODP_CIPHER_ALG_NULL, NULL,
- ODP_AUTH_ALG_AES_GMAC, &key_a5_128,
- NULL, &key_mcgrew_gcm_salt_2);
-}
-
-static void test_out_ipv4_esp_null_aes_gmac_192(void)
-{
- test_out_in_common(false,
- ODP_CIPHER_ALG_NULL, NULL,
- ODP_AUTH_ALG_AES_GMAC, &key_a5_192,
- NULL, &key_mcgrew_gcm_salt_2);
-}
-
-static void test_out_ipv4_esp_null_aes_gmac_256(void)
-{
- test_out_in_common(false,
- ODP_CIPHER_ALG_NULL, NULL,
- ODP_AUTH_ALG_AES_GMAC, &key_a5_256,
- NULL, &key_mcgrew_gcm_salt_2);
-}
-
-static void test_out_ipv4_esp_aes_ccm128(void)
-{
- test_out_in_common(false,
- ODP_CIPHER_ALG_AES_CCM, &key_a5_128,
- ODP_AUTH_ALG_AES_CCM, NULL,
- &key_3byte_salt, NULL);
-}
-
-static void test_out_ipv4_esp_aes_ccm192(void)
-{
- test_out_in_common(false,
- ODP_CIPHER_ALG_AES_CCM, &key_a5_192,
- ODP_AUTH_ALG_AES_CCM, NULL,
- &key_3byte_salt, NULL);
-}
-
-static void test_out_ipv4_esp_aes_ccm256(void)
-{
- test_out_in_common(false,
- ODP_CIPHER_ALG_AES_CCM, &key_a5_256,
- ODP_AUTH_ALG_AES_CCM, NULL,
- &key_3byte_salt, NULL);
-}
-
-static void test_out_ipv4_esp_chacha20_poly1305(void)
-{
- test_out_in_common(false,
- ODP_CIPHER_ALG_CHACHA20_POLY1305, &key_rfc7634,
- ODP_AUTH_ALG_CHACHA20_POLY1305, NULL,
- &key_rfc7634_salt, NULL);
-}
-
static void test_out_ipv4_ah_sha256_frag_check(void)
{
odp_ipsec_sa_param_t param;
@@ -1161,32 +1132,12 @@ odp_testinfo_t ipsec_out_suite[] = {
ipsec_check_esp_null_sha256),
ODP_TEST_INFO_CONDITIONAL(test_out_ipv4_esp_udp_null_sha256,
ipsec_check_esp_null_sha256),
- ODP_TEST_INFO_CONDITIONAL(test_out_ipv4_esp_aes_gcm128,
- ipsec_check_esp_aes_gcm_128),
- ODP_TEST_INFO_CONDITIONAL(test_out_ipv4_esp_aes_gcm192,
- ipsec_check_esp_aes_gcm_192),
- ODP_TEST_INFO_CONDITIONAL(test_out_ipv4_esp_aes_gcm256,
- ipsec_check_esp_aes_gcm_256),
ODP_TEST_INFO_CONDITIONAL(test_out_ipv4_ah_aes_gmac_128,
ipsec_check_ah_aes_gmac_128),
ODP_TEST_INFO_CONDITIONAL(test_out_ipv4_ah_aes_gmac_192,
ipsec_check_ah_aes_gmac_192),
ODP_TEST_INFO_CONDITIONAL(test_out_ipv4_ah_aes_gmac_256,
ipsec_check_ah_aes_gmac_256),
- ODP_TEST_INFO_CONDITIONAL(test_out_ipv4_esp_null_aes_gmac_128,
- ipsec_check_esp_null_aes_gmac_128),
- ODP_TEST_INFO_CONDITIONAL(test_out_ipv4_esp_null_aes_gmac_192,
- ipsec_check_esp_null_aes_gmac_192),
- ODP_TEST_INFO_CONDITIONAL(test_out_ipv4_esp_null_aes_gmac_256,
- ipsec_check_esp_null_aes_gmac_256),
- ODP_TEST_INFO_CONDITIONAL(test_out_ipv4_esp_aes_ccm128,
- ipsec_check_esp_aes_ccm_128),
- ODP_TEST_INFO_CONDITIONAL(test_out_ipv4_esp_aes_ccm192,
- ipsec_check_esp_aes_ccm_192),
- ODP_TEST_INFO_CONDITIONAL(test_out_ipv4_esp_aes_ccm256,
- ipsec_check_esp_aes_ccm_256),
- ODP_TEST_INFO_CONDITIONAL(test_out_ipv4_esp_chacha20_poly1305,
- ipsec_check_esp_chacha20_poly1305),
ODP_TEST_INFO_CONDITIONAL(test_out_ipv4_ah_sha256_frag_check,
ipsec_check_ah_sha256),
ODP_TEST_INFO_CONDITIONAL(test_out_ipv4_ah_sha256_frag_check_2,