diff mbox series

[API-NEXT,v2,1/20] test: crypto: explicitly pass auth_digest_len to crypto subsystem

Message ID 1495490409-30066-2-git-send-email-odpbot@yandex.ru
State Superseded
Headers show
Series [API-NEXT,v2,1/20] test: crypto: explicitly pass auth_digest_len to crypto subsystem | expand

Commit Message

Github ODP bot May 22, 2017, 9:59 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 34 (lumag:crypto-update-main-new)
 ** https://github.com/Linaro/odp/pull/34
 ** Patch: https://github.com/Linaro/odp/pull/34.patch
 ** Base sha: 826ee894aa0ebd09d42a17e1de077c46bc5b366a
 ** Merge commit sha: 7c49c61063e2d57f049a5436cf12a3c36710bb34
 **/
 .../validation/api/crypto/odp_crypto_test_inp.c    | 57 +++++++++++++---------
 .../validation/api/crypto/test_vectors.h           | 10 ++++
 .../validation/api/crypto/test_vectors_len.h       |  3 --
 3 files changed, 43 insertions(+), 27 deletions(-)
diff mbox series

Patch

diff --git a/test/common_plat/validation/api/crypto/odp_crypto_test_inp.c b/test/common_plat/validation/api/crypto/odp_crypto_test_inp.c
index bfc9da3c..3d09e374 100644
--- a/test/common_plat/validation/api/crypto/odp_crypto_test_inp.c
+++ b/test/common_plat/validation/api/crypto/odp_crypto_test_inp.c
@@ -201,6 +201,7 @@  static void alg_test(odp_crypto_op_t op,
 	ses_params.cipher_key = cipher_key;
 	ses_params.iv = ses_iv;
 	ses_params.auth_key = auth_key;
+	ses_params.auth_digest_len = digest_len;
 
 	rc = odp_crypto_session_create(&ses_params, &session, &status);
 	CU_ASSERT_FATAL(!rc);
@@ -620,7 +621,8 @@  void crypto_test_enc_alg_aes128_gcm(void)
 					  cipher_key.length, iv.length))
 			continue;
 		if (!check_auth_options(ODP_AUTH_ALG_AES_GCM,
-					auth_key.length, AES128_GCM_CHECK_LEN))
+					auth_key.length,
+					aes128_gcm_reference_tag_length[i]))
 			continue;
 
 		alg_test(ODP_CRYPTO_OP_ENCODE,
@@ -639,7 +641,7 @@  void crypto_test_enc_alg_aes128_gcm(void)
 			 aes128_gcm_reference_length[i],
 			 aes128_gcm_reference_ciphertext[i] +
 			 aes128_gcm_reference_length[i],
-			 AES128_GCM_CHECK_LEN);
+			 aes128_gcm_reference_tag_length[i]);
 	}
 }
 
@@ -664,7 +666,8 @@  void crypto_test_enc_alg_aes128_gcm_ovr_iv(void)
 					  cipher_key.length, iv.length))
 			continue;
 		if (!check_auth_options(ODP_AUTH_ALG_AES_GCM,
-					auth_key.length, AES128_GCM_CHECK_LEN))
+					auth_key.length,
+					aes128_gcm_reference_tag_length[i]))
 			continue;
 
 		alg_test(ODP_CRYPTO_OP_ENCODE,
@@ -683,7 +686,7 @@  void crypto_test_enc_alg_aes128_gcm_ovr_iv(void)
 			 aes128_gcm_reference_length[i],
 			 aes128_gcm_reference_ciphertext[i] +
 			 aes128_gcm_reference_length[i],
-			 AES128_GCM_CHECK_LEN);
+			 aes128_gcm_reference_tag_length[i]);
 	}
 }
 
@@ -714,7 +717,8 @@  void crypto_test_dec_alg_aes128_gcm(void)
 					  cipher_key.length, iv.length))
 			continue;
 		if (!check_auth_options(ODP_AUTH_ALG_AES_GCM,
-					auth_key.length, AES128_GCM_CHECK_LEN))
+					auth_key.length,
+					aes128_gcm_reference_tag_length[i]))
 			continue;
 
 		alg_test(ODP_CRYPTO_OP_DECODE,
@@ -728,12 +732,13 @@  void crypto_test_dec_alg_aes128_gcm(void)
 			 &aes128_gcm_cipher_range[i],
 			 &aes128_gcm_auth_range[i],
 			 aes128_gcm_reference_ciphertext[i],
-			 aes128_gcm_reference_length[i] + AES128_GCM_CHECK_LEN,
+			 aes128_gcm_reference_length[i] +
+			 aes128_gcm_reference_tag_length[i],
 			 aes128_gcm_reference_plaintext[i],
 			 aes128_gcm_reference_length[i],
 			 aes128_gcm_reference_ciphertext[i] +
 			 aes128_gcm_reference_length[i],
-			 AES128_GCM_CHECK_LEN);
+			 aes128_gcm_reference_tag_length[i]);
 
 		alg_test(ODP_CRYPTO_OP_DECODE,
 			 1,
@@ -746,11 +751,12 @@  void crypto_test_dec_alg_aes128_gcm(void)
 			 &aes128_gcm_cipher_range[i],
 			 &aes128_gcm_auth_range[i],
 			 aes128_gcm_reference_ciphertext[i],
-			 aes128_gcm_reference_length[i] + AES128_GCM_CHECK_LEN,
+			 aes128_gcm_reference_length[i] +
+			 aes128_gcm_reference_tag_length[i],
 			 aes128_gcm_reference_plaintext[i],
 			 aes128_gcm_reference_length[i],
 			 wrong_digest,
-			 AES128_GCM_CHECK_LEN);
+			 aes128_gcm_reference_tag_length[i]);
 	}
 }
 
