[crypto] Add scrypt key derivation to SymmetricKey
Add a method for key derivation using the scrypt algorithm to
crypto::SymmetricKey.
Rename the pre-existing method for key derivation (which uses PBKDF2) to
clearly disambiguate between the two.
TBRing because all the changes to files not under crypto/ are a trivial
library method name change.
[email protected],[email protected],[email protected],[email protected],[email protected]
Bug: 875931
Change-Id: Iaa0b2bb0fc3ae2481733072363718cffd8811b97
Reviewed-on: https://chromium-review.googlesource.com/1181881
Commit-Queue: David Davidović <[email protected]>
Reviewed-by: David Benjamin <[email protected]>
Reviewed-by: vitaliii <[email protected]>
Cr-Commit-Position: refs/heads/master@{#586247}
diff --git a/crypto/encryptor_unittest.cc b/crypto/encryptor_unittest.cc
index 2294bdb..76178dcb 100644
--- a/crypto/encryptor_unittest.cc
+++ b/crypto/encryptor_unittest.cc
@@ -16,7 +16,7 @@
TEST(EncryptorTest, EncryptDecrypt) {
std::unique_ptr<crypto::SymmetricKey> key(
- crypto::SymmetricKey::DeriveKeyFromPassword(
+ crypto::SymmetricKey::DeriveKeyFromPasswordUsingPbkdf2(
crypto::SymmetricKey::AES, "password", "saltiest", 1000, 256));
EXPECT_TRUE(key.get());
@@ -40,27 +40,27 @@
TEST(EncryptorTest, DecryptWrongKey) {
std::unique_ptr<crypto::SymmetricKey> key(
- crypto::SymmetricKey::DeriveKeyFromPassword(
+ crypto::SymmetricKey::DeriveKeyFromPasswordUsingPbkdf2(
crypto::SymmetricKey::AES, "password", "saltiest", 1000, 256));
EXPECT_TRUE(key.get());
// A wrong key that can be detected by implementations that validate every
// byte in the padding.
std::unique_ptr<crypto::SymmetricKey> wrong_key(
- crypto::SymmetricKey::DeriveKeyFromPassword(
+ crypto::SymmetricKey::DeriveKeyFromPasswordUsingPbkdf2(
crypto::SymmetricKey::AES, "wrongword", "sweetest", 1000, 256));
EXPECT_TRUE(wrong_key.get());
// A wrong key that can't be detected by any implementation. The password
// "wrongword;" would also work.
std::unique_ptr<crypto::SymmetricKey> wrong_key2(
- crypto::SymmetricKey::DeriveKeyFromPassword(
+ crypto::SymmetricKey::DeriveKeyFromPasswordUsingPbkdf2(
crypto::SymmetricKey::AES, "wrongword+", "sweetest", 1000, 256));
EXPECT_TRUE(wrong_key2.get());
// A wrong key that can be detected by all implementations.
std::unique_ptr<crypto::SymmetricKey> wrong_key3(
- crypto::SymmetricKey::DeriveKeyFromPassword(
+ crypto::SymmetricKey::DeriveKeyFromPasswordUsingPbkdf2(
crypto::SymmetricKey::AES, "wrongwordx", "sweetest", 1000, 256));
EXPECT_TRUE(wrong_key3.get());