• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*############################################################################
2   # Copyright 2016 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 FiniteField C++ wrapper interface.
20  */
21 #ifndef EPID_COMMON_TESTHELPER_FINITE_FIELD_WRAPPER_TESTHELPER_H_
22 #define EPID_COMMON_TESTHELPER_FINITE_FIELD_WRAPPER_TESTHELPER_H_
23 
24 #include <memory>
25 #include <vector>
26 
27 extern "C" {
28 #include "epid/common/math/finitefield.h"
29 }
30 
31 class FfElementObj;
32 
33 /*!
34 Wrapper class to provide Resource Allocation is Initialization handling
35 for FiniteField
36 */
37 class FiniteFieldObj {
38  public:
39   /// constructor
40   FiniteFieldObj();
41   /// copy constructor
42   FiniteFieldObj(FiniteFieldObj const& other);
43   /// assignment operator
44   FiniteFieldObj& operator=(FiniteFieldObj const& other);
45   /// Create a FiniteField
46   explicit FiniteFieldObj(BigNumStr const& prime);
47   /// Create a FiniteField
48   FiniteFieldObj(FiniteFieldObj const& ground_field,
49                  FfElementObj const& ground_element, int degree);
50   /// Create a FiniteField
51   FiniteFieldObj(FiniteFieldObj const& ground_field,
52                  BigNumStr const* irr_polynomial, int degree);
53   /// Destroy the FiniteField
54   ~FiniteFieldObj();
55   /// cast operator to get the pointer to the stored FiniteField
56   operator FiniteField*();
57   /// const cast operator to get the pointer to the stored FiniteField
58   operator const FiniteField*() const;
59   /// Get the underlying pointer
60   FiniteField* get();
61   /// Get the underlying pointer
62   FiniteField const* getc() const;
63   /// Get maximum size of field element
64   size_t GetElementMaxSize() const;
65 
66  private:
67   struct State;
68   std::unique_ptr<State> state_;
69 };
70 
71 #endif  // EPID_COMMON_TESTHELPER_FINITE_FIELD_WRAPPER_TESTHELPER_H_
72