@@ -779,7 +785,8 @@  void crypto_test_dec_alg_aes128_gcm_ovr_iv(void)
 					  cipher_key.length, iv.length))
 			continue;
 		if (!check_auth_options(ODP_AUTH_ALG_AES_GCM,
-					auth_key.length, AES128_GCM_CHECK_LEN))
+					auth_key.length,
+					aes128_gcm_reference_tag_length[i]))
 			continue;
 
 		alg_test(ODP_CRYPTO_OP_DECODE,
@@ -793,12 +800,13 @@  void crypto_test_dec_alg_aes128_gcm_ovr_iv(void)
 			 &aes128_gcm_cipher_range[i],
 			 &aes128_gcm_auth_range[i],
 			 aes128_gcm_reference_ciphertext[i],
-			 aes128_gcm_reference_length[i] + AES128_GCM_CHECK_LEN,
+			 aes128_gcm_reference_length[i] +
+			 aes128_gcm_reference_tag_length[i],
 			 aes128_gcm_reference_plaintext[i],
 			 aes128_gcm_reference_length[i],
 			 aes128_gcm_reference_ciphertext[i] +
 			 aes128_gcm_reference_length[i],
-			 AES128_GCM_CHECK_LEN);
+			 aes128_gcm_reference_tag_length[i]);
 
 		alg_test(ODP_CRYPTO_OP_DECODE,
 			 1,
@@ -811,11 +819,12 @@  void crypto_test_dec_alg_aes128_gcm_ovr_iv(void)
 			 &aes128_gcm_cipher_range[i],
 			 &aes128_gcm_auth_range[i],
 			 aes128_gcm_reference_ciphertext[i],
-			 aes128_gcm_reference_length[i] + AES128_GCM_CHECK_LEN,
+			 aes128_gcm_reference_length[i] +
+			 aes128_gcm_reference_tag_length[i],
 			 aes128_gcm_reference_plaintext[i],
 			 aes128_gcm_reference_length[i],
 			 wrong_digest,
-			 AES128_GCM_CHECK_LEN);
+			 aes128_gcm_reference_tag_length[i]);
 	}
 }
 
@@ -1004,7 +1013,7 @@  void crypto_test_gen_alg_hmac_md5(void)
 		auth_key.length = sizeof(hmac_md5_reference_key[i]);
 
 		if (!check_auth_options(ODP_AUTH_ALG_MD5_HMAC, auth_key.length,
-					HMAC_MD5_96_CHECK_LEN))
+					hmac_md5_reference_digest_length[i]))
 			continue;
 
 		alg_test(ODP_CRYPTO_OP_ENCODE,
@@ -1020,7 +1029,7 @@  void crypto_test_gen_alg_hmac_md5(void)
 			 hmac_md5_reference_length[i],
 			 NULL, 0,
 			 hmac_md5_reference_digest[i],
-			 HMAC_MD5_96_CHECK_LEN);
+			 hmac_md5_reference_digest_length[i]);
 	}
 }
 
@@ -1042,7 +1051,7 @@  void crypto_test_check_alg_hmac_md5(void)
 		auth_key.length = sizeof(hmac_md5_reference_key[i]);
 
 		if (!check_auth_options(ODP_AUTH_ALG_MD5_HMAC, auth_key.length,
-					HMAC_MD5_96_CHECK_LEN))
+					hmac_md5_reference_digest_length[i]))
 			continue;
 
 		alg_test(ODP_CRYPTO_OP_DECODE,
@@ -1058,7 +1067,7 @@  void crypto_test_check_alg_hmac_md5(void)
 			 hmac_md5_reference_length[i],
 			 NULL, 0,
 			 hmac_md5_reference_digest[i],
-			 HMAC_MD5_96_CHECK_LEN);
+			 hmac_md5_reference_digest_length[i]);
 
 		alg_test(ODP_CRYPTO_OP_DECODE,
 			 1,
@@ -1073,7 +1082,7 @@  void crypto_test_check_alg_hmac_md5(void)
 			 hmac_md5_reference_length[i],
 			 NULL, 0,
 			 wrong_digest,
-			 HMAC_MD5_96_CHECK_LEN);
+			 hmac_md5_reference_digest_length[i]);
 	}
 }
 
