verifier-testhelper.h 14 KB

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