• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 Test fixture class for EpidVerifier.
20  */
21 #ifndef EPID_VERIFIER_UNITTESTS_VERIFIER_TESTHELPER_H_
22 #define EPID_VERIFIER_UNITTESTS_VERIFIER_TESTHELPER_H_
23 
24 #include <vector>
25 
26 #include "epid/common-testhelper/epid_gtest-testhelper.h"
27 #include "gtest/gtest.h"
28 
29 extern "C" {
30 #include "epid/verifier/api.h"
31 }
32 
33 /// Test fixture class for EpidVerifier
34 class EpidVerifierTest : public ::testing::Test {
35  public:
36   /// Serialized identity element in G1
37   static const G1ElemStr kG1IdentityStr;
38   /// test public key
39   static const GroupPubKey kPubKeyStr;
40   /// test public key from Ikgf
41   static const GroupPubKey kPubKeyIkgfStr;
42   /// test public key of revoked group from Ikgf
43   static const GroupPubKey kPubKeyRevGroupIkgfStr;
44   /// verifier pre-computation data associated with pub_key_str
45   static const VerifierPrecomp kVerifierPrecompStr;
46   /// verifier pre-computation data associated with pub_key_str from Ikgf
47   static const VerifierPrecomp kVerifierPrecompIkgfStr;
48   /// Intel(R) EPID 2.0 parameters
49   static const Epid2Params kParamsStr;
50   /// public key in Grp01
51   static const GroupPubKey kGrp01Key;
52   /// private key based revocation list in Grp01
53   static const std::vector<uint8_t> kGrp01PrivRl;
54   /// signature based revocation list in Grp01
55   static const std::vector<uint8_t> kGrp01SigRl;
56   /// signature based revocation list from Ikgf
57   static const std::vector<uint8_t> kSigRlIkgf;
58   /// empty signature based revocation list from Ikgf
59   static const std::vector<uint8_t> kEmptySigRlIkgf;
60   /// number of SigRl entries for Grp01
61   static const uint32_t kGrp01SigRlN2 = 50;
62   /// verifier revocation list in Grp01 with one entry
63   static const std::vector<uint8_t> kGrp01VerRlOneEntry;
64   /// verifier revocation list in Grp01
65   static const std::vector<uint8_t> kGrp01VerRl;
66   /// empty verifier revocation in Grp01
67   static const std::vector<uint8_t> kEmptyGrp01VerRl;
68   /// C string with a message "test message"
69   static const std::vector<uint8_t> kTest0;
70   /// the message "test1"
71   static const std::vector<uint8_t> kTest1;
72   /// the basename "basename"
73   static const std::vector<uint8_t> kBasename;
74   /// the basename "basename1"
75   static const std::vector<uint8_t> kBasename1;
76   /// a data with bytes [0,255]
77   static const std::vector<uint8_t> kData_0_255;
78   /// Signature of kData_0_255 with kBsn0 by Grp01 Member0 using Sha512
79   static const std::vector<uint8_t> kSigGrp01Member0Sha512kBsn0Data_0_255;
80   /// Signature of Test0 with RandomBase by Grp01 Member0 using Sha256
81   static const std::vector<uint8_t> kSigGrp01Member0Sha256RandombaseTest0;
82   /// Signature of Test with RandomBase, Member0 using Sha256 from Ikgf
83   static const std::vector<uint8_t> kSigMember0Sha256RandombaseMsg0Ikgf;
84   /// Signature of Test1 with RandomBase by Grp01 Member0 using Sha384
85   static const std::vector<uint8_t> kSigGrp01Member0Sha384RandombaseTest0;
86   /// Signature of Test1 with RandomBase by Grp01 Member0 using Sha512
87   static const std::vector<uint8_t> kSigGrp01Member0Sha512RandombaseTest0;
88   /// Signature of msg0 with RandomBase by GrpX Member0 using Sha512/256
89   static const std::vector<uint8_t> kSigGrpXMember0Sha512256RandombaseMsg0;
90   /// Sig of Test1 with RandomBase by Grp01(no SigRl)  Member0 using Sha256
91   static const std::vector<uint8_t>
92       kSigGrp01Member0Sha256RandombaseTest1NoSigRl;
93   /// Sig of Test1 with Basename1 by Grp01(no SigRl) Member0 using Sha256
94   static const std::vector<uint8_t> kSigGrp01Member0Sha256Basename1Test1NoSigRl;
95   /// Sig of Test1 with Basename1 by Member0 using Sha256 from Ikgf
96   static const std::vector<uint8_t> kSigSha256Basename1Test1NoSigRlIkgf;
97   /// Sig of Test1 with RandomBase by Grp01(no SigRl) Member0 using Sha384
98   static const std::vector<uint8_t>
99       kSigGrp01Member0Sha384RandombaseTest1NoSigRl;
100   /// Sig of Test1 with RandomBase by Grp01(no SigRl) Member0 using Sha512
101   static const std::vector<uint8_t>
102       kSigGrp01Member0Sha512RandombaseTest1NoSigRl;
103   /// Sig of msg0 with RandomBase by GrpX(no SigRl) Member0 using Sha512/256
104   static const std::vector<uint8_t>
105       kSigGrpXMember0Sha512256RandombaseMsg0NoSigRl;
106   /// group based rl test data (empty rl)
107   static const std::vector<uint8_t> kGroupRlEmptyBuf;
108   /// group based rl test data (v=3, n=3, 3 revoked gid)
109   static const std::vector<uint8_t> kGroupRl3GidBuf;
110   /// group based rl test data (v=3, n=0, 3 revoked gid)
111   static const std::vector<uint8_t> kGroupRl3GidN0Buf;
112   /// group based rl test data (v=3, n=2, 3 revoked gid)
113   static const std::vector<uint8_t> kGroupRl3GidN2Buf;
114   /// group based rl test data (v=3, n=4, 3 revoked gid)
115   static const std::vector<uint8_t> kGroupRl3GidN4Buf;
116   /// a message
117   static const std::vector<uint8_t> kMsg0;
118   /// a message
119   static const std::vector<uint8_t> kMsg1;
120   /// a basename
121   static const std::vector<uint8_t> kBsn0;
122   /// a basename
123   static const std::vector<uint8_t> kBsn1;
124 
125   /// a group revocation list
126   static const std::vector<uint8_t> kGrpRl;
127   /// a group revocation list from Ikgf
128   static const std::vector<uint8_t> kGrpRlIkgf;
129   /// a group revocation list with single group revoked
130   static const std::vector<uint8_t> kGrpRlRevokedGrpXOnlyEntry;
131   /// a group revocation list with multiple entries
132   static const std::vector<uint8_t> kGrpRlRevokedGrpXFirstEntry;
133   /// a group revocation list with multiple entries
134   static const std::vector<uint8_t> kGrpRlRevokedGrpXMiddleEntry;
135   /// a group revocation list with multiple entries
136   static const std::vector<uint8_t> kGrpRlRevokedGrpXLastEntry;
137   /// private key based revocation list from Ikgf
138   static const std::vector<uint8_t> kPrivRlIkgf;
139   /// empty private key based revocation list from Ikgf
140   static const std::vector<uint8_t> kEmptyPrivRlIkgf;
141 
142   /// a group key in group X
143   static const GroupPubKey kGrpXKey;
144   /// the privrl of group X
145   static const std::vector<uint8_t> kGrpXPrivRl;
146   /// currpted privrl of group X
147   static const std::vector<uint8_t> kGrpXCorruptedPrivRl;
148   /// the privrl of group X with single entry PrivKey000 revoked
149   static const std::vector<uint8_t> kGrpXPrivRlRevokedPrivKey000OnlyEntry;
150   /// the sigrl of group X
151   static const std::vector<uint8_t> kGrpXSigRl;
152   /// a verifierrl of group X with bsn0 and SHA256 for some verifier
153   static const std::vector<uint8_t> kGrpXBsn0Sha256VerRl;
154   /// a verifierrl of group X with bsn0 and SHA384 for some verifier
155   static const std::vector<uint8_t> kGrpXBsn0Sha384VerRl;
156   /// a verifierrl of group X with bsn0 and SHA512 for some verifier
157   static const std::vector<uint8_t> kGrpXBsn0Sha512VerRl;
158   /// a verifierrl of group X with bsn0 and SHA512/256 for some verifier
159   static const std::vector<uint8_t> kGrpXBsn0Sha512256VerRl;
160   /// a verifierrl of group X with bsn0 for some verifier with single entry
161   static const std::vector<uint8_t> kGrpXBsn0VerRlSingleEntry;
162   /// a verifierrl of group X with bsn1 for some verifier
163   static const std::vector<uint8_t> kGrpXBsn1VerRl;
164   /// a verifierrl of group X with bsn1 for some verifier with 0-2 revoked
165   static const std::vector<uint8_t> kGrpXBsn1VerRl_012;
166 
167   /// the sigrl of group X corrputed
168   static const std::vector<uint8_t> kGrpXSigRlVersion2;
169 
170   /// a group key in group Y
171   static const GroupPubKey kGrpYKey;
172   /// the privrl of group Y
173   static const std::vector<uint8_t> kGrpYPrivRl;
174   /// the sigrl of group Y
175   static const std::vector<uint8_t> kGrpYSigRl;
176   /// a verifierrl of group Y for some verifier
177   static const std::vector<uint8_t> kGrpYVerRl;
178 
179   /// the sigrl of group X
180   static const std::vector<uint8_t> kGrpXSigRlMember0Sha256Bsn0Msg0OnlyEntry;
181   /// the sigrl of group X
182   static const std::vector<uint8_t> kGrpXSigRlMember0Sha256Bsn0Msg0FirstEntry;
183   /// the sigrl of group X
184   static const std::vector<uint8_t> kGrpXSigRlMember0Sha256Bsn0Msg0MiddleEntry;
185   /// the sigrl of group X
186   static const std::vector<uint8_t> kGrpXSigRlMember0Sha256Bsn0Msg0LastEntry;
187 
188   /// signature of msg0 by member0 of groupX with Sha256 bsn0
189   static const std::vector<uint8_t> kSigGrpXMember0Sha256Bsn0Msg0;
190   /// signature of msg0 by member0 with Sha256 bsn0 from Ikgf
191   static const std::vector<uint8_t> kSigMember0Sha256Bsn0Msg0Ikgf;
192   /// signature of msg0 by member0 with Sha256 bsn0 from Ikgf with empty SigRl
193   static const std::vector<uint8_t> kSigMember0Sha256Bsn0Msg0EmptySigRlIkgf;
194   /// signature of msg0 by member0 with Sha256 bsn0 from Ikgf without SigRl
195   static const std::vector<uint8_t> kSigMember0Sha256Bsn0Msg0NoSigRlIkgf;
196   /// signature of msg0 by member0 from SigRl first entry with Sha256 bsn0 from
197   /// Ikgf
198   static const std::vector<uint8_t> kSigRevSigMember0Sha256Bsn0Msg0Ikgf;
199   /// signature of msg0 by member0 from revoked Group with Sha256 bsn0 from Ikgf
200   static const std::vector<uint8_t> kRevGroupSigMember0Sha256Bsn0Msg0Ikgf;
201   /// signature of msg0 by member0 of groupX with Sha256 bsn0 single entry sigrl
202   static const std::vector<uint8_t>
203       kSigGrpXMember0Sha256Bsn0Msg0SingleEntrySigRl;
204   /// signature of msg0 by member0 of groupX with Sha256 bsn0 with revoked key
205   /// 000
206   static const std::vector<uint8_t> kSigGrpXRevokedPrivKey000Sha256Bsn0Msg0;
207   /// signature of msg0 by member0 with Sha256 bsn0 with revoked key from Ikgf
208   static const std::vector<uint8_t> kSigRevokedPrivKeySha256Bsn0Msg0Ikgf;
209   /// signature of msg0 by member0 of groupX with Sha256 bsn0 with revoked key
210   /// 001
211   static const std::vector<uint8_t> kSigGrpXRevokedPrivKey001Sha256Bsn0Msg0;
212   /// signature of msg0 by member0 of groupX with Sha256 bsn0 with revoked key
213   /// 002
214   static const std::vector<uint8_t> kSigGrpXRevokedPrivKey002Sha256Bsn0Msg0;
215   /// signature of msg1 by member0 of groupX with Sha256 bsn0
216   static const std::vector<uint8_t> kSigGrpXMember0Sha256Bsn0Msg1;
217   /// signature of msg0 by member0 of groupX with Sha256 bsn1
218   static const std::vector<uint8_t> kSigGrpXMember0Sha256Bsn1Msg0;
219   /// signature of msg0 by member0 of groupX with Sha256 rnd base
220   static const std::vector<uint8_t> kSigGrpXMember0Sha256RandbaseMsg0;
221   /// signature of msg0 by member0 of groupA with Sha256 rnd base
222   static const std::vector<uint8_t> kSigMember0Sha256RandbaseMsg0Ikgf;
223   /// signature of msg1 by member0 of groupX with Sha256 rnd base
224   static const std::vector<uint8_t> kSigGrpXMember0Sha256RandbaseMsg1;
225   /// signature of msg0 by member0 of groupX with Sha384 bsn0
226   static const std::vector<uint8_t> kSigGrpXMember0Sha384Bsn0Msg0;
227   /// signature of msg0 by member0 of groupX with Sha384 rnd base
228   static const std::vector<uint8_t> kSigGrpXMember0Sha384RandbaseMsg0;
229   /// signature of msg0 by member0 of groupX with Sha512 bsn0
230   static const std::vector<uint8_t> kSigGrpXMember0Sha512Bsn0Msg0;
231   /// signature of msg0 by member0 of groupX with Sha512 huge bsn
232   static const std::vector<uint8_t> kSigGrpXMember0Sha512HugeBsnMsg0;
233   /// signature of msg0 by member0 of groupX with Sha512 rnd base
234   static const std::vector<uint8_t> kSigGrpXMember0Sha512RandbaseMsg0;
235   /// signature of msg0 by member0 of groupX with Sha512256 bsn0
236   static const std::vector<uint8_t> kSigGrpXMember0Sha512256Bsn0Msg0;
237   /// signature of msg0 by member0 of groupX with Sha512256 rnd base
238   static const std::vector<uint8_t> kSigGrpXMember0Sha512256RandbaseMsg0;
239 
240   /// signature of msg0 by verrevokedmember0 of groupX Sha256 bsn0
241   static const std::vector<uint8_t> kSigGrpXVerRevokedMember0Sha256Bsn0Msg0;
242   /// signature of msg0 by verrevokedmember1 of groupX Sha256 bsn0
243   static const std::vector<uint8_t> kSigGrpXVerRevokedMember1Sha256Bsn0Msg0;
244   /// signature of msg0 by verrevokedmember2 of groupX Sha256 bsn0
245   static const std::vector<uint8_t> kSigGrpXVerRevokedMember2Sha256Bsn0Msg0;
246   /// signature of msg0 by verrevokedmember3 of groupX Sha256 bsn1
247   static const std::vector<uint8_t> kSigGrpXVerRevokedMember3Sha256Bsn1Msg0;
248   /// signature of msg0 by member1 of groupX with Sha256 bsn0
249   static const std::vector<uint8_t> kSigGrpXMember1Sha256Bsn0Msg0;
250 
251   /////////////////////////////////////////////////////////////////////
252   // EpidVerify Signature Based Revocation List Reject
253   /// GroupPubKey to be used for EpidVerify Signature Based Revocation List
254   /// Reject tests
255   static const GroupPubKey kPubKeySigRlVerify;
256   /// SigRl with 1 entry
257   static const std::vector<uint8_t> kSigRlSingleEntry;
258   /// SigRl with 1 entry
259   static const std::vector<uint8_t> kSigRlFiveEntries;
260   /// First entry in sigrl_five_entries
261   static const EpidSignature kSignatureSigrlFirst;
262   /// Middle entry in sigrl_five_entries
263   static const EpidSignature kSignatureSigrlMiddle;
264   /// Last entry in sigrl_five_entries
265   static const EpidSignature kSignatureSigrlLast;
266 
267   /// setup called before each TEST_F starts
SetUp()268   virtual void SetUp() {}
269   /// teardown called after each TEST_F finishes
TearDown()270   virtual void TearDown() {}
271 
272   /// value "1" represented as an octstr constant
273   /*!
274   this value is used frequently to set 32 bit fields. describing as a constant
275   here to reduce replication in code.
276   */
277   static const OctStr32 kOctStr32_1;
278 };
279 
280 #endif  // EPID_VERIFIER_UNITTESTS_VERIFIER_TESTHELPER_H_
281