@@ -1106,7 +1115,7 @@  void crypto_test_gen_alg_hmac_sha256(void)
 
 		if (!check_auth_options(ODP_AUTH_ALG_SHA256_HMAC,
 					auth_key.length,
-					HMAC_SHA256_128_CHECK_LEN))
+					hmac_sha256_reference_digest_length[i]))
 			continue;
 
 		alg_test(ODP_CRYPTO_OP_ENCODE,
@@ -1122,7 +1131,7 @@  void crypto_test_gen_alg_hmac_sha256(void)
 			 hmac_sha256_reference_length[i],
 			 NULL, 0,
 			 hmac_sha256_reference_digest[i],
-			 HMAC_SHA256_128_CHECK_LEN);
+			 hmac_sha256_reference_digest_length[i]);
 	}
 }
 
@@ -1146,7 +1155,7 @@  void crypto_test_check_alg_hmac_sha256(void)
 
 		if (!check_auth_options(ODP_AUTH_ALG_SHA256_HMAC,
 					auth_key.length,
-					HMAC_SHA256_128_CHECK_LEN))
+					hmac_sha256_reference_digest_length[i]))
 			continue;
 
 		alg_test(ODP_CRYPTO_OP_DECODE,
@@ -1162,7 +1171,7 @@  void crypto_test_check_alg_hmac_sha256(void)
 			 hmac_sha256_reference_length[i],
 			 NULL, 0,
 			 hmac_sha256_reference_digest[i],
-			 HMAC_SHA256_128_CHECK_LEN);
+			 hmac_sha256_reference_digest_length[i]);
 
 		alg_test(ODP_CRYPTO_OP_DECODE,
 			 1,
@@ -1177,7 +1186,7 @@  void crypto_test_check_alg_hmac_sha256(void)
 			 hmac_sha256_reference_length[i],
 			 NULL, 0,
 			 wrong_digest,
-			 HMAC_SHA256_128_CHECK_LEN);
+			 hmac_sha256_reference_digest_length[i]);
 	}
 }
 
diff --git a/test/common_plat/validation/api/crypto/test_vectors.h b/test/common_plat/validation/api/crypto/test_vectors.h
index a1cf4faf..defbda45 100644
--- a/test/common_plat/validation/api/crypto/test_vectors.h
+++ b/test/common_plat/validation/api/crypto/test_vectors.h
@@ -139,6 +139,8 @@  static uint8_t aes128_gcm_reference_iv[][AES128_GCM_IV_LEN] = {
 
 static uint32_t aes128_gcm_reference_length[] = { 84, 72, 72, 40};
 
+static uint32_t aes128_gcm_reference_tag_length[] = { 16, 16, 16, 16};
+
 static odp_packet_data_range_t aes128_gcm_cipher_range[] = {
 	{ .offset = 12, .length = 72 },
 	{ .offset = 8, .length = 64 },
@@ -306,6 +308,10 @@  static uint8_t hmac_md5_reference_digest[][HMAC_MD5_DIGEST_LEN] = {
 	  0xdb, 0xb8, 0xc7, 0x33, 0xf0, 0xe8, 0xb3, 0xf6 }
 };
 
+static uint32_t hmac_md5_reference_digest_length[] = {
+	12, 12, 12
+};
+
 static uint8_t hmac_sha256_reference_key[][HMAC_SHA256_KEY_LEN] = {
 	{ 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b,
 	  0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b,
@@ -350,4 +356,8 @@  static uint8_t hmac_sha256_reference_digest[][HMAC_SHA256_DIGEST_LEN] = {
 	  0x85, 0x4d, 0xb8, 0xeb, 0xd0, 0x91, 0x81, 0xa7 }
 };
 
+static uint32_t hmac_sha256_reference_digest_length[] = {
+	16, 16, 16
+};
+
 #endif
diff --git a/test/common_plat/validation/api/crypto/test_vectors_len.h b/test/common_plat/validation/api/crypto/test_vectors_len.h
index 4fbb5cd7..80fd927b 100644
--- a/test/common_plat/validation/api/crypto/test_vectors_len.h
+++ b/test/common_plat/validation/api/crypto/test_vectors_len.h
@@ -21,18 +21,15 @@ 
 #define AES128_GCM_IV_LEN         12
 #define AES128_GCM_MAX_DATA_LEN   106
 #define AES128_GCM_DIGEST_LEN     16
-#define AES128_GCM_CHECK_LEN      16
 
 /* HMAC-MD5 */
 #define HMAC_MD5_KEY_LEN        16
 #define HMAC_MD5_MAX_DATA_LEN   128
 #define HMAC_MD5_DIGEST_LEN     16
-#define HMAC_MD5_96_CHECK_LEN   12
 
 /* HMAC-SHA256 */
 #define HMAC_SHA256_KEY_LEN        32
 #define HMAC_SHA256_MAX_DATA_LEN   128
 #define HMAC_SHA256_DIGEST_LEN     32
-#define HMAC_SHA256_128_CHECK_LEN  16
 
 #endif