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

Unified Diff: crypto/encryptor_unittest.cc

Issue 10543146: Use NSS for symmetric key crypto operations on Windows and Mac. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: removed DEPS; rebased Created 8 years, 6 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
« no previous file with comments | « crypto/encryptor_mac.cc ('k') | crypto/encryptor_win.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: crypto/encryptor_unittest.cc
diff --git a/crypto/encryptor_unittest.cc b/crypto/encryptor_unittest.cc
index ac78b966da394b4bbeec520ef8cb31312f33619f..b0ec4bceec6b83f8a1b89ba59cbaead7b765285d 100644
--- a/crypto/encryptor_unittest.cc
+++ b/crypto/encryptor_unittest.cc
@@ -91,8 +91,8 @@ TEST(EncryptorTest, DecryptWrongKey) {
// invalid. If an implementation simply uses the last padding byte to
// determine the padding length without checking every padding byte,
// Encryptor::Decrypt() will still return true. This is the case for NSS
- // (crbug.com/124434) and Mac OS X 10.7 (crbug.com/127586).
-#if !defined(USE_NSS)
+ // (crbug.com/124434).
+#if !defined(USE_NSS) && !defined(OS_WIN) && !defined(OS_MACOSX)
crypto::Encryptor decryptor;
EXPECT_TRUE(decryptor.Init(wrong_key.get(), crypto::Encryptor::CBC, iv));
EXPECT_FALSE(decryptor.Decrypt(ciphertext, &decypted));
@@ -113,7 +113,7 @@ TEST(EncryptorTest, DecryptWrongKey) {
}
// CTR mode encryption is only implemented using NSS.
-#if defined(USE_NSS)
+#if defined(USE_NSS) || defined(OS_WIN) || defined(OS_MACOSX)
TEST(EncryptorTest, EncryptDecryptCTR) {
scoped_ptr<crypto::SymmetricKey> key(
@@ -149,11 +149,13 @@ TEST(EncryptorTest, EncryptDecryptCTR) {
TEST(EncryptorTest, CTRCounter) {
const int kCounterSize = 16;
- const char kTest1[] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
- uint8 buf[16];
+ const unsigned char kTest1[] =
+ {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
+ unsigned char buf[16];
// Increment 10 times.
- crypto::Encryptor::Counter counter1(std::string(kTest1, kCounterSize));
+ crypto::Encryptor::Counter counter1(
+ std::string(reinterpret_cast<const char*>(kTest1), kCounterSize));
for (int i = 0; i < 10; ++i)
counter1.Increment();
counter1.Write(buf);
@@ -161,18 +163,26 @@ TEST(EncryptorTest, CTRCounter) {
EXPECT_TRUE(buf[15] == 10);
// Check corner cases.
- const char kTest2[] = {0, 0, 0, 0, 0, 0, 0, 0,
- 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
- const char kExpect2[] = {0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0};
- crypto::Encryptor::Counter counter2(std::string(kTest2, kCounterSize));
+ const unsigned char kTest2[] = {
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff
+ };
+ const unsigned char kExpect2[] =
+ {0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0};
+ crypto::Encryptor::Counter counter2(
+ std::string(reinterpret_cast<const char*>(kTest2), kCounterSize));
counter2.Increment();
counter2.Write(buf);
EXPECT_EQ(0, memcmp(buf, kExpect2, kCounterSize));
- const char kTest3[] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
- const char kExpect3[] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
- crypto::Encryptor::Counter counter3(std::string(kTest3, kCounterSize));
+ const unsigned char kTest3[] = {
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff
+ };
+ const unsigned char kExpect3[] =
+ {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
+ crypto::Encryptor::Counter counter3(
+ std::string(reinterpret_cast<const char*>(kTest3), kCounterSize));
counter3.Increment();
counter3.Write(buf);
EXPECT_EQ(0, memcmp(buf, kExpect3, kCounterSize));
@@ -312,7 +322,7 @@ TEST(EncryptorTest, EncryptAES192CBCRegression) {
// Not all platforms allow import/generation of symmetric keys with an
// unsupported size.
-#if !defined(OS_WIN) && !defined(USE_NSS)
+#if !defined(USE_NSS) && !defined(OS_WIN) && !defined(OS_MACOSX)
TEST(EncryptorTest, UnsupportedKeySize) {
std::string key = "7 = bad";
std::string iv = "Sweet Sixteen IV";
« no previous file with comments | « crypto/encryptor_mac.cc ('k') | crypto/encryptor_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698