#ifdef UNSAFE_BUFFERS_BUILD
#pragma allow_unsafe_buffers
#endif
#include "crypto/encryptor.h"
#include <stddef.h>
#include <memory>
#include <string>
#include "base/containers/heap_array.h"
#include "base/containers/span.h"
#include "base/strings/string_number_conversions.h"
#include "crypto/symmetric_key.h"
#include "testing/gtest/include/gtest/gtest.h"
TEST(EncryptorTest, EncryptDecrypt) { … }
TEST(EncryptorTest, DecryptWrongKey) { … }
namespace {
const unsigned char kAES128CTRKey[] = …;
const unsigned char kAES256CTRKey[] = …;
const unsigned char kAESCTRInitCounter[] = …;
const unsigned char kAESCTRPlaintext[] = …;
const unsigned char kAES128CTRCiphertext[] = …;
const unsigned char kAES256CTRCiphertext[] = …;
void TestAESCTREncrypt(
const unsigned char* key, size_t key_size,
const unsigned char* init_counter, size_t init_counter_size,
const unsigned char* plaintext, size_t plaintext_size,
const unsigned char* ciphertext, size_t ciphertext_size) { … }
void TestAESCTRMultipleDecrypt(
const unsigned char* key, size_t key_size,
const unsigned char* init_counter, size_t init_counter_size,
const unsigned char* plaintext, size_t plaintext_size,
const unsigned char* ciphertext, size_t ciphertext_size) { … }
}
TEST(EncryptorTest, EncryptAES128CTR) { … }
TEST(EncryptorTest, EncryptAES256CTR) { … }
TEST(EncryptorTest, EncryptAES128CTR_MultipleDecrypt) { … }
TEST(EncryptorTest, EncryptAES256CTR_MultipleDecrypt) { … }
TEST(EncryptorTest, EncryptDecryptCTR) { … }
TEST(EncryptorTest, EncryptAES256CBC) { … }
TEST(EncryptorTest, EncryptAES128CBCRegression) { … }
TEST(EncryptorTest, UnsupportedKeySize) { … }
TEST(EncryptorTest, UnsupportedIV) { … }
TEST(EncryptorTest, EmptyEncryptCBC) { … }
TEST(EncryptorTest, EmptyEncryptCTR) { … }
TEST(EncryptorTest, CipherTextNotMultipleOfBlockSize) { … }