Commit Graph

88 Commits

Author SHA1 Message Date
Gaurav Shah
bcd8f4a07c Make kernel signature a part of the kernel preamble.
With this change, the kernel signature is a part of the preamble block (and therefore, used during preamble signature verification).

BUG=670
TEST=image verification tests still pass. corrected splicing test expectations (and it passes).

Review URL: http://codereview.chromium.org/2292001
2010-05-26 13:19:00 -07:00
Gaurav Shah
5fe021b411 Rebaseline linktest with new/modified kernel verification API functions.
Review URL: http://codereview.chromium.org/2248003
2010-05-26 10:53:16 -07:00
Gaurav Shah
bf7615bc31 Change kernel vboot header layout and add support for separate header verification.
This CL adds 2 things:
- Instead of having a kernel config, now we have a kernel preamble which contains some important parameters needed by the bootloader in the firmware to kernel hand-off. These parameters are verified using a separate preamble signature in addition to the kernel signature on actual kernel image data.

- Adds a new VerifyKernelHeader() API function which verifies the kernel verified boot header excluding the kernel data and also extracts parameters out of this header needed to verify the actual kernel image data (if deemed necessary). This allows for vboot header verification and data verification to be performed separately.

Review URL: http://codereview.chromium.org/2234003
2010-05-26 10:26:00 -07:00
Bill Richardson
0b8f35c6a5 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
2010-05-26 09:18:38 -07:00
Randall Spangler
a45586722f Expose GptData.current_kernel as an output of GptNextKernelEntry()
LoadKernel() needs to pass the kernel partition number out to the
BIOS, so it can be passed to the bootloader.

Review URL: http://codereview.chromium.org/2161007
2010-05-25 11:09:06 -07:00
Bill Richardson
93b09e5a4d Code cleanup.
Fix improper test of return value, replace order-dependent indices with
enumerated types in option parsing.

Review URL: http://codereview.chromium.org/2183001
2010-05-25 10:48:39 -07:00
Randall Spangler
590d10b109 Added struct members for bootloader offset/size.
Review URL: http://codereview.chromium.org/2163003
2010-05-24 16:04:11 -07:00
Randall Spangler
102bfba73a Load kernel APIs added (once more, from the correct repo)
Review URL: http://codereview.chromium.org/2165003
2010-05-24 15:14:33 -07:00
Louis Yung-Chieh Lo
8eaf239a04 support 'cgpt repair'
Review URL: http://codereview.chromium.org/2083020
2010-05-22 07:10:29 +08:00
Louis Yung-Chieh Lo
b31ddcec6a add cgpt framework and attribute support.
Review URL: http://codereview.chromium.org/2082015
2010-05-21 16:35:44 +08:00
Louis Yung-Chieh Lo
0dce41c2ec rename cgpt files with cgptlib prefix (to avoid conflicts to cgpt utility)
Review URL: http://codereview.chromium.org/2082007
2010-05-17 22:45:30 -07:00
Louis Yung-Chieh Lo
b17db3c4b9 cgpt supports GptNextKernelEntry() and GptUpdateKernelEntry()
Review URL: http://codereview.chromium.org/1922004
2010-05-05 11:21:08 -07:00
Louis Yung-Chieh Lo
49fa8e51ad Add more test cases for GptInit() and fixed some bugs
Review URL: http://codereview.chromium.org/1701017
2010-04-30 16:10:48 -07:00
Gaurav Shah
bd52fc793a VBoot Reference: Make kernel_config a 4K byte block, and move it after the verified boot block.
The kernel_config is now stored as a 4K binary block instead of the kconfig_options structure that was being used before. Since the verified boot code doesn't care what kernel config options are (other than the length of the kernel image and for verifying them before the rest of kernel), it is ok to keep them as a blackbox.

This CL also changes the verified boot kernel layout - VBlock Data followed by Kernel Config followed by the Kernel Image. This will allow them to be stored separately, or as a concatenated block (for easy memory mapping during kernel load). This should ease the process of generating a layout for verified boot kernel images which is also compatible with legacy BIOSes that don't support this mechanism.

Finally, there is also a new firmware API function to determine the size of a kernel verified boot block, given a pointer to its beginning (for determining the offset to the kernel config and data).

