@@ -354,17 +354,35 @@ recalculate_firmware_pcr_from_cbfs()
354
354
return 1
355
355
fi
356
356
357
- DO_WITH_DEBUG calc_pcr " $1 " 2 \
357
+ calculated_pcr= $( calc_pcr " $1 " 2 \
358
358
" $( read_and_pad_FMAP_from_cbmem " $1 " ) " \
359
359
" $( cbfs --read bootblock | $checksum_prog | awk -F ' ' ' {print $1}' ) " \
360
360
" $( cbfs --read fallback/romstage | $checksum_prog | awk -F ' ' ' {print $1}' ) " \
361
361
" $( cbfs --read fallback/postcar | $checksum_prog | awk -F ' ' ' {print $1}' ) " \
362
362
" $( cbfs --read fallback/ramstage | $checksum_prog | awk -F ' ' ' {print $1}' ) " \
363
363
" $( cbfs --read bootsplash.jpg | $checksum_prog | awk -F ' ' ' {print $1}' ) " \
364
- " $( cbfs --read fallback/payload | $checksum_prog | awk -F ' ' ' {print $1}' ) "
364
+ " $( cbfs --read fallback/payload | $checksum_prog | awk -F ' ' ' {print $1}' ) " )
365
365
366
- DEBUG " Actual TPM $( pcrs | grep " $PCR_STRING " ) "
366
+ DEBUG " Original TPM PCR2 value: $( pcrs | grep " $PCR_STRING " ) "
367
367
DEBUG " TPM event log reported by cbmem -L: $( cbmem -L) "
368
+ DEBUG " Calculated TPM PCR2 value from files: $calculated_pcr "
369
+ echo " $calculated_pcr "
370
+ }
371
+
372
+ verify_coreboot_measured_boot_tpm_event_log_vs_content_measured ()
373
+ {
374
+ measured_boot=$( tpmr calcfuturepcr 2 | xxd -p)
375
+ content_measured=$( tpmr recalculate_firmware_pcr_from_cbfs)
376
+
377
+ DEBUG " Measured boot from TPM event log: $measured_boot "
378
+ DEBUG " Measured boot from content measured by coreboot: $content_measured "
379
+
380
+ if [ " $measured_boot " == " $content_measured " ]; then
381
+ echo " Verified: TPM event log matches content measured by coreboot"
382
+ else
383
+ echo " Failed: TPM event log does not match content measured by coreboot"
384
+ die " TPM event log does not match content measured by coreboot"
385
+ fi
368
386
}
369
387
370
388
tpm2_extend () {
@@ -897,6 +915,10 @@ if [ "$CONFIG_TPM2_TOOLS" != "y" ]; then
897
915
shift
898
916
recalculate_firmware_pcr_from_cbfs " sha1"
899
917
;;
918
+ verify_coreboot_measured_boot_tpm_event_log_vs_content_measured)
919
+ shift
920
+ verify_coreboot_measured_boot_tpm_event_log_vs_content_measured
921
+ ;;
900
922
counter_create)
901
923
shift
902
924
tpm1_counter_create " $@ "
@@ -948,6 +970,9 @@ calc_pcr)
948
970
recalculate_firmware_pcr_from_cbfs)
949
971
recalculate_firmware_pcr_from_cbfs " sha256"
950
972
;;
973
+ verify_coreboot_measured_boot_tpm_event_log_vs_content_measured)
974
+ verify_coreboot_measured_boot_tpm_event_log_vs_content_measured
975
+ ;;
951
976
extend)
952
977
tpm2_extend " $@ "
953
978
;;
0 commit comments