blob: 559fe17fb28dacb8f68dcf8f2600bec1ef71c2d1 [file] [log] [blame]
cfroussios3b5a4e42016-05-31 11:02:181// 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.
15class OSCryptMockerLinux : public KeyStorageLinux {
16 public:
17 OSCryptMockerLinux() = default;
18 ~OSCryptMockerLinux() override = default;
19
cfroussios3b5a4e42016-05-31 11:02:1820 // Get a pointer to the stored password. OSCryptMockerLinux owns the pointer.
21 std::string* GetKeyPtr();
22
Christos Froussios2d15a8e2017-07-21 16:30:3423 // Inject the mocking scheme into OSCrypt.
24 static void SetUp();
cfroussios3b5a4e42016-05-31 11:02:1825
26 // Restore OSCrypt to its real behaviour.
27 static void TearDown();
28
29 protected:
30 // KeyStorageLinux
31 bool Init() override;
Christos Froussios985d1aac2017-11-09 11:01:0732 std::string GetKeyImpl() override;
cfroussios3b5a4e42016-05-31 11:02:1833
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_