Commit Graph

301 Commits

Author SHA1 Message Date
Bill Richardson
4f36ef3360 Changes to allow user-signed kernels to be generated.
Make vbutil_keyblock handle unsigned blocks. Also enable --unpack option and
add tests for it.

Modify vbutil_kernel to allow unsigned keyblocks, correct usage message,
and fix the --debug option which was somehow disabled.

Update load_kernel_test to accept /dev/null for the public key, to test
non-signed kernel keyblocks.

Review URL: http://codereview.chromium.org/3124004
2010-08-09 17:50:14 -07:00
Luigi Semenzato
fda9488f97 Utility to run the self test before we can run tcsd.
Also test of the effects of the self test.

Review URL: http://codereview.chromium.org/3077016
2010-08-04 11:51:13 -07:00
Luigi Semenzato
50d48feb9e Various bug fixes to tpm_lite. Some changes to the test suite.
Review URL: http://codereview.chromium.org/3091004
2010-08-04 08:35:12 -07:00
Gaurav Shah
9b16a66b9b Modify the key generation script and add an installer keyblock to the dev keys.
BUG=none
TEST=none

Review URL: http://codereview.chromium.org/3018024
2010-07-28 16:24:26 -07:00
Randall Spangler
87c13d806b Added size param to VerifyData()
Also renamed verify preamble functions, now that they do not need the
'2' at the end to differentiate them from the now-deleted original
implementation.

BUG=4501
TEST=Ran make runtests; all pass.

Review URL: http://codereview.chromium.org/3027009
2010-07-19 10:35:40 -07:00
Randall Spangler
3e1081fb71 Add lots of debugging to TPM library.
Temporarily disable TPM in developer mode.

Review URL: http://codereview.chromium.org/3041005
2010-07-19 10:04:21 -07:00
Randall Spangler
39f66114c0 Add tpm lite to vboot reference
Review URL: http://codereview.chromium.org/2919010
2010-07-14 09:10:23 -07:00
Luigi Semenzato
18b814d9bc New targets to compile and install rollback tests only with USE=rbtest emerge ...
Review URL: http://codereview.chromium.org/2962002
2010-07-08 17:17:02 -07:00
Luigi Semenzato
8510d919f9 Replace TlclDefineSpace with SafeDefineSpace for extra paranoia.
Review URL: http://codereview.chromium.org/2937001
2010-07-08 15:40:30 -07:00
Randall Spangler
93bccfc452 Fix makefiles to work with ebuild
Review URL: http://codereview.chromium.org/2951002
2010-07-08 15:26:35 -07:00
Randall Spangler
c9f917bfd0 Don't build rollback index test as part of 'all', since it depends on the real tlcl.
It'll still be built as part of 'make install'.

Review URL: http://codereview.chromium.org/2947002
2010-07-08 15:11:07 -07:00
Luigi Semenzato
416f681882 This test sets the TPM to a each of a large amount of "interesting" initial states, and runs the firmware code at user level.
This code compiles and installs using a modified ebuild (which needs to be committed after this change).

Review URL: http://codereview.chromium.org/2857030
2010-07-08 12:12:12 -07:00
Bill Richardson
9396c1050d Adding new directory with developer signing keys.
The keys in this directory are just like the official release keys, except
that they're not secret.

Review URL: http://codereview.chromium.org/2883018
2010-07-01 15:51:05 -07:00
Bill Richardson
abf0550458 Switch to using .vbprivk for signing everything now.
This makes it much simpler to keep track of what we're doing.

vbutil_key can now wrap both .keyb and .pem keys. It figures out which is
which by trying both and just using the one that works.

vbutil_keyblock and vbutil_kernel now use .vbprivk files for signing.

replace debug() with VBDEBUG(()) in host-side sources, too.

rename PrivateKeyRead to PrivateKeyReadPem

Add real PrivateKeyRead and PrivateKeyWrite for .vbprivk files.

Review URL: http://codereview.chromium.org/2871033
2010-07-01 10:22:06 -07:00
Bill Richardson
a08b5c9d03 Adding --repack and --headeronly options to vbutil_kernel
The --repack option lets us sign a previously signed kernel blob with a new
kernel data key.

