member-testhelper.h 4.1 KB

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