verifier_wrapper-testhelper.cc 1.9 KB

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