0

Relax the failure mode of EncryptorTest.UnsupportedKeySize so that we

can run the test on all platforms.

R=davidben@chromium.org,joth@chromium.org,rsleevi@chromium.org
BUG=

Review URL: https://codereview.chromium.org/432443003

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@286667 0039d316-1c4b-4281-b951-d872f2087c98
This commit is contained in:
wtc@chromium.org
2014-07-31 01:03:05 +00:00
parent d380e730eb
commit 1970276bae

@ -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())
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";