blob: 19a95a4078b145fc2f9797007ced147ba056bbac [file] [log] [blame]
Clay Murphyfcf8f182015-03-11 22:43:31 -07001page.title=Verifying Boot
Clay Murphy0d596682014-10-23 12:06:03 -07002@jd:body
3
4<!--
Clay Murphybc8a22a2015-03-02 18:49:17 -08005 Copyright 2015 The Android Open Source Project
Clay Murphy0d596682014-10-23 12:06:03 -07006
7 Licensed under the Apache License, Version 2.0 (the "License");
8 you may not use this file except in compliance with the License.
9 You may obtain a copy of the License at
10
11 http://www.apache.org/licenses/LICENSE-2.0
12
13 Unless required by applicable law or agreed to in writing, software
14 distributed under the License is distributed on an "AS IS" BASIS,
15 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 See the License for the specific language governing permissions and
17 limitations under the License.
18-->
19<div id="qv-wrapper">
20 <div id="qv">
21 <h2>In this document</h2>
22 <ol id="auto-toc">
23 </ol>
24 </div>
25</div>
Clay Murphy0d596682014-10-23 12:06:03 -070026
Clay Murphybc8a22a2015-03-02 18:49:17 -080027<h2 id=objective>Objective</h2>
28<p>Verified boot guarantees the integrity of the device software starting from a
29hardware root of trust up to the system partition. During boot, each stage
30verifies the integrity and authenticity of the next stage before executing it.</p>
Clay Murphy0d596682014-10-23 12:06:03 -070031
Clay Murphybc8a22a2015-03-02 18:49:17 -080032<p>This capability can be used to warn users of unexpected changes to the
33software when they acquire a used device, for example. It will also provide an
34additional signal of device integrity for remote attestation, and together with
35encryption and Trusted Execution Environment (TEE) root of trust binding, adds
36another layer of protection for user data against malicious system software.</p>
Clay Murphy0d596682014-10-23 12:06:03 -070037
Clay Murphybc8a22a2015-03-02 18:49:17 -080038<p>Note that if verification fails at any stage, the user must be visibly
39notified and always be given an option to continue using the device at
40their own discretion.</p>
Clay Murphy0d596682014-10-23 12:06:03 -070041
Clay Murphybc8a22a2015-03-02 18:49:17 -080042<h2 id=glossary>Glossary</h2>
Clay Murphy0d596682014-10-23 12:06:03 -070043
Clay Murphye25f9da2015-05-18 14:57:31 -070044<p class="table-caption" id="table1">
45 <strong>Table 1.</strong> Glossary of terms related to verified boot</p>
46
Clay Murphybc8a22a2015-03-02 18:49:17 -080047<table>
48 <tr>
49 <td>
50<p><strong>Term</strong></p>
51</td>
52 <td>
53<p><strong>Definition</strong></p>
54</td>
55 </tr>
56 <tr>
57 <td>
58<p>Boot state</p>
59</td>
60 <td>
61<p>The boot state of the device describes the level of protection provided to the
62end user if the device boots. Boot states are GREEN, YELLOW, ORANGE, and RED.</p>
63</td>
64 </tr>
65 <tr>
66 <td>
67<p>Device state</p>
68</td>
69 <td>
70<p>The device state indicates how freely software can be flashed to the device.
Clay Murphye25f9da2015-05-18 14:57:31 -070071Device states are LOCKED and UNLOCKED.</p>
Clay Murphybc8a22a2015-03-02 18:49:17 -080072</td>
73 </tr>
74 <tr>
75 <td>
76<p>dm-verity</p>
77</td>
78 <td>
79<p>Linux kernel driver for verifying the integrity of a partition at runtime using
80a hash tree and signed metadata.</p>
81</td>
82 </tr>
83 <tr>
84 <td>
85<p>Keystore</p>
86</td>
87 <td>
Clay Murphy0d596682014-10-23 12:06:03 -070088<p>A keystore is a signed collection of public keys.</p>
Clay Murphybc8a22a2015-03-02 18:49:17 -080089</td>
90 </tr>
91 <tr>
92 <td>
93<p>OEM key</p>
94</td>
95 <td>
96<p>The OEM key is a fixed, tamper-protected key available to the bootloader that
97must be used to verify the boot image.</p>
98</td>
99 </tr>
Clay Murphybc8a22a2015-03-02 18:49:17 -0800100</table>
Clay Murphy0d596682014-10-23 12:06:03 -0700101
Clay Murphybc8a22a2015-03-02 18:49:17 -0800102<h2 id=overview>Overview</h2>
Clay Murphy0d596682014-10-23 12:06:03 -0700103
Clay Murphybc8a22a2015-03-02 18:49:17 -0800104<p>In addition to device state - which already exists in devices and controls
105whether the bootloader allows new software to be flashed - we introduce the
Clay Murphye25f9da2015-05-18 14:57:31 -0700106concept of boot state that indicates the state of device integrity.</p>
107
108<h3 id=classes>Classes</h3>
109
110<p>We define two implementation classes for verified boot depending on how
111fully the device implements this specification, as follows:</p>
112
113<p><strong>Class A</strong> implements verified boot with full chain of trust
114up to verified partitions. This implementation must support the LOCKED device
115state, and GREEN and RED boot states.</p>
116
117<p><strong>Class B</strong> implements Class A and additionally supports the
118UNLOCKED device state and the ORANGE boot state.</p>
Clay Murphy0d596682014-10-23 12:06:03 -0700119
Clay Murphybc8a22a2015-03-02 18:49:17 -0800120<h3 id=verification_keys>Verification keys</h3>
Clay Murphy0d596682014-10-23 12:06:03 -0700121
Clay Murphybc8a22a2015-03-02 18:49:17 -0800122<p>Bootloader integrity must be verified using a hardware root of trust. For
Clay Murphye25f9da2015-05-18 14:57:31 -0700123verifying boot and recovery partitions, the bootloader must have a fixed OEM key
124available to it. It must always attempt to verify the boot partition using the OEM
125key first and try other possible keys only if this verification fails.</p>
Clay Murphy0d596682014-10-23 12:06:03 -0700126
Clay Murphye25f9da2015-05-18 14:57:31 -0700127<p>In Class B implementations, it must be possible for the user to flash
128software signed with other keys when the device is UNLOCKED. If the device is
129then LOCKED and verification using the OEM key fails, the bootloader must try
130verification using the certificate embedded in the partition signature.
131However, using a partition signed with anything other than the OEM key must
132result in a notification or a warning, as described below.</p>
Clay Murphy0d596682014-10-23 12:06:03 -0700133
Clay Murphybc8a22a2015-03-02 18:49:17 -0800134<h3 id=boot_state>Boot state</h3>
Clay Murphy0d596682014-10-23 12:06:03 -0700135
Clay Murphybc8a22a2015-03-02 18:49:17 -0800136<p>A verified device will ultimately boot into one of four states during each boot
137attempt:</p>
Clay Murphy0d596682014-10-23 12:06:03 -0700138
139<ul>
Clay Murphye25f9da2015-05-18 14:57:31 -0700140 <li>GREEN, indicating a full chain of trust extending from the bootloader to
141verified partitions, including the bootloader, boot partition, and all verified
142partitions.
143
144 <li>YELLOW, indicating the boot partition has been verified using the
145embedded certificate, and the signature is valid. The bootloader is required to
146display a notification and the fingerprint of the public key during boot.
147
148 <li>ORANGE, indicating a device may be freely modified. Device integrity is
149left to the user to verify out-of-band. The bootloader must display a warning
150to the user before allowing the boot process to continue.
151
152 <li>RED, indicating the device has failed verification. The bootloader must
153display a warning to the user before allowing the boot process to continue.
Clay Murphy0d596682014-10-23 12:06:03 -0700154</ul>
155
Clay Murphye25f9da2015-05-18 14:57:31 -0700156<p>The recovery partition must also be verified in the exact same way.</p>
Clay Murphybc8a22a2015-03-02 18:49:17 -0800157
Clay Murphye25f9da2015-05-18 14:57:31 -0700158<h3 id=device_state>Device state</h3>
Clay Murphybc8a22a2015-03-02 18:49:17 -0800159
Clay Murphye25f9da2015-05-18 14:57:31 -0700160<p>The device is required to be in one of two states at all times:</p>
Clay Murphybc8a22a2015-03-02 18:49:17 -0800161
Clay Murphye25f9da2015-05-18 14:57:31 -0700162<ol>
163 <li>LOCKED, indicating the device cannot be flashed. A LOCKED device must
164boot into the GREEN, YELLOW, or RED states during any attempted boot.
165
166 <li>UNLOCKED, indicating the device may be flashed freely and is not intended
167to be verified. An UNLOCKED device must always boot to the ORANGE boot state.
168</ol>
Clay Murphy0d596682014-10-23 12:06:03 -0700169
Clay Murphy1b77cc22014-12-17 18:20:06 -0800170<img src="../images/verified_boot.png" alt="Verified boot flow" id="figure1" />
Clay Murphy0d596682014-10-23 12:06:03 -0700171<p class="img-caption"><strong>Figure 1.</strong> Verified boot flow</p>
172
Clay Murphybc8a22a2015-03-02 18:49:17 -0800173<h2 id=detailed_design>Detailed design</h2>
Clay Murphy0d596682014-10-23 12:06:03 -0700174
Clay Murphybc8a22a2015-03-02 18:49:17 -0800175<p>Achieving full chain of trust requires support from both the bootloader and the
Clay Murphye25f9da2015-05-18 14:57:31 -0700176software on the boot partition, which is responsible for mounting further
177partitions. Verification metadata must also be appended to the system partition
178and any additional partitions whose integrity should be verified.</p>
Clay Murphybc8a22a2015-03-02 18:49:17 -0800179
180<h3 id=bootloader_requirements>Bootloader requirements</h3>
181
Clay Murphye25f9da2015-05-18 14:57:31 -0700182<p>The bootloader is the guardian of the device state and is responsible for
183initializing the TEE and binding its root of trust.</p>
Clay Murphybc8a22a2015-03-02 18:49:17 -0800184
185<p>Most importantly, the bootloader must verify the integrity of the boot and/or
186recovery partition before moving execution to the kernel and display the
Clay Murphye25f9da2015-05-18 14:57:31 -0700187warnings specified in the section <a href="#boot_state">Boot state</a>.</p>
Clay Murphybc8a22a2015-03-02 18:49:17 -0800188
Clay Murphye25f9da2015-05-18 14:57:31 -0700189<h4 id=changing_device_state>Changing device state</h4>
Clay Murphybc8a22a2015-03-02 18:49:17 -0800190
191<p>State changes are performed using the <code>fastboot flashing [unlock |
Clay Murphye25f9da2015-05-18 14:57:31 -0700192lock]</code> command. And to protect user data, <strong>all</strong>
Clay Murphybc8a22a2015-03-02 18:49:17 -0800193state transitions require a data wipe. Note the user must be asked for
194confirmation before data is deleted.</p>
Clay Murphy0d596682014-10-23 12:06:03 -0700195
Clay Murphybc8a22a2015-03-02 18:49:17 -0800196<ol>
197 <li>The UNLOCKED to LOCKED transition is anticipated when a user buys a used
Clay Murphy0d596682014-10-23 12:06:03 -0700198development device. As a result of locking the device, the user should have
199confidence that it is in a state produced by the OEM.
Clay Murphy0d596682014-10-23 12:06:03 -0700200
Clay Murphybc8a22a2015-03-02 18:49:17 -0800201 <li>The LOCKED to UNLOCKED transition is expected in the case where a developer
202wishes to disable verification on the device.
Clay Murphybc8a22a2015-03-02 18:49:17 -0800203</ol>
204
205<p>Requirements for <code>fastboot</code> commands that alter device state are listed in the table below:</p>
Clay Murphye25f9da2015-05-18 14:57:31 -0700206
207<p class="table-caption" id="table2">
208 <strong>Table 2.</strong> <code>fastboot</code> commands</p>
209
Clay Murphy0d596682014-10-23 12:06:03 -0700210<table>
Clay Murphybc8a22a2015-03-02 18:49:17 -0800211 <tr>
212 <td>
213<p><strong><code>fastboot</code> command</strong></p>
214</td>
215 <td>
216<p><strong>Requirements</strong></p>
217</td>
218 </tr>
219 <tr>
220 <td>
Clay Murphy4ddf3ad2015-03-18 14:38:41 -0700221<code>
222flashing lock</code></td>
Clay Murphybc8a22a2015-03-02 18:49:17 -0800223 <td>
Clay Murphy0d596682014-10-23 12:06:03 -0700224<ul>
Clay Murphy1c7cdd32015-05-26 12:27:45 -0700225 <li>Wipe data after asking the user for confirmation
Clay Murphy0d596682014-10-23 12:06:03 -0700226 <li>Clear a write-protected bit indicating the device is unlocked
Clay Murphy0d596682014-10-23 12:06:03 -0700227</ul>
Clay Murphybc8a22a2015-03-02 18:49:17 -0800228</td>
229 </tr>
230 <tr>
231 <td>
Clay Murphy4ddf3ad2015-03-18 14:38:41 -0700232<code>
233flashing unlock</code></td>
Clay Murphybc8a22a2015-03-02 18:49:17 -0800234 <td>
Clay Murphy0d596682014-10-23 12:06:03 -0700235<ul>
Clay Murphy1c7cdd32015-05-26 12:27:45 -0700236 <li>Wipe data after asking the user for confirmation
Clay Murphybc8a22a2015-03-02 18:49:17 -0800237 <li>Set a write-protected bit indicating the device is unlocked
Clay Murphy0d596682014-10-23 12:06:03 -0700238</ul>
Clay Murphybc8a22a2015-03-02 18:49:17 -0800239</td>
240 </tr>
241</table>
Clay Murphy0d596682014-10-23 12:06:03 -0700242
Clay Murphybc8a22a2015-03-02 18:49:17 -0800243<p>When altering partition contents, the bootloader must check the bits set by
244the above commands as described in the following table:</p>
Clay Murphye25f9da2015-05-18 14:57:31 -0700245
246<p class="table-caption" id="table3">
247 <strong>Table 3.</strong> <code>fastboot</code> command requirements</p>
248
Clay Murphybc8a22a2015-03-02 18:49:17 -0800249<table>
250 <tr>
251 <td>
252<p><strong><code>fastboot</code> command</strong></p>
253</td>
254 <td>
255<p><strong>Requirements</strong></p>
256</td>
257 </tr>
258 <tr>
259 <td>
Clay Murphy4ddf3ad2015-03-18 14:38:41 -0700260<code>
261flash &lt;partition&gt;</code></td>
Clay Murphybc8a22a2015-03-02 18:49:17 -0800262 <td>
Clay Murphye25f9da2015-05-18 14:57:31 -0700263 <p>If the bit set by <code>flashing unlock</code> is set, flash the
264 partition. Otherwise, do not allow flashing.<p>
Clay Murphybc8a22a2015-03-02 18:49:17 -0800265 </td>
266 </tr>
267</table>
Clay Murphy0d596682014-10-23 12:06:03 -0700268
Clay Murphye25f9da2015-05-18 14:57:31 -0700269<p>The same checks should be performed for any <code>fastboot</code> command
270that can be used to change the contents of partitions.</p>
Clay Murphy0d596682014-10-23 12:06:03 -0700271
Clay Murphye25f9da2015-05-18 14:57:31 -0700272<p class="note"><strong>Note</strong>: Class B implementations must support
273changing device state.</p>
Clay Murphy0d596682014-10-23 12:06:03 -0700274
Clay Murphye25f9da2015-05-18 14:57:31 -0700275<h4 id=binding_tee_root_of_trust>Binding TEE root of trust</h4>
Clay Murphybc8a22a2015-03-02 18:49:17 -0800276
Clay Murphye25f9da2015-05-18 14:57:31 -0700277<p>If TEE is available, the bootloader should pass the following information to
278the TEE to bind the Keymaster root of trust, after partition verification and
279TEE initialization:</p>
Clay Murphy0d596682014-10-23 12:06:03 -0700280
Clay Murphybc8a22a2015-03-02 18:49:17 -0800281<ol>
Clay Murphye25f9da2015-05-18 14:57:31 -0700282 <li>the public key that was used to sign the boot partition
283 <li>the current device state (LOCKED or UNLOCKED)
Clay Murphybc8a22a2015-03-02 18:49:17 -0800284</ol>
Clay Murphy0d596682014-10-23 12:06:03 -0700285
Clay Murphye25f9da2015-05-18 14:57:31 -0700286<p>This changes the keys derived by the TEE. Taking disk encryption as an example,
287this prevents user data from being decrypted when the device state changes.</p>
Clay Murphy0d596682014-10-23 12:06:03 -0700288
Clay Murphybc8a22a2015-03-02 18:49:17 -0800289<p class="note"><strong>Note:</strong> This means if the system software or the
290device state changes, encrypted user data will no longer be accessible as the
291TEE will attempt to use a different key to decrypt the data.</p>
Clay Murphy0d596682014-10-23 12:06:03 -0700292
Clay Murphye25f9da2015-05-18 14:57:31 -0700293<h4 id=booting_into_recovery>Booting into recovery</h4>
Clay Murphy0d596682014-10-23 12:06:03 -0700294
Clay Murphye25f9da2015-05-18 14:57:31 -0700295<p>The recovery partition should be verified in exactly the same manner as the
296boot partition.</p>
297
298<h4 id=comm_boot_state>Communicating boot state</h4>
299
300<p>System software needs to be able to determine the verification status of
301previous stages. The bootloader must specify the current boot state as a
302parameter on the kernel command line (or through the device tree under
303<code>firmware/android/verifiedbootstate</code>) as described in the table
304below:</p>
305
306<p class="table-caption" id="table4">
307 <strong>Table 4.</strong> Kernel command line parameters</p>
308
309<table>
310 <tr>
311 <th>Kernel command line parameter</th>
312 <th>Description</th>
313 </tr>
314 <tr>
315 <td><code>androidboot.verifiedbootstate=green</code></td>
316 <td>Device has booted into GREEN boot state.<br>
317 Boot partition has been verified using the OEM key and it’s valid.</td>
318 </tr>
319 <tr>
320 <td><code>androidboot.verifiedbootstate=yellow</code></td>
321 <td>Device has booted into YELLOW boot state.<br>
322 Boot partition has been verified using the certificate embedded into
323 the signature and it’s valid.</td>
324 </tr>
325 <tr>
326 <td><code>androidboot.verifiedbootstate=orange</code></td>
327 <td>Device has booted into ORANGE boot state.<br>
328 The device is unlocked and no verification has been performed.</td>
329 </tr>
330 <tr>
331 <td><code>androidboot.verifiedbootstate=red</code></td>
332 <td>Device has booted into RED boot state.<br>
333 The device has failed verification.</td>
334 </tr>
335</table>
Clay Murphybc8a22a2015-03-02 18:49:17 -0800336
337<h3 id=boot_partition>Boot partition</h3>
338
Clay Murphye25f9da2015-05-18 14:57:31 -0700339<p>Once execution has moved to the boot partition, the software there is responsible
340for setting up verification of further partitions. Due to its large size, the
341system partition typically cannot be verified similarly to previous parts but must be
342verified as it’s being accessed instead using the dm-verity kernel driver or a
343similar solution.</p>
Clay Murphybc8a22a2015-03-02 18:49:17 -0800344
Clay Murphye25f9da2015-05-18 14:57:31 -0700345<p>If dm-verity is used to verify large partitions, the signature of the verity
346metadata appended to each verified partition must be verified before the
347partition is mounted and dm-verity is set up for it.</p>
Clay Murphybc8a22a2015-03-02 18:49:17 -0800348
Clay Murphye25f9da2015-05-18 14:57:31 -0700349<h4 id=managing_dm-verity>Managing dm-verity</h4>
Clay Murphybc8a22a2015-03-02 18:49:17 -0800350
Clay Murphye25f9da2015-05-18 14:57:31 -0700351<p>By default, dm-verity operates in enforcing mode and verifies each block read
352from the partition against a hash tree passed to it during setup. If it
Clay Murphybc8a22a2015-03-02 18:49:17 -0800353comes across a block that fails to verify, it returns an I/O error and makes
354the block with unexpected contents inaccessible to user space. Depending on
355which block is corrupted, this may cause some of the programs that reside on
356the partition to malfunction.</p>
357
Clay Murphye25f9da2015-05-18 14:57:31 -0700358<p>Using an optional verity table parameter, dm-verity can be configured to
359function in logging mode. If dm-verity is not started in enforcing mode for any
360reason, or verity metadata cannot be verified, a warning must be displayed to
361the user, similar to the one shown before booting into the RED state.</p>
Clay Murphybc8a22a2015-03-02 18:49:17 -0800362
Clay Murphye25f9da2015-05-18 14:57:31 -0700363<img src="../images/dm-verity_mgmt.png" alt="dm-verity management" id="figure2" />
364<p class="img-caption"><strong>Figure 2.</strong> dm-verity management</p>
Clay Murphybc8a22a2015-03-02 18:49:17 -0800365
Clay Murphye25f9da2015-05-18 14:57:31 -0700366<h4 id=recovering_from_dm-verity_errors>Recovering from dm-verity errors</h4>
Clay Murphybc8a22a2015-03-02 18:49:17 -0800367
368<p>Since the system partition is by far larger than the boot partition, the
369probability of verification errors is also higher. Specifically, there is a
370larger probability of unintentional disk corruption, which will cause a
371verification failure and can potentially make an otherwise functional device
372unusable if a critical block in the partition can no longer be accessed.</p>
373
374<p>It’s generally not possible to distinguish disk corruption from malicious
375changes, so any change to the system partition must result in the user being
Clay Murphye25f9da2015-05-18 14:57:31 -0700376notified; and no unverified data must leak to user space until a warning has
Clay Murphybc8a22a2015-03-02 18:49:17 -0800377been shown. However, we must also assume most verification failures are
378not the result of malicious behavior; so the user must also have an option to
379continue using the device without verification.</p>
380
Clay Murphye25f9da2015-05-18 14:57:31 -0700381<p>When a dm-verity error is detected, the device must be rebooted and
382dm-verity must be started in logging mode during all subsequent restarts until
383any of the verified partitions is reflashed or changed by an OTA update. This
384means dm-verity state should be stored in a persistent flag. When a verified
385partition has been changed, the flag must be cleared and dm-verity must again
386be started in enforcing mode. Anytime dm-verity is not started in enforcing
387mode, a warning must be shown to the user before any of the verified partitions
388are mounted.</p>
Clay Murphybc8a22a2015-03-02 18:49:17 -0800389
390<h3 id=verified_partition>Verified partition</h3>
391
392<p>In a verified device, the system partition must always be verified. But any
Clay Murphye25f9da2015-05-18 14:57:31 -0700393other read-only partition should also be set to be verified, as well. Any
394read-only partition that contains executable code must be verified on a
395verified device. This includes vendor and OEM partitions, if they exist, for example.</p>
Clay Murphybc8a22a2015-03-02 18:49:17 -0800396
397<p>In order for a partition to be verified, signed verity metadata must be
398appended to it. The metadata consists of a hash tree of the partition contents
399and a verity table containing signed parameters and the root of the hash tree.
Clay Murphye25f9da2015-05-18 14:57:31 -0700400If this information is missing or invalid when dm-verity is set up for the
401partition, the user must be warned.</p>
Clay Murphy0d596682014-10-23 12:06:03 -0700402
403<h2 id=implementation_details>Implementation details</h2>
404
405<h3 id=key_types_and_sizes>Key types and sizes</h3>
406
407<p>The OEM key is recommended to be an RSA key with a modulus of 2048 bits or
408higher and a public exponent of 65537 (F4). The OEM key is required to be of
409equivalent or greater strength than such a key.</p>
410
Clay Murphy0d596682014-10-23 12:06:03 -0700411<h3 id=signature_format>Signature format</h3>
412
Clay Murphybc8a22a2015-03-02 18:49:17 -0800413<p>The signature on an Android verifiable boot image is an ASN.1 DER-encoded
414message, which can be parsed with a decoder similar to the one found at: <a
415href="https://android.googlesource.com/platform/bootable/recovery/+/f4a6ab27b335b69fbc419a9c1ef263004b561265/asn1_decoder.cpp">platform/bootable/recovery/asn1_decoder.cpp</a><br/>
Clay Murphy0d596682014-10-23 12:06:03 -0700416The message format itself is as follows:</p>
417
418<pre>
419AndroidVerifiedBootSignature DEFINITIONS ::=
Clay Murphybc8a22a2015-03-02 18:49:17 -0800420 BEGIN
421 FormatVersion ::= INTEGER
422 Certificate ::= Certificate OPTIONAL
423 AlgorithmIdentifier ::= SEQUENCE {
424 algorithm OBJECT IDENTIFIER,
425 parameters ANY DEFINED BY algorithm OPTIONAL
426 }
427 AuthenticatedAttributes ::= SEQUENCE {
428 target CHARACTER STRING,
429 length INTEGER
430 }
Clay Murphy0d596682014-10-23 12:06:03 -0700431
Clay Murphybc8a22a2015-03-02 18:49:17 -0800432 Signature ::= OCTET STRING
433 END
Clay Murphy0d596682014-10-23 12:06:03 -0700434</pre>
435
Clay Murphybc8a22a2015-03-02 18:49:17 -0800436<p>The <code>Certificate</code> field is the full X.509 certificate containing
437the public key used for signing, as defined by <a
Clay Murphy0d596682014-10-23 12:06:03 -0700438href="http://tools.ietf.org/html/rfc5280#section-4.1.1.2">RFC5280</a> section
Clay Murphye25f9da2015-05-18 14:57:31 -07004394.1. When LOCKED, the bootloader must always use the OEM key for verification
440first, and only boot to YELLOW or RED states if the embedded certificate is
441used for verification instead.</p>
Clay Murphy0d596682014-10-23 12:06:03 -0700442
Clay Murphybc8a22a2015-03-02 18:49:17 -0800443<p>The remaining structure is similar to that defined by <a
444href="http://tools.ietf.org/html/rfc5280#section-4.1.1.2">RFC5280</a> sections
4454.1.1.2 and 4.1.1.3 with the exception of the
446<code>AuthenticatedAttributes</code> field. This field contains the length of
447the image to be verified as an integer and the partition where the image can
448be found (boot, recovery, etc.).</p>
Clay Murphy0d596682014-10-23 12:06:03 -0700449
450<h3 id=signing_and_verifying_an_image>Signing and verifying an image</h3>
451
452<p>To produce a signed image:</p>
Clay Murphy0d596682014-10-23 12:06:03 -0700453<ol>
454 <li>Generate the unsigned image.
Clay Murphybc8a22a2015-03-02 18:49:17 -0800455 <li>0-pad the image to the next page size boundary (omit this step if already
456aligned).
Clay Murphye25f9da2015-05-18 14:57:31 -0700457 <li>Populate the fields of the <code>AuthenticatedAttributes</code> section
458 above based on the padded image and desired target partition.
Clay Murphy0d596682014-10-23 12:06:03 -0700459 <li>Append the <code>AuthenticatedAttributes</code> structure above to the image.
460 <li>Sign the image.
461</ol>
462
463<p>To verify the image:</p>
Clay Murphy0d596682014-10-23 12:06:03 -0700464<ol>
Clay Murphybc8a22a2015-03-02 18:49:17 -0800465 <li>Determine the size of the image to be loaded including padding (eg, by reading
466a header).
Clay Murphy0d596682014-10-23 12:06:03 -0700467 <li>Read the signature located at the offset above.
Clay Murphybc8a22a2015-03-02 18:49:17 -0800468 <li>Validate the contents of the <code>AuthenticatedAttributes</code> field.
Clay Murphye25f9da2015-05-18 14:57:31 -0700469 If these values do not validate, treat it as a signature validation error.
Clay Murphy0d596682014-10-23 12:06:03 -0700470 <li>Verify the image and <code>AuthenticatedAttributes</code> sections.
471</ol>
472
Clay Murphybc8a22a2015-03-02 18:49:17 -0800473<h3 id=user_experience>User experience</h3>
474
475<p>A user in the GREEN boot state should see no additional user interaction besides that
Clay Murphye25f9da2015-05-18 14:57:31 -0700476required by normal device boot. In other boot states, the user must see a
Clay Murphybc8a22a2015-03-02 18:49:17 -0800477warning for at least five seconds. Should the user interact with the device during
Clay Murphye25f9da2015-05-18 14:57:31 -0700478this time, the warning must remain visible at least 30 seconds longer, or until
479the user dismisses the warning.</p>
Clay Murphybc8a22a2015-03-02 18:49:17 -0800480
481<p>Sample user interaction screens for other states are shown in the following table:</p>
Clay Murphye25f9da2015-05-18 14:57:31 -0700482
483<p class="table-caption" id="table5">
484 <strong>Table 5.</strong> Sample user interaction screens</p>
485
Clay Murphybc8a22a2015-03-02 18:49:17 -0800486<table>
487 <tr>
488 <td>
489<p><strong>Device state</strong></p>
490</td>
491 <td>
492<p><strong>Sample UX</strong></p>
493</td>
494 </tr>
495 <tr>
496 <td>
497<p>YELLOW (before and after user interaction)</p>
498</td>
499 <td>
500<img src="../images/boot_yellow1.png" alt="Yellow device state 1" id="figure4" />
Clay Murphy1c7cdd32015-05-26 12:27:45 -0700501<p class="img-caption"><strong>Figure 3.</strong> Yellow state example 1 UI</p>
Clay Murphybc8a22a2015-03-02 18:49:17 -0800502</td>
503 <td>
504<img src="../images/boot_yellow2.png" alt="Yellow device state 2" id="figure5" />
Clay Murphy1c7cdd32015-05-26 12:27:45 -0700505<p class="img-caption"><strong>Figure 4.</strong> Yellow state example 2 UI</p>
Clay Murphybc8a22a2015-03-02 18:49:17 -0800506</td>
507
508 </tr>
509 <tr>
510 <td>
511<p>ORANGE</p>
512</td>
513 <td>
514<img src="../images/boot_orange.png" alt="Orange device state" id="figure6" />
Clay Murphy1c7cdd32015-05-26 12:27:45 -0700515<p class="img-caption"><strong>Figure 5.</strong> Orange state example UI</p>
Clay Murphybc8a22a2015-03-02 18:49:17 -0800516</td>
517 </tr>
518 <tr>
519 <td>
520<p>RED</p>
521</td>
522 <td>
523<img src="../images/boot_red.png" alt="Red device state" id="figure7" />
Clay Murphy1c7cdd32015-05-26 12:27:45 -0700524<p class="img-caption"><strong>Figure 6.</strong> Red state example UI</p>
Clay Murphybc8a22a2015-03-02 18:49:17 -0800525</td>
526 </tr>
527</table>