@@ -12,6 +12,205 @@ use trusted_cluster_operator_lib::{ApprovedImage, TrustedExecutionCluster};
1212use trusted_cluster_operator_test_utils:: * ;
1313
1414const EXPECTED_PCR4 : & str = "ff2b357be4a4bc66be796d4e7b2f1f27077dc89b96220aae60b443bcf4672525" ;
15+ const EXPECTED_PCR7 : & str = "b3a56a06c03a65277d0a787fcabc1e293eaa5d6dd79398f2dda741f7b874c65d" ;
16+ const EXPECTED_PCR14 : & str = "17cdefd9548f4383b67a37a901673bf3c8ded6f619d36c8007562de1d93c81cc" ;
17+ const TPMEVENT_PCR4EFICALL_HASH : & str =
18+ "3d6772b4f84ed47595d72a2c4c5ffd15f5bb72c7507fe26f2aaee2c69d5633ba" ;
19+ const TPMEVENT_SEPARATOR_HASH : & str =
20+ "df3f619804a92fdb4057192dc43dd748ea778adc52bc498ce80524c014b81119" ;
21+
22+ macro_rules! pcr4_ev_efi_action_event {
23+ ( ) => { {
24+ TPMEvent {
25+ pcr: 4 ,
26+ name: "EV_EFI_ACTION" . to_string( ) ,
27+ hash: hex:: decode( TPMEVENT_PCR4EFICALL_HASH ) . unwrap( ) ,
28+ id: TPMEventID :: Pcr4EfiCall ,
29+ }
30+ } } ;
31+ }
32+
33+ macro_rules! pcr_separator_event {
34+ ( $pcr: expr, $event_id: expr) => { {
35+ TPMEvent {
36+ pcr: $pcr,
37+ name: "EV_SEPARATOR" . to_string( ) ,
38+ hash: hex:: decode( TPMEVENT_SEPARATOR_HASH ) . unwrap( ) ,
39+ id: $event_id,
40+ }
41+ } } ;
42+ }
43+
44+ macro_rules! expected_pcr7 {
45+ ( ) => { {
46+ Pcr {
47+ id: 7 ,
48+ value: hex:: decode( EXPECTED_PCR7 ) . unwrap( ) ,
49+ events: vec![
50+ TPMEvent {
51+ pcr: 7 ,
52+ name: "EV_EFI_VARIABLE_DRIVER_CONFIG" . to_string( ) ,
53+ hash: hex:: decode(
54+ "ccfc4bb32888a345bc8aeadaba552b627d99348c767681ab3141f5b01e40a40e" ,
55+ )
56+ . unwrap( ) ,
57+ id: TPMEventID :: Pcr7SecureBoot ,
58+ } ,
59+ TPMEvent {
60+ pcr: 7 ,
61+ name: "EV_EFI_VARIABLE_DRIVER_CONFIG" . to_string( ) ,
62+ hash: hex:: decode(
63+ "adb6fc232943e39c374bf4782b6c697f43c39fca1f4b51dfceda21164e19a893" ,
64+ )
65+ . unwrap( ) ,
66+ id: TPMEventID :: Pcr7Pk ,
67+ } ,
68+ TPMEvent {
69+ pcr: 7 ,
70+ name: "EV_EFI_VARIABLE_DRIVER_CONFIG" . to_string( ) ,
71+ hash: hex:: decode(
72+ "b5432fe20c624811cb0296391bfdf948ebd02f0705ab8229bea09774023f0ebf" ,
73+ )
74+ . unwrap( ) ,
75+ id: TPMEventID :: Pcr7Kek ,
76+ } ,
77+ TPMEvent {
78+ pcr: 7 ,
79+ name: "EV_EFI_VARIABLE_DRIVER_CONFIG" . to_string( ) ,
80+ hash: hex:: decode(
81+ "4313e43de720194a0eabf4d6415d42b5a03a34fdc47bb1fc924cc4e665e6893d" ,
82+ )
83+ . unwrap( ) ,
84+ id: TPMEventID :: Pcr7Db ,
85+ } ,
86+ TPMEvent {
87+ pcr: 7 ,
88+ name: "EV_EFI_VARIABLE_DRIVER_CONFIG" . to_string( ) ,
89+ hash: hex:: decode(
90+ "001004ba58a184f09be6c1f4ec75a246cc2eefa9637b48ee428b6aa9bce48c55" ,
91+ )
92+ . unwrap( ) ,
93+ id: TPMEventID :: Pcr7Dbx ,
94+ } ,
95+ pcr_separator_event!( 7 , TPMEventID :: Pcr7Separator ) ,
96+ TPMEvent {
97+ pcr: 7 ,
98+ name: "EV_EFI_VARIABLE_AUTHORITY" . to_string( ) ,
99+ hash: hex:: decode(
100+ "4d4a8e2c74133bbdc01a16eaf2dbb5d575afeb36f5d8dfcf609ae043909e2ee9" ,
101+ )
102+ . unwrap( ) ,
103+ id: TPMEventID :: Pcr7ShimCert ,
104+ } ,
105+ TPMEvent {
106+ pcr: 7 ,
107+ name: "EV_EFI_VARIABLE_AUTHORITY" . to_string( ) ,
108+ hash: hex:: decode(
109+ "e8e9578f5951ef16b1c1aa18ef02944b8375ec45ed4b5d8cdb30428db4a31016" ,
110+ )
111+ . unwrap( ) ,
112+ id: TPMEventID :: Pcr7SbatLevel ,
113+ } ,
114+ TPMEvent {
115+ pcr: 7 ,
116+ name: "EV_EFI_VARIABLE_AUTHORITY" . to_string( ) ,
117+ hash: hex:: decode(
118+ "ad5901fd581e6640c742c488083b9ac2c48255bd28a16c106c6f9df52702ee3f" ,
119+ )
120+ . unwrap( ) ,
121+ id: TPMEventID :: Pcr7GrubMokListCert ,
122+ } ,
123+ ] ,
124+ }
125+ } } ;
126+ }
127+
128+ macro_rules! expected_pcr14 {
129+ ( ) => { {
130+ Pcr {
131+ id: 14 ,
132+ value: hex:: decode( "17cdefd9548f4383b67a37a901673bf3c8ded6f619d36c8007562de1d93c81cc" )
133+ . unwrap( ) ,
134+ events: vec![
135+ TPMEvent {
136+ pcr: 14 ,
137+ name: "EV_IPL" . to_string( ) ,
138+ hash: hex:: decode(
139+ "e8e48e3ad10bc243341b4663c0057aef0ec7894ccc9ecb0598f0830fa57f7220" ,
140+ )
141+ . unwrap( ) ,
142+ id: TPMEventID :: Pcr14MokList ,
143+ } ,
144+ TPMEvent {
145+ pcr: 14 ,
146+ name: "EV_IPL" . to_string( ) ,
147+ hash: hex:: decode(
148+ "8d8a3aae50d5d25838c95c034aadce7b548c9a952eb7925e366eda537c59c3b0" ,
149+ )
150+ . unwrap( ) ,
151+ id: TPMEventID :: Pcr14MokListX ,
152+ } ,
153+ TPMEvent {
154+ pcr: 14 ,
155+ name: "EV_IPL" . to_string( ) ,
156+ hash: hex:: decode(
157+ "4bf5122f344554c53bde2ebb8cd2b7e3d1600ad631c385a5d7cce23c7785459a" ,
158+ )
159+ . unwrap( ) ,
160+ id: TPMEventID :: Pcr14MokListTrusted ,
161+ } ,
162+ ] ,
163+ }
164+ } } ;
165+ }
166+
167+ macro_rules! pcr4_shim_event {
168+ ( ) => { {
169+ TPMEvent {
170+ pcr: 4 ,
171+ name: "EV_EFI_BOOT_SERVICES_APPLICATION" . to_string( ) ,
172+ hash: hex:: decode( "94896c17d49fc8c8df0cc2836611586edab1615ce7cb58cf13fc5798de56b367" )
173+ . unwrap( ) ,
174+ id: TPMEventID :: Pcr4Shim ,
175+ }
176+ } } ;
177+ }
178+
179+ macro_rules! expected_base_pcrs {
180+ ( ) => { {
181+ [
182+ Pcr {
183+ id: 4 ,
184+ value: hex:: decode( EXPECTED_PCR4 ) . unwrap( ) ,
185+ events: vec![
186+ pcr4_ev_efi_action_event!( ) ,
187+ pcr_separator_event!( 4 , TPMEventID :: Pcr4Separator ) ,
188+ pcr4_shim_event!( ) ,
189+ TPMEvent {
190+ pcr: 4 ,
191+ name: "EV_EFI_BOOT_SERVICES_APPLICATION" . to_string( ) ,
192+ hash: hex:: decode(
193+ "bc6844fc7b59b4f0c7da70a307fc578465411d7a2c34b0f4dc2cc154c873b644" ,
194+ )
195+ . unwrap( ) ,
196+ id: TPMEventID :: Pcr4Grub ,
197+ } ,
198+ TPMEvent {
199+ pcr: 4 ,
200+ name: "EV_EFI_BOOT_SERVICES_APPLICATION" . to_string( ) ,
201+ hash: hex:: decode(
202+ "2b1dc59bc61dbbc3db11a6f3b0708c948efd46cceb7f6c8ea2024b8d1b8c829a" ,
203+ )
204+ . unwrap( ) ,
205+ id: TPMEventID :: Pcr4Vmlinuz ,
206+ } ,
207+ ] ,
208+ } ,
209+ expected_pcr7!( ) ,
210+ expected_pcr14!( ) ,
211+ ]
212+ } } ;
213+ }
15214
16215named_test ! (
17216 async fn test_trusted_execution_cluster_uninstall( ) -> anyhow:: Result <( ) > {
@@ -45,187 +244,7 @@ named_test! {
45244async fn test_image_pcrs_configmap_updates( ) -> anyhow:: Result <( ) > {
46245 let test_ctx = setup!( ) . await ?;
47246
48- test_ctx. verify_expected_pcrs(
49- & [ & [
50- Pcr {
51- id: 4 ,
52- value: hex:: decode( EXPECTED_PCR4 ) . unwrap( ) ,
53- events: vec![
54- TPMEvent {
55- pcr: 4 ,
56- name: "EV_EFI_ACTION" . to_string( ) ,
57- hash: hex:: decode(
58- "3d6772b4f84ed47595d72a2c4c5ffd15f5bb72c7507fe26f2aaee2c69d5633ba" ,
59- )
60- . unwrap( ) ,
61- id: TPMEventID :: Pcr4EfiCall ,
62- } ,
63- TPMEvent {
64- pcr: 4 ,
65- name: "EV_SEPARATOR" . to_string( ) ,
66- hash: hex:: decode(
67- "df3f619804a92fdb4057192dc43dd748ea778adc52bc498ce80524c014b81119" ,
68- )
69- . unwrap( ) ,
70- id: TPMEventID :: Pcr4Separator ,
71- } ,
72- TPMEvent {
73- pcr: 4 ,
74- name: "EV_EFI_BOOT_SERVICES_APPLICATION" . to_string( ) ,
75- hash: hex:: decode(
76- "94896c17d49fc8c8df0cc2836611586edab1615ce7cb58cf13fc5798de56b367" ,
77- )
78- . unwrap( ) ,
79- id: TPMEventID :: Pcr4Shim ,
80- } ,
81- TPMEvent {
82- pcr: 4 ,
83- name: "EV_EFI_BOOT_SERVICES_APPLICATION" . to_string( ) ,
84- hash: hex:: decode(
85- "bc6844fc7b59b4f0c7da70a307fc578465411d7a2c34b0f4dc2cc154c873b644" ,
86- )
87- . unwrap( ) ,
88- id: TPMEventID :: Pcr4Grub ,
89- } ,
90- TPMEvent {
91- pcr: 4 ,
92- name: "EV_EFI_BOOT_SERVICES_APPLICATION" . to_string( ) ,
93- hash: hex:: decode(
94- "2b1dc59bc61dbbc3db11a6f3b0708c948efd46cceb7f6c8ea2024b8d1b8c829a" ,
95- )
96- . unwrap( ) ,
97- id: TPMEventID :: Pcr4Vmlinuz ,
98- } ,
99- ] ,
100- } ,
101- Pcr {
102- id: 7 ,
103- value: hex:: decode(
104- "b3a56a06c03a65277d0a787fcabc1e293eaa5d6dd79398f2dda741f7b874c65d" ,
105- )
106- . unwrap( ) ,
107- events: vec![
108- TPMEvent {
109- pcr: 7 ,
110- name: "EV_EFI_VARIABLE_DRIVER_CONFIG" . to_string( ) ,
111- hash: hex:: decode(
112- "ccfc4bb32888a345bc8aeadaba552b627d99348c767681ab3141f5b01e40a40e" ,
113- )
114- . unwrap( ) ,
115- id: TPMEventID :: Pcr7SecureBoot ,
116- } ,
117- TPMEvent {
118- pcr: 7 ,
119- name: "EV_EFI_VARIABLE_DRIVER_CONFIG" . to_string( ) ,
120- hash: hex:: decode(
121- "adb6fc232943e39c374bf4782b6c697f43c39fca1f4b51dfceda21164e19a893" ,
122- )
123- . unwrap( ) ,
124- id: TPMEventID :: Pcr7Pk ,
125- } ,
126- TPMEvent {
127- pcr: 7 ,
128- name: "EV_EFI_VARIABLE_DRIVER_CONFIG" . to_string( ) ,
129- hash: hex:: decode(
130- "b5432fe20c624811cb0296391bfdf948ebd02f0705ab8229bea09774023f0ebf" ,
131- )
132- . unwrap( ) ,
133- id: TPMEventID :: Pcr7Kek ,
134- } ,
135- TPMEvent {
136- pcr: 7 ,
137- name: "EV_EFI_VARIABLE_DRIVER_CONFIG" . to_string( ) ,
138- hash: hex:: decode(
139- "4313e43de720194a0eabf4d6415d42b5a03a34fdc47bb1fc924cc4e665e6893d" ,
140- )
141- . unwrap( ) ,
142- id: TPMEventID :: Pcr7Db ,
143- } ,
144- TPMEvent {
145- pcr: 7 ,
146- name: "EV_EFI_VARIABLE_DRIVER_CONFIG" . to_string( ) ,
147- hash: hex:: decode(
148- "001004ba58a184f09be6c1f4ec75a246cc2eefa9637b48ee428b6aa9bce48c55" ,
149- )
150- . unwrap( ) ,
151- id: TPMEventID :: Pcr7Dbx ,
152- } ,
153- TPMEvent {
154- pcr: 7 ,
155- name: "EV_SEPARATOR" . to_string( ) ,
156- hash: hex:: decode(
157- "df3f619804a92fdb4057192dc43dd748ea778adc52bc498ce80524c014b81119" ,
158- )
159- . unwrap( ) ,
160- id: TPMEventID :: Pcr7Separator ,
161- } ,
162- TPMEvent {
163- pcr: 7 ,
164- name: "EV_EFI_VARIABLE_AUTHORITY" . to_string( ) ,
165- hash: hex:: decode(
166- "4d4a8e2c74133bbdc01a16eaf2dbb5d575afeb36f5d8dfcf609ae043909e2ee9" ,
167- )
168- . unwrap( ) ,
169- id: TPMEventID :: Pcr7ShimCert ,
170- } ,
171- TPMEvent {
172- pcr: 7 ,
173- name: "EV_EFI_VARIABLE_AUTHORITY" . to_string( ) ,
174- hash: hex:: decode(
175- "e8e9578f5951ef16b1c1aa18ef02944b8375ec45ed4b5d8cdb30428db4a31016" ,
176- )
177- . unwrap( ) ,
178- id: TPMEventID :: Pcr7SbatLevel ,
179- } ,
180- TPMEvent {
181- pcr: 7 ,
182- name: "EV_EFI_VARIABLE_AUTHORITY" . to_string( ) ,
183- hash: hex:: decode(
184- "ad5901fd581e6640c742c488083b9ac2c48255bd28a16c106c6f9df52702ee3f" ,
185- )
186- . unwrap( ) ,
187- id: TPMEventID :: Pcr7GrubMokListCert ,
188- } ,
189- ] ,
190- } ,
191- Pcr {
192- id: 14 ,
193- value: hex:: decode(
194- "17cdefd9548f4383b67a37a901673bf3c8ded6f619d36c8007562de1d93c81cc" ,
195- )
196- . unwrap( ) ,
197- events: vec![
198- TPMEvent {
199- pcr: 14 ,
200- name: "EV_IPL" . to_string( ) ,
201- hash: hex:: decode(
202- "e8e48e3ad10bc243341b4663c0057aef0ec7894ccc9ecb0598f0830fa57f7220" ,
203- )
204- . unwrap( ) ,
205- id: TPMEventID :: Pcr14MokList ,
206- } ,
207- TPMEvent {
208- pcr: 14 ,
209- name: "EV_IPL" . to_string( ) ,
210- hash: hex:: decode(
211- "8d8a3aae50d5d25838c95c034aadce7b548c9a952eb7925e366eda537c59c3b0" ,
212- )
213- . unwrap( ) ,
214- id: TPMEventID :: Pcr14MokListX ,
215- } ,
216- TPMEvent {
217- pcr: 14 ,
218- name: "EV_IPL" . to_string( ) ,
219- hash: hex:: decode(
220- "4bf5122f344554c53bde2ebb8cd2b7e3d1600ad631c385a5d7cce23c7785459a" ,
221- )
222- . unwrap( ) ,
223- id: TPMEventID :: Pcr14MokListTrusted ,
224- } ,
225- ] ,
226- } ,
227- ] ]
228- ) . await ?;
247+ test_ctx. verify_expected_pcrs( & [ & expected_base_pcrs!( ) ] ) . await ?;
229248
230249 test_ctx. cleanup( ) . await ?;
231250
0 commit comments