verifier_wrapper-testhelper.cc 2.0 KB

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