member-testhelper.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  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 Member C++ wrapper interface.
  19. */
  20. #ifndef EPID_MEMBER_UNITTESTS_MEMBER_TESTHELPER_H_
  21. #define EPID_MEMBER_UNITTESTS_MEMBER_TESTHELPER_H_
  22. #include <stdint.h>
  23. #include <vector>
  24. #include "epid/common-testhelper/epid_gtest-testhelper.h"
  25. #include "epid/common-testhelper/member_wrapper-testhelper.h"
  26. #include "gtest/gtest.h"
  27. extern "C" {
  28. #include "epid/member/api.h"
  29. }
  30. typedef struct G1ElemStr G1ElemStr;
  31. /// compares G1ElemStr values
  32. bool operator==(G1ElemStr const& lhs, G1ElemStr const& rhs);
  33. /// compares MembershipCredential values
  34. bool operator==(MembershipCredential const& lhs,
  35. MembershipCredential const& rhs);
  36. /// compares GroupPubKey values
  37. bool operator==(GroupPubKey const& lhs, GroupPubKey const& rhs);
  38. /// Test fixture class for EpidMember
  39. class EpidMemberTest : public ::testing::Test {
  40. public:
  41. /// test data
  42. static const GroupPubKey kGroupPublicKey;
  43. /// test data
  44. static const PrivKey kMemberPrivateKey;
  45. /// test data
  46. static const std::vector<uint8_t> kGroupPublicKeyDataIkgf;
  47. /// test data
  48. static const std::vector<uint8_t> kMemberPrivateKeyDataIkgf;
  49. /// test data
  50. static const MemberPrecomp kMemberPrecomp;
  51. /// test data
  52. static const std::vector<uint8_t> kGrp01Member0SigTest1Sha256;
  53. /// test data
  54. static const std::vector<uint8_t> kGrp01Member0SigTest1Sha384;
  55. /// test data
  56. static const std::vector<uint8_t> kGrp01Member0SigTest1Sha512;
  57. /// test data
  58. static const std::vector<uint8_t> kTest1Msg;
  59. /// signature based revocation list with 50 entries
  60. static std::vector<uint8_t> kSigRlData;
  61. /// signature based revocation list with 5 entries
  62. static std::vector<uint8_t> kSigRl5EntryData;
  63. /// a message
  64. static const std::vector<uint8_t> kMsg0;
  65. /// a message
  66. static const std::vector<uint8_t> kMsg1;
  67. /// a basename
  68. static const std::vector<uint8_t> kBsn0;
  69. /// a basename
  70. static const std::vector<uint8_t> kBsn1;
  71. /// a data with bytes [0,255]
  72. static const std::vector<uint8_t> kData_0_255;
  73. /// a group key in group X
  74. static const GroupPubKey kGrpXKey;
  75. /// a member 0 private key in group X
  76. static const PrivKey kGrpXMember0PrivKey;
  77. /// a member private key in group X revoked in SigRl
  78. static const PrivKey kGrpXSigrevokedMember0PrivKey;
  79. /// a SigRl of group X
  80. static const std::vector<uint8_t> kGrpXSigRl;
  81. /// a SigRl with single entry of group X
  82. static const std::vector<uint8_t> kGrpXSigRlSingleEntry;
  83. /// a compressed private key in group X
  84. static const CompressedPrivKey kGrpXMember9CompressedKey;
  85. /// a private key in group X
  86. static const PrivKey kGrpXMember9PrivKey;
  87. /// a group key in group Y
  88. static const GroupPubKey kGrpYKey;
  89. /// a compressed private key in group Y
  90. static const CompressedPrivKey kGrpYMember9CompressedKey;
  91. /// value "1" represented as an octstr constant
  92. static const OctStr32 kOctStr32_1;
  93. /// EPS specific group public key
  94. static const GroupPubKey kEps0GroupPublicKey;
  95. /// EPS specific member private key
  96. static const PrivKey kEps0MemberPrivateKey;
  97. /// setup called before each TEST_F starts
  98. virtual void SetUp() {}
  99. /// teardown called after each TEST_F finishes
  100. virtual void TearDown() {}
  101. };
  102. #endif // EPID_MEMBER_UNITTESTS_MEMBER_TESTHELPER_H_