ecpoint_wrapper-testhelper.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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 EcPoint C++ wrapper interface.
  19. */
  20. #ifndef EPID_COMMON_TESTHELPER_ECPOINT_WRAPPER_TESTHELPER_H_
  21. #define EPID_COMMON_TESTHELPER_ECPOINT_WRAPPER_TESTHELPER_H_
  22. #include <memory>
  23. #include <vector>
  24. extern "C" {
  25. #include "epid/common/1.1/types.h"
  26. #include "epid/common/math/bignum.h"
  27. #include "epid/common/math/ecgroup.h"
  28. }
  29. class EcGroupObj;
  30. /*!
  31. Wrapper class to provide Resource Allocation is Initialization handling
  32. for EcPoint
  33. */
  34. class EcPointObj {
  35. public:
  36. /// constructor
  37. EcPointObj();
  38. /// copy constructor
  39. EcPointObj(EcPointObj const& other);
  40. /// assignment operator
  41. EcPointObj& operator=(EcPointObj const& other);
  42. /// Create an EcPoint
  43. explicit EcPointObj(EcGroupObj* group);
  44. /// Create an EcPoint
  45. EcPointObj(EcGroupObj* group, G1ElemStr const& bytes);
  46. /// Create an EcPoint
  47. EcPointObj(EcGroupObj* group, G2ElemStr const& bytes);
  48. /// Create an EcPoint
  49. EcPointObj(EcGroupObj* group, Epid11G2ElemStr const& bytes);
  50. /// Create an EcPoint
  51. EcPointObj(EcGroupObj* group, std::vector<unsigned char> const& bytes);
  52. /// Create an EcPoint
  53. EcPointObj(EcGroupObj* group, void const* bytes, size_t size);
  54. /// Destroy the EcPoint
  55. ~EcPointObj();
  56. /// cast operator to get the pointer to the stored EcPoint
  57. operator EcPoint*();
  58. /// const cast operator to get the pointer to the stored EcPoint
  59. operator const EcPoint*() const;
  60. /// Get the underlying pointer
  61. EcPoint* get();
  62. /// Get the underlying pointer
  63. EcPoint const* getc() const;
  64. /// Get element bytes
  65. std::vector<unsigned char> data() const;
  66. private:
  67. void init(EcGroupObj* group, unsigned char const* bytes, size_t size);
  68. struct State;
  69. std::unique_ptr<State> state_;
  70. };
  71. #endif // EPID_COMMON_TESTHELPER_ECPOINT_WRAPPER_TESTHELPER_H_