load_external-simulator-test.cc 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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. /// Tpm2LoadExternal unit tests.
  17. /*! \file */
  18. #include <stdint.h>
  19. #include "epid/common-testhelper/epid2params_wrapper-testhelper.h"
  20. #include "epid/common-testhelper/errors-testhelper.h"
  21. #include "epid/common-testhelper/prng-testhelper.h"
  22. #include "epid/member/tpm2/unittests/tpm2-testhelper.h"
  23. #include "gtest/gtest.h"
  24. extern "C" {
  25. #include "epid/member/tpm2/load_external.h"
  26. }
  27. namespace {
  28. //////////////////////////////////////////////////////////////////////////
  29. // Tpm2LoadExternal Tests
  30. TEST_F(EpidTpm2Test, LoadExternalCanLoadFValueSha384) {
  31. Prng my_prng;
  32. Epid2ParamsObj epid2params;
  33. FpElemStr f_str = this->kMemberFValue;
  34. Tpm2CtxObj ctx(&Prng::Generate, &my_prng, &f_str, epid2params);
  35. THROW_ON_EPIDERR(Tpm2SetHashAlg(ctx, kSha384));
  36. EXPECT_EQ(kEpidNoErr, Tpm2LoadExternal(ctx, &f_str));
  37. }
  38. TEST_F(EpidTpm2Test, LoadExternalCanLoadFValueSha512) {
  39. Prng my_prng;
  40. Epid2ParamsObj epid2params;
  41. FpElemStr f_str = this->kMemberFValue;
  42. Tpm2CtxObj ctx(&Prng::Generate, &my_prng, &f_str, epid2params);
  43. THROW_ON_EPIDERR(Tpm2SetHashAlg(ctx, kSha512));
  44. EXPECT_EQ(kEpidNoErr, Tpm2LoadExternal(ctx, &f_str));
  45. }
  46. TEST_F(EpidTpm2Test, LoadExternalCanLoadFValueSha512_256) {
  47. Prng my_prng;
  48. Epid2ParamsObj epid2params;
  49. FpElemStr f_str = this->kMemberFValue;
  50. Tpm2CtxObj ctx(&Prng::Generate, &my_prng, &f_str, epid2params);
  51. THROW_ON_EPIDERR(Tpm2SetHashAlg(ctx, kSha512_256));
  52. EXPECT_EQ(kEpidNoErr, Tpm2LoadExternal(ctx, &f_str));
  53. }
  54. } // namespace