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