tpm2_protocol/message/
integrity.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//! 22 Integrity Collection (PCR)
6
7use crate::{
8    data::{
9        Tpm2bDigest, Tpm2bEvent, TpmAlgId, TpmCc, TpmRh, TpmiYesNo, TpmlDigest, TpmlDigestValues,
10        TpmlPcrSelection,
11    },
12    tpm_struct,
13};
14use core::fmt::Debug;
15
16tpm_struct! {
17    #[derive(Debug, PartialEq, Eq, Clone)]
18    kind: Command,
19    name: TpmPcrEventCommand,
20    cc: TpmCc::PcrEvent,
21    no_sessions: false,
22    with_sessions: true,
23    handles: {
24        pub pcr_handle: u32,
25    },
26    parameters: {
27        pub event_data: Tpm2bEvent,
28    }
29}
30
31tpm_struct! {
32    #[derive(Debug, Default, PartialEq, Eq, Clone)]
33    kind: Response,
34    name: TpmPcrEventResponse,
35    cc: TpmCc::PcrEvent,
36    no_sessions: false,
37    with_sessions: true,
38    handles: {},
39    parameters: {
40        pub digests: TpmlDigestValues,
41    }
42}
43
44tpm_struct! {
45    #[derive(Debug, Default, PartialEq, Eq, Clone)]
46    kind: Command,
47    name: TpmPcrReadCommand,
48    cc: TpmCc::PcrRead,
49    no_sessions: true,
50    with_sessions: false,
51    handles: {},
52    parameters: {
53        pub pcr_selection_in: TpmlPcrSelection,
54    }
55}
56
57tpm_struct! {
58    #[derive(Debug, Default, PartialEq, Eq, Clone)]
59    kind: Response,
60    name: TpmPcrReadResponse,
61    cc: TpmCc::PcrRead,
62    no_sessions: true,
63    with_sessions: false,
64    handles: {},
65    parameters: {
66        pub pcr_update_counter: u32,
67        pub pcr_selection_out: TpmlPcrSelection,
68        pub pcr_values: TpmlDigest,
69    }
70}
71
72tpm_struct! {
73    #[derive(Debug, PartialEq, Eq, Clone)]
74    kind: Command,
75    name: TpmPcrExtendCommand,
76    cc: TpmCc::PcrExtend,
77    no_sessions: false,
78    with_sessions: true,
79    handles: {
80        pub pcr_handle: u32,
81    },
82    parameters: {
83        pub digests: TpmlDigestValues,
84    }
85}
86
87tpm_struct! {
88    #[derive(Debug, Default, PartialEq, Eq, Copy, Clone)]
89    kind: Response,
90    name: TpmPcrExtendResponse,
91    cc: TpmCc::PcrExtend,
92    no_sessions: false,
93    with_sessions: true,
94    handles: {},
95    parameters: {}
96}
97
98tpm_struct! {
99    #[derive(Debug, PartialEq, Eq, Clone)]
100    kind: Command,
101    name: TpmPcrAllocateCommand,
102    cc: TpmCc::PcrAllocate,
103    no_sessions: false,
104    with_sessions: true,
105    handles: {
106        pub auth_handle: crate::data::TpmiRhHierarchy,
107    },
108    parameters: {
109        pub pcr_allocation: TpmlPcrSelection,
110    }
111}
112
113tpm_struct! {
114    #[derive(Debug, PartialEq, Eq, Clone, Copy)]
115    kind: Response,
116    name: TpmPcrAllocateResponse,
117    cc: TpmCc::PcrAllocate,
118    no_sessions: false,
119    with_sessions: true,
120    handles: {},
121    parameters: {
122        pub allocation_success: TpmiYesNo,
123        pub max_pcr: u32,
124        pub size_needed: u32,
125        pub size_available: u32,
126    }
127}
128
129tpm_struct! {
130    #[derive(Debug, PartialEq, Eq, Clone)]
131    kind: Command,
132    name: TpmPcrSetAuthPolicyCommand,
133    cc: TpmCc::PcrSetAuthPolicy,
134    no_sessions: false,
135    with_sessions: true,
136    handles: {
137        pub auth_handle: crate::data::TpmiRhHierarchy,
138    },
139    parameters: {
140        pub auth_policy: Tpm2bDigest,
141        pub hash_alg: TpmAlgId,
142        pub pcr_num: TpmRh,
143    }
144}
145
146tpm_struct! {
147    #[derive(Debug, Default, PartialEq, Eq, Copy, Clone)]
148    kind: Response,
149    name: TpmPcrSetAuthPolicyResponse,
150    cc: TpmCc::PcrSetAuthPolicy,
151    no_sessions: false,
152    with_sessions: true,
153    handles: {},
154    parameters: {}
155}
156
157tpm_struct! {
158    #[derive(Debug, PartialEq, Eq, Clone)]
159    kind: Command,
160    name: TpmPcrSetAuthValueCommand,
161    cc: TpmCc::PcrSetAuthValue,
162    no_sessions: false,
163    with_sessions: true,
164    handles: {
165        pub pcr_handle: u32,
166    },
167    parameters: {
168        pub auth: Tpm2bDigest,
169    }
170}
171
172tpm_struct! {
173    #[derive(Debug, Default, PartialEq, Eq, Copy, Clone)]
174    kind: Response,
175    name: TpmPcrSetAuthValueResponse,
176    cc: TpmCc::PcrSetAuthValue,
177    no_sessions: false,
178    with_sessions: true,
179    handles: {},
180    parameters: {}
181}
182
183tpm_struct! {
184    #[derive(Debug, Default, PartialEq, Eq, Copy, Clone)]
185    kind: Command,
186    name: TpmPcrResetCommand,
187    cc: TpmCc::PcrReset,
188    no_sessions: false,
189    with_sessions: true,
190    handles: {
191        pub pcr_handle: u32,
192    },
193    parameters: {}
194}
195
196tpm_struct! {
197    #[derive(Debug, Default, PartialEq, Eq, Copy, Clone)]
198    kind: Response,
199    name: TpmPcrResetResponse,
200    cc: TpmCc::PcrReset,
201    no_sessions: false,
202    with_sessions: true,
203    handles: {},
204    parameters: {}
205}