blob: 86c379887350bf9b019a624383b533eb492bd3f1 [file] [log] [blame]
[email protected]3798a56a2012-08-30 09:03:461// Copyright (c) 2012 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
ygorshenin39e36782014-08-29 13:09:515#ifndef COMPONENTS_OWNERSHIP_MOCK_OWNER_KEY_UTIL_H_
6#define COMPONENTS_OWNERSHIP_MOCK_OWNER_KEY_UTIL_H_
[email protected]3798a56a2012-08-30 09:03:467
avif57136c12015-12-25 23:27:458#include <stdint.h>
9
dcheng82beb4f2016-04-26 00:35:0210#include <memory>
[email protected]3798a56a2012-08-30 09:03:4611#include <vector>
12
[email protected]3798a56a2012-08-30 09:03:4613#include "base/compiler_specific.h"
[email protected]57999812013-02-24 05:40:5214#include "base/files/file_path.h"
avif57136c12015-12-25 23:27:4515#include "base/macros.h"
ygorshenin39e36782014-08-29 13:09:5116#include "components/ownership/owner_key_util.h"
17#include "components/ownership/ownership_export.h"
[email protected]3798a56a2012-08-30 09:03:4618
davidbenee92e382015-05-26 20:25:4519namespace crypto {
20class RSAPrivateKey;
21}
22
ygorshenin39e36782014-08-29 13:09:5123namespace ownership {
[email protected]3798a56a2012-08-30 09:03:4624
ygorshenin39e36782014-08-29 13:09:5125// Implementation of OwnerKeyUtil which should be used only for
26// testing.
27class OWNERSHIP_EXPORT MockOwnerKeyUtil : public OwnerKeyUtil {
[email protected]3798a56a2012-08-30 09:03:4628 public:
29 MockOwnerKeyUtil();
30
ygorshenin39e36782014-08-29 13:09:5131 // OwnerKeyUtil implementation:
avif57136c12015-12-25 23:27:4532 bool ImportPublicKey(std::vector<uint8_t>* output) override;
davidbenee92e382015-05-26 20:25:4533 crypto::ScopedSECKEYPrivateKey FindPrivateKeyInSlot(
avif57136c12015-12-25 23:27:4534 const std::vector<uint8_t>& key,
davidbenee92e382015-05-26 20:25:4535 PK11SlotInfo* slot) override;
dcheng00ea022b2014-10-21 11:24:5636 bool IsPublicKeyPresent() override;
[email protected]3798a56a2012-08-30 09:03:4637
[email protected]7452c1c2012-11-23 18:44:5938 // Clears the public and private keys.
39 void Clear();
40
[email protected]3798a56a2012-08-30 09:03:4641 // Configures the mock to return the given public key.
avif57136c12015-12-25 23:27:4542 void SetPublicKey(const std::vector<uint8_t>& key);
[email protected]3798a56a2012-08-30 09:03:4643
44 // Sets the public key to use from the given private key, but doesn't
45 // configure the private key.
[email protected]4e8c49a2013-08-05 22:02:0746 void SetPublicKeyFromPrivateKey(const crypto::RSAPrivateKey& key);
[email protected]3798a56a2012-08-30 09:03:4647
48 // Sets the private key (also configures the public key).
dcheng82beb4f2016-04-26 00:35:0249 void SetPrivateKey(std::unique_ptr<crypto::RSAPrivateKey> key);
[email protected]3798a56a2012-08-30 09:03:4650
ygorshenin39e36782014-08-29 13:09:5151 private:
dcheng00ea022b2014-10-21 11:24:5652 ~MockOwnerKeyUtil() override;
[email protected]3798a56a2012-08-30 09:03:4653
avif57136c12015-12-25 23:27:4554 std::vector<uint8_t> public_key_;
davidbenee92e382015-05-26 20:25:4555 crypto::ScopedSECKEYPrivateKey private_key_;
[email protected]3798a56a2012-08-30 09:03:4656
57 DISALLOW_COPY_AND_ASSIGN(MockOwnerKeyUtil);
58};
59
ygorshenin39e36782014-08-29 13:09:5160} // namespace ownership
[email protected]3798a56a2012-08-30 09:03:4661
ygorshenin39e36782014-08-29 13:09:5162#endif // COMPONENTS_OWNERSHIP_MOCK_OWNER_KEY_UTIL_H_