The --headeronly option is so we can emit the new verification header
separately from the kernel blob.

More work to come...

Review URL: http://codereview.chromium.org/2812034
2010-06-30 21:59:43 -07:00
Gaurav Shah
bde9a64357 Fix name. Use existing directory check.
Review URL: http://codereview.chromium.org/2805051
2010-06-29 19:46:39 -07:00
Gaurav Shah
0ec7078d5b Rewrite gen_fuzz_test_cases.sh script to use new signing utilities.
TEST=Generated images verify successfully using right keys.

Review URL: http://codereview.chromium.org/2836036
2010-06-29 19:46:11 -07:00
Gaurav Shah
4d78d9a4fb Add a script to generate test vboot-format public keys.
Also add .vpubks for the existing test keys.

TEST=Ran the script.

Review URL: http://codereview.chromium.org/2873033
2010-06-29 17:29:18 -07:00
vbendeb
3ecaf776d8 Make vboot_reference build in MSVC command line environment.
This is a mostly NOOP change which modifies the source code
to compile cleanly in the MSVC command line build
environment.

A new makefile is introduced (msc/nmakefile) along with a
README.txt in the same directory explaining how to build
the code in the DOS window. As of this submission the build
is running in a 32 bit environment, the intention is to use
the same makefile for 64 bit builds in the future.

Enabling high compilation warnings level allowed to
identify a couple of bugs in the code which are being fixed.

Not all sources are being compiled in the MSVC environment,
only those in firmware/ and most of those in test/
subdirectories. The benchmark calculations require porting
of the timer facilities and are being postponed.

TEST

Built in DOS and linux environments. Ran unit tests in
linux environment.

Review URL: http://codereview.chromium.org/2809037
2010-06-24 16:19:53 -07:00
Randall Spangler
81d0996901 Assorted integration fixes.
MSVC does not like bitfields with extra bits in them, so it made the GptEntry struct too big.

Fixed a missing return value in LoadFirmware().

Added some debug output.

Fixed calls to SetupTPM().

Tested with 'make && make runtests'.  No errors.

Review URL: http://codereview.chromium.org/2865014
2010-06-23 10:15:38 -07:00
vbendeb
f7a45cc01d Reduce attributes size to comply with msc limitations.
It turned out that shared verified boot library fails to
work properly when compiled by msc in BIOS environment.

The culprit was identified as failing 64 bit logical
operations by preprocessor. It is probably possible to
come up with a certain compile flag set to fix the
operations, but it is not easy to modify and control the BIOS
compilation environment.

