sigs_linked-test.cc 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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 AreSigsLinkable unit tests.
  19. */
  20. #include "epid/common-testhelper/epid_gtest-testhelper.h"
  21. #include "gtest/gtest.h"
  22. extern "C" {
  23. #include "epid/verifier/api.h"
  24. }
  25. #include "epid/common-testhelper/verifier_wrapper-testhelper.h"
  26. #include "epid/verifier/unittests/verifier-testhelper.h"
  27. namespace {
  28. TEST_F(EpidVerifierTest, AreSigsLinkedReturnsFalseGivenNullParameters) {
  29. auto& sig = this->kSigGrpXMember0Sha256Bsn0Msg0;
  30. EXPECT_FALSE(EpidAreSigsLinked(nullptr, nullptr));
  31. EXPECT_FALSE(EpidAreSigsLinked((BasicSignature const*)sig.data(), nullptr));
  32. EXPECT_FALSE(EpidAreSigsLinked(nullptr, (BasicSignature const*)sig.data()));
  33. }
  34. TEST_F(EpidVerifierTest, SigsBySameMemberWithRandomBaseAreNotLinkable) {
  35. auto& sig1 = this->kSigGrpXMember0Sha256RandbaseMsg0;
  36. auto& sig2 = this->kSigGrpXMember0Sha256RandbaseMsg1;
  37. EXPECT_FALSE(EpidAreSigsLinked((BasicSignature const*)sig1.data(),
  38. (BasicSignature const*)sig2.data()));
  39. }
  40. TEST_F(EpidVerifierTest, SigsBySameMemberWithSameBasenameAreLinkable) {
  41. auto& sig1 = this->kSigGrpXMember0Sha256Bsn0Msg0;
  42. auto& sig2 = this->kSigGrpXMember0Sha256Bsn0Msg1;
  43. EXPECT_TRUE(EpidAreSigsLinked((BasicSignature const*)sig1.data(),
  44. (BasicSignature const*)sig2.data()));
  45. }
  46. TEST_F(EpidVerifierTest, SigsBySameMemberWithDifferentBasenameAreNotLinkable) {
  47. auto& sig1 = this->kSigGrpXMember0Sha256Bsn0Msg0;
  48. auto& sig2 = this->kSigGrpXMember0Sha256Bsn1Msg0;
  49. EXPECT_FALSE(EpidAreSigsLinked((BasicSignature const*)sig1.data(),
  50. (BasicSignature const*)sig2.data()));
  51. }
  52. TEST_F(EpidVerifierTest, SigsByDifferentMembersWithSameBasenameAreNotLinkable) {
  53. auto& sig1 = this->kSigGrpXMember0Sha256Bsn0Msg0;
  54. auto& sig2 = this->kSigGrpXMember1Sha256Bsn0Msg0;
  55. EXPECT_FALSE(EpidAreSigsLinked((BasicSignature const*)sig1.data(),
  56. (BasicSignature const*)sig2.data()));
  57. }
  58. } // namespace