tpm2_wrapper-testhelper.h 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. /*############################################################################
  2. # Copyright 2017 Intel Corporation
  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. /// Tpm2Ctx wrapper class.
  17. /*! \file */
  18. #ifndef EPID_MEMBER_TPM2_UNITTESTS_TPM2_WRAPPER_TESTHELPER_H_
  19. #define EPID_MEMBER_TPM2_UNITTESTS_TPM2_WRAPPER_TESTHELPER_H_
  20. #include <stdint.h>
  21. #include <vector>
  22. extern "C" {
  23. #include "epid/common/bitsupplier.h"
  24. #include "epid/common/types.h"
  25. }
  26. typedef struct Tpm2Ctx Tpm2Ctx;
  27. class Epid2ParamsObj;
  28. /// C++ Wrapper to manage memory for Tpm2Ctx via RAII
  29. class Tpm2CtxObj {
  30. public:
  31. /// Create a Tpm2Ctx
  32. Tpm2CtxObj(BitSupplier rnd_func, void* rnd_param, const FpElemStr* f,
  33. class Epid2ParamsObj const& params);
  34. // This class instances are not meant to be copied.
  35. // Explicitly delete copy constructor and assignment operator.
  36. Tpm2CtxObj(const Tpm2CtxObj&) = delete;
  37. Tpm2CtxObj& operator=(const Tpm2CtxObj&) = delete;
  38. /// Destroy the Tpm2Ctx
  39. ~Tpm2CtxObj();
  40. /// get a pointer to the stored Tpm2Ctx
  41. Tpm2Ctx* ctx() const;
  42. /// cast operator to get the pointer to the stored Tpm2Ctx
  43. operator Tpm2Ctx*() const;
  44. /// const cast operator to get the pointer to the stored Tpm2Ctx
  45. operator const Tpm2Ctx*() const;
  46. private:
  47. /// The stored Tpm2Ctx
  48. Tpm2Ctx* ctx_;
  49. };
  50. #endif // EPID_MEMBER_TPM2_UNITTESTS_TPM2_WRAPPER_TESTHELPER_H_