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 EcGroup C++ wrapper implementation.
20  */
21 #include <cstdio>
22 #include <stdexcept>
23 #include <string>
24 
25 #include "epid/common-testhelper/1.1/verifier_wrapper-testhelper.h"
26 
Epid11VerifierCtxObj(Epid11GroupPubKey const & pub_key)27 Epid11VerifierCtxObj::Epid11VerifierCtxObj(Epid11GroupPubKey const& pub_key)
28     : ctx_(nullptr) {
29   auto sts = Epid11VerifierCreate(&pub_key, nullptr, &ctx_);
30   if (kEpidNoErr != sts) {
31     printf("%s(%d): %s\n", __FILE__, __LINE__, "test defect:");
32     throw std::logic_error(std::string("Failed to call: ") +
33                            "Epid11VerifierCreate()");
34   }
35 }
36 
Epid11VerifierCtxObj(Epid11GroupPubKey const & pub_key,Epid11VerifierPrecomp const & precomp)37 Epid11VerifierCtxObj::Epid11VerifierCtxObj(Epid11GroupPubKey const& pub_key,
38                                            Epid11VerifierPrecomp const& precomp)
39     : ctx_(nullptr) {
40   auto sts = Epid11VerifierCreate(&pub_key, &precomp, &ctx_);
41   if (kEpidNoErr != sts) {
42     printf("%s(%d): %s\n", __FILE__, __LINE__, "test defect:");
43     throw std::logic_error(std::string("Failed to call: ") +
44                            "Epid11VerifierCreate()");
45   }
46 }
47 
~Epid11VerifierCtxObj()48 Epid11VerifierCtxObj::~Epid11VerifierCtxObj() { Epid11VerifierDelete(&ctx_); }
49 
ctx() const50 Epid11VerifierCtx* Epid11VerifierCtxObj::ctx() const { return ctx_; }
51 
operator Epid11VerifierCtx*() const52 Epid11VerifierCtxObj::operator Epid11VerifierCtx*() const { return ctx_; }
53 
operator const Epid11VerifierCtx*() const54 Epid11VerifierCtxObj::operator const Epid11VerifierCtx*() const { return ctx_; }
55