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

Side by Side Diff: components/os_crypt/os_crypt.h

Issue 1973483002: OSCrypt for POSIX uses libsecret to store a randomised encryption key. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed lsan failure Created 4 years, 7 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 COMPONENTS_OS_CRYPT_OS_CRYPT_H_ 5 #ifndef COMPONENTS_OS_CRYPT_OS_CRYPT_H_
6 #define COMPONENTS_OS_CRYPT_OS_CRYPT_H_ 6 #define COMPONENTS_OS_CRYPT_OS_CRYPT_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/macros.h" 10 #include "base/macros.h"
11 #include "base/strings/string16.h" 11 #include "base/strings/string16.h"
12 #include "build/build_config.h" 12 #include "build/build_config.h"
13 #if defined(USE_LIBSECRET)
Lei Zhang 2016/05/18 22:38:16 Add a blank line separator
cfroussios 2016/05/19 21:18:18 Done.
14 #include "components/os_crypt/key_storage_linux.h"
15 #include "components/os_crypt/key_storage_mock.h"
16 #endif
13 17
14 // The OSCrypt class gives access to simple encryption and decryption of 18 // The OSCrypt class gives access to simple encryption and decryption of
15 // strings. Note that on Mac, access to the system Keychain is required and 19 // strings. Note that on Mac, access to the system Keychain is required and
16 // these calls can block the current thread to collect user input. 20 // these calls can block the current thread to collect user input.
17 class OSCrypt { 21 class OSCrypt {
18 public: 22 public:
19 // Encrypt a string16. The output (second argument) is really an array of 23 // Encrypt a string16. The output (second argument) is really an array of
20 // bytes, but we're passing it back as a std::string. 24 // bytes, but we're passing it back as a std::string.
21 static bool EncryptString16(const base::string16& plaintext, 25 static bool EncryptString16(const base::string16& plaintext,
22 std::string* ciphertext); 26 std::string* ciphertext);
(...skipping 13 matching lines...) Expand all
36 // get your (binary) data into a string. 40 // get your (binary) data into a string.
37 static bool DecryptString(const std::string& ciphertext, 41 static bool DecryptString(const std::string& ciphertext,
38 std::string* plaintext); 42 std::string* plaintext);
39 43
40 #if defined(OS_MACOSX) 44 #if defined(OS_MACOSX)
41 // For unit testing purposes we instruct the Encryptor to use a mock Keychain 45 // For unit testing purposes we instruct the Encryptor to use a mock Keychain
42 // on the Mac. The default is to use the real Keychain. 46 // on the Mac. The default is to use the real Keychain.
43 static void UseMockKeychain(bool use_mock); 47 static void UseMockKeychain(bool use_mock);
44 #endif 48 #endif
45 49
50 #if defined(USE_LIBSECRET)
51 // For unit testing purposes, use a mocked |KeyStorage| service.
Lei Zhang 2016/05/18 22:38:16 Refer to variables as |var_name|, not classes.
cfroussios 2016/05/19 21:18:18 Acknowledged.
52 // A reference is to the |KeyStorageMock| is returned, so that the test can
53 // manipulate the service.
54 static KeyStorageMock* UseMockKeyStorage(bool use_mock);
Lei Zhang 2016/05/18 22:38:16 This sounds confusing. What does UseMock...(use_mo
cfroussios 2016/05/19 21:18:18 I changed it so that a pointer is no longer return
55 #endif
56
46 private: 57 private:
47 DISALLOW_IMPLICIT_CONSTRUCTORS(OSCrypt); 58 DISALLOW_IMPLICIT_CONSTRUCTORS(OSCrypt);
48 }; 59 };
49 60
50 #endif // COMPONENTS_OS_CRYPT_OS_CRYPT_H_ 61 #endif // COMPONENTS_OS_CRYPT_OS_CRYPT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698