• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 Test fixture class for Epid11Verifier.
20  */
21 #ifndef EPID_VERIFIER_1_1_UNITTESTS_VERIFIER_TESTHELPER_H_
22 #define EPID_VERIFIER_1_1_UNITTESTS_VERIFIER_TESTHELPER_H_
23 
24 #include <vector>
25 
26 #include "epid/common-testhelper/epid_gtest-testhelper.h"
27 #include "gtest/gtest.h"
28 
29 extern "C" {
30 #include "epid/verifier/1.1/api.h"
31 }
32 
33 /// Test fixture class for Epid11Verifier
34 class Epid11VerifierTest : public ::testing::Test {
35  public:
36   /// Serialized identity element in G3
37   static const Epid11G3ElemStr kG3IdentityStr;
38   /// test public key
39   static const Epid11GroupPubKey kPubKeyStr;
40   /// test public key for tests of msg containing all bytes
41   static const Epid11GroupPubKey kPubKeyStrForMsg0_255;
42   /// the message "test message"
43   static const std::vector<uint8_t> kMsg0;
44   /// the basename "basename1"
45   static const std::vector<uint8_t> kBsn0;
46   /// a data with bytes [0,255]
47   static const std::vector<uint8_t> kData_0_255;
48   /// Signature of kData_0_255 with kBsn0 by Grp01 Member0 using Sha256
49   static const std::vector<uint8_t> kSigGrp01Member0Sha256kBsn0Data_0_255;
50   /// the privrl of group X
51   static const std::vector<uint8_t> kGrpXPrivRl;
52   /// currpted privrl of group X
53   static const std::vector<uint8_t> kGrpXCorruptedPrivRl;
54   /// a single entry privrl for group X
55   static const std::vector<uint8_t> kGrpXPrivRlSingleEntry;
56   /// verifier pre-computation data associated with pub_key_str
57   static const Epid11VerifierPrecomp kVerifierPrecompStr;
58   /// Intel(R) EPID 1.1 parameters
59   static const Epid11Params kParamsStr;
60   /// signature of msg0 by member0 of groupX with Sha256 bsn0
61   static const std::vector<uint8_t> kSigGrpXMember0Sha256Bsn0Msg0;
62   /// signature of msg0 by member0 of groupX with Sha256 bsn0 with one NrProof
63   static const std::vector<uint8_t> kSigGrpXMember0Sha256Bsn0Msg0SingleEntry;
64   /// signature of msg0 by member0 of groupX with Sha256 bsn0 with three NrProof
65   static const std::vector<uint8_t> kSigGrpXMember0Sha256Bsn0Msg0ThreeEntry;
66   /// signature of msg1 by member0 of groupX with Sha256 bsn0
67   static const std::vector<uint8_t> kSigGrpXMember0Sha256Bsn0Msg1;
68   /// signature of msg0 by member0 of groupX with Sha256 bsn1
69   static const std::vector<uint8_t> kSigGrpXMember0Sha256Bsn1Msg0;
70   /// signature of msg0 by member0 of groupX with Sha256 rnd base
71   static const std::vector<uint8_t> kSigGrpXMember0Sha256RandbaseMsg0;
72   /// signature of msg0 by member0 of groupX with Sha256 rnd base with n2==1
73   static const std::vector<uint8_t> kSigGrpXMember0Sha256RandbaseMsg0N2One;
74   /// signature of msg1 by member0 of groupX with Sha256 rnd base
75   static const std::vector<uint8_t> kSigGrpXMember0Sha256RandbaseMsg1;
76   /// signature of msg0 by member1 of groupX with Sha256 bsn0
77   static const std::vector<uint8_t> kSigGrpXMember1Sha256Bsn0Msg0;
78   /// signature of msg0 by priv revoked member 0 of groupX with Sha256 bsn0
79   static const std::vector<uint8_t> kSigGrpXRevokedPrivKey000Sha256Bsn0Msg0;
80   /// signature of msg0 by priv revoked member 1 of groupX with Sha256 bsn0
81   static const std::vector<uint8_t> kSigGrpXRevokedPrivKey001Sha256Bsn0Msg0;
82   /// signature of msg0 by priv revoked member 2 of groupX with Sha256 bsn0
83   static const std::vector<uint8_t> kSigGrpXRevokedPrivKey002Sha256Bsn0Msg0;
84 
85   /// group based rl test data (empty rl)
86   static const std::vector<uint8_t> kGroupRlEmptyBuf;
87   /// group based rl test data (v=3, n=3, 3 revoked gid)
88   static const std::vector<uint8_t> kGroupRl3GidBuf;
89 
90   /// a group revocation list with single group revoked
91   static const std::vector<uint8_t> kGrpRlRevokedGrpXSingleEntry;
92   /// a group revocation list with multiple entries
93   static const std::vector<uint8_t> kGrpRlRevokedGrpXFirstEntry;
94   /// a group revocation list with multiple entries
95   static const std::vector<uint8_t> kGrpRlRevokedGrpXMiddleEntry;
96   /// a group revocation list with multiple entries
97   static const std::vector<uint8_t> kGrpRlRevokedGrpXLastEntry;
98 
99   /// signature based revocation list
100   static const std::vector<uint8_t> kSigRl;
101   /// signature based revocation list for tests of msg containing all bytes
102   static const std::vector<uint8_t> kSigRlForMsg0_255;
103   /// signature based revocation list (empty rl)
104   static const std::vector<uint8_t> kEmptySigRl;
105 
106   /// setup called before each TEST_F starts
SetUp()107   virtual void SetUp() {}
108   /// teardown called after each TEST_F finishes
TearDown()109   virtual void TearDown() {}
110 
111   /// value "1" represented as an octstr constant
112   /*!
113   this value is used frequently to set 32 bit fields. describing as a constant
114   here
115   to reduce replication in code.
116   */
117   static const OctStr32 kOctStr32_1;
118   /// the sigrl of group X
119   static const std::vector<uint8_t> kGrpXSigRlMember0Bsn0Msg0SingleEntry;
120   /// the sigrl of group X
121   static const std::vector<uint8_t> kGrpXSigRlMember0Bsn0Msg0FirstEntry;
122   /// the sigrl of group X
123   static const std::vector<uint8_t> kGrpXSigRlMember0Bsn0Msg0MiddleEntry;
124   /// the sigrl of group X
125   static const std::vector<uint8_t> kGrpXSigRlMember0Bsn0Msg0LastEntry;
126 };
127 
128 #endif  // EPID_VERIFIER_1_1_UNITTESTS_VERIFIER_TESTHELPER_H_
129