[API-NEXT,v2,3/7] test: crypto: add AES-GCM tests with wrong tag value

Message ID 1494021606-16187-2-git-send-email-odpbot@yandex.ru
State New
Headers show
Series
  • [API-NEXT,v2,1/7] linux: crypto: use auth_digest_len when calculating HMACs
Related show

Commit Message

Github ODP bot May 5, 2017, 10 p.m.
From: Dmitry Eremin-Solenikov <dmitry.ereminsolenikov@linaro.org>


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

---
/** Email created from pull request 24 (lumag:crypto-dal)
 ** https://github.com/Linaro/odp/pull/24
 ** Patch: https://github.com/Linaro/odp/pull/24.patch
 ** Base sha: 540490ddf3a1b3da4b80ed15fc874ccdfc49b60c
 ** Merge commit sha: 9e32a5ccf92bee9741891a2bb50d27ee8756e388
 **/
 .../validation/api/crypto/odp_crypto_test_inp.c    | 40 ++++++++++++++++++++++
 1 file changed, 40 insertions(+)

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 db380c2..de48ac0 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
@@ -697,10 +697,13 @@  void crypto_test_dec_alg_aes128_gcm(void)
 	odp_crypto_key_t cipher_key = { .data = NULL, .length = 0 },
 			 auth_key   = { .data = NULL, .length = 0 };
 	odp_crypto_iv_t iv = { .data = NULL, .length = AES128_GCM_IV_LEN };
+	uint8_t wrong_digest[AES128_GCM_DIGEST_LEN];
 	unsigned int test_vec_num = (sizeof(aes128_gcm_reference_length) /
 				     sizeof(aes128_gcm_reference_length[0]));
 	unsigned int i;
 
+	memset(wrong_digest, 0xa5, sizeof(wrong_digest));
+
 	for (i = 0; i < test_vec_num; i++) {
 		cipher_key.data = aes128_gcm_reference_key[i];
 		cipher_key.length = sizeof(aes128_gcm_reference_key[i]);
@@ -731,6 +734,23 @@  void crypto_test_dec_alg_aes128_gcm(void)
 			 aes128_gcm_reference_ciphertext[i] +
 			 aes128_gcm_reference_length[i],
 			 AES128_GCM_CHECK_LEN);
+
+		alg_test(ODP_CRYPTO_OP_DECODE,
+			 1,
+			 ODP_CIPHER_ALG_AES_GCM,
+			 iv,
+			 NULL,
+			 cipher_key,
+			 ODP_AUTH_ALG_AES_GCM,
+			 auth_key,
+			 &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_plaintext[i],
+			 aes128_gcm_reference_length[i],
+			 wrong_digest,
+			 AES128_GCM_CHECK_LEN);
 	}
 }
 
@@ -744,10 +764,13 @@  void crypto_test_dec_alg_aes128_gcm_ovr_iv(void)
 	odp_crypto_key_t cipher_key = { .data = NULL, .length = 0 },
 			 auth_key   = { .data = NULL, .length = 0 };
 	odp_crypto_iv_t iv = { .data = NULL, .length = AES128_GCM_IV_LEN };
+	uint8_t wrong_digest[AES128_GCM_DIGEST_LEN];
 	unsigned int test_vec_num = (sizeof(aes128_gcm_reference_length) /
 				     sizeof(aes128_gcm_reference_length[0]));
 	unsigned int i;
 
+	memset(wrong_digest, 0xa5, sizeof(wrong_digest));
+
 	for (i = 0; i < test_vec_num; i++) {
 		cipher_key.data = aes128_gcm_reference_key[i];
 		cipher_key.length = sizeof(aes128_gcm_reference_key[i]);
@@ -776,6 +799,23 @@  void crypto_test_dec_alg_aes128_gcm_ovr_iv(void)
 			 aes128_gcm_reference_ciphertext[i] +
 			 aes128_gcm_reference_length[i],
 			 AES128_GCM_CHECK_LEN);
+
+		alg_test(ODP_CRYPTO_OP_DECODE,
+			 1,
+			 ODP_CIPHER_ALG_AES_GCM,
+			 iv,
+			 aes128_gcm_reference_iv[i],
+			 cipher_key,
+			 ODP_AUTH_ALG_AES_GCM,
+			 auth_key,
+			 &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_plaintext[i],
+			 aes128_gcm_reference_length[i],
+			 wrong_digest,
+			 AES128_GCM_CHECK_LEN);
 	}
 }