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