• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*############################################################################
2   # Copyright 2016-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 
17 /*!
18  * \file
19  * \brief EcPoint C++ wrapper interface.
20  */
21 #ifndef EPID_COMMON_TESTHELPER_ECPOINT_WRAPPER_TESTHELPER_H_
22 #define EPID_COMMON_TESTHELPER_ECPOINT_WRAPPER_TESTHELPER_H_
23 
24 #include <memory>
25 #include <vector>
26 
27 extern "C" {
28 #include "epid/common/1.1/types.h"
29 #include "epid/common/math/bignum.h"
30 #include "epid/common/math/ecgroup.h"
31 }
32 
33 class EcGroupObj;
34 
35 /*!
36 Wrapper class to provide Resource Allocation is Initialization handling
37 for EcPoint
38 */
39 class EcPointObj {
40  public:
41   /// constructor
42   EcPointObj();
43   /// copy constructor
44   EcPointObj(EcPointObj const& other);
45   /// assignment operator
46   EcPointObj& operator=(EcPointObj const& other);
47   /// Create an EcPoint
48   explicit EcPointObj(EcGroupObj* group);
49   /// Create an EcPoint
50   EcPointObj(EcGroupObj* group, G1ElemStr const& bytes);
51   /// Create an EcPoint
52   EcPointObj(EcGroupObj* group, G2ElemStr const& bytes);
53   /// Create an EcPoint
54   EcPointObj(EcGroupObj* group, Epid11G2ElemStr const& bytes);
55   /// Create an EcPoint
56   EcPointObj(EcGroupObj* group, std::vector<unsigned char> const& bytes);
57   /// Create an EcPoint
58   EcPointObj(EcGroupObj* group, void const* bytes, size_t size);
59   /// Destroy the EcPoint
60   ~EcPointObj();
61   /// cast operator to get the pointer to the stored EcPoint
62   operator EcPoint*();
63   /// const cast operator to get the pointer to the stored EcPoint
64   operator const EcPoint*() const;
65   /// Get the underlying pointer
66   EcPoint* get();
67   /// Get the underlying pointer
68   EcPoint const* getc() const;
69   /// Get element bytes
70   std::vector<unsigned char> data() const;
71 
72  private:
73   void init(EcGroupObj* group, unsigned char const* bytes, size_t size);
74   struct State;
75   std::unique_ptr<State> state_;
76 };
77 
78 #endif  // EPID_COMMON_TESTHELPER_ECPOINT_WRAPPER_TESTHELPER_H_
79