cfroussios | b013c15b | 2016-09-03 01:10:16 | [diff] [blame] | 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 |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #ifndef COMPONENTS_OS_CRYPT_KEY_STORAGE_KEYRING_H_ |
| 6 | #define COMPONENTS_OS_CRYPT_KEY_STORAGE_KEYRING_H_ |
| 7 | |
| 8 | #include <string> |
| 9 | |
Matt Menke | ef8aab1 | 2018-07-31 14:42:17 | [diff] [blame] | 10 | #include "base/component_export.h" |
cfroussios | b013c15b | 2016-09-03 01:10:16 | [diff] [blame] | 11 | #include "base/macros.h" |
Christos Froussios | 494196d | 2017-07-14 10:10:04 | [diff] [blame] | 12 | #include "base/memory/ref_counted.h" |
cfroussios | b013c15b | 2016-09-03 01:10:16 | [diff] [blame] | 13 | #include "components/os_crypt/key_storage_linux.h" |
Anton Bikineev | 1156b5f | 2021-05-15 22:35:36 | [diff] [blame^] | 14 | #include "third_party/abseil-cpp/absl/types/optional.h" |
cfroussios | b013c15b | 2016-09-03 01:10:16 | [diff] [blame] | 15 | |
| 16 | namespace base { |
| 17 | class SingleThreadTaskRunner; |
cfroussios | b013c15b | 2016-09-03 01:10:16 | [diff] [blame] | 18 | } // namespace base |
| 19 | |
| 20 | // Specialisation of KeyStorageLinux that uses Libsecret. |
Matt Menke | ef8aab1 | 2018-07-31 14:42:17 | [diff] [blame] | 21 | class COMPONENT_EXPORT(OS_CRYPT) KeyStorageKeyring : public KeyStorageLinux { |
cfroussios | b013c15b | 2016-09-03 01:10:16 | [diff] [blame] | 22 | public: |
| 23 | explicit KeyStorageKeyring( |
| 24 | scoped_refptr<base::SingleThreadTaskRunner> main_thread_runner); |
| 25 | ~KeyStorageKeyring() override; |
| 26 | |
cfroussios | b013c15b | 2016-09-03 01:10:16 | [diff] [blame] | 27 | protected: |
| 28 | // KeyStorageLinux |
Christos Froussios | d6cfe11e | 2017-12-01 19:28:26 | [diff] [blame] | 29 | base::SequencedTaskRunner* GetTaskRunner() override; |
cfroussios | b013c15b | 2016-09-03 01:10:16 | [diff] [blame] | 30 | bool Init() override; |
Anton Bikineev | 1156b5f | 2021-05-15 22:35:36 | [diff] [blame^] | 31 | absl::optional<std::string> GetKeyImpl() override; |
cfroussios | b013c15b | 2016-09-03 01:10:16 | [diff] [blame] | 32 | |
| 33 | private: |
cfroussios | b013c15b | 2016-09-03 01:10:16 | [diff] [blame] | 34 | // Generate a random string and store it as OScrypt's new password. |
Anton Bikineev | 1156b5f | 2021-05-15 22:35:36 | [diff] [blame^] | 35 | absl::optional<std::string> AddRandomPasswordInKeyring(); |
cfroussios | b013c15b | 2016-09-03 01:10:16 | [diff] [blame] | 36 | |
| 37 | // Keyring calls need to originate from the main thread. |
| 38 | scoped_refptr<base::SingleThreadTaskRunner> main_thread_runner_; |
| 39 | |
| 40 | DISALLOW_COPY_AND_ASSIGN(KeyStorageKeyring); |
| 41 | }; |
| 42 | |
| 43 | #endif // COMPONENTS_OS_CRYPT_KEY_STORAGE_KEYRING_H_ |