Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Auth: Add support to make KEK and DB files optional #23

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ CFLAGS = -I$(shell pwd)/include
# _GNU_SOURCE for asprintf.
CFLAGS += -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_GNU_SOURCE

# EXTRA_CFLAGS can be set through make command line
CFLAGS += $(EXTRA_CFLAGS)

CFLAGS += $$(pkg-config --cflags libxml-2.0)

CFLAGS += -g -O2 -std=gnu99 \
Expand Down
18 changes: 16 additions & 2 deletions handler.c
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,20 @@ static const uint8_t EFI_IMAGE_SECURITY_DATABASE2[] = {'d',0,'b',0,'t',0};

#define AUTH_PATH_PREFIX "/var/lib/varstored"

/*
* The macro AUTH_ONLY_PK_REQUIRED makes KEK and DB files optional, allowing
* varstored and varstore-sb-state to copy only the PK file (which is always
* present) and switch the VM to user mode. This will prevent the VM to boot
* if it has SecureBoot enabled by the user but UEFI certificates are missing.
*/
#ifdef AUTH_ONLY_PK_REQUIRED
#define AUTH_DB_REQUIRED false
#define AUTH_KEK_REQUIRED false
#else
#define AUTH_DB_REQUIRED true
#define AUTH_KEK_REQUIRED true
#endif

/*
* Array of auth_info structs containing the information about the keys
* we need. Avoid switching to user mode before importing other keys by
Expand All @@ -157,9 +171,9 @@ static struct auth_info auth_info[] = {
{"dbx", EFI_IMAGE_SECURITY_DATABASE1, sizeof(EFI_IMAGE_SECURITY_DATABASE1),
&gEfiImageSecurityDatabaseGuid, AUTH_PATH_PREFIX "/dbx.auth", true, false},
{"db", EFI_IMAGE_SECURITY_DATABASE, sizeof(EFI_IMAGE_SECURITY_DATABASE),
&gEfiImageSecurityDatabaseGuid, AUTH_PATH_PREFIX "/db.auth", false, true},
&gEfiImageSecurityDatabaseGuid, AUTH_PATH_PREFIX "/db.auth", false, AUTH_DB_REQUIRED},
{"KEK", EFI_KEY_EXCHANGE_KEY_NAME, sizeof(EFI_KEY_EXCHANGE_KEY_NAME),
&gEfiGlobalVariableGuid, AUTH_PATH_PREFIX "/KEK.auth", false, true},
&gEfiGlobalVariableGuid, AUTH_PATH_PREFIX "/KEK.auth", false, AUTH_KEK_REQUIRED},
{"PK", EFI_PLATFORM_KEY_NAME, sizeof(EFI_PLATFORM_KEY_NAME),
&gEfiGlobalVariableGuid, AUTH_PATH_PREFIX "/PK.auth", false, true},
};
Expand Down