chromium/crypto/encryptor_unittest.cc

// Copyright 2012 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifdef UNSAFE_BUFFERS_BUILD
// TODO(crbug.com/351564777): Remove this and convert code to safer constructs.
#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 {

// From NIST SP 800-38a test cast:
// - F.5.1 CTR-AES128.Encrypt
// - F.5.6 CTR-AES256.Encrypt
// http://csrc.nist.gov/publications/nistpubs/800-38a/sp800-38a.pdf
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) {}

}  // namespace

TEST(EncryptorTest, EncryptAES128CTR) {}

TEST(EncryptorTest, EncryptAES256CTR) {}

TEST(EncryptorTest, EncryptAES128CTR_MultipleDecrypt) {}

TEST(EncryptorTest, EncryptAES256CTR_MultipleDecrypt) {}

TEST(EncryptorTest, EncryptDecryptCTR) {}

// TODO(wtc): add more known-answer tests.  Test vectors are available from
// http://www.ietf.org/rfc/rfc3602
// http://csrc.nist.gov/publications/nistpubs/800-38a/sp800-38a.pdf
// http://gladman.plushost.co.uk/oldsite/AES/index.php
// http://csrc.nist.gov/groups/STM/cavp/documents/aes/KAT_AES.zip

// NIST SP 800-38A test vector F.2.5 CBC-AES256.Encrypt.
TEST(EncryptorTest, EncryptAES256CBC) {}

// Expected output derived from the NSS implementation.
TEST(EncryptorTest, EncryptAES128CBCRegression) {}

// Symmetric keys with an unsupported size should be rejected. Whether they are
// rejected by SymmetricKey::Import or Encryptor::Init depends on the platform.
TEST(EncryptorTest, UnsupportedKeySize) {}

TEST(EncryptorTest, UnsupportedIV) {}

TEST(EncryptorTest, EmptyEncryptCBC) {}

TEST(EncryptorTest, EmptyEncryptCTR) {}

TEST(EncryptorTest, CipherTextNotMultipleOfBlockSize) {}