verifier-testhelper.h 13 KB

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