Chromium Code Reviews| 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 |