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

Side by Side 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 unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/signin/local_auth.h" 5 #include "chrome/browser/signin/local_auth.h"
6 6
7 #include "base/base64.h" 7 #include "base/base64.h"
8 #include "base/prefs/pref_service.h" 8 #include "base/prefs/pref_service.h"
9 #include "chrome/browser/profiles/profile_manager.h" 9 #include "chrome/browser/profiles/profile_manager.h"
10 #include "chrome/test/base/testing_browser_process.h" 10 #include "chrome/test/base/testing_browser_process.h"
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 base::Base64Decode(passhash.substr(1), &decodedhash); 49 base::Base64Decode(passhash.substr(1), &decodedhash);
50 EXPECT_FALSE(decodedhash.empty()); 50 EXPECT_FALSE(decodedhash.empty());
51 EXPECT_EQ(decodedhash.find(password), std::string::npos); 51 EXPECT_EQ(decodedhash.find(password), std::string::npos);
52 52
53 EXPECT_TRUE(ValidateLocalAuthCredentials(prof, password)); 53 EXPECT_TRUE(ValidateLocalAuthCredentials(prof, password));
54 EXPECT_FALSE(ValidateLocalAuthCredentials(prof, password + "1")); 54 EXPECT_FALSE(ValidateLocalAuthCredentials(prof, password + "1"));
55 55
56 SetLocalAuthCredentials(prof, password); // makes different salt 56 SetLocalAuthCredentials(prof, password); // makes different salt
57 EXPECT_NE(passhash, cache.GetLocalAuthCredentialsOfProfileAtIndex(0)); 57 EXPECT_NE(passhash, cache.GetLocalAuthCredentialsOfProfileAtIndex(0));
58 } 58 }
59
60 TEST(LocalAuthTest, TruncateStringTo16Bits) {
61 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
62 std::string three_chars = "ABC";
63 EXPECT_EQ(two_chars, TruncateStringByBits(two_chars, 16));
64 EXPECT_EQ(two_chars, TruncateStringByBits(three_chars, 16));
65 }
66
67 TEST(LocalAuthTest, TruncateStringTo14BitsLowBitsOnly) {
68 std::string two_chars = "A6";
69 std::string three_chars = "A6C";
70 EXPECT_EQ(two_chars, TruncateStringByBits(two_chars, 14));
71 EXPECT_EQ(two_chars, TruncateStringByBits(three_chars, 14));
72 }
73
74 TEST(LocalAuthTest, TruncateStringTo14BitsLowAndHighBits) {
75 std::string two_chars = "Az";
76 std::string three_chars = "AzC";
77 // 'z' = 0x7A, ':' = 0x3A.
78 std::string two_chars_truncated = "A:";
79 EXPECT_EQ(two_chars_truncated, TruncateStringByBits(two_chars, 14));
80 EXPECT_EQ(two_chars_truncated, TruncateStringByBits(three_chars, 14));
81 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698