OLD | NEW |
---|---|
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 #ifndef COMPONENTS_OS_CRYPT_KEY_STORAGE_LINUX_H_ | 5 #ifndef COMPONENTS_OS_CRYPT_KEY_STORAGE_LINUX_H_ |
6 #define COMPONENTS_OS_CRYPT_KEY_STORAGE_LINUX_H_ | 6 #define COMPONENTS_OS_CRYPT_KEY_STORAGE_LINUX_H_ |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 #include <string> | 9 #include <string> |
10 | 10 |
11 #include "base/macros.h" | 11 #include "base/macros.h" |
12 | 12 |
13 // An API for retrieving OSCrypt's password from the system's password storage | 13 // An API for retrieving OSCrypt's password from the system's password storage |
14 // service. | 14 // service. |
15 class KeyStorageLinux { | 15 class KeyStorageLinux { |
16 public: | 16 public: |
17 KeyStorageLinux() = default; | 17 KeyStorageLinux() = default; |
18 virtual ~KeyStorageLinux() = default; | 18 virtual ~KeyStorageLinux() = default; |
19 | 19 |
20 // Force OSCrypt to use a specific linux password store. | 20 // Force OSCrypt to use a specific linux password store. |
21 static void SetStore(const std::string& store_type); | 21 static void SetStore(const std::string& store_type); |
22 | 22 |
23 // The product name to use for permission prompts. | |
24 static void SetProductName(const std::string& product_name); | |
25 | |
23 // Tries to load the appropriate key storage. Returns null if none succeed. | 26 // Tries to load the appropriate key storage. Returns null if none succeed. |
24 static std::unique_ptr<KeyStorageLinux> CreateService(); | 27 static std::unique_ptr<KeyStorageLinux> CreateService(); |
25 | 28 |
26 // Gets the encryption key from the OS password-managing library. If a key is | 29 // Gets the encryption key from the OS password-managing library. If a key is |
27 // not found, a new key will be generated, stored and returned. | 30 // not found, a new key will be generated, stored and returned. |
28 virtual std::string GetKey() = 0; | 31 virtual std::string GetKey() = 0; |
29 | 32 |
30 protected: | 33 protected: |
31 // Loads the key storage. Returns false if the service is not available. | 34 // Loads the key storage. Returns false if the service is not available. |
32 virtual bool Init() = 0; | 35 virtual bool Init() = 0; |
33 | 36 |
37 // The name of the group, if any, containing the key. | |
38 static const char* const kFolderName; | |
Lei Zhang
2016/07/20 19:15:07
Can these be static const char kFoo[] ?
cfroussios
2016/07/21 11:49:46
Done.
| |
39 // The name of the entry with the encryption key. | |
40 static const char* const kKey; | |
41 | |
34 private: | 42 private: |
35 DISALLOW_COPY_AND_ASSIGN(KeyStorageLinux); | 43 DISALLOW_COPY_AND_ASSIGN(KeyStorageLinux); |
36 }; | 44 }; |
37 | 45 |
38 #endif // COMPONENTS_OS_CRYPT_KEY_STORAGE_LINUX_H_ | 46 #endif // COMPONENTS_OS_CRYPT_KEY_STORAGE_LINUX_H_ |
OLD | NEW |