• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
21 #include <stdint.h>
22 #include <vector>
23 
24 extern "C" {
25 #include "epid/common/bitsupplier.h"
26 #include "epid/common/types.h"
27 }
28 
29 typedef struct Tpm2Ctx Tpm2Ctx;
30 class Epid2ParamsObj;
31 
32 /// C++ Wrapper to manage memory for Tpm2Ctx via RAII
33 class Tpm2CtxObj {
34  public:
35   /// Create a Tpm2Ctx
36   Tpm2CtxObj(BitSupplier rnd_func, void* rnd_param, const FpElemStr* f,
37              class Epid2ParamsObj const& params);
38 
39   // This class instances are not meant to be copied.
40   // Explicitly delete copy constructor and assignment operator.
41   Tpm2CtxObj(const Tpm2CtxObj&) = delete;
42   Tpm2CtxObj& operator=(const Tpm2CtxObj&) = delete;
43 
44   /// Destroy the Tpm2Ctx
45   ~Tpm2CtxObj();
46   /// get a pointer to the stored Tpm2Ctx
47   Tpm2Ctx* ctx() const;
48   /// cast operator to get the pointer to the stored Tpm2Ctx
49   operator Tpm2Ctx*() const;
50   /// const cast operator to get the pointer to the stored Tpm2Ctx
51   operator const Tpm2Ctx*() const;
52 
53  private:
54   /// The stored Tpm2Ctx
55   Tpm2Ctx* ctx_;
56 };
57 
58 #endif  // EPID_MEMBER_TPM2_UNITTESTS_TPM2_WRAPPER_TESTHELPER_H_
59