Review URL: http://codereview.chromium.org/1732022
2010-04-29 15:30:25 -07:00
Gaurav Shah
887e3d4700 Vboot Reference: Remove dependency on TrouSers by not including tss/tcs.h
Use "tss_constants.h" with TPM data type and constant definitions  instead.

Review URL: http://codereview.chromium.org/1712018
2010-04-27 16:26:48 -07:00
Gaurav Shah
2480a18c45 Vboot Reference: Make kernel signing utility more flexible.
The CL adds the --config and --vblock option to kernel_utility.

--config <file> uses the file to populate the configuration portion within a signed vbootimage

Currently, the configuration file is assumed to only contain command line options to be passed to the kernel. In the future, we might want to change it so that it contains information about the kernel load address, entry points, etc. (refer to rspangler@ drive map design doc)

--vblock makes the tool only output the verification header instead of a one monolithic signed kernel image containing the verification information (with config information contained within it) followed by the actual kernel image

Review URL: http://codereview.chromium.org/1752013
2010-04-26 11:41:53 -07:00
Louis Yung-Chieh Lo
37f6b55a25 Add helper functions and files for gpt tests.
Review URL: http://codereview.chromium.org/1729006
2010-04-22 21:22:22 -07:00
Louis Yung-Chieh Lo
4bbf21e476 A simple test infrastructure -- idea stolen from Gaurav.
Review URL: http://codereview.chromium.org/1761004
2010-04-21 17:29:05 -07:00
Louis Yung-Chieh Lo
e1a25ab108 cgptlib stub for verified boot development.
Review URL: http://codereview.chromium.org/1547038
2010-04-20 10:52:41 -07:00
Gaurav Shah
065d360e10 Fix bug in GetLogicalFirmwareVersion().
Missed an offset while retrieving the firmware version.

Review URL: http://codereview.chromium.org/1665007
2010-04-19 15:42:46 -07:00
Gaurav Shah
0265882a34 Change VerifyFirmware() to take separate pointers to firmware verification header and firmware data.
The firmware verification code no longer assumes that verification data and firmware data are contiguous and follow each other. Needed for EFI where the actual firmware must be stored in its own firmware volume.

BUG=1704
TEST=modified existing tests for the new API, and they still pass

Review URL: http://codereview.chromium.org/1578035
2010-04-18 16:35:07 -07:00
Gaurav Shah
65127cc38a Add a --vblock option to firmware_utility to only output the verification block.
Needed if the verification block needs to be stored separately than the actual firmware data instead of one monlithic blob.

TEST = Tried the new option and verified that the output is correct.

Review URL: http://codereview.chromium.org/1525032
2010-04-14 14:29:02 -07:00
Gaurav Shah
c7686471b8 Remove big_[firmware|kernel]_tests from the script used in the autotest.
These tests wouldn't work on a 32-bit system.

Review URL: http://codereview.chromium.org/1624002
2010-04-05 18:44:05 -07:00
Gaurav Shah
f3dd1a6784 VBoot Reference: Output debug information using debug() instead of fprintf().
This should make it easier to switch off debug messages if needed.

TESTS=builds fine, autotest builds fine (using both arm/x86-generic)

Review URL: http://codereview.chromium.org/1607006
2010-04-05 15:50:00 -07:00
Gaurav Shah
ef7510fe40 Updated README
I clobbered my branch associated with the last CL. This is a new issue with the same change.

Review URL: http://codereview.chromium.org/1584005
2010-03-31 14:09:31 -07:00
Gaurav Shah
fc70d72aaa VBoot Reference: Refactoring Part 3
Refactor and restructure reference code into individual self-contain modules. I have revamped the way the code is structured to make it easy to determine which parts belong in the firmware and which are used by userland tools.

common/ - common utilities and stub functions (Firmware)
cryptolib/ - crypto library (Firmware)
misclibs/ - miscellaneous userland libraries (Userland)
sctips/ - Miscellaenous scripts (Userland)
tests/ - Tests (Userland)
vfirmware/ - Verified Firmware Implementation
vfirmware/firmware_image_fw.c (Firmware)
vfirmware/firmware_image.c (Userland)

vkernel/ - Verified Kernel Implementation
vkernel/kernel_image_fw.c (Firmware)
vkernel/kernel_image.c (Userland)

