sigs_linked-test.cc 2.6 KB

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