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

Unified Diff: crypto/symmetric_key_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/symmetric_key_unittest.cc
===================================================================
--- crypto/symmetric_key_unittest.cc (revision 79901)
+++ crypto/symmetric_key_unittest.cc (working copy)
@@ -2,18 +2,17 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "base/crypto/symmetric_key.h"
wtc 2011/04/07 05:35:53 It is correct to include "crypto/symmetric_key.h"
-
#include <string>
#include "base/memory/scoped_ptr.h"
#include "base/string_number_conversions.h"
#include "base/string_util.h"
+#include "crypto/symmetric_key.h"
#include "testing/gtest/include/gtest/gtest.h"
TEST(SymmetricKeyTest, GenerateRandomKey) {
- scoped_ptr<base::SymmetricKey> key(
- base::SymmetricKey::GenerateRandomKey(base::SymmetricKey::AES, 256));
+ scoped_ptr<crypto::SymmetricKey> key(
+ crypto::SymmetricKey::GenerateRandomKey(crypto::SymmetricKey::AES, 256));
ASSERT_TRUE(NULL != key.get());
std::string raw_key;
EXPECT_TRUE(key->GetRawKey(&raw_key));
@@ -21,8 +20,8 @@
// Do it again and check that the keys are different.
// (Note: this has a one-in-10^77 chance of failure!)
- scoped_ptr<base::SymmetricKey> key2(
- base::SymmetricKey::GenerateRandomKey(base::SymmetricKey::AES, 256));
+ scoped_ptr<crypto::SymmetricKey> key2(
+ crypto::SymmetricKey::GenerateRandomKey(crypto::SymmetricKey::AES, 256));
ASSERT_TRUE(NULL != key2.get());
std::string raw_key2;
EXPECT_TRUE(key2->GetRawKey(&raw_key2));
@@ -31,14 +30,14 @@
}
TEST(SymmetricKeyTest, ImportGeneratedKey) {
- scoped_ptr<base::SymmetricKey> key1(
- base::SymmetricKey::GenerateRandomKey(base::SymmetricKey::AES, 256));
+ scoped_ptr<crypto::SymmetricKey> key1(
+ crypto::SymmetricKey::GenerateRandomKey(crypto::SymmetricKey::AES, 256));
ASSERT_TRUE(NULL != key1.get());
std::string raw_key1;
EXPECT_TRUE(key1->GetRawKey(&raw_key1));
- scoped_ptr<base::SymmetricKey> key2(
- base::SymmetricKey::Import(base::SymmetricKey::AES, raw_key1));
+ scoped_ptr<crypto::SymmetricKey> key2(
+ crypto::SymmetricKey::Import(crypto::SymmetricKey::AES, raw_key1));
ASSERT_TRUE(NULL != key2.get());
std::string raw_key2;
@@ -48,16 +47,15 @@
}
TEST(SymmetricKeyTest, ImportDerivedKey) {
- scoped_ptr<base::SymmetricKey> key1(
- base::SymmetricKey::DeriveKeyFromPassword(base::SymmetricKey::HMAC_SHA1,
- "password", "somesalt", 1024,
- 160));
+ scoped_ptr<crypto::SymmetricKey> key1(
+ crypto::SymmetricKey::DeriveKeyFromPassword(
+ crypto::SymmetricKey::HMAC_SHA1, "password", "somesalt", 1024, 160));
ASSERT_TRUE(NULL != key1.get());
std::string raw_key1;
EXPECT_TRUE(key1->GetRawKey(&raw_key1));
- scoped_ptr<base::SymmetricKey> key2(
- base::SymmetricKey::Import(base::SymmetricKey::HMAC_SHA1, raw_key1));
+ scoped_ptr<crypto::SymmetricKey> key2(
+ crypto::SymmetricKey::Import(crypto::SymmetricKey::HMAC_SHA1, raw_key1));
ASSERT_TRUE(NULL != key2.get());
std::string raw_key2;
@@ -67,7 +65,7 @@
}
struct PBKDF2TestVector {
- base::SymmetricKey::Algorithm algorithm;
+ crypto::SymmetricKey::Algorithm algorithm;
const char* password;
const char* salt;
unsigned int rounds;
@@ -90,8 +88,8 @@
}
#endif // OS_MACOSX
- scoped_ptr<base::SymmetricKey> key(
- base::SymmetricKey::DeriveKeyFromPassword(
+ scoped_ptr<crypto::SymmetricKey> key(
+ crypto::SymmetricKey::DeriveKeyFromPassword(
test_data.algorithm,
test_data.password, test_data.salt,
test_data.rounds, test_data.key_size_in_bits));
@@ -109,7 +107,7 @@
// These tests come from
// http://www.ietf.org/id/draft-josefsson-pbkdf2-test-vectors-00.txt
{
- base::SymmetricKey::HMAC_SHA1,
+ crypto::SymmetricKey::HMAC_SHA1,
"password",
"salt",
1,
@@ -117,7 +115,7 @@
"0c60c80f961f0e71f3a9b524af6012062fe037a6",
},
{
- base::SymmetricKey::HMAC_SHA1,
+ crypto::SymmetricKey::HMAC_SHA1,
"password",
"salt",
2,
@@ -125,7 +123,7 @@
"ea6c014dc72d6f8ccd1ed92ace1d41f0d8de8957",
},
{
- base::SymmetricKey::HMAC_SHA1,
+ crypto::SymmetricKey::HMAC_SHA1,
"password",
"salt",
4096,
@@ -135,7 +133,7 @@
// This test takes over 30s to run on the trybots.
#if 0
{
- base::SymmetricKey::HMAC_SHA1,
+ crypto::SymmetricKey::HMAC_SHA1,
"password",
"salt",
16777216,
@@ -147,7 +145,7 @@
// These tests come from RFC 3962, via BSD source code at
// http://www.openbsd.org/cgi-bin/cvsweb/src/sbin/bioctl/pbkdf2.c?rev=HEAD&content-type=text/plain
{
- base::SymmetricKey::HMAC_SHA1,
+ crypto::SymmetricKey::HMAC_SHA1,
"password",
"ATHENA.MIT.EDUraeburn",
1,
@@ -155,7 +153,7 @@
"cdedb5281bb2f801565a1122b25635150ad1f7a0",
},
{
- base::SymmetricKey::HMAC_SHA1,
+ crypto::SymmetricKey::HMAC_SHA1,
"password",
"ATHENA.MIT.EDUraeburn",
2,
@@ -163,7 +161,7 @@
"01dbee7f4a9e243e988b62c73cda935da05378b9",
},
{
- base::SymmetricKey::HMAC_SHA1,
+ crypto::SymmetricKey::HMAC_SHA1,
"password",
"ATHENA.MIT.EDUraeburn",
1200,
@@ -171,7 +169,7 @@
"5c08eb61fdf71e4e4ec3cf6ba1f5512ba7e52ddb",
},
{
- base::SymmetricKey::HMAC_SHA1,
+ crypto::SymmetricKey::HMAC_SHA1,
"password",
"\0224VxxV4\022", /* 0x1234567878563412 */
5,
@@ -179,7 +177,7 @@
"d1daa78615f287e6a1c8b120d7062a493f98d203",
},
{
- base::SymmetricKey::HMAC_SHA1,
+ crypto::SymmetricKey::HMAC_SHA1,
"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
"pass phrase equals block size",
1200,
@@ -187,7 +185,7 @@
"139c30c0966bc32ba55fdbf212530ac9c5ec59f1",
},
{
- base::SymmetricKey::HMAC_SHA1,
+ crypto::SymmetricKey::HMAC_SHA1,
"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
"pass phrase exceeds block size",
1200,
@@ -195,7 +193,7 @@
"9ccad6d468770cd51b10e6a68721be611a8b4d28",
},
{
- base::SymmetricKey::HMAC_SHA1,
+ crypto::SymmetricKey::HMAC_SHA1,
"\360\235\204\236", /* g-clef (0xf09d849e) */
"EXAMPLE.COMpianist",
50,
@@ -205,7 +203,7 @@
// Regression tests for AES keys, derived from the Linux NSS implementation.
{
- base::SymmetricKey::AES,
+ crypto::SymmetricKey::AES,
"A test password",
"saltsalt",
1,
@@ -213,7 +211,7 @@
"44899a7777f0e6e8b752f875f02044b8ac593de146de896f2e8a816e315a36de",
},
{
- base::SymmetricKey::AES,
+ crypto::SymmetricKey::AES,
"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
"pass phrase exceeds block size",
20,

Powered by Google App Engine
This is Rietveld 408576698