Upstream version 10.39.225.0
[platform/framework/web/crosswalk.git] / src / components / ownership / mock_owner_key_util.h
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.
4
5 #ifndef COMPONENTS_OWNERSHIP_MOCK_OWNER_KEY_UTIL_H_
6 #define COMPONENTS_OWNERSHIP_MOCK_OWNER_KEY_UTIL_H_
7
8 #include <vector>
9
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"
16
17 namespace ownership {
18
19 // Implementation of OwnerKeyUtil which should be used only for
20 // testing.
21 class OWNERSHIP_EXPORT MockOwnerKeyUtil : public OwnerKeyUtil {
22  public:
23   MockOwnerKeyUtil();
24
25   // OwnerKeyUtil implementation:
26   virtual bool ImportPublicKey(std::vector<uint8>* output) OVERRIDE;
27 #if defined(USE_NSS)
28   virtual crypto::RSAPrivateKey* FindPrivateKeyInSlot(
29       const std::vector<uint8>& key,
30       PK11SlotInfo* slot) OVERRIDE;
31 #endif  // defined(USE_NSS)
32   virtual bool IsPublicKeyPresent() OVERRIDE;
33
34   // Clears the public and private keys.
35   void Clear();
36
37   // 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.
42   void SetPublicKeyFromPrivateKey(const crypto::RSAPrivateKey& key);
43
44   // Sets the private key (also configures the public key).
45   void SetPrivateKey(scoped_ptr<crypto::RSAPrivateKey> key);
46
47  private:
48   virtual ~MockOwnerKeyUtil();
49
50   std::vector<uint8> public_key_;
51   scoped_ptr<crypto::RSAPrivateKey> private_key_;
52
53   DISALLOW_COPY_AND_ASSIGN(MockOwnerKeyUtil);
54 };
55
56 }  // namespace ownership
57
58 #endif  // COMPONENTS_OWNERSHIP_MOCK_OWNER_KEY_UTIL_H_