Permalink
Browse files

Add auth_tag value testing (#323)

  • Loading branch information...
storojs72 authored and vixentael committed Sep 20, 2018
1 parent ab4d78b commit 669757adfc7f92245cbaea6c67a1788e2e2d2305
Showing with 11 additions and 0 deletions.
  1. +11 −0 tests/soter/soter_sym_test.c
@@ -268,6 +268,7 @@ static void test_known_values_gcm(void)
uint8_t auth_tag[MAX_AUTH_TAG_LENGTH];
uint8_t expected_auth_tag[MAX_AUTH_TAG_LENGTH];
size_t auth_tag_length=sizeof(auth_tag);
soter_status_t res;
@@ -307,6 +308,13 @@ static void test_known_values_gcm(void)
testsuite_fail_if(res, "string_to_bytes");
continue;
}
res = string_to_bytes(vectors_aead[i].authtag, expected_auth_tag, MAX_AUTH_TAG_LENGTH);
if (SOTER_SUCCESS != res)
{
testsuite_fail_if(res, "string_to_bytes");
continue;
}
/* Encryption */
ctx = soter_sym_aead_encrypt_create(vectors_aead[i].alg, key, strlen(vectors_aead[i].key) / 2, NULL,0,iv, strlen(vectors_aead[i].iv) / 2);
@@ -351,6 +359,9 @@ static void test_known_values_gcm(void)
}
testsuite_fail_if(memcmp(computed, ciphertext, computed_length), "known encryption");
testsuite_fail_if(memcmp(auth_tag, expected_auth_tag, auth_tag_length), "known encryption (auth tag value)");
/* Decryption */
ctx = soter_sym_aead_decrypt_create(vectors_aead[i].alg, key, strlen(vectors_aead[i].key) / 2, NULL, 0, iv, strlen(vectors_aead[i].iv) / 2);
if (NULL == ctx)

0 comments on commit 669757a

Please sign in to comment.