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/lazy_instance.h" | |
Lei Zhang
2016/07/12 19:12:24
Not used here -> goes in the .cc file.
cfroussios
2016/07/13 09:33:11
Done.
| |
11 #include "base/macros.h" | 12 #include "base/macros.h" |
12 | 13 |
13 // An API for retrieving OSCrypt's password from the system's password storage | 14 // An API for retrieving OSCrypt's password from the system's password storage |
14 // service. | 15 // service. |
15 class KeyStorageLinux { | 16 class KeyStorageLinux { |
16 public: | 17 public: |
17 KeyStorageLinux() = default; | 18 KeyStorageLinux() = default; |
18 virtual ~KeyStorageLinux() = default; | 19 virtual ~KeyStorageLinux() = default; |
19 | 20 |
20 // Tries to load all known key storages. Returns the first that succeeds or | 21 // Force OSCrypt to use a specific linux password store. |
21 // null if none succeed. | 22 static void SetStore(const std::string& store_type); |
23 | |
24 // Tries to load the appropriate key storage. Returns null if none succeed. | |
22 static std::unique_ptr<KeyStorageLinux> CreateService(); | 25 static std::unique_ptr<KeyStorageLinux> CreateService(); |
23 | 26 |
24 // Gets the encryption key from the OS password-managing library. If a key is | 27 // Gets the encryption key from the OS password-managing library. If a key is |
25 // not found, a new key will be generated, stored and returned. | 28 // not found, a new key will be generated, stored and returned. |
26 virtual std::string GetKey() = 0; | 29 virtual std::string GetKey() = 0; |
27 | 30 |
28 protected: | 31 protected: |
29 // Loads the key storage. Returns false if the service is not available. | 32 // Loads the key storage. Returns false if the service is not available. |
30 virtual bool Init() = 0; | 33 virtual bool Init() = 0; |
31 | 34 |
32 private: | 35 private: |
33 DISALLOW_COPY_AND_ASSIGN(KeyStorageLinux); | 36 DISALLOW_COPY_AND_ASSIGN(KeyStorageLinux); |
34 }; | 37 }; |
35 | 38 |
36 #endif // COMPONENTS_OS_CRYPT_KEY_STORAGE_LINUX_H_ | 39 #endif // COMPONENTS_OS_CRYPT_KEY_STORAGE_LINUX_H_ |
OLD | NEW |