1use crate::{
8 data::{
9 Tpm2b, Tpm2bDigest, Tpm2bName, Tpm2bNonce, Tpm2bTimeout, TpmAlgId, TpmCc, TpmaLocality,
10 TpmlDigest, TpmlPcrSelection, TpmtSignature, TpmtTkAuth,
11 },
12 tpm_response, tpm_struct,
13};
14use core::fmt::Debug;
15
16tpm_struct!(
17 #[derive(Debug, Default, PartialEq, Eq, Copy, Clone)]
18 TpmPolicyAuthValueCommand,
19 TpmCc::PolicyAuthValue,
20 false,
21 true,
22 1,
23 {}
24);
25
26tpm_struct!(
27 #[derive(Debug, PartialEq, Eq, Clone)]
28 TpmPolicyCommandCodeCommand,
29 TpmCc::PolicyCommandCode,
30 false,
31 true,
32 1,
33 {
34 pub code: TpmCc,
35 }
36);
37
38tpm_struct!(
39 #[derive(Debug, Default, PartialEq, Eq, Copy, Clone)]
40 TpmPolicyGetDigestCommand,
41 TpmCc::PolicyGetDigest,
42 false,
43 true,
44 1,
45 {}
46);
47
48tpm_struct!(
49 #[derive(Debug, Default, PartialEq, Eq, Clone)]
50 TpmPolicyOrCommand,
51 TpmCc::PolicyOR,
52 false,
53 true,
54 1,
55 {
56 pub p_hash_list: TpmlDigest,
57 }
58);
59
60tpm_struct!(
61 #[derive(Debug, Default, PartialEq, Eq, Copy, Clone)]
62 TpmPolicyPasswordCommand,
63 TpmCc::PolicyPassword,
64 false,
65 true,
66 1,
67 {}
68);
69
70tpm_struct!(
71 #[derive(Debug, Default, PartialEq, Eq, Clone)]
72 TpmPolicyPcrCommand,
73 TpmCc::PolicyPcr,
74 false,
75 true,
76 1,
77 {
78 pub pcr_digest: Tpm2bDigest,
79 pub pcrs: TpmlPcrSelection,
80 }
81);
82
83tpm_struct!(
84 #[derive(Debug, Default, PartialEq, Eq, Copy, Clone)]
85 TpmPolicyRestartCommand,
86 TpmCc::PolicyRestart,
87 false,
88 true,
89 0,
90 {}
91);
92
93tpm_struct!(
94 #[derive(Debug, Default, PartialEq, Eq, Clone)]
95 TpmPolicySecretCommand,
96 TpmCc::PolicySecret,
97 false,
98 true,
99 2,
100 {
101 pub nonce_tpm: Tpm2b,
102 pub cp_hash_a: Tpm2bDigest,
103 pub policy_ref: Tpm2b,
104 pub expiration: i32,
105 }
106);
107
108tpm_response!(
109 #[derive(Debug, Default, PartialEq, Eq, Clone)]
110 TpmPolicyGetDigestResponse,
111 TpmCc::PolicyGetDigest,
112 false,
113 true,
114 {
115 pub policy_digest: Tpm2bDigest,
116 }
117);
118
119tpm_struct!(
120 #[derive(Debug, Default, PartialEq, Eq, Copy, Clone)]
121 TpmPolicyAuthValueResponse,
122 TpmCc::PolicyAuthValue,
123 false,
124 true,
125 0,
126 {}
127);
128
129tpm_struct!(
130 #[derive(Debug, Default, PartialEq, Eq, Copy, Clone)]
131 TpmPolicyCommandCodeResponse,
132 TpmCc::PolicyCommandCode,
133 false,
134 true,
135 0,
136 {}
137);
138
139tpm_struct!(
140 #[derive(Debug, Default, PartialEq, Eq, Copy, Clone)]
141 TpmPolicyOrResponse,
142 TpmCc::PolicyOR,
143 false,
144 true,
145 0,
146 {}
147);
148
149tpm_struct!(
150 #[derive(Debug, Default, PartialEq, Eq, Copy, Clone)]
151 TpmPolicyPasswordResponse,
152 TpmCc::PolicyPassword,
153 false,
154 true,
155 0,
156 {}
157);
158
159tpm_struct!(
160 #[derive(Debug, Default, PartialEq, Eq, Copy, Clone)]
161 TpmPolicyPcrResponse,
162 TpmCc::PolicyPcr,
163 false,
164 true,
165 0,
166 {}
167);
168
169tpm_struct!(
170 #[derive(Debug, Default, PartialEq, Eq, Copy, Clone)]
171 TpmPolicyRestartResponse,
172 TpmCc::PolicyRestart,
173 false,
174 true,
175 0,
176 {}
177);
178
179tpm_struct!(
180 #[derive(Debug, Default, PartialEq, Eq, Copy, Clone)]
181 TpmPolicySecretResponse,
182 TpmCc::PolicySecret,
183 false,
184 true,
185 0,
186 {}
187);
188
189tpm_struct! (
190 #[derive(Debug, PartialEq, Eq, Clone)]
191 TpmPolicySignedCommand,
192 TpmCc::PolicySigned,
193 false,
194 true,
195 2,
196 {
197 pub nonce_tpm: Tpm2bNonce,
198 pub cp_hash_a: Tpm2bDigest,
199 pub policy_ref: Tpm2bNonce,
200 pub expiration: i32,
201 pub auth: TpmtSignature,
202 }
203);
204
205tpm_response!(
206 #[derive(Debug, PartialEq, Eq, Clone)]
207 TpmPolicySignedResponse,
208 TpmCc::PolicySigned,
209 false,
210 true,
211 {
212 pub timeout: Tpm2bTimeout,
213 pub policy_ticket: TpmtTkAuth,
214 }
215);
216
217tpm_struct! (
218 #[derive(Debug, PartialEq, Eq, Clone)]
219 TpmPolicyTicketCommand,
220 TpmCc::PolicyTicket,
221 false,
222 true,
223 1,
224 {
225 pub timeout: Tpm2bTimeout,
226 pub cp_hash_a: Tpm2bDigest,
227 pub policy_ref: Tpm2bNonce,
228 pub auth_name: Tpm2bName,
229 pub ticket: TpmtTkAuth,
230 }
231);
232
233tpm_response!(
234 #[derive(Debug, Default, PartialEq, Eq, Copy, Clone)]
235 TpmPolicyTicketResponse,
236 TpmCc::PolicyTicket,
237 false,
238 true,
239 {}
240);
241
242tpm_struct! (
243 #[derive(Debug, PartialEq, Eq, Copy, Clone)]
244 TpmPolicyLocalityCommand,
245 TpmCc::PolicyLocality,
246 false,
247 true,
248 1,
249 {
250 pub locality: TpmaLocality,
251 }
252);
253
254tpm_response!(
255 #[derive(Debug, Default, PartialEq, Eq, Copy, Clone)]
256 TpmPolicyLocalityResponse,
257 TpmCc::PolicyLocality,
258 false,
259 true,
260 {}
261);
262
263tpm_struct! (
264 #[derive(Debug, PartialEq, Eq, Clone)]
265 TpmPolicyCpHashCommand,
266 TpmCc::PolicyCpHash,
267 false,
268 true,
269 1,
270 {
271 pub cp_hash_a: Tpm2bDigest,
272 }
273);
274
275tpm_response!(
276 #[derive(Debug, Default, PartialEq, Eq, Copy, Clone)]
277 TpmPolicyCpHashResponse,
278 TpmCc::PolicyCpHash,
279 false,
280 true,
281 {}
282);
283
284tpm_struct!(
285 #[derive(Debug, Default, PartialEq, Eq, Copy, Clone)]
286 TpmPolicyPhysicalPresenceCommand,
287 TpmCc::PolicyPhysicalPresence,
288 false,
289 true,
290 1,
291 {}
292);
293
294tpm_response!(
295 #[derive(Debug, Default, PartialEq, Eq, Copy, Clone)]
296 TpmPolicyPhysicalPresenceResponse,
297 TpmCc::PolicyPhysicalPresence,
298 false,
299 true,
300 {}
301);
302
303tpm_struct!(
304 #[derive(Debug, PartialEq, Eq, Clone)]
305 TpmSetPrimaryPolicyCommand,
306 TpmCc::SetPrimaryPolicy,
307 false,
308 true,
309 1,
310 {
311 pub auth_policy: Tpm2bDigest,
312 pub hash_alg: TpmAlgId,
313 }
314);
315
316tpm_response!(
317 #[derive(Debug, Default, PartialEq, Eq, Copy, Clone)]
318 TpmSetPrimaryPolicyResponse,
319 TpmCc::SetPrimaryPolicy,
320 false,
321 true,
322 {}
323);