diff mbox series

[API-NEXT,v3,6/6] fixup! validation: crypto: use auth IV for GMAC test case

Message ID 1514242817-22123-7-git-send-email-odpbot@yandex.ru
State New
Headers show
Series [API-NEXT,v3,1/6] linux-gen: crypto: move session type to odp_crypto module | expand

Commit Message

Github ODP bot Dec. 25, 2017, 11 p.m. UTC
From: Dmitry Eremin-Solenikov <dmitry.ereminsolenikov@linaro.org>


Signed-off-by: Dmitry Eremin-Solenikov <dmitry.ereminsolenikov@linaro.org>

---
/** Email created from pull request 352 (lumag:crypto_gmac_iv)
 ** https://github.com/Linaro/odp/pull/352
 ** Patch: https://github.com/Linaro/odp/pull/352.patch
 ** Base sha: a5f07dbf95f982b7c5898434e56164ff976c0a0f
 ** Merge commit sha: 17da319d68f1b79fbec6d76e925b5d4c9665aaf3
 **/
 test/validation/api/crypto/odp_crypto_test_inp.c | 50 ++++++++++++++++++++++--
 1 file changed, 47 insertions(+), 3 deletions(-)
diff mbox series

Patch

diff --git a/test/validation/api/crypto/odp_crypto_test_inp.c b/test/validation/api/crypto/odp_crypto_test_inp.c
index 748a64dcf..d9b43c0b1 100644
--- a/test/validation/api/crypto/odp_crypto_test_inp.c
+++ b/test/validation/api/crypto/odp_crypto_test_inp.c
@@ -79,6 +79,7 @@  static int alg_op(odp_packet_t pkt,
 		  odp_bool_t *ok,
 		  odp_crypto_session_t session,
 		  uint8_t *op_iv_ptr,
+		  uint8_t *op_auth_iv_ptr,
 		  odp_packet_data_range_t *cipher_range,
 		  odp_packet_data_range_t *auth_range,
 		  uint8_t *aad,
@@ -99,8 +100,10 @@  static int alg_op(odp_packet_t pkt,
 
 	op_params.cipher_range = *cipher_range;
 	op_params.auth_range = *auth_range;
-	if (op_iv_ptr)
+	if (op_iv_ptr) {
 		op_params.override_iv_ptr = op_iv_ptr;
+		op_params.override_auth_iv_ptr = op_auth_iv_ptr;
+	}
 
 	op_params.aad_ptr = aad;
 
@@ -154,6 +157,7 @@  static int alg_packet_op(odp_packet_t pkt,
 			 odp_bool_t *ok,
 			 odp_crypto_session_t session,
 			 uint8_t *op_iv_ptr,
+			 uint8_t *op_auth_iv_ptr,
 			 odp_packet_data_range_t *cipher_range,
 			 odp_packet_data_range_t *auth_range,
 			 uint8_t *aad,
@@ -171,8 +175,10 @@  static int alg_packet_op(odp_packet_t pkt,
 
 	op_params.cipher_range = *cipher_range;
 	op_params.auth_range = *auth_range;
-	if (op_iv_ptr)
+	if (op_iv_ptr) {
 		op_params.override_iv_ptr = op_iv_ptr;
+		op_params.override_auth_iv_ptr = op_auth_iv_ptr;
+	}
 
 	op_params.aad_ptr = aad;
 
@@ -211,6 +217,7 @@  static int alg_packet_op_enq(odp_packet_t pkt,
 			     odp_bool_t *ok,
 			     odp_crypto_session_t session,
 			     uint8_t *op_iv_ptr,
+			     uint8_t *op_auth_iv_ptr,
 			     odp_packet_data_range_t *cipher_range,
 			     odp_packet_data_range_t *auth_range,
 			     uint8_t *aad,
@@ -229,8 +236,10 @@  static int alg_packet_op_enq(odp_packet_t pkt,
 
 	op_params.cipher_range = *cipher_range;
 	op_params.auth_range = *auth_range;
-	if (op_iv_ptr)
+	if (op_iv_ptr) {
 		op_params.override_iv_ptr = op_iv_ptr;
+		op_params.override_auth_iv_ptr = op_auth_iv_ptr;
+	}
 
 	op_params.aad_ptr = aad;
 
@@ -494,16 +503,19 @@  static void alg_test(odp_crypto_op_t op,
 		if (!suite_context.packet)
 			rc = alg_op(pkt, &ok, session,
 				    ovr_iv ? ref->iv : NULL,
+				    ovr_iv ? ref->auth_iv : NULL,
 				    &cipher_range, &auth_range,
 				    ref->aad, ref->length);
 		else if (ODP_CRYPTO_ASYNC == suite_context.op_mode)
 			rc = alg_packet_op_enq(pkt, &ok, session,
 					       ovr_iv ? ref->iv : NULL,
+					       ovr_iv ? ref->auth_iv : NULL,
 					       &cipher_range, &auth_range,
 					       ref->aad, ref->length);
 		else
 			rc = alg_packet_op(pkt, &ok, session,
 					   ovr_iv ? ref->iv : NULL,
+					   ovr_iv ? ref->auth_iv : NULL,
 					   &cipher_range, &auth_range,
 					   ref->aad, ref->length);
 		if (rc < 0)
@@ -1167,6 +1179,20 @@  static void crypto_test_gen_alg_aes_gmac(void)
 			 false);
 }
 
+static void crypto_test_gen_alg_aes_gmac_ovr_iv(void)
+{
+	unsigned int test_vec_num = (sizeof(aes_gmac_reference) /
+				     sizeof(aes_gmac_reference[0]));
+	unsigned int i;
+
+	for (i = 0; i < test_vec_num; i++)
+		alg_test(ODP_CRYPTO_OP_ENCODE,
+			 ODP_CIPHER_ALG_NULL,
+			 ODP_AUTH_ALG_AES_GMAC,
+			 &aes_gmac_reference[i],
+			 true);
+}
+
 static void crypto_test_check_alg_aes_gmac(void)
 {
 	unsigned int test_vec_num = (sizeof(aes_gmac_reference) /
@@ -1181,6 +1207,20 @@  static void crypto_test_check_alg_aes_gmac(void)
 			 false);
 }
 
+static void crypto_test_check_alg_aes_gmac_ovr_iv(void)
+{
+	unsigned int test_vec_num = (sizeof(aes_gmac_reference) /
+				     sizeof(aes_gmac_reference[0]));
+	unsigned int i;
+
+	for (i = 0; i < test_vec_num; i++)
+		alg_test(ODP_CRYPTO_OP_DECODE,
+			 ODP_CIPHER_ALG_NULL,
+			 ODP_AUTH_ALG_AES_GMAC,
+			 &aes_gmac_reference[i],
+			 true);
+}
+
 int crypto_suite_sync_init(void)
 {
 	suite_context.pool = odp_pool_lookup("packet_pool");
@@ -1288,8 +1328,12 @@  odp_testinfo_t crypto_suite[] = {
 				  check_alg_hmac_sha512),
 	ODP_TEST_INFO_CONDITIONAL(crypto_test_gen_alg_aes_gmac,
 				  check_alg_aes_gmac),
+	ODP_TEST_INFO_CONDITIONAL(crypto_test_gen_alg_aes_gmac_ovr_iv,
+				  check_alg_aes_gmac),
 	ODP_TEST_INFO_CONDITIONAL(crypto_test_check_alg_aes_gmac,
 				  check_alg_aes_gmac),
+	ODP_TEST_INFO_CONDITIONAL(crypto_test_check_alg_aes_gmac_ovr_iv,
+				  check_alg_aes_gmac),
 	ODP_TEST_INFO_NULL,
 };