Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add auth_tag value testing #323

Merged
merged 1 commit into from
Sep 20, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions tests/soter/soter_sym_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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)
Expand Down