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

Unified Diff: chrome/browser/signin/local_auth_unittest.cc

Issue 862103002: Only store leading 13 bits of password hash. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Pre-review check Created 5 years, 11 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: chrome/browser/signin/local_auth_unittest.cc
diff --git a/chrome/browser/signin/local_auth_unittest.cc b/chrome/browser/signin/local_auth_unittest.cc
index 68ee397043ad9c9614b444ad6611043eda24453d..e0a59b39af9ddac49b71ae85fd299226a4b40367 100644
--- a/chrome/browser/signin/local_auth_unittest.cc
+++ b/chrome/browser/signin/local_auth_unittest.cc
@@ -56,3 +56,26 @@ TEST(LocalAuthTest, SetAndCheckCredentials) {
SetLocalAuthCredentials(prof, password); // makes different salt
EXPECT_NE(passhash, cache.GetLocalAuthCredentialsOfProfileAtIndex(0));
}
+
+TEST(LocalAuthTest, TruncateStringTo16Bits) {
+ std::string two_chars = "AB";
jww 2015/01/22 21:48:18 It seems like you might want these tests to actual
Mike Lerman 2015/01/27 21:02:26 TruncateStringTo16Bit was a tricky method to write
+ std::string three_chars = "ABC";
+ EXPECT_EQ(two_chars, TruncateStringByBits(two_chars, 16));
+ EXPECT_EQ(two_chars, TruncateStringByBits(three_chars, 16));
+}
+
+TEST(LocalAuthTest, TruncateStringTo14BitsLowBitsOnly) {
+ std::string two_chars = "A6";
+ std::string three_chars = "A6C";
+ EXPECT_EQ(two_chars, TruncateStringByBits(two_chars, 14));
+ EXPECT_EQ(two_chars, TruncateStringByBits(three_chars, 14));
+}
+
+TEST(LocalAuthTest, TruncateStringTo14BitsLowAndHighBits) {
+ std::string two_chars = "Az";
+ std::string three_chars = "AzC";
+ // 'z' = 0x7A, ':' = 0x3A.
+ std::string two_chars_truncated = "A:";
+ EXPECT_EQ(two_chars_truncated, TruncateStringByBits(two_chars, 14));
+ EXPECT_EQ(two_chars_truncated, TruncateStringByBits(three_chars, 14));
+}

Powered by Google App Engine
This is Rietveld 408576698