Add unit test for any length in AES-GCM.

This commit is contained in:
Nathan Moinvaziri 2023-04-26 17:27:35 -07:00
parent 99efb55637
commit c958ac8f7c

View File

@ -255,7 +255,7 @@ TEST(crypt, aes128_gcm) {
mz_crypt_aes_set_mode(aes, MZ_AES_MODE_GCM);
EXPECT_EQ(mz_crypt_aes_set_encrypt_key(aes, key, key_length, iv, iv_length), MZ_OK);
EXPECT_EQ(mz_crypt_aes_encrypt(aes, buf, test_length), test_length);
EXPECT_EQ(mz_crypt_aes_encrypt(aes, buf + test_length, test_length), test_length);
EXPECT_EQ(mz_crypt_aes_encrypt(aes, buf + test_length - 1, test_length - 1), test_length - 1);
EXPECT_EQ(mz_crypt_aes_get_tag(aes, tag, sizeof(tag)), MZ_OK);
mz_crypt_aes_delete(&aes);
@ -266,12 +266,12 @@ TEST(crypt, aes128_gcm) {
mz_crypt_aes_set_mode(aes, MZ_AES_MODE_GCM);
EXPECT_EQ(mz_crypt_aes_set_decrypt_key(aes, key, key_length, iv, iv_length), MZ_OK);
EXPECT_EQ(mz_crypt_aes_decrypt(aes, buf, test_length), test_length);
EXPECT_EQ(mz_crypt_aes_decrypt(aes, buf + test_length, test_length), test_length);
EXPECT_EQ(mz_crypt_aes_decrypt(aes, buf + test_length - 1, test_length - 1), test_length - 1);
EXPECT_EQ(mz_crypt_aes_verify_tag(aes, tag, sizeof(tag)), MZ_OK);
mz_crypt_aes_delete(&aes);
EXPECT_EQ(memcmp(buf, test, test_length), 0);
EXPECT_EQ(memcmp(buf + test_length, test, test_length), 0);
EXPECT_EQ(memcmp(buf + test_length, test, test_length - 1), 0);
#endif
}