Roll tools/swarming_client/ to 41036ec833891e4cf59050e4ac0c5d4986e48a75.
[chromium-blink-merge.git] / components / ownership / mock_owner_key_util.h
blob4b0cc8da0362e4ff7a79ff7ec26631dcc6089683
1 // 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.
5 #ifndef COMPONENTS_OWNERSHIP_MOCK_OWNER_KEY_UTIL_H_
6 #define COMPONENTS_OWNERSHIP_MOCK_OWNER_KEY_UTIL_H_
8 #include <vector>
10 #include "base/basictypes.h"
11 #include "base/compiler_specific.h"
12 #include "base/files/file_path.h"
13 #include "base/memory/scoped_ptr.h"
14 #include "components/ownership/owner_key_util.h"
15 #include "components/ownership/ownership_export.h"
17 namespace ownership {
19 // Implementation of OwnerKeyUtil which should be used only for
20 // testing.
21 class OWNERSHIP_EXPORT MockOwnerKeyUtil : public OwnerKeyUtil {
22 public:
23 MockOwnerKeyUtil();
25 // OwnerKeyUtil implementation:
26 bool ImportPublicKey(std::vector<uint8>* output) override;
27 #if defined(USE_NSS)
28 crypto::RSAPrivateKey* FindPrivateKeyInSlot(const std::vector<uint8>& key,
29 PK11SlotInfo* slot) override;
30 #endif // defined(USE_NSS)
31 bool IsPublicKeyPresent() override;
33 // Clears the public and private keys.
34 void Clear();
36 // Configures the mock to return the given public key.
37 void SetPublicKey(const std::vector<uint8>& key);
39 // Sets the public key to use from the given private key, but doesn't
40 // configure the private key.
41 void SetPublicKeyFromPrivateKey(const crypto::RSAPrivateKey& key);
43 // Sets the private key (also configures the public key).
44 void SetPrivateKey(scoped_ptr<crypto::RSAPrivateKey> key);
46 private:
47 ~MockOwnerKeyUtil() override;
49 std::vector<uint8> public_key_;
50 scoped_ptr<crypto::RSAPrivateKey> private_key_;
52 DISALLOW_COPY_AND_ASSIGN(MockOwnerKeyUtil);
55 } // namespace ownership
57 #endif // COMPONENTS_OWNERSHIP_MOCK_OWNER_KEY_UTIL_H_