blob: 8242fff88d1cef058315191be3dacef5726277a6 [file] [log] [blame]
Gaurav Shah56c9f4d2010-03-03 13:15:53 -08001This directory contains a reference implementation for Chrome OS
2verified boot in firmware.
3
4----------
5Directory Structure
6----------
7
Gaurav Shahef7510f2010-03-31 14:09:31 -07008The source is organized into distinct modules -
Gaurav Shah56c9f4d2010-03-03 13:15:53 -08009
Randall Spangler620c38c2010-06-17 14:45:22 -070010firmware/ - Contains ONLY the code required by the BIOS to validate
11the secure boot components. There shouldn't be any code in here that
12signs or generates images. BIOS should require ONLY this directory to
13implement secure boot. Refer to firmware/README for futher details.
Gaurav Shah56c9f4d2010-03-03 13:15:53 -080014
Randall Spangler620c38c2010-06-17 14:45:22 -070015cgpt/ - Utility to read/write/modify GPT partitions. Much like the
16gpt tool, but with support for Chrome OS extensiosn.
Gaurav Shah56c9f4d2010-03-03 13:15:53 -080017
Randall Spangler620c38c2010-06-17 14:45:22 -070018host/ - Miscellaneous functions used by userland utilities.
Gaurav Shahef7510f2010-03-31 14:09:31 -070019
20utility/ - Utilities for generating and verifying signed
21firmware and kernel images, as well as arbitrary blobs.
22
Gaurav Shah56c9f4d2010-03-03 13:15:53 -080023tests/ - User-land tests and benchmarks that test the reference
24implementation. Please have a look at these if you'd like to
25understand how to use the reference implementation.
26
vbendeb70e95092010-06-14 15:41:27 -070027build/ - a directory where the generated files go to.
28
29--------------------
30Building and testing
31--------------------
32
33The suite can be built on the host or in the chroot environment.
34
35Building on the host could fail if certain packages are not installed. If
36there are host environment build problems due to missing .h files, try
37researching what packages the files belong to and install the missing packages
38before reporting a problem.
39
40To build the software run
41
42make
43
44in the top level directory. The build output is placed in the ./build
45directory.
46
47To run the tests either invoke
48
49RUNTESTS=1 make
50
51in the top level directory or
52
53cd tests
54BUILD=../build make runtests
55
Gaurav Shah56c9f4d2010-03-03 13:15:53 -080056
57----------
58Some useful utilities:
59----------
60
Randall Spangler620c38c2010-06-17 14:45:22 -070061vbutil_key Convert a public key into .vbpubk format
62vbutil_keyblock Wrap a public key inside a signature and checksum
63vbutil_firmware Create a .vblock with signature info for a
64 firmware image
65vbutil_kernel Pack a kernel image, bootloader, and config into
66 a signed binary
Gaurav Shah56c9f4d2010-03-03 13:15:53 -080067
Randall Spangler620c38c2010-06-17 14:45:22 -070068dumpRSAPublicKey Dump RSA Public key (from a DER-encoded X509
69 certificate) in a format suitable for
70 use by RSAVerify* functions in
71 crypto/.
Gaurav Shah56c9f4d2010-03-03 13:15:53 -080072
73verify_data.c Verify a given signature on a given file.
74
75
Gaurav Shahef7510f2010-03-31 14:09:31 -070076
Gaurav Shah5b730c42010-03-29 12:50:09 -070077----------
78Generating a signed firmware image:
79----------
80
81* Step 1: Generate RSA root and signing keys.
82
83# Root key is always 8192 bits.
84$ openssl genrsa -F4 -out root_key.pem 8192
85
86# Signing key can be between 1024-8192 bits.
87$ openssl genrsa -F4 -out signing_key.pem <1024|2048|4096|8192>
88
89Note: The -F4 option must be specified to generate RSA keys with
90 a public exponent of 65535. RSA keys with 3 as a public
91 exponent (the default) won't work.
92
93* Step 2: Generate pre-processed public versions of the above keys using
Gaurav Shahef7510f2010-03-31 14:09:31 -070094 utility/dumpRSAPublicKey
Gaurav Shah5b730c42010-03-29 12:50:09 -070095
96# dumpRSAPublicKey expects an x509 certificate as input.
97$ openssl req -batch -new -x509 -key root_key.pem -out root_key.crt
98$ openssl req -batch -new -x509 -key signing_key.pem -out signing_key.crt
Gaurav Shahef7510f2010-03-31 14:09:31 -070099$ utility/dumpRSAPublicKey root_key.crt > root_key.keyb
100$ utility/dumpRSAPublicKey signing_key.crt > signing_key.keyb
Gaurav Shah5b730c42010-03-29 12:50:09 -0700101
Randall Spangler620c38c2010-06-17 14:45:22 -0700102************** TODO: STUFF PAST HERE IS OUT OF DATE ***************
103
Gaurav Shah5b730c42010-03-29 12:50:09 -0700104At this point we have all the requisite keys needed to generate a signed
105firmware image.
106
107.pem RSA Public/Private Key Pair
108.crt X509 Key Certificate
109.keyb Pre-processed RSA Public Key
110
111
Gaurav Shahef7510f2010-03-31 14:09:31 -0700112* Step 3: Use utility/firmware_utility to generate a signed firmare blob.
Gaurav Shah5b730c42010-03-29 12:50:09 -0700113
Gaurav Shahef7510f2010-03-31 14:09:31 -0700114$ utility/firmware_utility --generate \
Gaurav Shah5b730c42010-03-29 12:50:09 -0700115 --root_key root_key.pem \
116 --firmware_sign_key signing_key.pem \
117 --firmware_sign_key_pub signing_key.keyb \
118 --firmware_sign_algorithm <algoid> \
119 --firmware_key_version 1 \
120 --firmware_version 1 \
121 --in <firmware blob file> \
122 --out <output file>
123
124Where <algoid> is based on the signature algorithm to use for firmware
125signining. The list of <algoid> specifications can be output by running
Gaurav Shahef7510f2010-03-31 14:09:31 -0700126'utility/firmware_utility' without any arguments.
Gaurav Shah5b730c42010-03-29 12:50:09 -0700127
128Note: --firmware_key_version and --firmware_version are part of a signed
129 image and are used to prevent rollbacks to older version. For testing,
130 they can just be set valid values.
131
132
133* Step 4: Verify that this image verifies.
134
Gaurav Shahef7510f2010-03-31 14:09:31 -0700135$ utility/firmware_utility --verify \
Gaurav Shah5b730c42010-03-29 12:50:09 -0700136 --in <signed firmware image>
137 --root_key_pub root_key.keyb
138Verification SUCCESS.
139
140
141Note: The verification functions expects a pointer to the
142 pre-processed public root key as input. For testing purposes,
143 root_key.keyb can be stored in RW part of the firmware. For the
144 final firmware, this will be a fixed public key which cannot be
145 changed and must be stored in RO firmware.
146
147----------
148Generating a signed kernel image:
149----------
150
151The steps for generating a signed kernel image are similar to that of
152a firmware image. Since verification is chained - RO firmware verifies
153RW firmware which verifies the kernel, only the keys change. An additional
154kernel signing key must be generated. The firmware signing generated above
155is the root key equivalent for signed kernel images.