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

Side by Side Diff: chrome/browser/chromeos/login/google_authenticator.h

Issue 2820006: Use GetSystemSalt from the cryptohome lib instead of reading salt off disk. (Closed)
Patch Set: Created 10 years, 6 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 (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 #ifndef CHROME_BROWSER_CHROMEOS_LOGIN_GOOGLE_AUTHENTICATOR_H_ 5 #ifndef CHROME_BROWSER_CHROMEOS_LOGIN_GOOGLE_AUTHENTICATOR_H_
6 #define CHROME_BROWSER_CHROMEOS_LOGIN_GOOGLE_AUTHENTICATOR_H_ 6 #define CHROME_BROWSER_CHROMEOS_LOGIN_GOOGLE_AUTHENTICATOR_H_
7 7
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 virtual void OnURLFetchComplete(const URLFetcher* source, 63 virtual void OnURLFetchComplete(const URLFetcher* source,
64 const GURL& url, 64 const GURL& url,
65 const URLRequestStatus& status, 65 const URLRequestStatus& status,
66 int response_code, 66 int response_code,
67 const ResponseCookies& cookies, 67 const ResponseCookies& cookies,
68 const std::string& data); 68 const std::string& data);
69 69
70 70
71 71
72 // Public for testing. 72 // Public for testing.
73 void set_system_salt(const std::vector<unsigned char>& new_salt) { 73 void set_system_salt(const chromeos::CryptohomeBlob& new_salt) {
74 system_salt_ = new_salt; 74 system_salt_ = new_salt;
75 } 75 }
76 void set_localaccount(const std::string& new_name) { 76 void set_localaccount(const std::string& new_name) {
77 localaccount_ = new_name; 77 localaccount_ = new_name;
78 checked_for_localaccount_ = true; 78 checked_for_localaccount_ = true;
79 } 79 }
80 void set_username(const std::string& fake_user) { username_ = fake_user; } 80 void set_username(const std::string& fake_user) { username_ = fake_user; }
81 void set_password_hash(const std::string& fake_hash) { 81 void set_password_hash(const std::string& fake_hash) {
82 ascii_hash_ = fake_hash; 82 ascii_hash_ = fake_hash;
83 } 83 }
84 84
85 // These methods must be called on the UI thread, as they make DBus calls 85 // These methods must be called on the UI thread, as they make DBus calls
86 // and also call back to the login UI. 86 // and also call back to the login UI.
87 void OnLoginSuccess(const std::string& credentials); 87 void OnLoginSuccess(const std::string& credentials);
88 void CheckOffline(const std::string& error); 88 void CheckOffline(const std::string& error);
89 void CheckLocalaccount(const std::string& error); 89 void CheckLocalaccount(const std::string& error);
90 void OnLoginFailure(const std::string& data); 90 void OnLoginFailure(const std::string& data);
91 91
92 // Perform basic canonicalization of |email_address|, taking into account 92 // Perform basic canonicalization of |email_address|, taking into account
93 // that gmail does not consider '.' or caps inside a username to matter. 93 // that gmail does not consider '.' or caps inside a username to matter.
94 // For example, c.masone@gmail.com == cMaSone@gmail.com, per 94 // For example, c.masone@gmail.com == cMaSone@gmail.com, per
95 // http://mail.google.com/support/bin/answer.py?hl=en&ctx=mail&answer=10313# 95 // http://mail.google.com/support/bin/answer.py?hl=en&ctx=mail&answer=10313#
96 static std::string Canonicalize(const std::string& email_address); 96 static std::string Canonicalize(const std::string& email_address);
97 97
98 // The signal to cryptohomed that we want a tmpfs. 98 // The signal to cryptohomed that we want a tmpfs.
99 // TODO(cmasone): revisit this after cryptohome re-impl 99 // TODO(cmasone): revisit this after cryptohome re-impl
100 static const char kTmpfsTrigger[]; 100 static const char kTmpfsTrigger[];
101 101
102 private: 102 private:
103 // If we don't have the system salt yet, loads it from |path|. 103 // If we don't have the system salt yet, loads it from the CryptohomeLibrary.
104 // Should only be called on the FILE thread. 104 void LoadSystemSalt();
105 void LoadSystemSalt(const FilePath& path);
106 105
107 // If we haven't already, looks in a file called |filename| next to 106 // If we haven't already, looks in a file called |filename| next to
108 // the browser executable for a "localaccount" name, and retrieves it 107 // the browser executable for a "localaccount" name, and retrieves it
109 // if one is present. If someone attempts to authenticate with this 108 // if one is present. If someone attempts to authenticate with this
110 // username, we will mount a tmpfs for them and let them use the 109 // username, we will mount a tmpfs for them and let them use the
111 // browser. 110 // browser.
112 // Should only be called on the FILE thread. 111 // Should only be called on the FILE thread.
113 void LoadLocalaccount(const std::string& filename); 112 void LoadLocalaccount(const std::string& filename);
114 113
115 // Stores a hash of |password|, salted with the ascii of |system_salt_|. 114 // Stores a hash of |password|, salted with the ascii of |system_salt_|.
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 static const char kOpenSSLMagic[]; 159 static const char kOpenSSLMagic[];
161 160
162 // Name of a file, next to chrome, that contains a local account username. 161 // Name of a file, next to chrome, that contains a local account username.
163 static const char kLocalaccountFile[]; 162 static const char kLocalaccountFile[];
164 163
165 URLFetcher* fetcher_; 164 URLFetcher* fetcher_;
166 URLRequestContextGetter* getter_; 165 URLRequestContextGetter* getter_;
167 std::string username_; 166 std::string username_;
168 std::string ascii_hash_; 167 std::string ascii_hash_;
169 std::string request_body_; 168 std::string request_body_;
170 std::vector<unsigned char> system_salt_; 169 chromeos::CryptohomeBlob system_salt_;
171 std::string localaccount_; 170 std::string localaccount_;
172 bool checked_for_localaccount_; // needed becasuse empty localaccount_ is ok. 171 bool checked_for_localaccount_; // needed becasuse empty localaccount_ is ok.
173 bool unlock_; // True if authenticating to unlock the computer. 172 bool unlock_; // True if authenticating to unlock the computer.
174 bool try_again_; // True if we're willing to retry the login attempt. 173 bool try_again_; // True if we're willing to retry the login attempt.
175 174
176 friend class GoogleAuthenticatorTest; 175 friend class GoogleAuthenticatorTest;
177 FRIEND_TEST_ALL_PREFIXES(GoogleAuthenticatorTest, SaltToAsciiTest); 176 FRIEND_TEST_ALL_PREFIXES(GoogleAuthenticatorTest, SaltToAsciiTest);
178 FRIEND_TEST_ALL_PREFIXES(GoogleAuthenticatorTest, CheckTwoFactorResponse); 177 FRIEND_TEST_ALL_PREFIXES(GoogleAuthenticatorTest, CheckTwoFactorResponse);
179 FRIEND_TEST_ALL_PREFIXES(GoogleAuthenticatorTest, CheckNormalErrorCode); 178 FRIEND_TEST_ALL_PREFIXES(GoogleAuthenticatorTest, CheckNormalErrorCode);
180 FRIEND_TEST_ALL_PREFIXES(GoogleAuthenticatorTest, EmailAddressNoOp); 179 FRIEND_TEST_ALL_PREFIXES(GoogleAuthenticatorTest, EmailAddressNoOp);
181 FRIEND_TEST_ALL_PREFIXES(GoogleAuthenticatorTest, EmailAddressIgnoreCaps); 180 FRIEND_TEST_ALL_PREFIXES(GoogleAuthenticatorTest, EmailAddressIgnoreCaps);
182 FRIEND_TEST_ALL_PREFIXES(GoogleAuthenticatorTest, 181 FRIEND_TEST_ALL_PREFIXES(GoogleAuthenticatorTest,
183 EmailAddressIgnoreDomainCaps); 182 EmailAddressIgnoreDomainCaps);
184 FRIEND_TEST_ALL_PREFIXES(GoogleAuthenticatorTest, 183 FRIEND_TEST_ALL_PREFIXES(GoogleAuthenticatorTest,
185 EmailAddressIgnoreOneUsernameDot); 184 EmailAddressIgnoreOneUsernameDot);
186 FRIEND_TEST_ALL_PREFIXES(GoogleAuthenticatorTest, 185 FRIEND_TEST_ALL_PREFIXES(GoogleAuthenticatorTest,
187 EmailAddressIgnoreManyUsernameDots); 186 EmailAddressIgnoreManyUsernameDots);
188 FRIEND_TEST_ALL_PREFIXES(GoogleAuthenticatorTest, 187 FRIEND_TEST_ALL_PREFIXES(GoogleAuthenticatorTest,
189 EmailAddressIgnoreConsecutiveUsernameDots); 188 EmailAddressIgnoreConsecutiveUsernameDots);
190 FRIEND_TEST_ALL_PREFIXES(GoogleAuthenticatorTest, 189 FRIEND_TEST_ALL_PREFIXES(GoogleAuthenticatorTest,
191 EmailAddressDifferentOnesRejected); 190 EmailAddressDifferentOnesRejected);
192 FRIEND_TEST_ALL_PREFIXES(GoogleAuthenticatorTest, 191 FRIEND_TEST_ALL_PREFIXES(GoogleAuthenticatorTest,
193 EmailAddressIgnorePlusSuffix); 192 EmailAddressIgnorePlusSuffix);
194 FRIEND_TEST_ALL_PREFIXES(GoogleAuthenticatorTest, 193 FRIEND_TEST_ALL_PREFIXES(GoogleAuthenticatorTest,
195 EmailAddressIgnoreMultiPlusSuffix); 194 EmailAddressIgnoreMultiPlusSuffix);
196 FRIEND_TEST_ALL_PREFIXES(GoogleAuthenticatorTest, ReadSaltTest); 195 FRIEND_TEST_ALL_PREFIXES(GoogleAuthenticatorTest, ReadSaltOnlyOnceTest);
197 FRIEND_TEST_ALL_PREFIXES(GoogleAuthenticatorTest, ReadLocalaccountTest); 196 FRIEND_TEST_ALL_PREFIXES(GoogleAuthenticatorTest, ReadLocalaccountTest);
198 FRIEND_TEST_ALL_PREFIXES(GoogleAuthenticatorTest, 197 FRIEND_TEST_ALL_PREFIXES(GoogleAuthenticatorTest,
199 ReadLocalaccountTrailingWSTest); 198 ReadLocalaccountTrailingWSTest);
200 FRIEND_TEST_ALL_PREFIXES(GoogleAuthenticatorTest, ReadNoLocalaccountTest); 199 FRIEND_TEST_ALL_PREFIXES(GoogleAuthenticatorTest, ReadNoLocalaccountTest);
201 FRIEND_TEST_ALL_PREFIXES(GoogleAuthenticatorTest, LoginNetFailureTest); 200 FRIEND_TEST_ALL_PREFIXES(GoogleAuthenticatorTest, LoginNetFailureTest);
202 FRIEND_TEST_ALL_PREFIXES(GoogleAuthenticatorTest, LoginDeniedTest); 201 FRIEND_TEST_ALL_PREFIXES(GoogleAuthenticatorTest, LoginDeniedTest);
203 FRIEND_TEST_ALL_PREFIXES(GoogleAuthenticatorTest, TwoFactorLoginTest); 202 FRIEND_TEST_ALL_PREFIXES(GoogleAuthenticatorTest, TwoFactorLoginTest);
204 203
205 DISALLOW_COPY_AND_ASSIGN(GoogleAuthenticator); 204 DISALLOW_COPY_AND_ASSIGN(GoogleAuthenticator);
206 }; 205 };
207 206
208 } // namespace chromeos 207 } // namespace chromeos
209 208
210 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_GOOGLE_AUTHENTICATOR_H_ 209 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_GOOGLE_AUTHENTICATOR_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698