tpm2_protocol/message/
object.rs

1// SPDX-License-Identifier: MIT OR Apache-2.0
2// Copyright (c) 2025 Opinsys Oy
3// Copyright (c) 2024-2025 Jarkko Sakkinen
4
5use crate::{
6    data::{
7        Tpm2b, Tpm2bAuth, Tpm2bCreationData, Tpm2bDigest, Tpm2bEncryptedSecret, Tpm2bIdObject,
8        Tpm2bName, Tpm2bPrivate, Tpm2bPublic, Tpm2bSensitive, Tpm2bSensitiveCreate, TpmCc, TpmRh,
9        TpmlPcrSelection, TpmtTkCreation,
10    },
11    tpm_response, tpm_struct, TpmTransient,
12};
13use core::fmt::Debug;
14
15tpm_struct! {
16    #[derive(Debug, Default, PartialEq, Eq, Clone)]
17    TpmCreateCommand,
18    TpmCc::Create,
19    false,
20    true,
21    1,
22    {
23        pub in_sensitive: Tpm2bSensitiveCreate,
24        pub in_public: Tpm2bPublic,
25        pub outside_info: Tpm2b,
26        pub creation_pcr: TpmlPcrSelection,
27    }
28}
29
30tpm_response! {
31    #[derive(Debug, PartialEq, Eq, Clone)]
32    TpmCreateResponse,
33    TpmCc::Create,
34    false,
35    true,
36    {
37        pub out_private: Tpm2bPrivate,
38        pub out_public: Tpm2bPublic,
39        pub creation_data: Tpm2bCreationData,
40        pub creation_hash: Tpm2bDigest,
41        pub creation_ticket: TpmtTkCreation,
42    }
43}
44
45tpm_struct! {
46    #[derive(Debug, Default, PartialEq, Eq, Clone)]
47    TpmLoadCommand,
48    TpmCc::Load,
49    false,
50    true,
51    1,
52    {
53        pub in_private: Tpm2bPrivate,
54        pub in_public: Tpm2bPublic,
55    }
56}
57
58tpm_response! {
59    #[derive(Debug, PartialEq, Eq, Clone)]
60    TpmLoadResponse,
61    TpmCc::Load,
62    false,
63    true,
64    pub object_handle: TpmTransient,
65    {
66        pub name: Tpm2bName,
67    }
68}
69
70tpm_struct! {
71    #[derive(Debug, PartialEq, Eq, Clone)]
72    TpmLoadExternalCommand,
73    TpmCc::LoadExternal,
74    true,
75    true,
76    0,
77    {
78        pub in_private: Tpm2bSensitive,
79        pub in_public: Tpm2bPublic,
80        pub hierarchy: TpmRh,
81    }
82}
83
84tpm_response! {
85    #[derive(Debug, PartialEq, Eq, Clone)]
86    TpmLoadExternalResponse,
87    TpmCc::LoadExternal,
88    true,
89    true,
90    pub object_handle: TpmTransient,
91    {
92        pub name: Tpm2bName,
93    }
94}
95
96tpm_struct! {
97    #[derive(Debug, Default, PartialEq, Eq, Copy, Clone)]
98    TpmReadPublicCommand,
99    TpmCc::ReadPublic,
100    true,
101    true,
102    1,
103    {}
104}
105
106tpm_response! {
107    #[derive(Debug, Default, PartialEq, Eq, Clone)]
108    TpmReadPublicResponse,
109    TpmCc::ReadPublic,
110    true,
111    false,
112    {
113        pub out_public: Tpm2bPublic,
114        pub name: Tpm2bName,
115        pub qualified_name: Tpm2bName,
116    }
117}
118
119tpm_struct! {
120    #[derive(Debug, PartialEq, Eq, Clone)]
121    TpmActivateCredentialCommand,
122    TpmCc::ActivateCredential,
123    true,
124    true,
125    2,
126    {
127        pub credential_blob: Tpm2bIdObject,
128        pub secret: Tpm2bEncryptedSecret,
129    }
130}
131
132tpm_response! {
133    #[derive(Debug, PartialEq, Eq, Clone)]
134    TpmActivateCredentialResponse,
135    TpmCc::ActivateCredential,
136    true,
137    true,
138    {
139        pub cert_info: Tpm2bDigest,
140    }
141}
142
143tpm_struct! {
144    #[derive(Debug, PartialEq, Eq, Clone)]
145    TpmMakeCredentialCommand,
146    TpmCc::MakeCredential,
147    true,
148    true,
149    1,
150    {
151        pub credential: Tpm2bDigest,
152        pub object_name: Tpm2bName,
153    }
154}
155
156tpm_response! {
157    #[derive(Debug, PartialEq, Eq, Clone)]
158    TpmMakeCredentialResponse,
159    TpmCc::MakeCredential,
160    true,
161    true,
162    {
163        pub credential_blob: Tpm2bIdObject,
164        pub secret: Tpm2bEncryptedSecret,
165    }
166}
167
168tpm_struct! {
169    #[derive(Debug, Default, PartialEq, Eq, Copy, Clone)]
170    TpmUnsealCommand,
171    TpmCc::Unseal,
172    false,
173    true,
174    1,
175    {}
176}
177
178tpm_response! {
179    #[derive(Debug, Default, PartialEq, Eq, Clone)]
180    TpmUnsealResponse,
181    TpmCc::Unseal,
182    false,
183    true,
184    {
185        pub out_data: Tpm2b,
186    }
187}
188
189tpm_struct! {
190    #[derive(Debug, Default, PartialEq, Eq, Clone)]
191    TpmObjectChangeAuthCommand,
192    TpmCc::ObjectChangeAuth,
193    false,
194    true,
195    2,
196    {
197        pub new_auth: Tpm2bAuth,
198    }
199}
200
201tpm_response! {
202    #[derive(Debug, Default, PartialEq, Eq, Clone)]
203    TpmObjectChangeAuthResponse,
204    TpmCc::ObjectChangeAuth,
205    false,
206    true,
207    {
208        pub out_private: Tpm2bPrivate,
209    }
210}