Commit Graph

314 Commits

Author SHA1 Message Date
Bill Richardson
5deb67f225 Make LoadKernel() pass back the kernel partition's UniqueGuid.
LoadKernel already returns the partition number for the selected kernel.
This change makes it also return the GPT Entry's UniqueGuid, which will
eventually be passed to the kernel itself, so the kernel can determine which
of several possible devices it has booted from. It doesn't know for certain
because the BIOS and the kernel may enumerate the devices in a different
order.

BUG=chromium-os:4984

Review URL: http://codereview.chromium.org/3056014
2010-07-23 17:22:25 -07:00
Bill Richardson
e272940ec5 Fix load_kernel_test, add check to LoadKernel to detect bad args.
load_kernel_test was failing because it wasn't setting
params->kernel_buffer_size before calling LoadKernel(). This fixes that,
plus adds some checks to LoadKernel so that it will notice bad params if it
happens again.

Review URL: http://codereview.chromium.org/3060004
2010-07-22 12:23:47 -07:00
Gaurav Shah
553d00ec86 (In the right repository this time.)
Do not directly manipulate global structs. Work on the local copy instead.

In firmware-land, globals are a bad idea.

Review URL: http://codereview.chromium.org/3027011
2010-07-19 19:22:10 -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
vbendeb
b2b0fcc0f6 Introduce ability to change the kernel command line.
After this change vbutil_kernel allows to repack an existing
signed ChromeOS kernel such that the kernel command line is
changed on operator's request.

The new command line parameter is --verbose which causes
--verify to print out current contents of the kernel
command line.

Some refactoring and cleaning were also done:
 - provide a macro to access command line buffer inside
   a kernel blob
 - ReadConfigFile() a new wrapper to preprocess the
   config file.
 - keep the key_block and preamble in the blob when
   unpacking an existing signed kernel for --repack and
   --verify.
 - make --pack expect at least one of the two:
   --config or --keyblock, thus allowing to change the
   command line without replacing anything else in the
   signed kernel image.
 - refactor Verify() to use OldBlob() to preprocess the
   image.

The top level Makefile was changed to allow compiling for debugging.

Build with DEBUG=1 in the make command line to enable gdb debugging and debug printouts. Build with DISABLE_NDEBUG=1 in the make command line to enable cryptolib debug outputs.

BUG=http://code.google.com/p/chromium-os/issues/detail?id=4814

TEST=see below

1. Observe that all unit tests still pass by running

(vboot_reference $) RUNTESTS=1 make

2. On a working DVT system copy the running kernel into a
file using

dd if=/dev/sda2 of=/tmp/dev.kernel

and transfer the file to the host into /tmp/try/dev.kernel

Then create the new config file in /tmp/try/new.conf.txt and run the following commands:
vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
(vboot_reference $) ./build/utility/vbutil_kernel  --verify /tmp/try/dev.kernel  --signpubkey tests/devkeys/kernel_subkey.vbpubk --verbose
Key block:
  Size:                0x4b8
  Data key algorithm:  4 RSA2048 SHA256
  Data key version:    1
  Flags:               7
Preamble:
  Size:                0xfb48
  Header version:      2.0
  Kernel version:      1
  Body load address:   0x100000
  Body size:           0x302000
  Bootloader address:  0x3fe000
  Bootloader size:     0x4000
Body verification succeeded.
Config:
earlyprintk=serial,ttyS0,115200 console=ttyS0,115200 init=/sbin/init add_efi_memmap boot=local rootwait ro noresume noswap i915.modeset=1 loglevel=7 cros_secure root=/dev/sd%D%P dm_verity.error_behavior=2 dm_verity.max_bios=1024 dm="0 2097152 verity ROOT_DEV HASH_DEV 2097152 1 sha1 a7fbd641ba25488509987959d5756d802790ef8f" noinitrd

(vboot_reference $)   ./build/utility/vbutil_kernel  --repack /tmp/try/dev.kernel.repacked  --signprivate tests/devkeys/kernel_data_key.vbprivk  --oldblob /tmp/try/dev.kernel --config /tmp/try/new.conf.txt
(vboot_reference $)  ./build/utility/vbutil_kernel  --verify /tmp/try/dev.kernel.repacked  --signpubkey tests/devkeys/kernel_subkey.vbpubk --verbose
Key block:
  Size:                0x4b8
  Data key algorithm:  4 RSA2048 SHA256
  Data key version:    1
  Flags:               7