The alternative solution is to limit the size of the field
in question to 16 bits (especially since this is the only
part of the attributes field which is supposed to be
altered by firmware.

A union is being introduced in firmware/lib/cgptlib/include/gpt.h:GptEntry to allow
accessing the field both as a 64 bit entity and a top
16 bit field. All places where this field is used are
being modified appropriately.

tests/Makefile is being fixed to allow controlling test run
from the top level directory.

Tested by building everything and running tests.
All tests pass.

Review URL: http://codereview.chromium.org/2799019
2010-06-21 08:44:16 -07:00
Randall Spangler
620c38cf34 Remove unused files, and tidy the directory structure of the remaining ones.
Review URL: http://codereview.chromium.org/2815011
2010-06-17 14:45:22 -07:00
vbendeb
cae179aaf9 This CL makes sure that the tests dirctory Makefile works
properly, i.e. rebuild relevant targets if any of the
dependencies (implicit or explicit) change.

To make dependency generation easier the three source files
in the tests directory shared among many programs
(rollback_index_mock.c test_common.c timer_utils.c and
crc32_test.c) are separated into a library, with each of
them getting its own the automated dependency script
generated by the compiler.

To simplify rule definitions, all applications built in the
test directory get linked with -lcrypto and -lrt, which is
not a problem as the linker will not use the library unless
needed.

Tested by touching different .h and .c files in ./tests,
running make and then and observing the make results.

Also verified that emerging works for x86 in chroot environment.

Review URL: http://codereview.chromium.org/2847012
2010-06-16 13:56:58 -07:00
Randall Spangler
bd529f05dd Move old vkernel code out of vboot_firmware.
It will go away entirely once the build has moved to vboot_kernel.

Review URL: http://codereview.chromium.org/2866006
2010-06-16 12:51:26 -07:00
Randall Spangler
d471f2a839 Remove old firmware verification code, now that firmware build has switched to the new algorithms.
Review URL: http://codereview.chromium.org/2835006
2010-06-16 12:05:10 -07:00
Randall Spangler
39ed88efe9 Implemented pipelined hash calculation in LoadFirmware()
Review URL: http://codereview.chromium.org/2802002
2010-06-15 14:53:01 -07:00
Luigi Semenzato
2666f10dec Fix normal/recovery mode, and RO firmware vs. RW firmware behavior.
Review URL: http://codereview.chromium.org/2792009
2010-06-15 08:12:32 -07:00
vbendeb
70e9509a27 Rework the vboot_reference make system.
After this change the generated files are placed in a
separate tree (such thet they don't show in the
`git status' output anymore) and the dependencies are
followed properly (if a .h file changes the
appropriate .o files and apps get rebuilt).

Tested as follows:

> $ make clean
> $ make # build succeeds
> $ git status # shows clean directory
> $ RUNTESTS=1 make # (captured test output matches that of the test run before any changes)
> $ touch ./vboot_firmware/include/tlcl.h
> $ make  # make succeeds
> $ find build -type f -newer ./vboot_firmware/include/tlcl.h
build/vboot_firmware/lib/rollback_index.o
build/vboot_firmware/lib/rollback_index.o.d
build/vboot_firmware/a.out
build/vboot_fw.a
build/utility/vbutil_key
build/utility/kernel_utility.d
build/utility/vbutil_key.d
build/utility/verify_data
build/utility/load_kernel_test.d
build/utility/vbutil_keyblock.d
build/utility/vbutil_kernel
build/utility/vbutil_kernel.d
build/utility/firmware_utility
build/utility/signature_digest_utility.d
build/utility/kernel_utility
build/utility/verify_data.d
build/utility/vbutil_keyblock
build/utility/signature_digest_utility
build/utility/load_kernel_test
build/utility/firmware_utility.d
build/tests/vboot_common3_tests
build/tests/vboot_common2_tests
build/host/a.out
$ >

Review URL: http://codereview.chromium.org/2845001
2010-06-14 15:41:27 -07:00
Randall Spangler
729b87258b Clean up of key block functions
No substantial new code, just making the old code consistent.

Review URL: http://codereview.chromium.org/2729021
2010-06-11 11:16:20 -07:00
Randall Spangler
7d6898dbaa Added vbutil_kernel.
Review URL: http://codereview.chromium.org/2730011
2010-06-11 09:22:13 -07:00
Bill Richardson
f1372d9109 Nearly complete rewrite of cgpt tool.
This fixes a number of bugs, adds a bunch of commands, and essentially makes
cgpt ready to use as a replacement for gpt. Still to do is to add commands
and options that will let it generated intentionally bad partitions, for use
in testing.

Review URL: http://codereview.chromium.org/2719008
2010-06-11 09:15:55 -07:00
Randall Spangler
6a97b3e2a1 Add vbutil_keyblock
Review URL: http://codereview.chromium.org/2748008
2010-06-10 17:55:02 -07:00
Randall Spangler
d55c645372 Utility to pack public key, version, algorithm into a single file in VbPublicKey format
Review URL: http://codereview.chromium.org/2762009
2010-06-10 12:43:51 -07:00
Randall Spangler
d183644564 Major refactoring of structures, with unit tests. This matches the doc I sent out earlier.
Firmware-side code for LoadKernel() is in place now.  LoadFirmware() replacement coming soon.

The new functions are implemented in parallel to the existing ones (i.e., everything that used to work still does).

Review URL: http://codereview.chromium.org/2745007
2010-06-10 09:59:04 -07:00
Luigi Semenzato
59204c57d0 Import recent tpm_lite changes that make all TPM commands return a status.
Review URL: http://codereview.chromium.org/2711006
2010-06-09 13:37:15 -07:00
Randall Spangler
4a7a9e3925 Uses TPM return codes.
Rollback_index funcs now all return 0 if succcess, nonzero if error.
(Note: not fully implemented; Luigi, please clean this up in a
subsequent CL)

LoadKernel() checks return codes from TPM funcs.

LoadKernel() only looks at versions from TPM in normal boot mode.

Review URL: http://codereview.chromium.org/2735004
2010-06-08 15:44:24 -07:00
Bill Richardson
31066a4515 Ignore the AlternateLBA field in the GPT headers.
We know where to look, and we'll look there regardless. We don't care where
the header creator thinks it should be.

Update tests to match.

Oh, and don't assume that I mean "/dev/FOO" if I just say "FOO". That's
really annoying.

Review URL: http://codereview.chromium.org/2606002
2010-06-03 15:20:19 -07:00
Gaurav Shah
9592919196 Add a kernel subkey signing algorithm key and algorithm fields to firmware preamble.
Review URL: http://codereview.chromium.org/2589001
2010-06-03 11:11:33 -07:00
Gaurav Shah
d4f13e3580 Remove obsolete VerifyKernelDriver() and associated data structures.
The kernel rollback test needs to be rebaselined to use the LoadKernel() (or may combined with load_kernel_test). Will do that as a separate CL when that is close to its final form.

Review URL: http://codereview.chromium.org/2584001
2010-06-03 07:50:50 -07:00
Gaurav Shah
e642198b93 Add a Makefile target to run all vboot_reference tests.
Review URL: http://codereview.chromium.org/2561003
2010-06-03 07:49:32 -07:00
Colin Chow
afdd058ebc fix int reference to unint64 from http://codereview.chromium.org/2438005
Review URL: http://codereview.chromium.org/2550001
2010-06-02 18:20:59 -07:00
Randall Spangler
3dcf9dce04 Much rearranging of cgptlib. Passes all its (new) unit tests.
Also includes part of LoadKernel(), which I'll split into a separate
CL.  With some hacks, gets into VerifyKernel() before dying because
I'm not passing in the right key blob.

cgptlib is now pretty stable, and worth looking at.  LoadKernel() less so.

Thanks,
   Randall

Review URL: http://codereview.chromium.org/2438005
2010-06-02 12:46:17 -07:00
Luigi Semenzato
52a8d2df06 Add recovery mode protection to new NVRAM locking scheme.
Also fix the TPM initialization.

Review URL: http://codereview.chromium.org/2344002
2010-05-28 10:34:31 -07:00
Luigi Semenzato
596b64052e New anti-rollback strategy (no TPM NVRAM write cycles for locking).
Review URL: http://codereview.chromium.org/2225005
2010-05-27 14:04:52 -07:00
Bill Richardson
f5db4b86fa Modifying the kernel_utility tool to create our magic blob.
For the --generate operation, the --in <file> option is gone and there are
three new required options:

  --vmlinuz <file>         Embedded kernel image
  --config <file>          Embedded kernel command-line parameters
  --bootloader <file>      Embedded bootloader stub

This takes the specified kernel, extracts the 32-bit component, and combines
that with the configuration file (essentially just the kernel cmdline
string) and the bootstub image . The resulting blob is signed and ready to
put in a kernel partition.

There's also an optional --padding parameter, to specify how much extra
(unsigned) space to leave between the signature header and the kernel blob.
The default is 0x4000, which is about four times as much needed when using
the largest signature size we currently support.

Review URL: http://codereview.chromium.org/2283005
2010-05-27 11:15:14 -07:00
Randall Spangler
3003c1dd50 Moved cgptlib into vboot_firmware
Moved cgptlib tests into tests

Review URL: http://codereview.chromium.org/2303003
2010-05-27 09:20:11 -07:00
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
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
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