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 Verifier C++ wrapper implementation.
20 */
21 #include <cstdio>
22 #include <stdexcept>
23 #include <string>
24
25 #include "epid/common-testhelper/verifier_wrapper-testhelper.h"
26
VerifierCtxObj(GroupPubKey const & pub_key)27 VerifierCtxObj::VerifierCtxObj(GroupPubKey const& pub_key) : ctx_(nullptr) {
28 auto sts = EpidVerifierCreate(&pub_key, nullptr, &ctx_);
29 if (kEpidNoErr != sts) {
30 printf("%s(%d): %s\n", __FILE__, __LINE__, "test defect:");
31 throw std::logic_error(std::string("Failed to call: ") +
32 "EpidVerifierCreate()");
33 }
34 }
35
VerifierCtxObj(GroupPubKey const & pub_key,VerifierPrecomp const & precomp)36 VerifierCtxObj::VerifierCtxObj(GroupPubKey const& pub_key,
37 VerifierPrecomp const& precomp)
38 : ctx_(nullptr) {
39 auto sts = EpidVerifierCreate(&pub_key, &precomp, &ctx_);
40 if (kEpidNoErr != sts) {
41 printf("%s(%d): %s\n", __FILE__, __LINE__, "test defect:");
42 throw std::logic_error(std::string("Failed to call: ") +
43 "EpidVerifierCreate()");
44 }
45 }
46
~VerifierCtxObj()47 VerifierCtxObj::~VerifierCtxObj() { EpidVerifierDelete(&ctx_); }
48
ctx() const49 VerifierCtx* VerifierCtxObj::ctx() const { return ctx_; }
50
operator VerifierCtx*() const51 VerifierCtxObj::operator VerifierCtx*() const { return ctx_; }
52
operator const VerifierCtx*() const53 VerifierCtxObj::operator const VerifierCtx*() const { return ctx_; }
54