Preamble:
  Size:                0xfb48
  Header version:      2.0
  Kernel version:      1
  Body load address:   0x100000
  Body size:           0x302000
  Bootloader address:  0x3fe000
  Bootloader size:     0x4000
Body verification succeeded.
Config:
console=tty2 init=/sbin/init add_efi_memmap boot=local rootwait ro noresume noswap i915.modeset=1 loglevel=7 cros_secure root=/dev/sd%D%P dm_verity.error_behavior=2 dm_verity.max_bios=1024 dm="0 2097152 verity ROOT_DEV HASH_DEV 2097152 1 sha1 ff06384015a7726baff719ee68eab312b1d45570" noinitrd
(vboot_reference $)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Observe the chanegd command line printed by --verify --verbose. Then transfer the new kernel image back to the DVT system, dd it into /dev/sda2 and restart the DVT system.

Observe kernel startup messages dumped on the screen (due to the changed kernel command line).

Then examine /proc/cmdline to verify that the command line indeed matches the contents of /tmp/try/new.conf.txt on the host.

3. Build the code with

(vboot_reference$) DEBUG=1 make

 observe that debug information is visible by gdb.

  Build the code with

(vboot_reference$) DISABLE_DEBUG=1 make

and observe that  -DNDEBUG is dropped from the compiler invocation line.

Review URL: http://codereview.chromium.org/3004001
2010-07-15 15:09:47 -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
Mandeep Singh Baines
64aec24de8 Make optional flag optional
Change-Id: I022a0bdf58b4884b0bc8c640b6b543e419743fd1

Review URL: http://codereview.chromium.org/2959005
2010-07-09 17:41:41 -07:00
Gaurav Shah
2abbc4b6fd Add an optional flag argument to load_kernel_test.
Review URL: http://codereview.chromium.org/2905006
2010-07-09 14:56:50 -07:00
Louis Yung-Chieh Lo
783e64e70e load_kernel_test tests the recovery image now (submit for Bill)
See original CL here: http://codereview.chromium.org/2803033/show

Review URL: http://codereview.chromium.org/2830038
2010-07-05 13:06:19 +08:00
Randall Spangler
ceef83f9e3 vbutil_firmware uses .vbprivk
Review URL: http://codereview.chromium.org/2812042
2010-07-02 13:14:42 -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
Will Drewry
46186faf46 utility: add a simple tool for dumping the kernel config
Adds dump_kernel_config.c which takes in a file, reads it
all in to memory, then walks the blob until it can determine
the location of the kernel command line.

This is needed to allow the kernel config to inform legacy bootloader
configuration during autoupdates without packaging up dm-verity specific
options in some additional update metadata.

TEST=manual run over build_kernel_image.sh output
BUG=chromium-os:327

Review URL: http://codereview.chromium.org/2811029
2010-06-25 13:40:43 -05: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
Bill Richardson
249677d0ad Add some debug output to vbutil_kernel, display values in hex.
Review URL: http://codereview.chromium.org/2859019
2010-06-23 11:16:37 -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
Randall Spangler
f302905224 Move all system includes in vboot_firmware to sysincludes.h
This makes it much easier to port vboot_firmware to platforms (such as
UEFI) which don't have the standard include files; only sysincludes.h
needs to be altered.

