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