mirror of
https://github.com/Telecominfraproject/OpenCellular.git
synced 2025-11-24 10:14:55 +00:00
Rearrange vboot_reference directories to isolate external components.
This creates a new vboot_firmware subdirectory, and which contains the entirety of the BIOS code. There shouldn't be anything in this directory that is NOT required by the BIOS. Review URL: http://codereview.chromium.org/2219004
This commit is contained in:
8
Makefile
8
Makefile
@@ -5,13 +5,15 @@
|
||||
export CC ?= gcc
|
||||
export CFLAGS = -Wall -DNDEBUG -O3 -Werror
|
||||
export TOP = $(shell pwd)
|
||||
export FWDIR=$(TOP)/vboot_firmware
|
||||
export INCLUDES = \
|
||||
-I$(TOP)/common/include \
|
||||
-I$(TOP)/cryptolib/include \
|
||||
-I$(FWDIR)/include \
|
||||
-I$(TOP)/misclibs/include \
|
||||
-I$(TOP)/cgptlib
|
||||
|
||||
SUBDIRS=common cgptlib cryptolib misclibs vfirmware vkernel utility tests
|
||||
export FWLIB=$(FWDIR)/vboot_fw.a
|
||||
|
||||
SUBDIRS=vboot_firmware cgptlib misclibs vfirmware vkernel utility tests
|
||||
|
||||
all:
|
||||
set -e; \
|
||||
|
||||
44
README
44
README
@@ -7,26 +7,21 @@ Directory Structure
|
||||
|
||||
The source is organized into distinct modules -
|
||||
|
||||
cryptolib/ - Contains the implementation for the crypto library. This
|
||||
includes implementations for SHA1, SHA256, SHA512, and RSA signature
|
||||
verification (for PKCS #1 v1.5 signatures).
|
||||
vboot_firmware/ - Contains ONLY the code required by the BIOS to validate
|
||||
the secure boot components. There shouldn't be any code in here that signs
|
||||
or generates images. BIOS should require ONLY this directory to implement
|
||||
secure boot. Refer to vboot_firmware/README for futher details.
|
||||
|
||||
common/ - Utility functions and stub implementations for wrapper
|
||||
functions used in the verification code. These stub implementations
|
||||
will need to be replaced with appropriate firmware equivalents.
|
||||
cgptlib/ - Work in progress for handling GPT headers. Parts of this will no
|
||||
doubt be migrated into vboot_firmware/
|
||||
|
||||
misclibs/ - Miscellaneous functions used by userland utilities.
|
||||
|
||||
utility/ - Utilities for generating and verifying signed
|
||||
firmware and kernel images, as well as arbitrary blobs.
|
||||
|
||||
vfirmware/ and vkernel/ - The main firmware and kernel image
|
||||
verification modules. It has functions for verifying and manipulating
|
||||
signed firmware and kernel images. The main files of interest are:
|
||||
vfirmware/firmware_image_fw.c (verification Functions used in Firmware)
|
||||
vfirmware/firmware_image.c (functions for userland tools)
|
||||
vkernel/kernel_image_fw.c (verification functions used in Firmware)
|
||||
vkernel/kernel_image.c (functions for userland tools)
|
||||
vfirmware/ and vkernel/ - Functions for generating, verifying, and
|
||||
manipulating signed firmware and kernel images.
|
||||
|
||||
tests/ - User-land tests and benchmarks that test the reference
|
||||
implementation. Please have a look at these if you'd like to
|
||||
@@ -49,29 +44,6 @@ dumpRSAPublicKey.c Dump RSA Public key (from a DER-encoded X509
|
||||
verify_data.c Verify a given signature on a given file.
|
||||
|
||||
|
||||
----------
|
||||
What is required for a minimal verified boot implementation
|
||||
----------
|
||||
|
||||
1) cryptolib/ - as a separate module since it will be used by others
|
||||
parts of the verified boot process.
|
||||
|
||||
2) common/ - this contains the interface for dealing with memory allocation
|
||||
and interacting with the TPM. The stubs will need to be replaced with their
|
||||
firmware-level equivalents.
|
||||
|
||||
3) Verified Firmware and Kernel image verification - This is the core
|
||||
of the verified boot implementation. They are implemented under vfirmware
|
||||
and vkernel (for firmware and kernel image verification respectively).
|
||||
|
||||
firmware_image_fw.c and kernel_image_fw.c : Contain verification logic
|
||||
used in the firmware. Needed.
|
||||
|
||||
firmware_image.c and kernel_image.c : High level functions used by userland
|
||||
tools. NOT needed in the firmware.
|
||||
|
||||
cryptolib/, common/, vfirmware/firmware_image_fw.c are part of the RO firmware.
|
||||
vkernel/kernel_image_fw.c is part of the RW firmware (it verifies the OS kernel).
|
||||
|
||||
----------
|
||||
Generating a signed firmware image:
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
TOP ?= ../../
|
||||
CFLAGS += -Wall -DNDEBUG -Werror -ansi
|
||||
LIBS = $(TOP)/cgptlib/libcgpt.a $(TOP)/common/libcommon.a
|
||||
LIBS = $(TOP)/cgptlib/libcgpt.a $(FWLIB)
|
||||
OBJS = cgptlib_test.o quick_sort_test.o crc32_test.o
|
||||
OUT = cgptlib_test
|
||||
|
||||
|
||||
@@ -1,18 +0,0 @@
|
||||
# Copyright (c) 2010 The Chromium OS Authors. All rights reserved.
|
||||
# Use of this source code is governed by a BSD-style license that can be
|
||||
# found in the LICENSE file.
|
||||
|
||||
SRCS = boot_device_stub.c rollback_index.c tlcl_stub.c utility_stub.c
|
||||
OBJS = $(SRCS:.c=.o)
|
||||
INCLUDES += -I./include/
|
||||
|
||||
all: libcommon.a
|
||||
|
||||
libcommon.a: $(OBJS)
|
||||
ar rs $@ $^
|
||||
|
||||
.c.o: $(OBJS)
|
||||
$(CC) $(CFLAGS) $(INCLUDES) -c $< -o $@
|
||||
|
||||
clean:
|
||||
rm -f $(OBJS) libcommon.a
|
||||
@@ -1,23 +0,0 @@
|
||||
# Copyright (c) 2010 The Chromium OS Authors. All rights reserved.
|
||||
# Use of this source code is governed by a BSD-style license that can be
|
||||
# found in the LICENSE file.
|
||||
|
||||
TOP ?= ../
|
||||
SRCS = rsa.c sha1.c sha2.c padding.c rsa_utility.c sha_utility.c
|
||||
OBJS = $(SRCS:.c=.o)
|
||||
CFLAGS += -DUNROLL_LOOPS -DHAVE_ENDIAN_H -DHAVE_LITTLE_ENDIAN -DNDEBUG
|
||||
INCLUDES += -I./include/ -I$(TOP)/common/include/
|
||||
|
||||
all: libcrypto.a
|
||||
|
||||
libcrypto.a: $(OBJS)
|
||||
ar rs libcrypto.a $(OBJS)
|
||||
|
||||
padding.c: $(TOP)/scripts/genpadding.sh
|
||||
$(TOP)/scripts/genpadding.sh >$@
|
||||
|
||||
.c.o: $(OBJS)
|
||||
$(CC) $(CFLAGS) -ansi $(INCLUDES) -c $< -o $@
|
||||
|
||||
clean:
|
||||
rm -f $(OBJS) libcrypto.a
|
||||
@@ -6,7 +6,7 @@ TOP ?= ../
|
||||
CC ?= gcc
|
||||
INCLUDES += -I./include \
|
||||
-I$(TOP)/common/include \
|
||||
-I$(TOP)/cryptolib/include \
|
||||
-I$(TOP)/vboot_firmware/lib/cryptolib/include \
|
||||
-I$(TOP)/vfirmware/include \
|
||||
-I$(TOP)/vkernel/include
|
||||
|
||||
|
||||
@@ -6,18 +6,14 @@ TOP ?= ../
|
||||
CC ?= gcc
|
||||
CFLAGS ?= -Wall -DNDEBUG -O3 -Werror
|
||||
INCLUDES += -I./include \
|
||||
-I../cryptolib/include \
|
||||
-I../common/include \
|
||||
-I$(FWDIR)/lib/cryptolib/include \
|
||||
-I../misclibs/include \
|
||||
-I../vfirmware/include\
|
||||
-I../vkernel/include
|
||||
BASE_LIBS = $(TOP)/cryptolib/libcrypto.a $(TOP)/common/libcommon.a
|
||||
IMAGE_LIBS = $(TOP)/vfirmware/firmware_image.o \
|
||||
$(TOP)/vfirmware/firmware_image_fw.o \
|
||||
$(TOP)/vkernel/kernel_image.o \
|
||||
$(TOP)/vkernel/kernel_image_fw.o
|
||||
$(TOP)/vkernel/kernel_image.o
|
||||
UTIL_LIBS = $(TOP)/misclibs/file_keys.o $(TOP)/misclibs/signature_digest.o
|
||||
LIBS = $(IMAGE_LIBS) $(UTIL_LIBS) -lcrypto $(BASE_LIBS)
|
||||
LIBS = $(IMAGE_LIBS) $(UTIL_LIBS) $(FWLIB) -lcrypto
|
||||
|
||||
TEST_BINS = big_firmware_tests \
|
||||
big_kernel_tests \
|
||||
@@ -75,18 +71,18 @@ kernel_verify_benchmark: kernel_verify_benchmark.c timer_utils.c \
|
||||
$(CC) $(CFLAGS) $(INCLUDES) $^ -o $@ -lrt $(LIBS)
|
||||
|
||||
rsa_padding_test: rsa_padding_test.c
|
||||
$(CC) $(CFLAGS) $(INCLUDES) $^ -o $@ $(UTIL_LIBS) $(BASE_LIBS) \
|
||||
$(CC) $(CFLAGS) $(INCLUDES) $^ -o $@ $(UTIL_LIBS) $(FWLIB) \
|
||||
-lcrypto
|
||||
|
||||
rsa_verify_benchmark: rsa_verify_benchmark.c timer_utils.c
|
||||
$(CC) $(CFLAGS) $(INCLUDES) $^ -o $@ -lrt $(UTIL_LIBS) $(BASE_LIBS) \
|
||||
$(CC) $(CFLAGS) $(INCLUDES) $^ -o $@ -lrt $(UTIL_LIBS) $(FWLIB) \
|
||||
-lcrypto
|
||||
|
||||
sha_benchmark: sha_benchmark.c timer_utils.c
|
||||
$(CC) $(CFLAGS) $(INCLUDES) $^ -o $@ -lrt $(BASE_LIBS)
|
||||
$(CC) $(CFLAGS) $(INCLUDES) $^ -o $@ -lrt $(FWLIB)
|
||||
|
||||
sha_tests: sha_tests.c
|
||||
$(CC) $(CFLAGS) $(INCLUDES) $^ -o $@ $(BASE_LIBS)
|
||||
$(CC) $(CFLAGS) $(INCLUDES) $^ -o $@ $(FWLIB)
|
||||
|
||||
verify_firmware_fuzz_driver: verify_firmware_fuzz_driver.c \
|
||||
rollback_index_mock.c
|
||||
|
||||
@@ -6,8 +6,7 @@ TOP ?= ../
|
||||
CC ?= gcc
|
||||
CXX ?= g++
|
||||
INCLUDES += -I./include \
|
||||
-I../cryptolib/include \
|
||||
-I../common/include \
|
||||
-I$(FWDIR)/lib/cryptolib/include \
|
||||
-I../misclibs/include \
|
||||
-I../vfirmware/include\
|
||||
-I../vkernel/include
|
||||
@@ -15,10 +14,7 @@ CFLAGS ?= -Wall -DNDEBUG -O3 -Werror $(INCLUDES)
|
||||
LIBS = $(TOP)/misclibs/file_keys.o \
|
||||
$(TOP)/misclibs/signature_digest.o \
|
||||
$(TOP)/vfirmware/firmware_image.o \
|
||||
$(TOP)/vfirmware/firmware_image_fw.o \
|
||||
$(TOP)/vkernel/kernel_image.o \
|
||||
$(TOP)/vkernel/kernel_image_fw.o
|
||||
FIRMWARELIBS = $(TOP)/cryptolib/libcrypto.a $(TOP)/common/libcommon.a
|
||||
$(TOP)/vkernel/kernel_image.o
|
||||
SUBDIRS = cgpt
|
||||
|
||||
TARGET_BINS = dumpRSAPublicKey \
|
||||
@@ -39,21 +35,19 @@ subdirs:
|
||||
dumpRSAPublicKey: dumpRSAPublicKey.c
|
||||
$(CC) $(CFLAGS) $(INCLUDES) $< -o $@ -lcrypto
|
||||
|
||||
firmware_utility: firmware_utility.cc $(LIBS) $(FIRMWARELIBS)
|
||||
firmware_utility: firmware_utility.cc $(LIBS) $(FWLIB)
|
||||
$(CXX) $(CFLAGS) $(INCLUDES) -ggdb -D__STDC_LIMIT_MACROS $< \
|
||||
-o $@ $(FIRMWARELIBS) $(LIBS) $(TOP)/common/libcommon.a \
|
||||
-lcrypto
|
||||
-o $@ $(LIBS) $(FWLIB) -lcrypto
|
||||
|
||||
kernel_utility: kernel_utility.cc $(LIBS) $(FIRMWARELIBS)
|
||||
kernel_utility: kernel_utility.cc $(LIBS) $(FWLIB)
|
||||
$(CXX) $(CFLAGS) $(INCLUDES) -ggdb -D__STDC_LIMIT_MACROS $< \
|
||||
-o $@ $(FIRMWARELIBS) $(LIBS) $(TOP)/common/libcommon.a \
|
||||
-lcrypto
|
||||
-o $@ $(LIBS) $(FWLIB) -lcrypto
|
||||
|
||||
signature_digest_utility: signature_digest_utility.c $(LIBS) $(FIRMWARELIBS)
|
||||
$(CC) $(CFLAGS) $(INCLUDES) $< -o $@ $(LIBS) $(FIRMWARELIBS) -lcrypto
|
||||
signature_digest_utility: signature_digest_utility.c $(LIBS) $(FWLIB)
|
||||
$(CC) $(CFLAGS) $(INCLUDES) $< -o $@ $(LIBS) $(FWLIB) -lcrypto
|
||||
|
||||
verify_data: verify_data.c $(LIBS) $(FIRMWARELIBS)
|
||||
$(CC) $(CFLAGS) $(INCLUDES) $< -o $@ $(LIBS) $(FIRMWARELIBS) -lcrypto
|
||||
verify_data: verify_data.c $(LIBS) $(FWLIB)
|
||||
$(CC) $(CFLAGS) $(INCLUDES) $< -o $@ $(LIBS) $(FWLIB) -lcrypto
|
||||
|
||||
clean:
|
||||
set -e; \
|
||||
|
||||
@@ -6,8 +6,7 @@ TOP ?= ../../
|
||||
CC ?= cc
|
||||
INCLUDES += -I$(TOP)/common/include
|
||||
CFLAGS += -Wall -Werror -ggdb
|
||||
LIBS += $(TOP)/common/libcommon.a \
|
||||
$(TOP)/cgptlib/libcgpt.a
|
||||
LIBS += $(TOP)/cgptlib/libcgpt.a $(FWLIB)
|
||||
|
||||
all: cgpt
|
||||
|
||||
|
||||
44
vboot_firmware/Makefile
Normal file
44
vboot_firmware/Makefile
Normal file
@@ -0,0 +1,44 @@
|
||||
# Copyright (c) 2010 The Chromium OS Authors. All rights reserved.
|
||||
# Use of this source code is governed by a BSD-style license that can be
|
||||
# found in the LICENSE file.
|
||||
|
||||
LIBNAME = vboot_fw.a
|
||||
|
||||
CC ?= gcc
|
||||
CFLAGS = -Wall -DNDEBUG -O3 -Werror
|
||||
|
||||
FWTOP := $(shell pwd)
|
||||
LIBDIR = $(FWTOP)/lib
|
||||
STUBDIR = $(FWTOP)/stub
|
||||
TESTDIR = $(FWTOP)/linktest
|
||||
|
||||
INC = \
|
||||
-I$(FWTOP)/include \
|
||||
-I$(LIBDIR)/include \
|
||||
-I$(LIBDIR)/cryptolib/include
|
||||
|
||||
|
||||
LIB_SRCS := $(shell find $(LIBDIR) -iname '*.c')
|
||||
LIB_OBJS := $(LIB_SRCS:%.c=%.o)
|
||||
|
||||
STUB_SRCS := $(shell find $(STUBDIR) -iname '*.c')
|
||||
STUB_OBJS := $(STUB_SRCS:%.c=%.o)
|
||||
|
||||
|
||||
test : $(LIBNAME)
|
||||
$(CC) $(CFLAGS) $(INC) -o $(TESTDIR)/a.out $(TESTDIR)/main.c $(LIBNAME)
|
||||
|
||||
$(LIBNAME) : $(LIB_OBJS) $(STUB_OBJS)
|
||||
rm -f $@
|
||||
ar qc $@ $^
|
||||
|
||||
%o : %c
|
||||
$(CC) $(CFLAGS) $(INC) -c -o $@ $<
|
||||
|
||||
clean: FORCE
|
||||
rm -f $(LIBNAME) $(LIB_OBJS) $(STUB_OBJS) $(TESTDIR)/a.out
|
||||
|
||||
FORCE:
|
||||
|
||||
|
||||
.PHONY: FORCE
|
||||
6
vboot_firmware/README
Normal file
6
vboot_firmware/README
Normal file
@@ -0,0 +1,6 @@
|
||||
|
||||
lib/ is stuff that the BIOS needs to link with.
|
||||
|
||||
stub/ is stuff to be implemented by the BIOS.
|
||||
|
||||
include/ describes the interfaces between the two parts.
|
||||
@@ -38,7 +38,7 @@ typedef struct LoadKernelParams {
|
||||
uint64_t bootloader_size; /* Size of bootloader image in bytes */
|
||||
} LoadKernelParams;
|
||||
|
||||
uintn_t LoadKernel(LoadKernelParams* params);
|
||||
uint64_t LoadKernel(LoadKernelParams* params);
|
||||
/* Attempts to load the kernel from the current device.
|
||||
*
|
||||
* Returns LOAD_KERNEL_SUCCESS if successful, error code on failure. */
|
||||
3
vboot_firmware/lib/cryptolib/README
Normal file
3
vboot_firmware/lib/cryptolib/README
Normal file
@@ -0,0 +1,3 @@
|
||||
This contains the implementation for the crypto library. This includes
|
||||
implementations for SHA1, SHA256, SHA512, and RSA signature verification
|
||||
(for PKCS #1 v1.5 signatures).
|
||||
55
vboot_firmware/linktest/main.c
Normal file
55
vboot_firmware/linktest/main.c
Normal file
@@ -0,0 +1,55 @@
|
||||
#include <stdio.h>
|
||||
|
||||
#include "firmware_image_fw.h"
|
||||
#include "kernel_image_fw.h"
|
||||
#include "load_kernel_fw.h"
|
||||
#include "rollback_index.h"
|
||||
#include "tlcl.h"
|
||||
|
||||
int main(void)
|
||||
{
|
||||
|
||||
// firmware_image_fw.h
|
||||
VerifyFirmwareHeader(0, 0, 0, 0);
|
||||
VerifyFirmwarePreamble(0, 0, 0, 0);
|
||||
VerifyFirmwareData(0, 0, 0, 0, 0);
|
||||
VerifyFirmware(0, 0, 0);
|
||||
GetLogicalFirmwareVersion(0);
|
||||
VerifyFirmwareDriver_f(0, 0, 0, 0, 0);
|
||||
|
||||
// kernel_image_fw.h
|
||||
VerifyKernelHeader(0, 0, 0, 0, 0, 0);
|
||||
VerifyKernelConfig(0, 0, 0, 0);
|
||||
VerifyKernelData(0, 0, 0, 0, 0);
|
||||
VerifyKernel(0, 0, 0);
|
||||
GetLogicalKernelVersion(0);
|
||||
VerifyKernelDriver_f(0, 0, 0, 0);
|
||||
|
||||
// load_kernel_fw.h
|
||||
// FIXME: LoadKernel(0);
|
||||
|
||||
// rollback_index.h
|
||||
SetupTPM();
|
||||
GetStoredVersion(0);
|
||||
WriteStoredVersion(0, 0);
|
||||
LockStoredVersion(0);
|
||||
|
||||
// tlcl.h
|
||||
TlclLibinit();
|
||||
TlclStartup();
|
||||
TlclSelftestfull();
|
||||
TlclDefineSpace(0, 0, 0);
|
||||
TlclWrite(0, 0, 0);
|
||||
TlclRead(0, 0, 0);
|
||||
TlclWriteLock(0);
|
||||
TlclReadLock(0);
|
||||
TlclAssertPhysicalPresence();
|
||||
TlclSetNvLocked();
|
||||
TlclIsOwned();
|
||||
TlclForceClear();
|
||||
TlclPhysicalEnable();
|
||||
TlclPhysicalSetDeactivated(0);
|
||||
TlclGetFlags(0, 0);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -4,11 +4,11 @@
|
||||
|
||||
CC ?= gcc
|
||||
INCLUDES += -I./include \
|
||||
-I../cryptolib/include \
|
||||
-I$(FWDIR)/lib/cryptolib/include \
|
||||
-I../common/include \
|
||||
-I../misclibs/include
|
||||
CFLAGS ?= -Wall -DNDEBUG -O3 -Werror
|
||||
FIRMWARE_OUT = firmware_image_fw.o firmware_image.o
|
||||
FIRMWARE_OUT = firmware_image.o
|
||||
|
||||
all: $(FIRMWARE_OUT)
|
||||
|
||||
|
||||
@@ -4,11 +4,11 @@
|
||||
|
||||
CC ?= gcc
|
||||
INCLUDES += -I./include \
|
||||
-I../cryptolib/include \
|
||||
-I$(FWDIR)/lib/cryptolib/include \
|
||||
-I../common/include \
|
||||
-I../misclibs/include
|
||||
CFLAGS ?= -Wall -DNDEBUG -O3 -Werror
|
||||
KERNEL_OUT = kernel_image_fw.o kernel_image.o
|
||||
KERNEL_OUT = kernel_image.o
|
||||
|
||||
all: $(KERNEL_OUT)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user