Review URL: http://codereview.chromium.org/2833012
2010-06-16 13:42: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
vbendeb
2a0155663e One of the last moment mods of the original make rework
CL (http://codereview.chromium.org/2845001) resulted in broken
dependencies.

This CL completes the modification (the trick is to ensure
that the default target is always the first).

Note that the tests subdirectory Makefile still does not
properly follow the dependencies, it will have to be
addressed in a separate CL.

Tested by touching different .h and .c files and observing the results.

Review URL: http://codereview.chromium.org/2819004
2010-06-16 12:49:31 -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
695cd16f13 Add load_kernel2_test
Add debug messages to LoadKernel2()

Review URL: http://codereview.chromium.org/2800007
2010-06-15 23:38:23 -07:00
vbendeb
c5e5f4ef55 The code compiled fine on the desktop, but causes a warning in the chroot environment, which in turn causes make to stop.
The fix is to use an explicit format statement.

Tested in chroot environment for x86-generic - was failing before the fix and passes after the fix.

TBR: msb

Review URL: http://codereview.chromium.org/2808009
2010-06-15 18:54:26 -07:00
vbendeb
e3b4ac96bc Rough first draft of the firmware signing utility.
Based on utility/vbutil_kernel.c.

Should be merged with it eventually. Not really tested either, suggesting to submit it just to have a baseline for the verified boot chain.

Review URL: http://codereview.chromium.org/2792014
2010-06-15 15:01:20 -07:00
Randall Spangler
dcab8fab94 Add vbutil_firmware
Review URL: http://codereview.chromium.org/2837005
2010-06-15 14:50:51 -07:00
Randall Spangler
81d696f394 fix typos in load_kernel_test
Review URL: http://codereview.chromium.org/2820004
2010-06-14 17:23: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
Gaurav Shah
5173426100 Add option to specify a kernel subkey signing key to firmware signing utility.
If no kernel subkey signing key is specified, it reuses the firmware signing key.

Review URL: http://codereview.chromium.org/2696003
2010-06-08 00:16:35 -07:00
Bill Richardson
77d26e5190 Enable attributes to display and set properly.
Review URL: http://codereview.chromium.org/2614002
2010-06-04 12:26:42 -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
Hung-Te Lin
08dc5f381d Add 'recovery_key' in Google Binary Block (GBB) utility
Review URL: http://codereview.chromium.org/2553001
2010-06-03 14:35:47 -07:00
Randall Spangler
19d1313735 fixed VerifyKernelHeader
removed extra debugging
fixed printf() format specifiers

Review URL: http://codereview.chromium.org/2561001
2010-06-03 09:43:43 -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
Hung-Te Lin
21ef1a3678 Refine gbb_utility for better maintainance
* now -g (get mode) becomes default
 * properties are now managed in a more generalized way so adding new property would be more easy

Review URL: http://codereview.chromium.org/2549001
2010-06-02 18:13:47 -07:00
Randall Spangler
b8976b6d44 Remove load_kernel from build
Review URL: http://codereview.chromium.org/2535001
2010-06-02 16:38:33 -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
Bill Richardson
5374a06114 Add cgpt utility to installable binaries.
Review URL: http://codereview.chromium.org/2490001
2010-06-02 08:23:30 -07:00
Louis Yung-Chieh Lo
e6cf857685 cgpt supports dev and add/delete/modify commands.
Review URL: http://codereview.chromium.org/2374001
2010-05-29 18:54:25 +08:00
Gaurav Shah
67660cda7a Add --subkey_in and --subkey_out options to firmware signing utility.
With this change, just like the kernel signing utility, the firmware signing utility now supports outputting the key signature (subkey) header and reusing it to generate new signed firmware images without requiring the root key (assuming the firmware signing key doesn't change).

Also, some minor comment fixes I missed the last time around.

Review URL: http://codereview.chromium.org/2366004
2010-05-29 01:58:07 -07:00
Gaurav Shah
f666780e86 Add --subkey_in option to kernel signing utility.
This allows for using an existing key signature (subkey) header to generate new signed images if the kernel signing is unchanged. This obviates the need to take out the firmware private key each time a new signed kernel image is generated.

A similar change will also be propagated to the firmware signing utility. We would REALLY like to reduce the need to take out the verified boot private root key (used for generating R/W firmware key signature headers) everytime we generate a new signed R/W firmware image.

Review URL: http://codereview.chromium.org/2372001
2010-05-28 11:47:33 -07:00
Gaurav Shah
2a9c66cd71 Cleanup option parsing for firmware signing utility.
This is basically the same as Bill's changes for kernel_utility.

Review URL: http://codereview.chromium.org/2322003
2010-05-28 11:42:48 -07:00
Hung-Te Lin
262668fcf3 Added gbb_utility (tool for Google Binary Block)
Review URL: http://codereview.chromium.org/2346001
2010-05-28 10:32:02 -07:00
Bill Richardson
4052c3e3b8 random cleanup
Review URL: http://codereview.chromium.org/2353001
2010-05-27 18:16:09 -07:00
Bill Richardson
82e0860e6d need to chmod binaries
Review URL: http://codereview.chromium.org/2325002
2010-05-27 18:03:32 -07:00