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, bool(const std::string&, 41 const std::string&, 42 const std::string&, 43 const std::string&, 44 const std::string&, 45 std::string*)); 46 MOCK_METHOD9(CreateCertifiedKey, bool(KeyType, 47 KeyUsage, 48 const std::string&, 49 const std::string&, 50 std::string*, 51 std::string*, 52 std::string*, 53 std::string*, 54 std::string*)); 55 MOCK_METHOD2(SealToPCR0, bool(const std::string&, std::string*)); 56 MOCK_METHOD2(Unseal, bool(const std::string&, std::string*)); 57 MOCK_METHOD1(GetEndorsementPublicKey, bool(std::string*)); 58 MOCK_METHOD3(Unbind, bool(const std::string&, const std::string&, 59 std::string*)); 60 MOCK_METHOD3(Sign, bool(const std::string&, const std::string&, 61 std::string*)); 62 }; 63 64 } // namespace attestation 65 66 #endif // ATTESTATION_COMMON_MOCK_TPM_UTILITY_H_ 67