Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(895)

Unified Diff: crypto/encryptor_unittest.cc

Issue 6805019: Move crypto files out of base, to a top level directory. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: crypto/encryptor_unittest.cc
===================================================================
--- crypto/encryptor_unittest.cc (revision 79901)
+++ crypto/encryptor_unittest.cc (working copy)
@@ -2,25 +2,25 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "base/crypto/encryptor.h"
wtc 2011/04/07 05:35:53 It's correct to include "crypto/encryptor.h" first
rvargas (doing something else) 2011/04/08 21:04:07 I wish the style guide did't change under me.
-
#include <string>
-#include "base/crypto/symmetric_key.h"
#include "base/memory/scoped_ptr.h"
#include "base/string_number_conversions.h"
+#include "crypto/encryptor.h"
+#include "crypto/symmetric_key.h"
#include "testing/gtest/include/gtest/gtest.h"
TEST(EncryptorTest, EncryptDecrypt) {
- scoped_ptr<base::SymmetricKey> key(base::SymmetricKey::DeriveKeyFromPassword(
- base::SymmetricKey::AES, "password", "saltiest", 1000, 256));
+ scoped_ptr<crypto::SymmetricKey> key(
+ crypto::SymmetricKey::DeriveKeyFromPassword(
+ crypto::SymmetricKey::AES, "password", "saltiest", 1000, 256));
EXPECT_TRUE(NULL != key.get());
- base::Encryptor encryptor;
+ crypto::Encryptor encryptor;
// The IV must be exactly as long as the cipher block size.
std::string iv("the iv: 16 bytes");
EXPECT_EQ(16U, iv.size());
- EXPECT_TRUE(encryptor.Init(key.get(), base::Encryptor::CBC, iv));
+ EXPECT_TRUE(encryptor.Init(key.get(), crypto::Encryptor::CBC, iv));
std::string plaintext("this is the plaintext");
std::string ciphertext;
@@ -86,15 +86,15 @@
};
std::string key(reinterpret_cast<const char*>(raw_key), sizeof(raw_key));
- scoped_ptr<base::SymmetricKey> sym_key(base::SymmetricKey::Import(
- base::SymmetricKey::AES, key));
+ scoped_ptr<crypto::SymmetricKey> sym_key(crypto::SymmetricKey::Import(
+ crypto::SymmetricKey::AES, key));
ASSERT_TRUE(NULL != sym_key.get());
- base::Encryptor encryptor;
+ crypto::Encryptor encryptor;
// The IV must be exactly as long a the cipher block size.
std::string iv(reinterpret_cast<const char*>(raw_iv), sizeof(raw_iv));
EXPECT_EQ(16U, iv.size());
- EXPECT_TRUE(encryptor.Init(sym_key.get(), base::Encryptor::CBC, iv));
+ EXPECT_TRUE(encryptor.Init(sym_key.get(), crypto::Encryptor::CBC, iv));
std::string plaintext(reinterpret_cast<const char*>(raw_plaintext),
sizeof(raw_plaintext));
@@ -119,14 +119,14 @@
"D4A67A0BA33C30F207344D81D1E944BBE65587C3D7D9939A"
"C070C62B9C15A3EA312EA4AD1BC7929F4D3C16B03AD5ADA8";
- scoped_ptr<base::SymmetricKey> sym_key(base::SymmetricKey::Import(
- base::SymmetricKey::AES, key));
+ scoped_ptr<crypto::SymmetricKey> sym_key(crypto::SymmetricKey::Import(
+ crypto::SymmetricKey::AES, key));
ASSERT_TRUE(NULL != sym_key.get());
- base::Encryptor encryptor;
+ crypto::Encryptor encryptor;
// The IV must be exactly as long a the cipher block size.
EXPECT_EQ(16U, iv.size());
- EXPECT_TRUE(encryptor.Init(sym_key.get(), base::Encryptor::CBC, iv));
+ EXPECT_TRUE(encryptor.Init(sym_key.get(), crypto::Encryptor::CBC, iv));
std::string ciphertext;
EXPECT_TRUE(encryptor.Encrypt(plaintext, &ciphertext));
@@ -145,14 +145,14 @@
std::string plaintext = "Small text";
std::string expected_ciphertext_hex = "78DE5D7C2714FC5C61346C5416F6C89A";
- scoped_ptr<base::SymmetricKey> sym_key(base::SymmetricKey::Import(
- base::SymmetricKey::AES, key));
+ scoped_ptr<crypto::SymmetricKey> sym_key(crypto::SymmetricKey::Import(
+ crypto::SymmetricKey::AES, key));
ASSERT_TRUE(NULL != sym_key.get());
- base::Encryptor encryptor;
+ crypto::Encryptor encryptor;
// The IV must be exactly as long a the cipher block size.
EXPECT_EQ(16U, iv.size());
- EXPECT_TRUE(encryptor.Init(sym_key.get(), base::Encryptor::CBC, iv));
+ EXPECT_TRUE(encryptor.Init(sym_key.get(), crypto::Encryptor::CBC, iv));
std::string ciphertext;
EXPECT_TRUE(encryptor.Encrypt(plaintext, &ciphertext));
@@ -170,26 +170,26 @@
TEST(EncryptorTest, UnsupportedKeySize) {
std::string key = "7 = bad";
std::string iv = "Sweet Sixteen IV";
- scoped_ptr<base::SymmetricKey> sym_key(base::SymmetricKey::Import(
- base::SymmetricKey::AES, key));
+ scoped_ptr<crypto::SymmetricKey> sym_key(crypto::SymmetricKey::Import(
+ crypto::SymmetricKey::AES, key));
ASSERT_TRUE(NULL != sym_key.get());
- base::Encryptor encryptor;
+ crypto::Encryptor encryptor;
// The IV must be exactly as long a the cipher block size.
EXPECT_EQ(16U, iv.size());
- EXPECT_FALSE(encryptor.Init(sym_key.get(), base::Encryptor::CBC, iv));
+ EXPECT_FALSE(encryptor.Init(sym_key.get(), crypto::Encryptor::CBC, iv));
}
#endif // unsupported platforms.
TEST(EncryptorTest, UnsupportedIV) {
std::string key = "128=SixteenBytes";
std::string iv = "OnlyForteen :(";
- scoped_ptr<base::SymmetricKey> sym_key(base::SymmetricKey::Import(
- base::SymmetricKey::AES, key));
+ scoped_ptr<crypto::SymmetricKey> sym_key(crypto::SymmetricKey::Import(
+ crypto::SymmetricKey::AES, key));
ASSERT_TRUE(NULL != sym_key.get());
- base::Encryptor encryptor;
- EXPECT_FALSE(encryptor.Init(sym_key.get(), base::Encryptor::CBC, iv));
+ crypto::Encryptor encryptor;
+ EXPECT_FALSE(encryptor.Init(sym_key.get(), crypto::Encryptor::CBC, iv));
}
TEST(EncryptorTest, EmptyEncrypt) {
@@ -198,14 +198,14 @@
std::string plaintext;
std::string expected_ciphertext_hex = "8518B8878D34E7185E300D0FCC426396";
- scoped_ptr<base::SymmetricKey> sym_key(base::SymmetricKey::Import(
- base::SymmetricKey::AES, key));
+ scoped_ptr<crypto::SymmetricKey> sym_key(crypto::SymmetricKey::Import(
+ crypto::SymmetricKey::AES, key));
ASSERT_TRUE(NULL != sym_key.get());
- base::Encryptor encryptor;
+ crypto::Encryptor encryptor;
// The IV must be exactly as long a the cipher block size.
EXPECT_EQ(16U, iv.size());
- EXPECT_TRUE(encryptor.Init(sym_key.get(), base::Encryptor::CBC, iv));
+ EXPECT_TRUE(encryptor.Init(sym_key.get(), crypto::Encryptor::CBC, iv));
std::string ciphertext;
EXPECT_TRUE(encryptor.Encrypt(plaintext, &ciphertext));
@@ -217,14 +217,14 @@
std::string key = "128=SixteenBytes";
std::string iv = "Sweet Sixteen IV";
- scoped_ptr<base::SymmetricKey> sym_key(base::SymmetricKey::Import(
- base::SymmetricKey::AES, key));
+ scoped_ptr<crypto::SymmetricKey> sym_key(crypto::SymmetricKey::Import(
+ crypto::SymmetricKey::AES, key));
ASSERT_TRUE(NULL != sym_key.get());
- base::Encryptor encryptor;
+ crypto::Encryptor encryptor;
// The IV must be exactly as long a the cipher block size.
EXPECT_EQ(16U, iv.size());
- EXPECT_TRUE(encryptor.Init(sym_key.get(), base::Encryptor::CBC, iv));
+ EXPECT_TRUE(encryptor.Init(sym_key.get(), crypto::Encryptor::CBC, iv));
std::string decrypted;
EXPECT_FALSE(encryptor.Decrypt("", &decrypted));

Powered by Google App Engine
This is Rietveld 408576698