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

Unified Diff: crypto/encryptor_unittest.cc

Issue 432443003: Relax the failure mode of EncryptorTest.UnsupportedKeySize so that we (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 5 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 | « no previous file | no next file » | 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 f095659c521271ac9825e869d8273c2be9b6b83b..1a99783679f64d4786f01c7e85b4e403b3a0c2aa 100644
--- a/crypto/encryptor_unittest.cc
+++ b/crypto/encryptor_unittest.cc
@@ -456,22 +456,21 @@ TEST(EncryptorTest, EncryptAES128CBCRegression) {
EXPECT_EQ(plaintext, decrypted);
}
-// Not all platforms allow import/generation of symmetric keys with an
-// unsupported size.
-#if !defined(USE_NSS) && !defined(OS_WIN) && !defined(OS_MACOSX)
+// 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) {
std::string key = "7 = bad";
std::string iv = "Sweet Sixteen IV";
scoped_ptr<crypto::SymmetricKey> sym_key(crypto::SymmetricKey::Import(
crypto::SymmetricKey::AES, key));
- ASSERT_TRUE(sym_key.get());
+ if (!sym_key.get())
wtc 2014/07/30 22:33:12 David, it just occurred to me that perhaps we shou
davidben 2014/07/31 16:12:15 Hrm, maybe. I didn't add one already. That probabl
+ return;
crypto::Encryptor encryptor;
- // The IV must be exactly as long a the cipher block size.
+ // The IV must be exactly as long as the cipher block size.
EXPECT_EQ(16U, iv.size());
EXPECT_FALSE(encryptor.Init(sym_key.get(), crypto::Encryptor::CBC, iv));
}
-#endif // unsupported platforms.
TEST(EncryptorTest, UnsupportedIV) {
std::string key = "128=SixteenBytes";
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698