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

Side by Side Diff: chromeos/cryptohome/cryptohome_library.cc

Issue 23904025: Move IsRunningOnChromeOS to SysInfo (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge fix Created 7 years, 2 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 | Annotate | Revision Log
« no previous file with comments | « chromeos/cert_loader.cc ('k') | chromeos/dbus/bluetooth_agent_service_provider.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "chromeos/cryptohome/cryptohome_library.h" 5 #include "chromeos/cryptohome/cryptohome_library.h"
6 6
7 #include <map> 7 #include <map>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/chromeos/chromeos_version.h"
11 #include "base/memory/weak_ptr.h" 10 #include "base/memory/weak_ptr.h"
12 #include "base/strings/string_number_conversions.h" 11 #include "base/strings/string_number_conversions.h"
13 #include "base/strings/string_util.h" 12 #include "base/strings/string_util.h"
13 #include "base/sys_info.h"
14 #include "chromeos/dbus/cryptohome_client.h" 14 #include "chromeos/dbus/cryptohome_client.h"
15 #include "chromeos/dbus/dbus_method_call_status.h" 15 #include "chromeos/dbus/dbus_method_call_status.h"
16 #include "chromeos/dbus/dbus_thread_manager.h" 16 #include "chromeos/dbus/dbus_thread_manager.h"
17 #include "crypto/encryptor.h" 17 #include "crypto/encryptor.h"
18 #include "crypto/nss_util.h" 18 #include "crypto/nss_util.h"
19 #include "crypto/sha2.h" 19 #include "crypto/sha2.h"
20 #include "crypto/symmetric_key.h" 20 #include "crypto/symmetric_key.h"
21 21
22 namespace chromeos { 22 namespace chromeos {
23 23
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 return result; 103 return result;
104 } 104 }
105 105
106 virtual std::string GetSystemSalt() OVERRIDE { 106 virtual std::string GetSystemSalt() OVERRIDE {
107 LoadSystemSalt(); // no-op if it's already loaded. 107 LoadSystemSalt(); // no-op if it's already loaded.
108 return system_salt_; 108 return system_salt_;
109 } 109 }
110 110
111 virtual std::string EncryptWithSystemSalt(const std::string& token) OVERRIDE { 111 virtual std::string EncryptWithSystemSalt(const std::string& token) OVERRIDE {
112 // Don't care about token encryption while debugging. 112 // Don't care about token encryption while debugging.
113 if (!base::chromeos::IsRunningOnChromeOS()) 113 if (!base::SysInfo::IsRunningOnChromeOS())
114 return token; 114 return token;
115 115
116 if (!LoadSystemSaltKey()) { 116 if (!LoadSystemSaltKey()) {
117 LOG(WARNING) << "System salt key is not available for encrypt."; 117 LOG(WARNING) << "System salt key is not available for encrypt.";
118 return std::string(); 118 return std::string();
119 } 119 }
120 return EncryptTokenWithKey(system_salt_key_.get(), 120 return EncryptTokenWithKey(system_salt_key_.get(),
121 system_salt_, 121 system_salt_,
122 token); 122 token);
123 } 123 }
124 124
125 virtual std::string DecryptWithSystemSalt( 125 virtual std::string DecryptWithSystemSalt(
126 const std::string& encrypted_token_hex) OVERRIDE { 126 const std::string& encrypted_token_hex) OVERRIDE {
127 // Don't care about token encryption while debugging. 127 // Don't care about token encryption while debugging.
128 if (!base::chromeos::IsRunningOnChromeOS()) 128 if (!base::SysInfo::IsRunningOnChromeOS())
129 return encrypted_token_hex; 129 return encrypted_token_hex;
130 130
131 if (!LoadSystemSaltKey()) { 131 if (!LoadSystemSaltKey()) {
132 LOG(WARNING) << "System salt key is not available for decrypt."; 132 LOG(WARNING) << "System salt key is not available for decrypt.";
133 return std::string(); 133 return std::string();
134 } 134 }
135 return DecryptTokenWithKey(system_salt_key_.get(), 135 return DecryptTokenWithKey(system_salt_key_.get(),
136 system_salt_, 136 system_salt_,
137 encrypted_token_hex); 137 encrypted_token_hex);
138 } 138 }
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
294 294
295 CryptohomeLibrary::CryptohomeLibrary() {} 295 CryptohomeLibrary::CryptohomeLibrary() {}
296 CryptohomeLibrary::~CryptohomeLibrary() {} 296 CryptohomeLibrary::~CryptohomeLibrary() {}
297 297
298 static CryptohomeLibrary* g_cryptohome_library = NULL; 298 static CryptohomeLibrary* g_cryptohome_library = NULL;
299 static CryptohomeLibrary* g_test_cryptohome_library = NULL; 299 static CryptohomeLibrary* g_test_cryptohome_library = NULL;
300 300
301 // static 301 // static
302 void CryptohomeLibrary::Initialize() { 302 void CryptohomeLibrary::Initialize() {
303 CHECK(!g_cryptohome_library); 303 CHECK(!g_cryptohome_library);
304 if (base::chromeos::IsRunningOnChromeOS()) 304 if (base::SysInfo::IsRunningOnChromeOS())
305 g_cryptohome_library = new CryptohomeLibraryImpl(); 305 g_cryptohome_library = new CryptohomeLibraryImpl();
306 else 306 else
307 g_cryptohome_library = new CryptohomeLibraryStubImpl(); 307 g_cryptohome_library = new CryptohomeLibraryStubImpl();
308 } 308 }
309 309
310 // static 310 // static
311 bool CryptohomeLibrary::IsInitialized() { 311 bool CryptohomeLibrary::IsInitialized() {
312 return g_cryptohome_library; 312 return g_cryptohome_library;
313 } 313 }
314 314
(...skipping 18 matching lines...) Expand all
333 CHECK(!g_test_cryptohome_library || !impl); 333 CHECK(!g_test_cryptohome_library || !impl);
334 g_test_cryptohome_library = impl; 334 g_test_cryptohome_library = impl;
335 } 335 }
336 336
337 // static 337 // static
338 CryptohomeLibrary* CryptohomeLibrary::GetTestImpl() { 338 CryptohomeLibrary* CryptohomeLibrary::GetTestImpl() {
339 return new CryptohomeLibraryStubImpl(); 339 return new CryptohomeLibraryStubImpl();
340 } 340 }
341 341
342 } // namespace chromeos 342 } // namespace chromeos
OLDNEW
« no previous file with comments | « chromeos/cert_loader.cc ('k') | chromeos/dbus/bluetooth_agent_service_provider.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698