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 EcGroup C++ wrapper interface. 20 */ 21 #ifndef EPID_COMMON_TESTHELPER_ECGROUP_WRAPPER_TESTHELPER_H_ 22 #define EPID_COMMON_TESTHELPER_ECGROUP_WRAPPER_TESTHELPER_H_ 23 24 #include <memory> 25 #include <vector> 26 27 extern "C" { 28 #include "epid/common/math/ecgroup.h" 29 } 30 31 #include "epid/common-testhelper/finite_field_wrapper-testhelper.h" 32 33 /*! 34 Wrapper class to provide Resource Allocation is Initialization handling 35 for EcGroup 36 */ 37 class EcGroupObj { 38 public: 39 /// constructor 40 EcGroupObj(); 41 /// copy constructor 42 EcGroupObj(EcGroupObj const& other); 43 /// assignment operator 44 EcGroupObj& operator=(EcGroupObj const& other); 45 /// Create a EcGroup 46 explicit EcGroupObj(FiniteFieldObj* ff, FfElement const* a, 47 FfElement const* b, FfElement const* x, 48 FfElement const* y, BigNum const* order, 49 BigNum const* cofactor); 50 /// Destroy the EcGroup 51 ~EcGroupObj(); 52 /// cast operator to get the pointer to the stored EcGroup 53 operator EcGroup*(); 54 /// const cast operator to get the pointer to the stored EcGroup 55 operator const EcGroup*() const; 56 /// Get the underlying pointer 57 EcGroup* get(); 58 /// Get the underlying pointer 59 EcGroup const* getc() const; 60 /// Get maximum size of group element 61 size_t GetElementMaxSize() const; 62 63 private: 64 struct State; 65 std::unique_ptr<State> state_; 66 }; 67 68 #endif // EPID_COMMON_TESTHELPER_ECGROUP_WRAPPER_TESTHELPER_H_ 69