• 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 #ifndef EPID_COMMON_1_1_TYPES_H_
17 #define EPID_COMMON_1_1_TYPES_H_
18 
19 /*!
20 * \file
21 * \brief SDK data types for Intel(R) EPID 1.1.
22 */
23 
24 #include <limits.h>  // for CHAR_BIT
25 
26 #include "epid/common/types.h"
27 
28 /// Intel(R) EPID 1.1 specific data types.
29 /*!
30 \defgroup Epid11Types Intel(R) EPID 1.1 specific types
31 Defines serialized data types used by the SDK. These data types
32 are only used by components that need to do Intel(R) EPID 1.1
33 verification.
34 
35 \ingroup EpidTypes
36 \see <a href="group___epid11_verifier_module.html#details"><b>Intel(R) EPID 1.1
37 support</b></a>
38 @{
39 */
40 
41 #pragma pack(1)
42 
43 /// 80 bit octet string
44 typedef struct OctStr80 {
45   unsigned char data[80 / CHAR_BIT];  ///< 80 bit data
46 } OctStr80;
47 
48 /// 600 bit octet string
49 typedef struct OctSt600 {
50   unsigned char data[600 / CHAR_BIT];  ///< 600 bit data
51 } OctStr600;
52 
53 /// 768 bit octet string
54 typedef struct OctStr768 {
55   unsigned char data[768 / CHAR_BIT];  ///< 768 bit data
56 } OctStr768;
57 
58 /// Serialized Fq3 element
59 typedef struct Fq3ElemStr {
60   FqElemStr a[3];  ///< polynomial coefficient
61 } Fq3ElemStr;
62 
63 /// Serialized Intel(R) EPID 1.1 G1 element
64 typedef G1ElemStr Epid11G1ElemStr;
65 
66 /// Serialized Intel(R) EPID 1.1 G3 element
67 typedef G1ElemStr Epid11G3ElemStr;
68 
69 /// Serialized Intel(R) EPID 1.1 G2 element
70 typedef struct Epid11G2ElemStr {
71   FqElemStr x[3];  ///< an integer between [0, q-1]
72   FqElemStr y[3];  ///< an integer between [0, q-1]
73 } Epid11G2ElemStr;
74 
75 /// Serialized Intel(R) EPID 1.1 GT element
76 typedef struct Epid11GtElemStr {
77   Fq3ElemStr a[2];  ///< an element in Fq3
78 } Epid11GtElemStr;
79 
80 /// Intel(R) EPID 1.1 Parameters.
81 /*!
82 Intel(R) EPID 1.1 parameters are: (p, q, h, a, b, coeff, qnr, orderG2, p', q',
83 h', a', b', g1, g2, g3). The size of the Intel(R) EPID public parameters of G1,
84 G2, G3, and GT is 6464 bits or 808 bytes.
85 */
86 typedef struct Epid11Params {
87   BigNumStr p;  ///< a prime
88   BigNumStr q;  ///< a prime
89   OctStr32 h;   ///< a small integer, also denoted as cofactor
90   FqElemStr a;  ///< an integer between [0, q-1]
91   FqElemStr b;  ///< an integer between [0, q-1]
92   /*! the coefficients of an irreducible polynomial
93   coeff[0], coeff[1], coeff[2] are 256-bit integers between [0, q - 1]*/
94   BigNumStr coeff[3];
95   FqElemStr qnr;      ///< a quadratic non-residue (an integer between [0, q-1])
96   OctStr768 orderG2;  ///< the total number of points in G2 elliptic curve
97   BigNumStr p_tick;   ///< a prime
98   BigNumStr q_tick;   ///< a prime
99   OctStr32 h_tick;    ///< a small integer, also denoted as cofactor
100   FqElemStr a_tick;   ///< an integer between [0, q-1]
101   FqElemStr b_tick;   ///< an integer between [0, q-1]
102   Epid11G1ElemStr g1;  ///< a generator(an element) of G1
103   Epid11G2ElemStr g2;  ///<  a generator (an element) of G2
104   Epid11G1ElemStr g3;  ///<  a generator (an element) of G3
105 } Epid11Params;
106 
107 /// Intel(R) EPID 1.1 group ID
108 typedef OctStr32 Epid11GroupId;
109 
110 /// Intel(R) EPID 1.1 group public key
111 /*!
112 * Group public key: (gid, h1, h2, w)
113 */
114 typedef struct Epid11GroupPubKey {
115   Epid11GroupId gid;   ///< group ID
116   Epid11G1ElemStr h1;  ///< an element in G1
117   Epid11G1ElemStr h2;  ///< an element in G1
118   Epid11G2ElemStr w;   ///< an element in G2
119 } Epid11GroupPubKey;
120 
121 /// Intel(R) EPID 1.1 basic signature.
122 /*!
123 * Basic signature: (B, K, T1, T2, c, nd, sx, sy, sf, sa, sb, salpha, sbeta)
124 */
125 typedef struct Epid11BasicSignature {
126   Epid11G3ElemStr B;   ///< an element in G3
127   Epid11G3ElemStr K;   ///< an element in G3
128   Epid11G1ElemStr T1;  ///< an element in G1
129   Epid11G1ElemStr T2;  ///< an element in G1
130   OctStr256 c;         ///< a 256-bit integer
131   OctStr80 nd;         ///< an 80-bit integer
132   FpElemStr sx;        ///< an integer between [0, p-1]
133   FpElemStr sy;        ///< an integer between [0, p-1]
134   OctStr600 sf;        ///< a 593-bit integer
135   FpElemStr sa;        ///< an integer between [0, p-1]
136   FpElemStr sb;        ///< an integer between [0, p-1]
137   FpElemStr salpha;    ///< an integer between [0, p-1]
138   FpElemStr sbeta;     ///< an integer between [0, p-1]
139 } Epid11BasicSignature;
140 
141 /// Intel(R) EPID 1.1 non-revoked Proof
142 /*!
143 * Non-revoked Proof: (T, c, smu, snu)
144 */
145 typedef struct Epid11NrProof {
146   Epid11G3ElemStr T;  ///< an element in G3
147   OctStr256 c;        ///< a 256-bit integer
148   FpElemStr smu;      ///< an integer between [0, p'-1]
149   FpElemStr snu;      ///< an integer between [0, p'-1]
150 } Epid11NrProof;
151 
152 /// Intel(R) EPID 1.1 Signature
153 /*!
154 * Signature: (sigma0, RLver, n2, sigma[0], ..., sigma[n2-1])
155 */
156 typedef struct Epid11Signature {
157   Epid11BasicSignature sigma0;  ///< basic signature
158   OctStr32 rl_ver;              ///< revocation list version number
159   OctStr32 n2;                  ///< number of entries in SigRL
160   Epid11NrProof sigma[1];  ///< array of non-revoked proofs (flexible array)
161 } Epid11Signature;
162 
163 /// Intel(R) EPID 1.1 private-key based revocation list
164 /*!
165 * Private-key based revocation list PrivRL: (gid, RLver, n1, f[0],
166 * ..., f[n1-1])
167 */
168 typedef struct Epid11PrivRl {
169   Epid11GroupId gid;  ///< group ID
170   OctStr32 version;   ///< revocation list version number
171   OctStr32 n1;        ///< number of entries in PrivRL
172   FpElemStr f[1];     ///< integers between [1, p-1]  (flexible array)
173 } Epid11PrivRl;
174 
175 /// Intel(R) EPID 1.1 entry in SigRL (B,K)
176 typedef struct Epid11SigRlEntry {
177   Epid11G3ElemStr b;  ///< an element of G1
178   Epid11G3ElemStr k;  ///< an element of G1
179 } Epid11SigRlEntry;
180 
181 /// Intel(R) EPID 1.1 signature based revocation list
182 /*!
183 * Signature based revocation list SigRL: (gid, RLver, n2, B[0],
184 * K[0], ..., B[n2-1], K[n2-1])
185 */
186 typedef struct Epid11SigRl {
187   Epid11GroupId gid;       ///< group ID
188   OctStr32 version;        ///< revocation list version number
189   OctStr32 n2;             ///< number of entries in SigRL
190   Epid11SigRlEntry bk[1];  ///< revoked  Bs and Ks (flexible array)
191 } Epid11SigRl;
192 
193 /// Intel(R) EPID 1.1 group revocation list
194 /*!
195 * Group revocation list GroupRL: (RLver, n3, gid[0], ...,
196 * gid[n3-1])
197 */
198 typedef struct Epid11GroupRl {
199   OctStr32 version;      ///< revocation list version number
200   OctStr32 n3;           ///< number of entries in GroupRL
201   Epid11GroupId gid[1];  ///< revoked group IDs (flexible array)
202 } Epid11GroupRl;
203 
204 #pragma pack()
205 
206 /*! @} */
207 #endif  // EPID_COMMON_1_1_TYPES_H_
208