tpm2_protocol/message/
non_volatile.rs

1// SPDX-License-Identifier: MIT OR Apache-2.0
2// Copyright (c) 2025 Opinsys Oy
3// Copyright (c) 2024-2025 Jarkko Sakkinen
4
5//! 23 Non-Volatile (NV) Storage
6
7use crate::{
8    data::{
9        Tpm2bAttest, Tpm2bAuth, Tpm2bData, Tpm2bMaxNvBuffer, Tpm2bName, Tpm2bNvPublic, TpmCc,
10        TpmtSignature,
11    },
12    tpm_struct,
13};
14use core::fmt::Debug;
15
16tpm_struct!(
17    #[derive(Debug, PartialEq, Eq, Clone)]
18    TpmNvDefineSpaceCommand,
19    TpmCc::NvDefineSpace,
20    false,
21    true,
22    1,
23    {
24        pub auth: Tpm2bAuth,
25        pub public_info: Tpm2bNvPublic,
26    }
27);
28
29tpm_struct!(
30    #[derive(Debug, Default, PartialEq, Eq, Copy, Clone)]
31    TpmNvDefineSpaceResponse,
32    TpmCc::NvDefineSpace,
33    false,
34    true,
35    0,
36    {}
37);
38
39tpm_struct!(
40    #[derive(Debug, PartialEq, Eq, Copy, Clone)]
41    TpmNvUndefineSpaceCommand,
42    TpmCc::NvUndefineSpace,
43    false,
44    true,
45    2,
46    {}
47);
48
49tpm_struct!(
50    #[derive(Debug, Default, PartialEq, Eq, Copy, Clone)]
51    TpmNvUndefineSpaceResponse,
52    TpmCc::NvUndefineSpace,
53    false,
54    true,
55    0,
56    {}
57);
58
59tpm_struct!(
60    #[derive(Debug, PartialEq, Eq, Copy, Clone)]
61    TpmNvUndefineSpaceSpecialCommand,
62    TpmCc::NvUndefineSpaceSpecial,
63    false,
64    true,
65    2,
66    {}
67);
68
69tpm_struct!(
70    #[derive(Debug, Default, PartialEq, Eq, Copy, Clone)]
71    TpmNvUndefineSpaceSpecialResponse,
72    TpmCc::NvUndefineSpaceSpecial,
73    false,
74    true,
75    0,
76    {}
77);
78
79tpm_struct!(
80    #[derive(Debug, PartialEq, Eq, Copy, Clone)]
81    TpmNvReadPublicCommand,
82    TpmCc::NvReadPublic,
83    true,
84    false,
85    1,
86    {}
87);
88
89tpm_struct!(
90    #[derive(Debug, PartialEq, Eq, Clone)]
91    TpmNvReadPublicResponse,
92    TpmCc::NvReadPublic,
93    true,
94    false,
95    0,
96    {
97        pub nv_public: Tpm2bNvPublic,
98        pub nv_name: Tpm2bName,
99    }
100);
101
102tpm_struct!(
103    #[derive(Debug, PartialEq, Eq, Clone)]
104    TpmNvWriteCommand,
105    TpmCc::NvWrite,
106    false,
107    true,
108    2,
109    {
110        pub data: Tpm2bMaxNvBuffer,
111        pub offset: u16,
112    }
113);
114
115tpm_struct!(
116    #[derive(Debug, Default, PartialEq, Eq, Copy, Clone)]
117    TpmNvWriteResponse,
118    TpmCc::NvWrite,
119    false,
120    true,
121    0,
122    {}
123);
124
125tpm_struct!(
126    #[derive(Debug, Default, PartialEq, Eq, Copy, Clone)]
127    TpmNvIncrementCommand,
128    TpmCc::NvIncrement,
129    false,
130    true,
131    2,
132    {}
133);
134
135tpm_struct!(
136    #[derive(Debug, Default, PartialEq, Eq, Copy, Clone)]
137    TpmNvIncrementResponse,
138    TpmCc::NvIncrement,
139    false,
140    true,
141    0,
142    {}
143);
144
145tpm_struct!(
146    #[derive(Debug, PartialEq, Eq, Clone)]
147    TpmNvExtendCommand,
148    TpmCc::NvExtend,
149    false,
150    true,
151    2,
152    {
153        pub data: Tpm2bMaxNvBuffer,
154    }
155);
156
157tpm_struct!(
158    #[derive(Debug, Default, PartialEq, Eq, Copy, Clone)]
159    TpmNvExtendResponse,
160    TpmCc::NvExtend,
161    false,
162    true,
163    0,
164    {}
165);
166
167tpm_struct!(
168    #[derive(Debug, PartialEq, Eq, Copy, Clone)]
169    TpmNvSetBitsCommand,
170    TpmCc::NvSetBits,
171    false,
172    true,
173    2,
174    {
175        pub bits: u64,
176    }
177);
178
179tpm_struct!(
180    #[derive(Debug, Default, PartialEq, Eq, Copy, Clone)]
181    TpmNvSetBitsResponse,
182    TpmCc::NvSetBits,
183    false,
184    true,
185    0,
186    {}
187);
188
189tpm_struct!(
190    #[derive(Debug, Default, PartialEq, Eq, Copy, Clone)]
191    TpmNvWriteLockCommand,
192    TpmCc::NvWriteLock,
193    false,
194    true,
195    2,
196    {}
197);
198
199tpm_struct!(
200    #[derive(Debug, Default, PartialEq, Eq, Copy, Clone)]
201    TpmNvWriteLockResponse,
202    TpmCc::NvWriteLock,
203    false,
204    true,
205    0,
206    {}
207);
208
209tpm_struct!(
210    #[derive(Debug, Default, PartialEq, Eq, Copy, Clone)]
211    TpmNvGlobalWriteLockCommand,
212    TpmCc::NvGlobalWriteLock,
213    false,
214    true,
215    1,
216    {}
217);
218
219tpm_struct!(
220    #[derive(Debug, Default, PartialEq, Eq, Copy, Clone)]
221    TpmNvGlobalWriteLockResponse,
222    TpmCc::NvGlobalWriteLock,
223    false,
224    true,
225    0,
226    {}
227);
228
229tpm_struct!(
230    #[derive(Debug, PartialEq, Eq, Copy, Clone)]
231    TpmNvReadCommand,
232    TpmCc::NvRead,
233    false,
234    true,
235    2,
236    {
237        pub size: u16,
238        pub offset: u16,
239    }
240);
241
242tpm_struct!(
243    #[derive(Debug, Default, PartialEq, Eq, Clone)]
244    TpmNvReadResponse,
245    TpmCc::NvRead,
246    false,
247    true,
248    0,
249    {
250        pub data: Tpm2bMaxNvBuffer,
251    }
252);
253
254tpm_struct!(
255    #[derive(Debug, Default, PartialEq, Eq, Copy, Clone)]
256    TpmNvReadLockCommand,
257    TpmCc::NvReadLock,
258    false,
259    true,
260    2,
261    {}
262);
263
264tpm_struct!(
265    #[derive(Debug, Default, PartialEq, Eq, Copy, Clone)]
266    TpmNvReadLockResponse,
267    TpmCc::NvReadLock,
268    false,
269    true,
270    0,
271    {}
272);
273
274tpm_struct!(
275    #[derive(Debug, PartialEq, Eq, Clone)]
276    TpmNvChangeAuthCommand,
277    TpmCc::NvChangeAuth,
278    false,
279    true,
280    1,
281    {
282        pub new_auth: Tpm2bAuth,
283    }
284);
285
286tpm_struct!(
287    #[derive(Debug, Default, PartialEq, Eq, Copy, Clone)]
288    TpmNvChangeAuthResponse,
289    TpmCc::NvChangeAuth,
290    false,
291    true,
292    0,
293    {}
294);
295
296tpm_struct!(
297    #[derive(Debug, PartialEq, Eq, Clone)]
298    TpmNvCertifyCommand,
299    TpmCc::NvCertify,
300    false,
301    true,
302    3,
303    {
304        pub qualifying_data: Tpm2bData,
305        pub in_scheme: TpmtSignature,
306        pub size: u16,
307        pub offset: u16,
308    }
309);
310
311tpm_struct! {
312    #[derive(Debug, PartialEq, Eq, Clone)]
313    TpmNvCertifyResponse,
314    TpmCc::NvCertify,
315    false,
316    true,
317    0,
318    {
319        pub certify_info: Tpm2bAttest,
320        pub signature: TpmtSignature,
321    }
322}