• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* Microsoft Reference Implementation for TPM 2.0
2  *
3  *  The copyright in this software is being made available under the BSD License,
4  *  included below. This software may be subject to other third party and
5  *  contributor rights, including patent rights, and no such rights are granted
6  *  under this license.
7  *
8  *  Copyright (c) Microsoft Corporation
9  *
10  *  All rights reserved.
11  *
12  *  BSD License
13  *
14  *  Redistribution and use in source and binary forms, with or without modification,
15  *  are permitted provided that the following conditions are met:
16  *
17  *  Redistributions of source code must retain the above copyright notice, this list
18  *  of conditions and the following disclaimer.
19  *
20  *  Redistributions in binary form must reproduce the above copyright notice, this
21  *  list of conditions and the following disclaimer in the documentation and/or
22  *  other materials provided with the distribution.
23  *
24  *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ""AS IS""
25  *  AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26  *  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
27  *  DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
28  *  ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29  *  (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30  *  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
31  *  ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32  *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33  *  SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34  */
35 #ifndef _ACT_H_
36 #define _ACT_H_
37 
38 #include "TpmProfile.h"
39 
40 #if !(defined RH_ACT_0) || (RH_ACT_0 != YES)
41 #   undef   RH_ACT_0
42 #   define  RH_ACT_0 NO
43 #   define IF_ACT_0_IMPLEMENTED(op)
44 #else
45 #   define IF_ACT_0_IMPLEMENTED(op) op(0)
46 #endif
47 #if !(defined RH_ACT_1) || (RH_ACT_1 != YES)
48 #   undef   RH_ACT_1
49 #   define  RH_ACT_1 NO
50 #   define IF_ACT_1_IMPLEMENTED(op)
51 #else
52 #   define IF_ACT_1_IMPLEMENTED(op) op(1)
53 #endif
54 #if !(defined RH_ACT_2) || (RH_ACT_2 != YES)
55 #   undef   RH_ACT_2
56 #   define  RH_ACT_2 NO
57 #   define IF_ACT_2_IMPLEMENTED(op)
58 #else
59 #   define IF_ACT_2_IMPLEMENTED(op) op(2)
60 #endif
61 #if !(defined RH_ACT_3) || (RH_ACT_3 != YES)
62 #   undef   RH_ACT_3
63 #   define  RH_ACT_3 NO
64 #   define IF_ACT_3_IMPLEMENTED(op)
65 #else
66 #   define IF_ACT_3_IMPLEMENTED(op) op(3)
67 #endif
68 #if !(defined RH_ACT_4) || (RH_ACT_4 != YES)
69 #   undef   RH_ACT_4
70 #   define  RH_ACT_4 NO
71 #   define IF_ACT_4_IMPLEMENTED(op)
72 #else
73 #   define IF_ACT_4_IMPLEMENTED(op) op(4)
74 #endif
75 #if !(defined RH_ACT_5) || (RH_ACT_5 != YES)
76 #   undef   RH_ACT_5
77 #   define  RH_ACT_5 NO
78 #   define IF_ACT_5_IMPLEMENTED(op)
79 #else
80 #   define IF_ACT_5_IMPLEMENTED(op) op(5)
81 #endif
82 #if !(defined RH_ACT_6) || (RH_ACT_6 != YES)
83 #   undef   RH_ACT_6
84 #   define  RH_ACT_6 NO
85 #   define IF_ACT_6_IMPLEMENTED(op)
86 #else
87 #   define IF_ACT_6_IMPLEMENTED(op) op(6)
88 #endif
89 #if !(defined RH_ACT_7) || (RH_ACT_7 != YES)
90 #   undef   RH_ACT_7
91 #   define  RH_ACT_7 NO
92 #   define IF_ACT_7_IMPLEMENTED(op)
93 #else
94 #   define IF_ACT_7_IMPLEMENTED(op) op(7)
95 #endif
96 #if !(defined RH_ACT_8) || (RH_ACT_8 != YES)
97 #   undef   RH_ACT_8
98 #   define  RH_ACT_8 NO
99 #   define IF_ACT_8_IMPLEMENTED(op)
100 #else
101 #   define IF_ACT_8_IMPLEMENTED(op) op(8)
102 #endif
103 #if !(defined RH_ACT_9) || (RH_ACT_9 != YES)
104 #   undef   RH_ACT_9
105 #   define  RH_ACT_9 NO
106 #   define IF_ACT_9_IMPLEMENTED(op)
107 #else
108 #   define IF_ACT_9_IMPLEMENTED(op) op(9)
109 #endif
110 #if !(defined RH_ACT_A) || (RH_ACT_A != YES)
111 #   undef   RH_ACT_A
112 #   define  RH_ACT_A NO
113 #   define IF_ACT_A_IMPLEMENTED(op)
114 #else
115 #   define IF_ACT_A_IMPLEMENTED(op) op(A)
116 #endif
117 #if !(defined RH_ACT_B) || (RH_ACT_B != YES)
118 #   undef   RH_ACT_B
119 #   define  RH_ACT_B NO
120 #   define IF_ACT_B_IMPLEMENTED(op)
121 #else
122 #   define IF_ACT_B_IMPLEMENTED(op) op(B)
123 #endif
124 #if !(defined RH_ACT_C) || (RH_ACT_C != YES)
125 #   undef   RH_ACT_C
126 #   define  RH_ACT_C NO
127 #   define IF_ACT_C_IMPLEMENTED(op)
128 #else
129 #   define IF_ACT_C_IMPLEMENTED(op) op(C)
130 #endif
131 #if !(defined RH_ACT_D) || (RH_ACT_D != YES)
132 #   undef   RH_ACT_D
133 #   define  RH_ACT_D NO
134 #   define IF_ACT_D_IMPLEMENTED(op)
135 #else
136 #   define IF_ACT_D_IMPLEMENTED(op) op(D)
137 #endif
138 #if !(defined RH_ACT_E) || (RH_ACT_E != YES)
139 #   undef   RH_ACT_E
140 #   define  RH_ACT_E NO
141 #   define IF_ACT_E_IMPLEMENTED(op)
142 #else
143 #   define IF_ACT_E_IMPLEMENTED(op) op(E)
144 #endif
145 #if !(defined RH_ACT_F) || (RH_ACT_F != YES)
146 #   undef   RH_ACT_F
147 #   define  RH_ACT_F NO
148 #   define IF_ACT_F_IMPLEMENTED(op)
149 #else
150 #   define IF_ACT_F_IMPLEMENTED(op) op(F)
151 #endif
152 
153 
154 #ifndef TPM_RH_ACT_0
155 #error Need numeric definition for TPM_RH_ACT_0
156 #endif
157 
158 #ifndef TPM_RH_ACT_1
159 #   define TPM_RH_ACT_1    (TPM_RH_ACT_0 + 1)
160 #endif
161 #ifndef TPM_RH_ACT_2
162 #   define TPM_RH_ACT_2    (TPM_RH_ACT_0 + 2)
163 #endif
164 #ifndef TPM_RH_ACT_3
165 #   define TPM_RH_ACT_3    (TPM_RH_ACT_0 + 3)
166 #endif
167 #ifndef TPM_RH_ACT_4
168 #   define TPM_RH_ACT_4    (TPM_RH_ACT_0 + 4)
169 #endif
170 #ifndef TPM_RH_ACT_5
171 #   define TPM_RH_ACT_5    (TPM_RH_ACT_0 + 5)
172 #endif
173 #ifndef TPM_RH_ACT_6
174 #   define TPM_RH_ACT_6    (TPM_RH_ACT_0 + 6)
175 #endif
176 #ifndef TPM_RH_ACT_7
177 #   define TPM_RH_ACT_7    (TPM_RH_ACT_0 + 7)
178 #endif
179 #ifndef TPM_RH_ACT_8
180 #   define TPM_RH_ACT_8    (TPM_RH_ACT_0 + 8)
181 #endif
182 #ifndef TPM_RH_ACT_9
183 #   define TPM_RH_ACT_9    (TPM_RH_ACT_0 + 9)
184 #endif
185 #ifndef TPM_RH_ACT_A
186 #   define TPM_RH_ACT_A    (TPM_RH_ACT_0 + 0xA)
187 #endif
188 #ifndef TPM_RH_ACT_B
189 #   define TPM_RH_ACT_B    (TPM_RH_ACT_0 + 0xB)
190 #endif
191 #ifndef TPM_RH_ACT_C
192 #   define TPM_RH_ACT_C    (TPM_RH_ACT_0 + 0xC)
193 #endif
194 #ifndef TPM_RH_ACT_D
195 #   define TPM_RH_ACT_D    (TPM_RH_ACT_0 + 0xD)
196 #endif
197 #ifndef TPM_RH_ACT_E
198 #   define TPM_RH_ACT_E    (TPM_RH_ACT_0 + 0xE)
199 #endif
200 #ifndef TPM_RH_ACT_F
201 #   define TPM_RH_ACT_F    (TPM_RH_ACT_0 + 0xF)
202 #endif
203 
204 #define FOR_EACH_ACT(op)                                                            \
205     IF_ACT_0_IMPLEMENTED(op)                                                        \
206     IF_ACT_1_IMPLEMENTED(op)                                                        \
207     IF_ACT_2_IMPLEMENTED(op)                                                        \
208     IF_ACT_3_IMPLEMENTED(op)                                                        \
209     IF_ACT_4_IMPLEMENTED(op)                                                        \
210     IF_ACT_5_IMPLEMENTED(op)                                                        \
211     IF_ACT_6_IMPLEMENTED(op)                                                        \
212     IF_ACT_7_IMPLEMENTED(op)                                                        \
213     IF_ACT_8_IMPLEMENTED(op)                                                        \
214     IF_ACT_9_IMPLEMENTED(op)                                                        \
215     IF_ACT_A_IMPLEMENTED(op)                                                        \
216     IF_ACT_B_IMPLEMENTED(op)                                                        \
217     IF_ACT_C_IMPLEMENTED(op)                                                        \
218     IF_ACT_D_IMPLEMENTED(op)                                                        \
219     IF_ACT_E_IMPLEMENTED(op)                                                        \
220     IF_ACT_F_IMPLEMENTED(op)
221 
222 // This is the mask for ACT that are implemented
223 //#define ACT_MASK(N)     | (1 << 0x##N)
224 //#define ACT_IMPLEMENTED_MASK    (0 FOR_EACH_ACT(ACT_MASK))
225 
226 #define CASE_ACT_HANDLE(N)     case TPM_RH_ACT_##N:
227 #define CASE_ACT_NUMBER(N)     case 0x##N:
228 
229 typedef struct ACT_STATE
230 {
231     UINT32          remaining;
232     TPM_ALG_ID      hashAlg;
233     TPM2B_DIGEST    authPolicy;
234 } ACT_STATE, *P_ACT_STATE;
235 
236 #endif // _ACT_H_
237