verifier-testhelper.h 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  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 Epid11Verifier.
  19. */
  20. #ifndef EPID_VERIFIER_1_1_UNITTESTS_VERIFIER_TESTHELPER_H_
  21. #define EPID_VERIFIER_1_1_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/1.1/api.h"
  27. }
  28. /// Test fixture class for Epid11Verifier
  29. class Epid11VerifierTest : public ::testing::Test {
  30. public:
  31. /// Serialized identity element in G3
  32. static const Epid11G3ElemStr kG3IdentityStr;
  33. /// test public key
  34. static const Epid11GroupPubKey kPubKeyStr;
  35. /// test public key for tests of msg containing all bytes
  36. static const Epid11GroupPubKey kPubKeyStrForMsg0_255;
  37. /// the message "test message"
  38. static const std::vector<uint8_t> kMsg0;
  39. /// the basename "basename1"
  40. static const std::vector<uint8_t> kBsn0;
  41. /// a data with bytes [0,255]
  42. static const std::vector<uint8_t> kData_0_255;
  43. /// Signature of kData_0_255 with kBsn0 by Grp01 Member0 using Sha256
  44. static const std::vector<uint8_t> kSigGrp01Member0Sha256kBsn0Data_0_255;
  45. /// the privrl of group X
  46. static const std::vector<uint8_t> kGrpXPrivRl;
  47. /// currpted privrl of group X
  48. static const std::vector<uint8_t> kGrpXCorruptedPrivRl;
  49. /// a single entry privrl for group X
  50. static const std::vector<uint8_t> kGrpXPrivRlSingleEntry;
  51. /// verifier pre-computation data associated with pub_key_str
  52. static const Epid11VerifierPrecomp kVerifierPrecompStr;
  53. /// Intel(R) EPID 1.1 parameters
  54. static const Epid11Params kParamsStr;
  55. /// signature of msg0 by member0 of groupX with Sha256 bsn0
  56. static const std::vector<uint8_t> kSigGrpXMember0Sha256Bsn0Msg0;
  57. /// signature of msg0 by member0 of groupX with Sha256 bsn0 with one NrProof
  58. static const std::vector<uint8_t> kSigGrpXMember0Sha256Bsn0Msg0SingleEntry;
  59. /// signature of msg0 by member0 of groupX with Sha256 bsn0 with three NrProof
  60. static const std::vector<uint8_t> kSigGrpXMember0Sha256Bsn0Msg0ThreeEntry;
  61. /// signature of msg1 by member0 of groupX with Sha256 bsn0
  62. static const std::vector<uint8_t> kSigGrpXMember0Sha256Bsn0Msg1;
  63. /// signature of msg0 by member0 of groupX with Sha256 bsn1
  64. static const std::vector<uint8_t> kSigGrpXMember0Sha256Bsn1Msg0;
  65. /// signature of msg0 by member0 of groupX with Sha256 rnd base
  66. static const std::vector<uint8_t> kSigGrpXMember0Sha256RandbaseMsg0;
  67. /// signature of msg0 by member0 of groupX with Sha256 rnd base with n2==1
  68. static const std::vector<uint8_t> kSigGrpXMember0Sha256RandbaseMsg0N2One;
  69. /// signature of msg1 by member0 of groupX with Sha256 rnd base
  70. static const std::vector<uint8_t> kSigGrpXMember0Sha256RandbaseMsg1;
  71. /// signature of msg0 by member1 of groupX with Sha256 bsn0
  72. static const std::vector<uint8_t> kSigGrpXMember1Sha256Bsn0Msg0;
  73. /// signature of msg0 by priv revoked member 0 of groupX with Sha256 bsn0
  74. static const std::vector<uint8_t> kSigGrpXRevokedPrivKey000Sha256Bsn0Msg0;
  75. /// signature of msg0 by priv revoked member 1 of groupX with Sha256 bsn0
  76. static const std::vector<uint8_t> kSigGrpXRevokedPrivKey001Sha256Bsn0Msg0;
  77. /// signature of msg0 by priv revoked member 2 of groupX with Sha256 bsn0
  78. static const std::vector<uint8_t> kSigGrpXRevokedPrivKey002Sha256Bsn0Msg0;
  79. /// group based rl test data (empty rl)
  80. static const std::vector<uint8_t> kGroupRlEmptyBuf;
  81. /// group based rl test data (v=3, n=3, 3 revoked gid)
  82. static const std::vector<uint8_t> kGroupRl3GidBuf;
  83. /// a group revocation list with single group revoked
  84. static const std::vector<uint8_t> kGrpRlRevokedGrpXSingleEntry;
  85. /// a group revocation list with multiple entries
  86. static const std::vector<uint8_t> kGrpRlRevokedGrpXFirstEntry;
  87. /// a group revocation list with multiple entries
  88. static const std::vector<uint8_t> kGrpRlRevokedGrpXMiddleEntry;
  89. /// a group revocation list with multiple entries
  90. static const std::vector<uint8_t> kGrpRlRevokedGrpXLastEntry;
  91. /// signature based revocation list
  92. static const std::vector<uint8_t> kSigRl;
  93. /// signature based revocation list for tests of msg containing all bytes
  94. static const std::vector<uint8_t> kSigRlForMsg0_255;
  95. /// signature based revocation list (empty rl)
  96. static const std::vector<uint8_t> kEmptySigRl;
  97. /// setup called before each TEST_F starts
  98. virtual void SetUp() {}
  99. /// teardown called after each TEST_F finishes
  100. virtual void TearDown() {}
  101. /// value "1" represented as an octstr constant
  102. /*!
  103. this value is used frequently to set 32 bit fields. describing as a constant
  104. here
  105. to reduce replication in code.
  106. */
  107. static const OctStr32 kOctStr32_1;
  108. /// the sigrl of group X
  109. static const std::vector<uint8_t> kGrpXSigRlMember0Bsn0Msg0SingleEntry;
  110. /// the sigrl of group X
  111. static const std::vector<uint8_t> kGrpXSigRlMember0Bsn0Msg0FirstEntry;
  112. /// the sigrl of group X
  113. static const std::vector<uint8_t> kGrpXSigRlMember0Bsn0Msg0MiddleEntry;
  114. /// the sigrl of group X
  115. static const std::vector<uint8_t> kGrpXSigRlMember0Bsn0Msg0LastEntry;
  116. };
  117. #endif // EPID_VERIFIER_1_1_UNITTESTS_VERIFIER_TESTHELPER_H_