Review URL: http://codereview.chromium.org/1581005
2010-03-31 13:26:55 -07:00
Gaurav Shah
5411c7a9f0 combined patch for:
http://codereview.chromium.org/1574005
http://codereview.chromium.org/1604001

Review URL: http://codereview.chromium.org/1585007
2010-03-31 10:56:49 -07:00
David Garcia
21c3f7fef7 Revert "VBoot Reference: Refactor Part 2 - Crypto Libraries"
This reverts commit e018a80a37aaa45681f45f5852f04d20aedd8b2d.

Review URL: http://codereview.chromium.org/1593002
2010-03-31 09:04:15 -07:00
Gaurav Shah
d46c347018 VBoot Reference: Refactor Part 2 - Crypto Libraries
Removing multiple top level includes - now padding.h, rsa.h and sha.h are used internally and cryptolib.h must be used instead for all modules that wish to use crypto functions.

I am trying to separate refactors involving code movement from one file to another, and the movement of files themselves into separate CLs so that it's clear what changed.

Review URL: http://codereview.chromium.org/1574005
2010-03-30 23:08:10 -07:00
Gaurav Shah
ed9c96a7aa VBoot Reference: Refactor Pass 1: Split {firmware|kernel}_image
This CL refactors verified boot firmware and kernel image functions into firmware and userland portions. Data Types and Functions that need to be a part of the final firmware implementation reside in files with "_fw" suffix - firmware_image_fw.{c|h} and kernel_image_fw.{c|h}.

Also some Makefile cleanups.

Review URL: http://codereview.chromium.org/1599001
2010-03-30 18:56:07 -07:00
Gaurav Shah
091dfdf425 Make image verification test script call big_{firmware|kernel} tests.
Review URL: http://codereview.chromium.org/1530009
2010-03-30 16:01:46 -07:00
Gaurav Shah
7982ed3ae5 Use UINT64_C macros from stdint.h.
Review URL: http://codereview.chromium.org/1587005
2010-03-30 14:01:50 -07:00
Gaurav Shah
d0f3298bb1 Explicitly use the ULL suffix to specify a large constant.
This hopefully fixes the ARM build error.

TBR = wad@chromium.org

Review URL: http://codereview.chromium.org/1591001
2010-03-30 00:37:38 -07:00
Gaurav Shah
e450be4ce4 Propagate use of uint64_t to more functions that may need to deal with arbitrary length data.
This CL fixes some functions to use uint64_t that I missed the first time around. It ended up requiring some minor changes to how some of the helper functions work (StatefulMemcpy*()).

Also adds new tests to make sure that reference code can verify/process big firmware and kernel images.

BUG=670
TEST=Adds some new, old ones still pass.

Review URL: http://codereview.chromium.org/1519008
2010-03-29 21:27:08 -07:00
Gaurav Shah
463be3f135 VBoot Reference: Fix splicing bugs in Firmware and Kernel verification.
BUG=670
TESTS=Adds new tests which verify this doesn't occur anymore. Existing tests still pass.

The existing code computes and verifies signatures on firmware/kernel data and firmware/kernel versions separately. This causes a image splicing bug where it is possible to combine together a version signature from a valid new firmware with firmware data and signature from an older version. The same problem exists with kernel verification.

This CL fixes this by changing the firmware/kernel signatures to also include the version information.

For the Firmware, there's a separate signature on the preamble (which contains the version) but the firmware signature now also includes this preamble in addition to the firmware data.

For the Kernel, there's a separate signature on the kernel config/options (wich also contains the version), but the kernel signature now also includes these config/options in addition to the kernel data.

Review URL: http://codereview.chromium.org/1430001
2010-03-29 16:13:45 -07:00
Gaurav Shah
5b730c4a33 VBoot ReferenceL Add instructions to generate (self-)signed firmware images.
Review URL: http://codereview.chromium.org/1573001
2010-03-29 12:50:09 -07:00
Gaurav Shah
f37ae21b3c Fix benchmark output label.
Review URL: http://codereview.chromium.org/1456002
2010-03-26 13:47:05 -07:00
Gaurav Shah
a82bf268b2 VBoot Reference: Add kernel rollback prevention and choosing logic.
Also adds tests for kernel rollback prevention.

