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

Unified Diff: chromeos/login/auth/key_unittest.cc

Issue 515153002: Add new Chrome OS key type: Salted SHA256 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@d_2_367847_add_get_key_data_ex_call
Patch Set: Created 6 years, 4 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 | « chromeos/login/auth/key.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chromeos/login/auth/key_unittest.cc
diff --git a/chromeos/login/auth/key_unittest.cc b/chromeos/login/auth/key_unittest.cc
index 76e38cb3fe482824d86802cc68bc9351330559fb..26a6c8d808fa4fada9d9a07520bbf4cff3c3ad0a 100644
--- a/chromeos/login/auth/key_unittest.cc
+++ b/chromeos/login/auth/key_unittest.cc
@@ -44,4 +44,23 @@ TEST(KeyTest, TransformToSaltedAES2561234) {
EXPECT_EQ("GUkNnvqoULf/cXbZscVUnANmLBB0ovjGZsj1sKzP5BE=", key.GetSecret());
}
+TEST(KeyTest, TransformToSaltedSHA256) {
+ Key key(kPassword);
+ key.Transform(Key::KEY_TYPE_SALTED_SHA256, kSalt);
+ EXPECT_EQ(Key::KEY_TYPE_SALTED_SHA256, key.GetKeyType());
+ EXPECT_EQ("WwGUF3Hkf6QIOAqmdXA/TyScTFDo4d+ow5xfof0zGdo=", key.GetSecret());
+}
+
+// The values in the KeyType enum must never change because they are stored as
+// ints in the user's cryptohome key metadata.
+TEST(KeyTest, KeyTypeStable) {
+ EXPECT_EQ(0, Key::KEY_TYPE_PASSWORD_PLAIN);
+ EXPECT_EQ(1, Key::KEY_TYPE_SALTED_SHA256_TOP_HALF);
+ EXPECT_EQ(2, Key::KEY_TYPE_SALTED_PBKDF2_AES256_1234);
+ EXPECT_EQ(3, Key::KEY_TYPE_SALTED_SHA256);
+ // The sentinel does not have to remain stable. It should be adjusted whenever
+ // a new key type is added.
+ EXPECT_EQ(4, Key::KEY_TYPE_COUNT);
+}
+
} // namespace chromeos
« no previous file with comments | « chromeos/login/auth/key.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698