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

Unified Diff: crypto/encryptor_unittest.cc

Issue 7056026: Implement AES-CTR for NSS. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 7 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
diff --git a/crypto/encryptor_unittest.cc b/crypto/encryptor_unittest.cc
index b916854a9d81e9b71cc51457bc4512dcdf1ae602..4fae84eb553d95cd67d3e2c51ce6f00ea40985a9 100644
--- a/crypto/encryptor_unittest.cc
+++ b/crypto/encryptor_unittest.cc
@@ -35,6 +35,30 @@ TEST(EncryptorTest, EncryptDecrypt) {
EXPECT_EQ(plaintext, decypted);
}
+TEST(EncryptorTest, EncryptDecryptECB) {
+ scoped_ptr<crypto::SymmetricKey> key(
+ crypto::SymmetricKey::DeriveKeyFromPassword(
+ crypto::SymmetricKey::AES, "password", "saltiest", 1000, 128));
+ EXPECT_TRUE(NULL != key.get());
+
+ 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(), crypto::Encryptor::ECB, iv));
Ryan Sleevi 2011/05/23 05:55:04 |iv| has no meaning in ECB mode.
+
+ std::string plaintext("normal plaintext");
+ std::string ciphertext;
+ EXPECT_TRUE(encryptor.Encrypt(plaintext, &ciphertext));
+
+ EXPECT_LT(0U, ciphertext.size());
+
+ std::string decypted;
+ EXPECT_TRUE(encryptor.Decrypt(ciphertext, &decypted));
+
+ EXPECT_EQ(plaintext, decypted);
+}
+
// 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

Powered by Google App Engine
This is Rietveld 408576698