sigs_linked-test.cc 2.8 KB

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