diff mbox series

[API-NEXT,v1,3/4] validation: crypto: use auth IV for GMAC test case

Message ID 1513724415-24899-4-git-send-email-odpbot@yandex.ru
State Superseded
Headers show
Series [API-NEXT,v1,1/4] linux-gen: crypto: move session type to odp_crypto module | expand

Commit Message

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


Change GMAC testing code to use new auth IV fields.

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: 12fd3a9224a856271934986a1bad981843915d68
 ** Merge commit sha: ceb7bff0f74da9fec7efa8d45d3078c2485ca305
 **/
 test/validation/api/crypto/odp_crypto_test_inp.c | 11 +++++++++--
 test/validation/api/crypto/test_vectors.h        |  8 +++++---
 2 files changed, 14 insertions(+), 5 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 cba472ded..9c2303ac5 100644
--- a/test/validation/api/crypto/odp_crypto_test_inp.c
+++ b/test/validation/api/crypto/odp_crypto_test_inp.c
@@ -314,6 +314,10 @@  static void alg_test(odp_crypto_op_t op,
 		.data = ovr_iv ? NULL : ref->iv,
 		.length = ref->iv_length
 	};
+	odp_crypto_iv_t auth_iv = {
+		.data = ovr_iv ? NULL : ref->auth_iv,
+		.length = ref->auth_iv_length
+	};
 	int num, i;
 	int found;
 
@@ -407,6 +411,7 @@  static void alg_test(odp_crypto_op_t op,
 	/* Search for the test case */
 	for (i = 0; i < num; i++) {
 		if (auth_capa[i].digest_len == ref->digest_length &&
+		    auth_capa[i].iv_len     == auth_iv.length &&
 		    auth_capa[i].key_len    == auth_key.length) {
 			found = 1;
 			break;
@@ -415,8 +420,9 @@  static void alg_test(odp_crypto_op_t op,
 
 	if (!found) {
 		printf("\n    Unsupported: alg=%s, key_len=%" PRIu32 ", "
-		       "digest_len=%" PRIu32 "\n", auth_alg_name(auth_alg),
-		       auth_key.length, ref->digest_length);
+		       "digest_len=%" PRIu32 ", iv_len=%" PRIu32 "\n",
+		       auth_alg_name(auth_alg), auth_key.length,
+		       ref->digest_length, auth_iv.length);
 		return;
 	}
 
@@ -432,6 +438,7 @@  static void alg_test(odp_crypto_op_t op,
 	ses_params.output_pool = suite_context.pool;
 	ses_params.cipher_key = cipher_key;
 	ses_params.iv = iv;
+	ses_params.auth_iv = auth_iv;
 	ses_params.auth_key = auth_key;
 	ses_params.auth_digest_len = ref->digest_length;
 	ses_params.auth_aad_len = ref->aad_length;
diff --git a/test/validation/api/crypto/test_vectors.h b/test/validation/api/crypto/test_vectors.h
index f2ce9eb2f..90b020356 100644
--- a/test/validation/api/crypto/test_vectors.h
+++ b/test/validation/api/crypto/test_vectors.h
@@ -16,6 +16,8 @@  typedef struct crypto_test_reference_s {
 	uint8_t auth_key[MAX_KEY_LEN];
 	uint32_t iv_length;
 	uint8_t iv[MAX_IV_LEN];
+	uint32_t auth_iv_length;
+	uint8_t auth_iv[MAX_IV_LEN];
 	uint32_t length;
 	uint8_t plaintext[MAX_DATA_LEN];
 	uint8_t ciphertext[MAX_DATA_LEN];
@@ -447,9 +449,9 @@  static crypto_test_reference_t aes_gmac_reference[] = {
 		.auth_key_length = AES128_GCM_KEY_LEN,
 		.auth_key = { 0x4c, 0x80, 0xcd, 0xef, 0xbb, 0x5d, 0x10, 0xda,
 			      0x90, 0x6a, 0xc7, 0x3c, 0x36, 0x13, 0xa6, 0x34},
-		.iv_length = AES_GCM_IV_LEN,
-		.iv = { 0x22, 0x43, 0x3c, 0x64, 0x00, 0x00, 0x00, 0x00,
-			0x00, 0x00, 0x00, 0x00 },
+		.auth_iv_length = AES_GCM_IV_LEN,
+		.auth_iv = { 0x22, 0x43, 0x3c, 0x64, 0x00, 0x00, 0x00, 0x00,
+			     0x00, 0x00, 0x00, 0x00 },
 		.length = 68,
 		.plaintext = { 0x00, 0x00, 0x43, 0x21, 0x00, 0x00, 0x00, 0x07,
 			       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,