blob: 79e071b6b3f71275e0ccc19444f5967690c4f4a5 [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
8#include <vector>
9
10#include "base/basictypes.h"
11#include "base/compiler_specific.h"
[email protected]57999812013-02-24 05:40:5212#include "base/files/file_path.h"
[email protected]3798a56a2012-08-30 09:03:4613#include "base/memory/scoped_ptr.h"
ygorshenin39e36782014-08-29 13:09:5114#include "components/ownership/owner_key_util.h"
15#include "components/ownership/ownership_export.h"
[email protected]3798a56a2012-08-30 09:03:4616
ygorshenin39e36782014-08-29 13:09:5117namespace ownership {
[email protected]3798a56a2012-08-30 09:03:4618
ygorshenin39e36782014-08-29 13:09:5119// Implementation of OwnerKeyUtil which should be used only for
20// testing.
21class OWNERSHIP_EXPORT MockOwnerKeyUtil : public OwnerKeyUtil {
[email protected]3798a56a2012-08-30 09:03:4622 public:
23 MockOwnerKeyUtil();
24
ygorshenin39e36782014-08-29 13:09:5125 // OwnerKeyUtil implementation:
mostynbfe59f482014-10-06 15:04:4626 virtual bool ImportPublicKey(std::vector<uint8>* output) override;
ygorshenin39e36782014-08-29 13:09:5127#if defined(USE_NSS)
[email protected]196e53e82014-05-21 01:50:2528 virtual crypto::RSAPrivateKey* FindPrivateKeyInSlot(
29 const std::vector<uint8>& key,
mostynbfe59f482014-10-06 15:04:4630 PK11SlotInfo* slot) override;
ygorshenin39e36782014-08-29 13:09:5131#endif // defined(USE_NSS)
mostynbfe59f482014-10-06 15:04:4632 virtual bool IsPublicKeyPresent() override;
[email protected]3798a56a2012-08-30 09:03:4633
[email protected]7452c1c2012-11-23 18:44:5934 // Clears the public and private keys.
35 void Clear();
36
[email protected]3798a56a2012-08-30 09:03:4637 // Configures the mock to return the given public key.
38 void SetPublicKey(const std::vector<uint8>& key);
39
40 // Sets the public key to use from the given private key, but doesn't
41 // configure the private key.
[email protected]4e8c49a2013-08-05 22:02:0742 void SetPublicKeyFromPrivateKey(const crypto::RSAPrivateKey& key);
[email protected]3798a56a2012-08-30 09:03:4643
44 // Sets the private key (also configures the public key).
[email protected]4e8c49a2013-08-05 22:02:0745 void SetPrivateKey(scoped_ptr<crypto::RSAPrivateKey> key);
[email protected]3798a56a2012-08-30 09:03:4646
ygorshenin39e36782014-08-29 13:09:5147 private:
[email protected]3798a56a2012-08-30 09:03:4648 virtual ~MockOwnerKeyUtil();
49
[email protected]3798a56a2012-08-30 09:03:4650 std::vector<uint8> public_key_;
51 scoped_ptr<crypto::RSAPrivateKey> private_key_;
52
53 DISALLOW_COPY_AND_ASSIGN(MockOwnerKeyUtil);
54};
55
ygorshenin39e36782014-08-29 13:09:5156} // namespace ownership
[email protected]3798a56a2012-08-30 09:03:4657
ygorshenin39e36782014-08-29 13:09:5158#endif // COMPONENTS_OWNERSHIP_MOCK_OWNER_KEY_UTIL_H_