Debian Codegraph @

src/boot/secure-boot.h

raw
1 /* SPDX-License-Identifier: LGPL-2.1-or-later */
2 #pragma once
3
4 #include "efi.h"
5 #include "efivars.h"
6
7 typedef enum {
8 ENROLL_OFF, /* no Secure Boot key enrollment whatsoever, even manual entries are not generated */
9 ENROLL_MANUAL, /* Secure Boot key enrollment is strictly manual: manual entries are generated and need to be selected by the user */
10 ENROLL_IF_SAFE, /* Automatically enroll if it is safe (if we are running inside a VM, for example). */
11 ENROLL_FORCE, /* Secure Boot key enrollment may be automatic if it is available but might not be safe */
12 _SECURE_BOOT_ENROLL_MAX,
13 } secure_boot_enroll;
14
15 typedef enum {
16 ENROLL_ACTION_REBOOT, /* Reboot the system after enrollment */
17 ENROLL_ACTION_SHUTDOWN, /* Shutdown the system after enrollment */
18 _SECURE_BOOT_ENROLL_ACTION_MAX,
19 } secure_boot_enroll_action;
20
21 enum {
22 ENROLL_TIMEOUT_HIDDEN = 0,
23 ENROLL_TIMEOUT_MIN = 1,
24 ENROLL_TIMEOUT_DEFAULT = 15,
25 ENROLL_TIMEOUT_MAX = UINT32_MAX,
26 };
27
28 bool secure_boot_enabled(void);
29 SecureBootMode secure_boot_mode(void);
30
31 EFI_STATUS secure_boot_enroll_at(EFI_FILE *root_dir, const char16_t *path, bool force,
32 secure_boot_enroll_action action, uint64_t timeout_sec);
33
34 typedef bool (*security_validator_t)(
35 const void *ctx,
36 const EFI_DEVICE_PATH *device_path,
37 const void *file_buffer,
38 size_t file_size);
39
40 void install_security_override(security_validator_t validator, const void *validator_ctx);
41 void uninstall_security_override(void);
42 bool security_override_available(void);
43
44 DECLARE_STRING_TABLE_LOOKUP_TO_STRING(secure_boot_enroll, secure_boot_enroll);
45 DECLARE_STRING_TABLE_LOOKUP_TO_STRING(secure_boot_enroll_action, secure_boot_enroll_action);