mock_tpm_utility.h revision a6e332ee7f5fe52c1291d961dbeda975c8272044
103d54dfbcbdd04384e8c0419b7c45282664a2c1aDarren Krahn// Copyright 2014 The Chromium OS Authors. All rights reserved.
203d54dfbcbdd04384e8c0419b7c45282664a2c1aDarren Krahn// Use of this source code is governed by a BSD-style license that can be
303d54dfbcbdd04384e8c0419b7c45282664a2c1aDarren Krahn// found in the LICENSE file.
403d54dfbcbdd04384e8c0419b7c45282664a2c1aDarren Krahn
503d54dfbcbdd04384e8c0419b7c45282664a2c1aDarren Krahn#ifndef TRUNKS_MOCK_TPM_UTILITY_H_
603d54dfbcbdd04384e8c0419b7c45282664a2c1aDarren Krahn#define TRUNKS_MOCK_TPM_UTILITY_H_
703d54dfbcbdd04384e8c0419b7c45282664a2c1aDarren Krahn
803d54dfbcbdd04384e8c0419b7c45282664a2c1aDarren Krahn#include "trunks/tpm_utility.h"
903d54dfbcbdd04384e8c0419b7c45282664a2c1aDarren Krahn
1003d54dfbcbdd04384e8c0419b7c45282664a2c1aDarren Krahn#include <string>
1103d54dfbcbdd04384e8c0419b7c45282664a2c1aDarren Krahn
1203d54dfbcbdd04384e8c0419b7c45282664a2c1aDarren Krahn#include <gmock/gmock.h>
1303d54dfbcbdd04384e8c0419b7c45282664a2c1aDarren Krahn
1403d54dfbcbdd04384e8c0419b7c45282664a2c1aDarren Krahnnamespace trunks {
1503d54dfbcbdd04384e8c0419b7c45282664a2c1aDarren Krahn
1603d54dfbcbdd04384e8c0419b7c45282664a2c1aDarren Krahnclass MockTpmUtility : public TpmUtility {
1703d54dfbcbdd04384e8c0419b7c45282664a2c1aDarren Krahn public:
1803d54dfbcbdd04384e8c0419b7c45282664a2c1aDarren Krahn  MockTpmUtility();
19295e851b66fb19c05a14401e834337962a58c493Darren Krahn  ~MockTpmUtility() override;
2003d54dfbcbdd04384e8c0419b7c45282664a2c1aDarren Krahn
2103d54dfbcbdd04384e8c0419b7c45282664a2c1aDarren Krahn  MOCK_METHOD0(Startup, TPM_RC());
22d75dcae8a010d1ced7554dd25a440bee350a2d06Utkarsh Sanghi  MOCK_METHOD0(Clear, TPM_RC());
23e8b9a556d4561617747fed4ee5ced70fce9a4392Utkarsh Sanghi  MOCK_METHOD0(Shutdown, void());
2403d54dfbcbdd04384e8c0419b7c45282664a2c1aDarren Krahn  MOCK_METHOD0(InitializeTpm, TPM_RC());
25e7eb2bf306af6e8408cd77125861542d19e5ec6dUtkarsh Sanghi  MOCK_METHOD1(AllocatePCR, TPM_RC(const std::string&));
2666d0d268e571647ca99a2bdf4835d967449d7ddeUtkarsh Sanghi  MOCK_METHOD3(TakeOwnership, TPM_RC(const std::string&,
2766d0d268e571647ca99a2bdf4835d967449d7ddeUtkarsh Sanghi                                     const std::string&,
2866d0d268e571647ca99a2bdf4835d967449d7ddeUtkarsh Sanghi                                     const std::string&));
295d3b9451ae2e912aefed0669dd50b2a777ea0ab2Utkarsh Sanghi  MOCK_METHOD2(StirRandom, TPM_RC(const std::string&, AuthorizationDelegate*));
308b2bf63478b292937f85b3b0e215882af461a999Utkarsh Sanghi  MOCK_METHOD3(GenerateRandom, TPM_RC(size_t,
315d3b9451ae2e912aefed0669dd50b2a777ea0ab2Utkarsh Sanghi                                      AuthorizationDelegate*,
328b2bf63478b292937f85b3b0e215882af461a999Utkarsh Sanghi                                      std::string*));
338b2bf63478b292937f85b3b0e215882af461a999Utkarsh Sanghi  MOCK_METHOD3(ExtendPCR,
345d3b9451ae2e912aefed0669dd50b2a777ea0ab2Utkarsh Sanghi               TPM_RC(int, const std::string&, AuthorizationDelegate*));
35579dd8a934c684f2e2a34d9aa2f67953320428acUtkarsh Sanghi  MOCK_METHOD2(ReadPCR, TPM_RC(int, std::string*));
368b2bf63478b292937f85b3b0e215882af461a999Utkarsh Sanghi  MOCK_METHOD6(AsymmetricEncrypt, TPM_RC(TPM_HANDLE,
379dc77fecdb2446da134b9b2901173bb4dcf5e5e4Utkarsh Sanghi                                         TPM_ALG_ID,
38b3ba5e0b579a5462c7137cf49b49cc9a78d87944Utkarsh Sanghi                                         TPM_ALG_ID,
39b3ba5e0b579a5462c7137cf49b49cc9a78d87944Utkarsh Sanghi                                         const std::string&,
405d3b9451ae2e912aefed0669dd50b2a777ea0ab2Utkarsh Sanghi                                         AuthorizationDelegate*,
41b3ba5e0b579a5462c7137cf49b49cc9a78d87944Utkarsh Sanghi                                         std::string*));
421ef82e4a52abc91d0e8db12500c2da0d8c21f62cUtkarsh Sanghi  MOCK_METHOD6(AsymmetricDecrypt, TPM_RC(TPM_HANDLE,
439dc77fecdb2446da134b9b2901173bb4dcf5e5e4Utkarsh Sanghi                                         TPM_ALG_ID,
44b3ba5e0b579a5462c7137cf49b49cc9a78d87944Utkarsh Sanghi                                         TPM_ALG_ID,
45b3ba5e0b579a5462c7137cf49b49cc9a78d87944Utkarsh Sanghi                                         const std::string&,
465d3b9451ae2e912aefed0669dd50b2a777ea0ab2Utkarsh Sanghi                                         AuthorizationDelegate*,
47b3ba5e0b579a5462c7137cf49b49cc9a78d87944Utkarsh Sanghi                                         std::string*));
481ef82e4a52abc91d0e8db12500c2da0d8c21f62cUtkarsh Sanghi  MOCK_METHOD6(Sign, TPM_RC(TPM_HANDLE,
49748f7d68284813a78b883f9c05988f6de535fc8aUtkarsh Sanghi                            TPM_ALG_ID,
50748f7d68284813a78b883f9c05988f6de535fc8aUtkarsh Sanghi                            TPM_ALG_ID,
51748f7d68284813a78b883f9c05988f6de535fc8aUtkarsh Sanghi                            const std::string&,
525d3b9451ae2e912aefed0669dd50b2a777ea0ab2Utkarsh Sanghi                            AuthorizationDelegate*,
53748f7d68284813a78b883f9c05988f6de535fc8aUtkarsh Sanghi                            std::string*));
546f68562edf5f66006c08de24d558732d6a389631Utkarsh Sanghi  MOCK_METHOD6(Verify, TPM_RC(TPM_HANDLE,
55748f7d68284813a78b883f9c05988f6de535fc8aUtkarsh Sanghi                              TPM_ALG_ID,
56748f7d68284813a78b883f9c05988f6de535fc8aUtkarsh Sanghi                              TPM_ALG_ID,
57748f7d68284813a78b883f9c05988f6de535fc8aUtkarsh Sanghi                              const std::string&,
586f68562edf5f66006c08de24d558732d6a389631Utkarsh Sanghi                              const std::string&,
596f68562edf5f66006c08de24d558732d6a389631Utkarsh Sanghi                              AuthorizationDelegate*));
60fded77411da5ef66dff7389e49f40900c19d510cUtkarsh Sanghi  MOCK_METHOD2(CertifyCreation, TPM_RC(TPM_HANDLE,
61fded77411da5ef66dff7389e49f40900c19d510cUtkarsh Sanghi                                       const std::string&));
621ef82e4a52abc91d0e8db12500c2da0d8c21f62cUtkarsh Sanghi  MOCK_METHOD4(ChangeKeyAuthorizationData, TPM_RC(TPM_HANDLE,
6333ca033c9665b8496f3491037403ae1574a54227Utkarsh Sanghi                                                  const std::string&,
645d3b9451ae2e912aefed0669dd50b2a777ea0ab2Utkarsh Sanghi                                                  AuthorizationDelegate*,
6533ca033c9665b8496f3491037403ae1574a54227Utkarsh Sanghi                                                  std::string*));
6633ca033c9665b8496f3491037403ae1574a54227Utkarsh Sanghi  MOCK_METHOD7(ImportRSAKey, TPM_RC(AsymmetricKeyUsage,
6733ca033c9665b8496f3491037403ae1574a54227Utkarsh Sanghi                                    const std::string&,
6833ca033c9665b8496f3491037403ae1574a54227Utkarsh Sanghi                                    uint32_t,
6933ca033c9665b8496f3491037403ae1574a54227Utkarsh Sanghi                                    const std::string&,
7033ca033c9665b8496f3491037403ae1574a54227Utkarsh Sanghi                                    const std::string&,
715d3b9451ae2e912aefed0669dd50b2a777ea0ab2Utkarsh Sanghi                                    AuthorizationDelegate*,
7233ca033c9665b8496f3491037403ae1574a54227Utkarsh Sanghi                                    std::string*));
730ebbc58fe6d45378a5b502c33eb1c4289fd8b05bUtkarsh Sanghi  MOCK_METHOD10(CreateRSAKeyPair, TPM_RC(AsymmetricKeyUsage,
740ebbc58fe6d45378a5b502c33eb1c4289fd8b05bUtkarsh Sanghi                                         int,
750ebbc58fe6d45378a5b502c33eb1c4289fd8b05bUtkarsh Sanghi                                         uint32_t,
760ebbc58fe6d45378a5b502c33eb1c4289fd8b05bUtkarsh Sanghi                                         const std::string&,
770ebbc58fe6d45378a5b502c33eb1c4289fd8b05bUtkarsh Sanghi                                         const std::string&,
780ebbc58fe6d45378a5b502c33eb1c4289fd8b05bUtkarsh Sanghi                                         bool,
790ebbc58fe6d45378a5b502c33eb1c4289fd8b05bUtkarsh Sanghi                                         int,
800ebbc58fe6d45378a5b502c33eb1c4289fd8b05bUtkarsh Sanghi                                         AuthorizationDelegate*,
810ebbc58fe6d45378a5b502c33eb1c4289fd8b05bUtkarsh Sanghi                                         std::string*,
820ebbc58fe6d45378a5b502c33eb1c4289fd8b05bUtkarsh Sanghi                                         std::string*));
832ff7e22ba2ef3bb7ce2747b1b9706dd242ef9284Utkarsh Sanghi  MOCK_METHOD3(LoadKey, TPM_RC(const std::string&,
845d3b9451ae2e912aefed0669dd50b2a777ea0ab2Utkarsh Sanghi                               AuthorizationDelegate*,
856465502c740d2599d95e09232c744f6d2ed54505Utkarsh Sanghi                               TPM_HANDLE*));
866465502c740d2599d95e09232c744f6d2ed54505Utkarsh Sanghi  MOCK_METHOD2(GetKeyName, TPM_RC(TPM_HANDLE, std::string*));
878b2bf63478b292937f85b3b0e215882af461a999Utkarsh Sanghi  MOCK_METHOD2(GetKeyPublicArea, TPM_RC(TPM_HANDLE, TPMT_PUBLIC*));
88a6e332ee7f5fe52c1291d961dbeda975c8272044Utkarsh Sanghi  MOCK_METHOD4(SealData, TPM_RC(const std::string&,
89a6e332ee7f5fe52c1291d961dbeda975c8272044Utkarsh Sanghi                                const std::string&,
90a6e332ee7f5fe52c1291d961dbeda975c8272044Utkarsh Sanghi                                AuthorizationDelegate*,
91a6e332ee7f5fe52c1291d961dbeda975c8272044Utkarsh Sanghi                                std::string*));
92a6e332ee7f5fe52c1291d961dbeda975c8272044Utkarsh Sanghi  MOCK_METHOD3(UnsealData, TPM_RC(const std::string&,
93a6e332ee7f5fe52c1291d961dbeda975c8272044Utkarsh Sanghi                                  AuthorizationDelegate*,
94a6e332ee7f5fe52c1291d961dbeda975c8272044Utkarsh Sanghi                                  std::string*));
95a6e332ee7f5fe52c1291d961dbeda975c8272044Utkarsh Sanghi  MOCK_METHOD1(StartSession, TPM_RC(HmacSession*));
96a6e332ee7f5fe52c1291d961dbeda975c8272044Utkarsh Sanghi  MOCK_METHOD3(GetPolicyDigestForPcrValue, TPM_RC(int,
97a6e332ee7f5fe52c1291d961dbeda975c8272044Utkarsh Sanghi                                                  const std::string&,
98a6e332ee7f5fe52c1291d961dbeda975c8272044Utkarsh Sanghi                                                  std::string*));
9939dd58452d7fe3ebe93490a6239a76b385bd676dUtkarsh Sanghi  MOCK_METHOD3(DefineNVSpace, TPM_RC(uint32_t,
10039dd58452d7fe3ebe93490a6239a76b385bd676dUtkarsh Sanghi                                     size_t,
1015d3b9451ae2e912aefed0669dd50b2a777ea0ab2Utkarsh Sanghi                                     AuthorizationDelegate*));
10239dd58452d7fe3ebe93490a6239a76b385bd676dUtkarsh Sanghi  MOCK_METHOD2(DestroyNVSpace, TPM_RC(uint32_t,
1035d3b9451ae2e912aefed0669dd50b2a777ea0ab2Utkarsh Sanghi                                      AuthorizationDelegate*));
10439dd58452d7fe3ebe93490a6239a76b385bd676dUtkarsh Sanghi  MOCK_METHOD2(LockNVSpace, TPM_RC(uint32_t,
1055d3b9451ae2e912aefed0669dd50b2a777ea0ab2Utkarsh Sanghi                                   AuthorizationDelegate*));
10639dd58452d7fe3ebe93490a6239a76b385bd676dUtkarsh Sanghi  MOCK_METHOD4(WriteNVSpace, TPM_RC(uint32_t,
10739dd58452d7fe3ebe93490a6239a76b385bd676dUtkarsh Sanghi                                    uint32_t,
10839dd58452d7fe3ebe93490a6239a76b385bd676dUtkarsh Sanghi                                    const std::string&,
1095d3b9451ae2e912aefed0669dd50b2a777ea0ab2Utkarsh Sanghi                                    AuthorizationDelegate*));
11039dd58452d7fe3ebe93490a6239a76b385bd676dUtkarsh Sanghi  MOCK_METHOD5(ReadNVSpace, TPM_RC(uint32_t,
11139dd58452d7fe3ebe93490a6239a76b385bd676dUtkarsh Sanghi                                   uint32_t,
11239dd58452d7fe3ebe93490a6239a76b385bd676dUtkarsh Sanghi                                   size_t,
11339dd58452d7fe3ebe93490a6239a76b385bd676dUtkarsh Sanghi                                   std::string*,
1145d3b9451ae2e912aefed0669dd50b2a777ea0ab2Utkarsh Sanghi                                   AuthorizationDelegate*));
11539dd58452d7fe3ebe93490a6239a76b385bd676dUtkarsh Sanghi  MOCK_METHOD2(GetNVSpaceName, TPM_RC(uint32_t, std::string*));
11639dd58452d7fe3ebe93490a6239a76b385bd676dUtkarsh Sanghi  MOCK_METHOD2(GetNVSpacePublicArea, TPM_RC(uint32_t, TPMS_NV_PUBLIC*));
11703d54dfbcbdd04384e8c0419b7c45282664a2c1aDarren Krahn};
11803d54dfbcbdd04384e8c0419b7c45282664a2c1aDarren Krahn
11903d54dfbcbdd04384e8c0419b7c45282664a2c1aDarren Krahn}  // namespace trunks
12003d54dfbcbdd04384e8c0419b7c45282664a2c1aDarren Krahn
12103d54dfbcbdd04384e8c0419b7c45282664a2c1aDarren Krahn#endif  // TRUNKS_MOCK_TPM_UTILITY_H_
122