cfroussios | 3b5a4e4 | 2016-05-31 11:02:18 | [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_OS_CRYPT_MOCKER_LINUX_H_ |
| 6 | #define COMPONENTS_OS_CRYPT_OS_CRYPT_MOCKER_LINUX_H_ |
| 7 | |
| 8 | #include <string> |
| 9 | |
| 10 | #include "base/macros.h" |
| 11 | #include "base/strings/string_piece.h" |
| 12 | #include "components/os_crypt/key_storage_linux.h" |
| 13 | |
| 14 | // Holds and serves a password from memory. |
| 15 | class OSCryptMockerLinux : public KeyStorageLinux { |
| 16 | public: |
| 17 | OSCryptMockerLinux() = default; |
| 18 | ~OSCryptMockerLinux() override = default; |
| 19 | |
cfroussios | 3b5a4e4 | 2016-05-31 11:02:18 | [diff] [blame] | 20 | // Get a pointer to the stored password. OSCryptMockerLinux owns the pointer. |
| 21 | std::string* GetKeyPtr(); |
| 22 | |
Christos Froussios | 2d15a8e | 2017-07-21 16:30:34 | [diff] [blame] | 23 | // Inject the mocking scheme into OSCrypt. |
| 24 | static void SetUp(); |
cfroussios | 3b5a4e4 | 2016-05-31 11:02:18 | [diff] [blame] | 25 | |
| 26 | // Restore OSCrypt to its real behaviour. |
| 27 | static void TearDown(); |
| 28 | |
| 29 | protected: |
| 30 | // KeyStorageLinux |
| 31 | bool Init() override; |
Christos Froussios | 985d1aac | 2017-11-09 11:01:07 | [diff] [blame] | 32 | std::string GetKeyImpl() override; |
cfroussios | 3b5a4e4 | 2016-05-31 11:02:18 | [diff] [blame] | 33 | |
| 34 | private: |
| 35 | std::string key_; |
| 36 | |
| 37 | DISALLOW_COPY_AND_ASSIGN(OSCryptMockerLinux); |
| 38 | }; |
| 39 | |
| 40 | #endif // COMPONENTS_OS_CRYPT_OS_CRYPT_MOCKER_LINUX_H_ |