tpm2_protocol/message/
hierarchy.rs

1// SPDX-License-Identifier: MIT OR Apache-2.0
2// Copyright (c) 2025 Opinsys Oy
3
4//! 24.1 `TPM2_CreatePrimary`
5//! 24.2 `TPM2_HierarchyControl`
6//! 24.3 `TPM2_SetPrimaryPolicy`
7//! 24.4 `TPM2_ChangePPS`
8//! 24.5 `TPM2_ChangeEPS`
9//! 24.6 `TPM2_Clear`
10//! 24.7 `TPM2_ClearControl`
11//! 24.8 `TPM2_HierarchyChangeAuth`
12//! 24.9 `TPM2_ReadOnlyControl`
13
14use crate::{
15    data::{
16        Tpm2bAuth, Tpm2bCreationData, Tpm2bData, Tpm2bDigest, Tpm2bName, Tpm2bPublic,
17        Tpm2bSensitiveCreate, TpmAlgId, TpmCc, TpmRh, TpmiYesNo, TpmlPcrSelection, TpmtTkCreation,
18    },
19    tpm_struct, TpmTransient,
20};
21use core::fmt::Debug;
22
23tpm_struct! {
24    #[derive(Debug, Default, PartialEq, Eq, Clone)]
25    kind: Command,
26    name: TpmCreatePrimaryCommand,
27    cc: TpmCc::CreatePrimary,
28    no_sessions: false,
29    with_sessions: true,
30    handles: {
31        pub primary_handle: crate::data::TpmiRhHierarchy,
32    },
33    parameters: {
34        pub in_sensitive: Tpm2bSensitiveCreate,
35        pub in_public: Tpm2bPublic,
36        pub outside_info: Tpm2bData,
37        pub creation_pcr: TpmlPcrSelection,
38    }
39}
40
41tpm_struct! {
42    #[derive(Debug, PartialEq, Eq, Clone)]
43    kind: Response,
44    name: TpmCreatePrimaryResponse,
45    cc: TpmCc::CreatePrimary,
46    no_sessions: false,
47    with_sessions: true,
48    handles: {
49        pub object_handle: TpmTransient,
50    },
51    parameters: {
52        pub out_public: Tpm2bPublic,
53        pub creation_data: Tpm2bCreationData,
54        pub creation_hash: Tpm2bDigest,
55        pub creation_ticket: TpmtTkCreation,
56        pub name: Tpm2bName,
57    }
58}
59
60tpm_struct! {
61    #[derive(Debug, PartialEq, Eq, Clone, Copy)]
62    kind: Command,
63    name: TpmHierarchyControlCommand,
64    cc: TpmCc::HierarchyControl,
65    no_sessions: false,
66    with_sessions: true,
67    handles: {
68        pub auth_handle: crate::data::TpmiRhHierarchy,
69    },
70    parameters: {
71        pub enable: TpmRh,
72        pub state: TpmiYesNo,
73    }
74}
75
76tpm_struct! {
77    #[derive(Debug, Default, PartialEq, Eq, Copy, Clone)]
78    kind: Response,
79    name: TpmHierarchyControlResponse,
80    cc: TpmCc::HierarchyControl,
81    no_sessions: false,
82    with_sessions: true,
83    handles: {},
84    parameters: {}
85}
86
87tpm_struct! {
88    #[derive(Debug, PartialEq, Eq, Clone)]
89    kind: Command,
90    name: TpmHierarchyChangeAuthCommand,
91    cc: TpmCc::HierarchyChangeAuth,
92    no_sessions: false,
93    with_sessions: true,
94    handles: {
95        pub auth_handle: crate::data::TpmiRhHierarchy,
96    },
97    parameters: {
98        pub new_auth: Tpm2bAuth,
99    }
100}
101
102tpm_struct! {
103    #[derive(Debug, Default, PartialEq, Eq, Copy, Clone)]
104    kind: Response,
105    name: TpmHierarchyChangeAuthResponse,
106    cc: TpmCc::HierarchyChangeAuth,
107    no_sessions: false,
108    with_sessions: true,
109    handles: {},
110    parameters: {}
111}
112
113tpm_struct! {
114    #[derive(Debug, Default, PartialEq, Eq, Copy, Clone)]
115    kind: Command,
116    name: TpmChangePpsCommand,
117    cc: TpmCc::ChangePps,
118    no_sessions: false,
119    with_sessions: true,
120    handles: {
121        pub auth_handle: crate::data::TpmiRhHierarchy,
122    },
123    parameters: {}
124}
125
126tpm_struct! {
127    #[derive(Debug, Default, PartialEq, Eq, Copy, Clone)]
128    kind: Response,
129    name: TpmChangePpsResponse,
130    cc: TpmCc::ChangePps,
131    no_sessions: false,
132    with_sessions: true,
133    handles: {},
134    parameters: {}
135}
136
137tpm_struct! {
138    #[derive(Debug, Default, PartialEq, Eq, Copy, Clone)]
139    kind: Command,
140    name: TpmChangeEpsCommand,
141    cc: TpmCc::ChangeEps,
142    no_sessions: false,
143    with_sessions: true,
144    handles: {
145        pub auth_handle: crate::data::TpmiRhHierarchy,
146    },
147    parameters: {}
148}
149
150tpm_struct! {
151    #[derive(Debug, Default, PartialEq, Eq, Copy, Clone)]
152    kind: Response,
153    name: TpmChangeEpsResponse,
154    cc: TpmCc::ChangeEps,
155    no_sessions: false,
156    with_sessions: true,
157    handles: {},
158    parameters: {}
159}
160
161tpm_struct! {
162    #[derive(Debug, Default, PartialEq, Eq, Copy, Clone)]
163    kind: Command,
164    name: TpmClearCommand,
165    cc: TpmCc::Clear,
166    no_sessions: false,
167    with_sessions: true,
168    handles: {
169        pub auth_handle: crate::data::TpmiRhHierarchy,
170    },
171    parameters: {}
172}
173
174tpm_struct! {
175    #[derive(Debug, Default, PartialEq, Eq, Copy, Clone)]
176    kind: Response,
177    name: TpmClearResponse,
178    cc: TpmCc::Clear,
179    no_sessions: false,
180    with_sessions: true,
181    handles: {},
182    parameters: {}
183}
184
185tpm_struct! {
186    #[derive(Debug, PartialEq, Eq, Clone, Copy)]
187    kind: Command,
188    name: TpmClearControlCommand,
189    cc: TpmCc::ClearControl,
190    no_sessions: false,
191    with_sessions: true,
192    handles: {
193        pub auth: crate::data::TpmiRhHierarchy,
194    },
195    parameters: {
196        pub disable: TpmiYesNo,
197    }
198}
199
200tpm_struct! {
201    #[derive(Debug, Default, PartialEq, Eq, Copy, Clone)]
202    kind: Response,
203    name: TpmClearControlResponse,
204    cc: TpmCc::ClearControl,
205    no_sessions: false,
206    with_sessions: true,
207    handles: {},
208    parameters: {}
209}
210
211tpm_struct! {
212    #[derive(Debug, PartialEq, Eq, Clone)]
213    kind: Command,
214    name: TpmSetPrimaryPolicyCommand,
215    cc: TpmCc::SetPrimaryPolicy,
216    no_sessions: false,
217    with_sessions: true,
218    handles: {
219        pub auth_handle: crate::data::TpmiRhHierarchy,
220    },
221    parameters: {
222        pub auth_policy: Tpm2bDigest,
223        pub hash_alg: TpmAlgId,
224    }
225}
226
227tpm_struct! {
228    #[derive(Debug, Default, PartialEq, Eq, Copy, Clone)]
229    kind: Response,
230    name: TpmSetPrimaryPolicyResponse,
231    cc: TpmCc::SetPrimaryPolicy,
232    no_sessions: false,
233    with_sessions: true,
234    handles: {},
235    parameters: {}
236}
237
238tpm_struct! {
239    #[derive(Debug, PartialEq, Eq, Clone, Copy)]
240    kind: Command,
241    name: TpmReadOnlyControlCommand,
242    cc: TpmCc::ReadOnlyControl,
243    no_sessions: false,
244    with_sessions: true,
245    handles: {
246        pub auth_handle: crate::data::TpmiRhHierarchy,
247    },
248    parameters: {
249        pub state: TpmiYesNo,
250    }
251}
252
253tpm_struct! {
254    #[derive(Debug, Default, PartialEq, Eq, Copy, Clone)]
255    kind: Response,
256    name: TpmReadOnlyControlResponse,
257    cc: TpmCc::ReadOnlyControl,
258    no_sessions: false,
259    with_sessions: true,
260    handles: {},
261    parameters: {}
262}