• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //
2 // Copyright (C) 2015 The Android Open Source Project
3 //
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 //      http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 //
16 
17 #ifndef ATTESTATION_COMMON_MOCK_TPM_UTILITY_H_
18 #define ATTESTATION_COMMON_MOCK_TPM_UTILITY_H_
19 
20 #include "attestation/common/tpm_utility.h"
21 
22 #include <string>
23 
24 #include <gmock/gmock.h>
25 
26 namespace attestation {
27 
28 class MockTpmUtility : public TpmUtility {
29  public:
30   MockTpmUtility();
31   ~MockTpmUtility() override;
32   // By default this class will fake seal/unbind/sign operations by passing the
33   // input through Transform(<method>). E.g. The expected output of a fake Sign
34   // operation on "foo" can be computed by calling
35   // MockTpmUtility::Transform("Sign", "foo").
36   static std::string Transform(const std::string& method,
37                                const std::string& input);
38 
39   MOCK_METHOD0(IsTpmReady, bool());
40   MOCK_METHOD6(ActivateIdentity,
41                bool(const std::string&,
42                     const std::string&,
43                     const std::string&,
44                     const std::string&,
45                     const std::string&,
46                     std::string*));
47   MOCK_METHOD9(CreateCertifiedKey,
48                bool(KeyType,
49                     KeyUsage,
50                     const std::string&,
51                     const std::string&,
52                     std::string*,
53                     std::string*,
54                     std::string*,
55                     std::string*,
56                     std::string*));
57   MOCK_METHOD2(SealToPCR0, bool(const std::string&, std::string*));
58   MOCK_METHOD2(Unseal, bool(const std::string&, std::string*));
59   MOCK_METHOD1(GetEndorsementPublicKey, bool(std::string*));
60   MOCK_METHOD3(Unbind,
61                bool(const std::string&, const std::string&, std::string*));
62   MOCK_METHOD3(Sign,
63                bool(const std::string&, const std::string&, std::string*));
64 };
65 
66 }  // namespace attestation
67 
68 #endif  // ATTESTATION_COMMON_MOCK_TPM_UTILITY_H_
69