Review URL: http://codereview.chromium.org/1320010
2010-03-26 10:38:08 -07:00
Gaurav Shah
3199eed3d3 Move test utility functions to a common place.
Also removes the dev_mode flag from Firmware Image verification as key signature for the firmware should be checked whether or not dev mode is enabled.

BUG=670
TEST=All tests still pass.

Merge remote branch 'refs/remotes/origin/master' into fixtests

Fix tests, remove dev mode. Move common code.

Review URL: http://codereview.chromium.org/1280002
2010-03-25 13:04:45 -07:00
Gaurav Shah
7853971362 Add another missing header to remove compile time error.
Interestingly, the compile failure is only caused on the buildbot and not my build machine.

Review URL: http://codereview.chromium.org/1239006
2010-03-24 17:13:24 -07:00
Gaurav Shah
0df08373a2 Add missing header.
This should fix the test build problems.

Review URL: http://codereview.chromium.org/1219007
2010-03-24 14:22:41 -07:00
Gaurav Shah
ce0cc30e55 VBoot Reference: Add version checking to for preventing rollbacks.
This CL adds a new function VerifyFirmwareDriver_f() means to be a part of the RO firmware which determine which copy of the firmware to boot from. It is meant to ensure that a particular firmware is only booted if 1) it verifies successfully, 2) its version is newer or equal to current stored version. In addition, the driver function also updates the stored version if needed.

Currently I am using the TLCL API with stub calls, (in fact, most of the TPM interaction is done in rollback_index.c which implements the actual version query/update API) used by the firmware.

Review URL: http://codereview.chromium.org/1241002
2010-03-24 13:48:55 -07:00
Gaurav Shah
1e56693763 Fix test return values (otherwise, autotest mistakenly thinks it failed).
Review URL: http://codereview.chromium.org/1138006
2010-03-22 18:25:11 -07:00
Gaurav Shah
13937119e6 Vboot Reference: Add kernel image verification benchmark.
Refactor duplicate code for the firmware image benchmark. Also fixes some functions that manipulate kernel blobs (use uint64_t instead if int).

Review URL: http://codereview.chromium.org/1079009
2010-03-22 17:59:09 -07:00
Gaurav Shah
e268eefd6a Vboot Reference: Add a firmware verification benchmark.
The benchmark calculates the time taken to verify a firmware image of various sizes for various combinations of signature algorithm. This is meant to be called through autotest.

Review URL: http://codereview.chromium.org/1127007
2010-03-22 16:02:12 -07:00
Gaurav Shah
445925fe0f Vboot Reference: Spring cleaning of test scripts.
Moved duplicated code to "common.sh". Make directory detection more robust.

Review URL: http://codereview.chromium.org/1101004
2010-03-19 16:19:09 -07:00
Gaurav Shah
528a2c113e Add --describe flag to {firmware|kernel}_utility.
This spews out useful information about a verified boot firmware/kernel image. Also adds a helper function to calculate header checksum. That code was being duplicated at multiple places.

Review URL: http://codereview.chromium.org/1088001
2010-03-18 13:10:10 -07:00
Gaurav Shah
ccaa90f735 Add fuzz testing driver programs for kernel and firmware verification.
The driver programs are useful in quick and dirty fuzz testing of the verification code with blind smartfuzzers like Bunny (http://code.google.com/p/bunny-the-fuzzer/).

Also fixes a bug with image generation in kernel_utility.

Tests: All existing tests still pass. VerifyKernel() and VerifyFirmware() can successfully verify images generated by {firmware|kernel}_utility.

Review URL: http://codereview.chromium.org/975007
2010-03-17 20:40:23 -07:00
Gaurav Shah
4f39386902 Add a command line string field to verified boot kernel config image.
Also some cleanup of duplicated code.

BUG=670
TEST=Existing image verification tests still pass.

Review URL: http://codereview.chromium.org/874006
2010-03-12 18:13:24 -08:00
Gaurav Shah
259de40640 VBoot Reference: Fix many memory leaks.
Fix memory leaks found using Valgrind, adds sanity checking to RSAPublicKey parsing code to prevent crazy behavior.

Review URL: http://codereview.chromium.org/858008
2010-03-12 17:42:03 -08:00