OLD | NEW |
---|---|
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 #include "components/os_crypt/key_storage_linux.h" | |
vabr (Chromium)
2016/05/13 15:10:18
You should #include this file unconditionally if y
cfroussios
2016/05/13 17:09:12
Right now, the entry-point to OSCrypt is this file
| |
13 | 14 |
14 // The OSCrypt class gives access to simple encryption and decryption of | 15 // 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 | 16 // 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. | 17 // these calls can block the current thread to collect user input. |
17 class OSCrypt { | 18 class OSCrypt { |
18 public: | 19 public: |
19 // Encrypt a string16. The output (second argument) is really an array of | 20 // Encrypt a string16. The output (second argument) is really an array of |
20 // bytes, but we're passing it back as a std::string. | 21 // bytes, but we're passing it back as a std::string. |
21 static bool EncryptString16(const base::string16& plaintext, | 22 static bool EncryptString16(const base::string16& plaintext, |
22 std::string* ciphertext); | 23 std::string* ciphertext); |
(...skipping 13 matching lines...) Expand all Loading... | |
36 // get your (binary) data into a string. | 37 // get your (binary) data into a string. |
37 static bool DecryptString(const std::string& ciphertext, | 38 static bool DecryptString(const std::string& ciphertext, |
38 std::string* plaintext); | 39 std::string* plaintext); |
39 | 40 |
40 #if defined(OS_MACOSX) | 41 #if defined(OS_MACOSX) |
41 // For unit testing purposes we instruct the Encryptor to use a mock Keychain | 42 // 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. | 43 // on the Mac. The default is to use the real Keychain. |
43 static void UseMockKeychain(bool use_mock); | 44 static void UseMockKeychain(bool use_mock); |
44 #endif | 45 #endif |
45 | 46 |
47 #if defined(USE_LIBSECRET) | |
48 static KeyStorageMock* UseMockKeyStorage(bool use_mock); | |
vabr (Chromium)
2016/05/13 15:10:18
nit: Please describe what the method does.
cfroussios
2016/05/13 17:09:12
Done.
| |
49 #endif | |
50 | |
46 private: | 51 private: |
47 DISALLOW_IMPLICIT_CONSTRUCTORS(OSCrypt); | 52 DISALLOW_IMPLICIT_CONSTRUCTORS(OSCrypt); |
48 }; | 53 }; |
49 | 54 |
50 #endif // COMPONENTS_OS_CRYPT_OS_CRYPT_H_ | 55 #endif // COMPONENTS_OS_CRYPT_OS_CRYPT_H_ |
OLD | NEW |