blob: 04ab0c93fc15cadcffe963b66d83161688f5d9c4 [file] [log] [blame]
Gaurav Shah56c9f4d2010-03-03 13:15:53 -08001This directory contains a reference implementation for Chrome OS
2verified boot in firmware.
3
Bill Richardsonbc3f0b72014-09-05 12:40:20 -07004----------
5Directory Structure
Gaurav Shah56c9f4d2010-03-03 13:15:53 -08006----------
7
Gaurav Shahef7510f2010-03-31 14:09:31 -07008The source is organized into distinct modules -
Gaurav Shah56c9f4d2010-03-03 13:15:53 -08009
Bill Richardsonbc3f0b72014-09-05 12:40:20 -070010firmware/
Gaurav Shah56c9f4d2010-03-03 13:15:53 -080011
Bill Richardsonbc3f0b72014-09-05 12:40:20 -070012 Contains ONLY the code required by the BIOS to validate the secure boot
13 components. There shouldn't be any code in here that signs or generates
14 images. BIOS should require ONLY this directory to implement secure boot.
15 Refer to firmware/README for futher details.
Gaurav Shah56c9f4d2010-03-03 13:15:53 -080016
Bill Richardsonbc3f0b72014-09-05 12:40:20 -070017cgpt/
Gaurav Shahef7510f2010-03-31 14:09:31 -070018
Bill Richardsonbc3f0b72014-09-05 12:40:20 -070019 Utility to read/write/modify GPT partitions. Similar to GNU parted or any
20 other GPT tool, but this has support for Chrome OS extensions.
Gaurav Shahef7510f2010-03-31 14:09:31 -070021
Bill Richardsonbc3f0b72014-09-05 12:40:20 -070022host/
Gaurav Shah56c9f4d2010-03-03 13:15:53 -080023
Bill Richardsonbc3f0b72014-09-05 12:40:20 -070024 Miscellaneous functions needed by userland utilities.
25
26futility/
27
28 The "firmware utility" tool, used to create, sign, and validate Chrome OS
29 images.
30
31utility/
32
33 Random other utilities, not necesssarily related to verified boot as such.
34
35tests/
36
37 User-land tests and benchmarks that test the reference implementation.
38 Please have a look at these if you'd like to understand how to use the
39 reference implementation.
40
41build/
42
43 The output directory where the generated files will be placed, and where
44 tests are run.
45
46scripts/
47
48 Tools and scripts used to generate and use new signing keypairs. These are
49 typically used only on a secure machine.
50
vbendeb70e95092010-06-14 15:41:27 -070051
52--------------------
53Building and testing
54--------------------
55
56The suite can be built on the host or in the chroot environment.
57
58Building on the host could fail if certain packages are not installed. If
59there are host environment build problems due to missing .h files, try
60researching what packages the files belong to and install the missing packages
61before reporting a problem.
62
vbendeb70e95092010-06-14 15:41:27 -070063
Bill Richardsonbc3f0b72014-09-05 12:40:20 -070064The commands are the more-or-less expected ones:
vbendeb70e95092010-06-14 15:41:27 -070065
Bill Richardsonbc3f0b72014-09-05 12:40:20 -070066 make
67 make runtests
Bill Richardsonefa87562014-09-11 10:41:51 -070068 make install [ DESTDIR=/usr/local ]
vbendeb70e95092010-06-14 15:41:27 -070069
Gaurav Shah56c9f4d2010-03-03 13:15:53 -080070
Bill Richardsonbc3f0b72014-09-05 12:40:20 -070071
72----------
73Some useful utilities:
Gaurav Shah56c9f4d2010-03-03 13:15:53 -080074----------
75
Bill Richardsonbc3f0b72014-09-05 12:40:20 -070076futility vbutil_key Convert a public key into .vbpubk format
77futility vbutil_keyblock Wrap a public key inside a signature and checksum
78futility vbutil_firmware Create a .vblock with signature info for a
79 firmware image
80futility vbutil_kernel Pack a kernel image, bootloader, and config into
81 a signed binary
Gaurav Shah56c9f4d2010-03-03 13:15:53 -080082
Bill Richardsonbc3f0b72014-09-05 12:40:20 -070083dumpRSAPublicKey Dump RSA Public key (from a DER-encoded X509
84 certificate) in a format suitable for use by
85 RSAVerify* functions in crypto/.
Gaurav Shah56c9f4d2010-03-03 13:15:53 -080086
Bill Richardsonbc3f0b72014-09-05 12:40:20 -070087verify_data.c Verify a given signature on a given file.
Gaurav Shah56c9f4d2010-03-03 13:15:53 -080088
Bill Richardsonbc3f0b72014-09-05 12:40:20 -070089
90
Gaurav Shah5b730c42010-03-29 12:50:09 -070091----------
Bill Richardsonbc3f0b72014-09-05 12:40:20 -070092Generating a signed firmware image:
93----------
94
95* Step 0: Build the tools, install them somewhere.
Gaurav Shah5b730c42010-03-29 12:50:09 -070096
97* Step 1: Generate RSA root and signing keys.
98
Bill Richardsonbc3f0b72014-09-05 12:40:20 -070099 The root key is always 8192 bits.
Gaurav Shah5b730c42010-03-29 12:50:09 -0700100
Bill Richardsonbc3f0b72014-09-05 12:40:20 -0700101 $ openssl genrsa -F4 -out root_key.pem 8192
Gaurav Shah5b730c42010-03-29 12:50:09 -0700102
Bill Richardsonbc3f0b72014-09-05 12:40:20 -0700103 The signing key can be between 1024-8192 bits.
104
105 $ openssl genrsa -F4 -out signing_key.pem <1024|2048|4096|8192>
106
107 Note: The -F4 option must be specified to generate RSA keys with a public
108 exponent of 65535. RSA keys with 3 as a public exponent (the default)
109 won't work.
Gaurav Shah5b730c42010-03-29 12:50:09 -0700110
111* Step 2: Generate pre-processed public versions of the above keys using
Bill Richardsonbc3f0b72014-09-05 12:40:20 -0700112 dumpRSAPublicKey. This utility expects an x509 certificate as
113 input, and emits an intermediate representation for further
114 processing.
Gaurav Shah5b730c42010-03-29 12:50:09 -0700115
Bill Richardsonbc3f0b72014-09-05 12:40:20 -0700116 $ openssl req -batch -new -x509 -key root_key.pem -out root_key.crt
117 $ openssl req -batch -new -x509 -key signing_key.pem -out signing_key.crt
118 $ dumpRSAPublicKey root_key.crt > root_key.keyb
119 $ dumpRSAPublicKey signing_key.crt > signing_key.keyb
Gaurav Shah5b730c42010-03-29 12:50:09 -0700120
Randall Spangler620c38c2010-06-17 14:45:22 -0700121************** TODO: STUFF PAST HERE IS OUT OF DATE ***************
122
Gaurav Shah5b730c42010-03-29 12:50:09 -0700123At this point we have all the requisite keys needed to generate a signed
124firmware image.
125
126.pem RSA Public/Private Key Pair
127.crt X509 Key Certificate
128.keyb Pre-processed RSA Public Key
129
130
Gaurav Shahef7510f2010-03-31 14:09:31 -0700131* Step 3: Use utility/firmware_utility to generate a signed firmare blob.
Gaurav Shah5b730c42010-03-29 12:50:09 -0700132
Gaurav Shahef7510f2010-03-31 14:09:31 -0700133$ utility/firmware_utility --generate \
Gaurav Shah5b730c42010-03-29 12:50:09 -0700134 --root_key root_key.pem \
135 --firmware_sign_key signing_key.pem \
136 --firmware_sign_key_pub signing_key.keyb \
137 --firmware_sign_algorithm <algoid> \
138 --firmware_key_version 1 \
139 --firmware_version 1 \
140 --in <firmware blob file> \
141 --out <output file>
142
Bill Richardsonbc3f0b72014-09-05 12:40:20 -0700143Where <algoid> is based on the signature algorithm to use for firmware
Gaurav Shah5b730c42010-03-29 12:50:09 -0700144signining. The list of <algoid> specifications can be output by running
Gaurav Shahef7510f2010-03-31 14:09:31 -0700145'utility/firmware_utility' without any arguments.
Gaurav Shah5b730c42010-03-29 12:50:09 -0700146
Bill Richardsonbc3f0b72014-09-05 12:40:20 -0700147Note: --firmware_key_version and --firmware_version are part of a signed
Gaurav Shah5b730c42010-03-29 12:50:09 -0700148 image and are used to prevent rollbacks to older version. For testing,
Bill Richardsonbc3f0b72014-09-05 12:40:20 -0700149 they can just be set to valid values.
Gaurav Shah5b730c42010-03-29 12:50:09 -0700150
151
152* Step 4: Verify that this image verifies.
153
Gaurav Shahef7510f2010-03-31 14:09:31 -0700154$ utility/firmware_utility --verify \
Gaurav Shah5b730c42010-03-29 12:50:09 -0700155 --in <signed firmware image>
156 --root_key_pub root_key.keyb
157Verification SUCCESS.
158
159
160Note: The verification functions expects a pointer to the
161 pre-processed public root key as input. For testing purposes,
162 root_key.keyb can be stored in RW part of the firmware. For the
163 final firmware, this will be a fixed public key which cannot be
164 changed and must be stored in RO firmware.
165
Bill Richardsonbc3f0b72014-09-05 12:40:20 -0700166----------
167Generating a signed kernel image:
Gaurav Shah5b730c42010-03-29 12:50:09 -0700168----------
169
170The steps for generating a signed kernel image are similar to that of
171a firmware image. Since verification is chained - RO firmware verifies
172RW firmware which verifies the kernel, only the keys change. An additional
173kernel signing key must be generated. The firmware signing generated above
174is the root key equivalent for signed kernel images.