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

Side by Side Diff: components/os_crypt/os_crypt_linux.cc

Issue 2152493002: Revert of Forward password-store switch to OSCrypt component (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 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
« no previous file with comments | « components/os_crypt/os_crypt.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "components/os_crypt/os_crypt.h" 5 #include "components/os_crypt/os_crypt.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <iterator> 10 #include <iterator>
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 // Strip off the versioning prefix before decrypting. 203 // Strip off the versioning prefix before decrypting.
204 std::string raw_ciphertext = 204 std::string raw_ciphertext =
205 ciphertext.substr(strlen(kObfuscationPrefix[version])); 205 ciphertext.substr(strlen(kObfuscationPrefix[version]));
206 206
207 if (!encryptor.Decrypt(raw_ciphertext, plaintext)) 207 if (!encryptor.Decrypt(raw_ciphertext, plaintext))
208 return false; 208 return false;
209 209
210 return true; 210 return true;
211 } 211 }
212 212
213 // static
214 void OSCrypt::SetStore(const std::string& store_type) {
215 // Changing the targeted password store makes no sense after initializing.
216 DCHECK(!g_cache.Get().is_key_storage_cached);
217
218 KeyStorageLinux::SetStore(store_type);
219 }
220
221 void UseMockKeyStorageForTesting(KeyStorageLinux* (*get_key_storage_mock)(), 213 void UseMockKeyStorageForTesting(KeyStorageLinux* (*get_key_storage_mock)(),
222 std::string* (*get_password_v11_mock)()) { 214 std::string* (*get_password_v11_mock)()) {
223 // Save the real implementation to restore it later. 215 // Save the real implementation to restore it later.
224 static bool is_get_password_saved = false; 216 static bool is_get_password_saved = false;
225 static std::string* (*get_password_save[arraysize(g_get_password)])(); 217 static std::string* (*get_password_save[arraysize(g_get_password)])();
226 if (!is_get_password_saved) { 218 if (!is_get_password_saved) {
227 std::copy(std::begin(g_get_password), std::end(g_get_password), 219 std::copy(std::begin(g_get_password), std::end(g_get_password),
228 std::begin(get_password_save)); 220 std::begin(get_password_save));
229 is_get_password_saved = true; 221 is_get_password_saved = true;
230 } 222 }
231 223
232 if (get_key_storage_mock && get_password_v11_mock) { 224 if (get_key_storage_mock && get_password_v11_mock) {
233 // Bypass calling KeyStorage::CreateService and caching of the key for V11 225 // Bypass calling KeyStorage::CreateService and caching of the key for V11
234 g_get_password[Version::V11] = get_password_v11_mock; 226 g_get_password[Version::V11] = get_password_v11_mock;
235 // OSCrypt will determine the encryption version by checking if a 227 // OSCrypt will determine the encryption version by checking if a
236 // |KeyStorage| instance can be created. Enable V11 by returning the mock. 228 // |KeyStorage| instance can be created. Enable V11 by returning the mock.
237 g_key_storage_provider = get_key_storage_mock; 229 g_key_storage_provider = get_key_storage_mock;
238 } else { 230 } else {
239 // Restore real implementation 231 // Restore real implementation
240 std::copy(std::begin(get_password_save), std::end(get_password_save), 232 std::copy(std::begin(get_password_save), std::end(get_password_save),
241 std::begin(g_get_password)); 233 std::begin(g_get_password));
242 } 234 }
243 } 235 }
OLDNEW
« no previous file with comments | « components/os_crypt/os_crypt.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698