Debian Codegraph @

src/boot/measure.h

raw
1 /* SPDX-License-Identifier: LGPL-2.1-or-later */
2 #pragma once
3
4 #include "efi.h"
5
6 #if ENABLE_TPM
7
8 bool tpm_present(void);
9 uint32_t tpm_get_active_pcr_banks(void);
10
11 /* Routines for boot-time TPM PCR measurement as well as submitting an event log entry about it. The latter
12 * can be done with two different event log record types. For old stuff we use EV_IPL (which is legacy, and
13 * not great to recognize properly during PCR validation). For new stuff we use properly tagged
14 * EV_EVENT_TAG record. */
15
16 /* Old stuff is logged as EV_IPL */
17 EFI_STATUS tpm_log_ipl_event(uint32_t pcrindex, EFI_PHYSICAL_ADDRESS buffer, size_t buffer_size, const char16_t *description, bool *ret_measured);
18 EFI_STATUS tpm_log_ipl_event_ascii(uint32_t pcrindex, EFI_PHYSICAL_ADDRESS buffer, size_t buffer_size, const
19 char *description, bool *ret_measured);
20
21 /* New stuff is logged as EV_EVENT_TAG */
22 EFI_STATUS tpm_log_tagged_event(uint32_t pcrindex, EFI_PHYSICAL_ADDRESS buffer, size_t buffer_size, uint32_t event_id, const char16_t *description, bool *ret_measured);
23
24 EFI_STATUS tpm_log_load_options(const char16_t *load_options, bool *ret_measured);
25
26 #else
27
28 static inline bool tpm_present(void) {
29 return false;
30 }
31
32 static inline uint32_t tpm_get_active_pcr_banks(void) {
33 return 0;
34 }
35
36 static inline EFI_STATUS tpm_log_ipl_event(uint32_t pcrindex, EFI_PHYSICAL_ADDRESS buffer, size_t buffer_size, const char16_t *description, bool *ret_measured) {
37 if (ret_measured)
38 *ret_measured = false;
39 return EFI_SUCCESS;
40 }
41
42 static inline EFI_STATUS tpm_log_ipl_event_ascii(uint32_t pcrindex, EFI_PHYSICAL_ADDRESS buffer, size_t buffer_size, const char *description, bool *ret_measured) {
43 if (ret_measured)
44 *ret_measured = false;
45 return EFI_SUCCESS;
46 }
47
48 static inline EFI_STATUS tpm_log_tagged_event(uint32_t pcrindex, EFI_PHYSICAL_ADDRESS buffer, size_t buffer_size, uint32_t event_id, const char16_t *description, bool *ret_measured) {
49 if (ret_measured)
50 *ret_measured = false;
51 return EFI_SUCCESS;
52 }
53
54 static inline EFI_STATUS tpm_log_load_options(const char16_t *load_options, bool *ret_measured) {
55 if (ret_measured)
56 *ret_measured = false;
57 return EFI_SUCCESS;
58 }
59
60 #endif