bignum_wrapper-testhelper.h 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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 Bignum C++ wrapper interface.
  19. */
  20. #ifndef EPID_COMMON_TESTHELPER_BIGNUM_WRAPPER_TESTHELPER_H_
  21. #define EPID_COMMON_TESTHELPER_BIGNUM_WRAPPER_TESTHELPER_H_
  22. #include <memory>
  23. #include <vector>
  24. extern "C" {
  25. #include "epid/common/math/bignum.h"
  26. }
  27. /*!
  28. Wrapper class to provide Resource Allocation is Initialization handling
  29. for BigNum
  30. */
  31. class BigNumObj {
  32. public:
  33. /// Create a BigNum of default size ( sizeof(BigNumStr) )
  34. BigNumObj();
  35. /// copy constructor
  36. BigNumObj(BigNumObj const& other);
  37. /// assignment operator
  38. BigNumObj& operator=(BigNumObj const& other);
  39. /// Create a BigNum of specific size
  40. explicit BigNumObj(size_t data_size_bytes);
  41. /// Create a BigNum of specific size and initialize it to bytes
  42. BigNumObj(size_t data_size_bytes, std::vector<unsigned char> const& bytes);
  43. /// Create a BigNum of specific size and initialize it to bytes
  44. BigNumObj(size_t data_size_bytes, BigNumStr const& bytes);
  45. /// Create a BigNum the same size as bytes and initialize it to bytes
  46. explicit BigNumObj(std::vector<unsigned char> const& bytes);
  47. /// Create a BigNum the same size as bytes and initialize it to bytes
  48. explicit BigNumObj(BigNumStr const& bytes);
  49. /// Destroy the Bignum
  50. ~BigNumObj();
  51. /// cast operator to get the pointer to the stored BigNum
  52. operator BigNum*();
  53. /// const cast operator to get the pointer to the stored BigNum
  54. operator const BigNum*() const;
  55. /// Get the underlying pointer
  56. BigNum* get();
  57. /// Get the underlying pointer
  58. BigNum const* getc() const;
  59. private:
  60. struct State;
  61. std::unique_ptr<State> state_;
  62. };
  63. #endif // EPID_COMMON_TESTHELPER_BIGNUM_WRAPPER_TESTHELPER_H_