mirror of
https://github.com/zlib-ng/minizip-ng
synced 2025-03-28 21:13:18 +00:00
Add unit test for any length in AES-GCM.
This commit is contained in:
parent
99efb55637
commit
c958ac8f7c
@ -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
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user