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