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