tpm2-testhelper.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. /*############################################################################
  2. # Copyright 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. /// TPM fixture class.
  17. /*! \file */
  18. #ifndef EPID_MEMBER_TPM2_UNITTESTS_TPM2_TESTHELPER_H_
  19. #define EPID_MEMBER_TPM2_UNITTESTS_TPM2_TESTHELPER_H_
  20. #include <stdint.h>
  21. #include <climits>
  22. #include <vector>
  23. #include "epid/common-testhelper/epid_gtest-testhelper.h"
  24. #include "epid/member/tpm2/unittests/tpm2_wrapper-testhelper.h"
  25. #include "gtest/gtest.h"
  26. extern "C" {
  27. #include "epid/common/bitsupplier.h"
  28. #include "epid/common/src/hashsize.h"
  29. #include "epid/member/tpm2/context.h"
  30. }
  31. typedef struct FqElemStr FqElemStr;
  32. typedef struct FpElemStr FpElemStr;
  33. typedef struct G1ElemStr G1ElemStr;
  34. /// Test fixture class for Tpm
  35. class EpidTpm2Test : public ::testing::Test {
  36. public:
  37. // tpm digest
  38. static const std::vector<uint8_t> kTpmFfElemStrData;
  39. static const G1ElemStr kEpidPointStr;
  40. static const uint8_t kDigestSha256[EPID_SHA256_DIGEST_BITSIZE / CHAR_BIT];
  41. static const FpElemStr kMemberFValue;
  42. static const G1ElemStr kP1Str;
  43. static const G1ElemStr kg1Str;
  44. static const std::vector<uint8_t> kS2Sha256;
  45. static const FqElemStr kY2Sha256Str;
  46. static const G1ElemStr kP2Sha256Str;
  47. static const G1ElemStr kP2Sha256ExpF;
  48. static const std::vector<uint8_t> kS2Sha384;
  49. static const FqElemStr kY2Sha384Str;
  50. static const G1ElemStr kP2Sha384Str;
  51. static const G1ElemStr kP2Sha384ExpF;
  52. static const std::vector<uint8_t> kS2Sha512;
  53. static const FqElemStr kY2Sha512Str;
  54. static const G1ElemStr kP2Sha512Str;
  55. static const G1ElemStr kP2Sha512ExpF;
  56. static const std::vector<uint8_t> kS2Sha512256;
  57. static const FqElemStr kY2Sha512256Str;
  58. static const G1ElemStr kP2Sha512256Str;
  59. static const G1ElemStr kP2Sha512256ExpF;
  60. /// setup called before each TEST_F starts
  61. virtual void SetUp() {}
  62. /// teardown called after each TEST_F finishes
  63. virtual void TearDown() {}
  64. };
  65. /// compares FpElemStr values
  66. bool operator==(FpElemStr const& lhs, FpElemStr const& rhs);
  67. /// compares G1ElemStr values
  68. bool operator==(G1ElemStr const& lhs, G1ElemStr const& rhs);
  69. #endif // EPID_MEMBER_TPM2_UNITTESTS_TPM2_TESTHELPER_H_