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