OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef COMPONENTS_OWNERSHIP_MOCK_OWNER_KEY_UTIL_H_ | 5 #ifndef COMPONENTS_OWNERSHIP_MOCK_OWNER_KEY_UTIL_H_ |
6 #define COMPONENTS_OWNERSHIP_MOCK_OWNER_KEY_UTIL_H_ | 6 #define COMPONENTS_OWNERSHIP_MOCK_OWNER_KEY_UTIL_H_ |
7 | 7 |
| 8 #include <stdint.h> |
| 9 |
8 #include <vector> | 10 #include <vector> |
9 | 11 |
10 #include "base/basictypes.h" | |
11 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
12 #include "base/files/file_path.h" | 13 #include "base/files/file_path.h" |
| 14 #include "base/macros.h" |
13 #include "base/memory/scoped_ptr.h" | 15 #include "base/memory/scoped_ptr.h" |
14 #include "components/ownership/owner_key_util.h" | 16 #include "components/ownership/owner_key_util.h" |
15 #include "components/ownership/ownership_export.h" | 17 #include "components/ownership/ownership_export.h" |
16 | 18 |
17 namespace crypto { | 19 namespace crypto { |
18 class RSAPrivateKey; | 20 class RSAPrivateKey; |
19 } | 21 } |
20 | 22 |
21 namespace ownership { | 23 namespace ownership { |
22 | 24 |
23 // Implementation of OwnerKeyUtil which should be used only for | 25 // Implementation of OwnerKeyUtil which should be used only for |
24 // testing. | 26 // testing. |
25 class OWNERSHIP_EXPORT MockOwnerKeyUtil : public OwnerKeyUtil { | 27 class OWNERSHIP_EXPORT MockOwnerKeyUtil : public OwnerKeyUtil { |
26 public: | 28 public: |
27 MockOwnerKeyUtil(); | 29 MockOwnerKeyUtil(); |
28 | 30 |
29 // OwnerKeyUtil implementation: | 31 // OwnerKeyUtil implementation: |
30 bool ImportPublicKey(std::vector<uint8>* output) override; | 32 bool ImportPublicKey(std::vector<uint8_t>* output) override; |
31 crypto::ScopedSECKEYPrivateKey FindPrivateKeyInSlot( | 33 crypto::ScopedSECKEYPrivateKey FindPrivateKeyInSlot( |
32 const std::vector<uint8>& key, | 34 const std::vector<uint8_t>& key, |
33 PK11SlotInfo* slot) override; | 35 PK11SlotInfo* slot) override; |
34 bool IsPublicKeyPresent() override; | 36 bool IsPublicKeyPresent() override; |
35 | 37 |
36 // Clears the public and private keys. | 38 // Clears the public and private keys. |
37 void Clear(); | 39 void Clear(); |
38 | 40 |
39 // Configures the mock to return the given public key. | 41 // Configures the mock to return the given public key. |
40 void SetPublicKey(const std::vector<uint8>& key); | 42 void SetPublicKey(const std::vector<uint8_t>& key); |
41 | 43 |
42 // Sets the public key to use from the given private key, but doesn't | 44 // Sets the public key to use from the given private key, but doesn't |
43 // configure the private key. | 45 // configure the private key. |
44 void SetPublicKeyFromPrivateKey(const crypto::RSAPrivateKey& key); | 46 void SetPublicKeyFromPrivateKey(const crypto::RSAPrivateKey& key); |
45 | 47 |
46 // Sets the private key (also configures the public key). | 48 // Sets the private key (also configures the public key). |
47 void SetPrivateKey(scoped_ptr<crypto::RSAPrivateKey> key); | 49 void SetPrivateKey(scoped_ptr<crypto::RSAPrivateKey> key); |
48 | 50 |
49 private: | 51 private: |
50 ~MockOwnerKeyUtil() override; | 52 ~MockOwnerKeyUtil() override; |
51 | 53 |
52 std::vector<uint8> public_key_; | 54 std::vector<uint8_t> public_key_; |
53 crypto::ScopedSECKEYPrivateKey private_key_; | 55 crypto::ScopedSECKEYPrivateKey private_key_; |
54 | 56 |
55 DISALLOW_COPY_AND_ASSIGN(MockOwnerKeyUtil); | 57 DISALLOW_COPY_AND_ASSIGN(MockOwnerKeyUtil); |
56 }; | 58 }; |
57 | 59 |
58 } // namespace ownership | 60 } // namespace ownership |
59 | 61 |
60 #endif // COMPONENTS_OWNERSHIP_MOCK_OWNER_KEY_UTIL_H_ | 62 #endif // COMPONENTS_OWNERSHIP_MOCK_OWNER_KEY_UTIL_H_ |
OLD | NEW |