blob: e05e729ee63d22de647107c465f2933564349f39 [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 Murphybda31db2015-11-16 16:10:18 -0800358<p>If dm-verity is always enforcing against correctly signed metadata, nothing
359more needs be done. However, using an optional verity table parameter, dm-verity
360can be configured to function in a logging mode where it detects and logs
361errors but allows I/O to be completed despite them. If dm-verity is not started
362in enforcing mode for any reason, or verity metadata cannot be verified, a
363warning must be displayed to the user if the device is allowed to boot, similar
364to the one shown before booting into the RED state.</p>
Clay Murphybc8a22a2015-03-02 18:49:17 -0800365
Clay Murphye25f9da2015-05-18 14:57:31 -0700366<img src="../images/dm-verity_mgmt.png" alt="dm-verity management" id="figure2" />
367<p class="img-caption"><strong>Figure 2.</strong> dm-verity management</p>
Clay Murphybc8a22a2015-03-02 18:49:17 -0800368
Clay Murphye25f9da2015-05-18 14:57:31 -0700369<h4 id=recovering_from_dm-verity_errors>Recovering from dm-verity errors</h4>
Clay Murphybc8a22a2015-03-02 18:49:17 -0800370
371<p>Since the system partition is by far larger than the boot partition, the
372probability of verification errors is also higher. Specifically, there is a
373larger probability of unintentional disk corruption, which will cause a
374verification failure and can potentially make an otherwise functional device
375unusable if a critical block in the partition can no longer be accessed.</p>
376
Clay Murphybda31db2015-11-16 16:10:18 -0800377<p>If dm-verity is always in enforcing mode, nothing further needs to be done.
378If logging mode is implemented and dm-verity detects an error while in
379enforcing mode, the device must be rebooted and dm-verity must be started in
380logging mode during all subsequent restarts until any of the verified
381partitions is reflashed or changed by an OTA update. This means dm-verity state
382should be stored in a persistent flag. When a verified partition has been
383changed, the flag must be cleared and dm-verity must again be started in
384enforcing mode. Anytime dm-verity is not started in enforcing mode, a warning
385must be shown to the user before any of the verified partitions are
386mounted. No unverified data must be allowed to leak to user space without the
387user being warned.</p>
Clay Murphybc8a22a2015-03-02 18:49:17 -0800388
389<h3 id=verified_partition>Verified partition</h3>
390
391<p>In a verified device, the system partition must always be verified. But any
Clay Murphye25f9da2015-05-18 14:57:31 -0700392other read-only partition should also be set to be verified, as well. Any
393read-only partition that contains executable code must be verified on a
394verified device. This includes vendor and OEM partitions, if they exist, for example.</p>
Clay Murphybc8a22a2015-03-02 18:49:17 -0800395
396<p>In order for a partition to be verified, signed verity metadata must be
397appended to it. The metadata consists of a hash tree of the partition contents
398and a verity table containing signed parameters and the root of the hash tree.
Clay Murphye25f9da2015-05-18 14:57:31 -0700399If this information is missing or invalid when dm-verity is set up for the
400partition, the user must be warned.</p>
Clay Murphy0d596682014-10-23 12:06:03 -0700401
402<h2 id=implementation_details>Implementation details</h2>
403
404<h3 id=key_types_and_sizes>Key types and sizes</h3>
405
406<p>The OEM key is recommended to be an RSA key with a modulus of 2048 bits or
407higher and a public exponent of 65537 (F4). The OEM key is required to be of
408equivalent or greater strength than such a key.</p>
409
Clay Murphy0d596682014-10-23 12:06:03 -0700410<h3 id=signature_format>Signature format</h3>
411
Clay Murphybc8a22a2015-03-02 18:49:17 -0800412<p>The signature on an Android verifiable boot image is an ASN.1 DER-encoded
413message, which can be parsed with a decoder similar to the one found at: <a
414href="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 -0700415The message format itself is as follows:</p>
416
417<pre>
418AndroidVerifiedBootSignature DEFINITIONS ::=
Clay Murphybc8a22a2015-03-02 18:49:17 -0800419 BEGIN
420 FormatVersion ::= INTEGER
421 Certificate ::= Certificate OPTIONAL
422 AlgorithmIdentifier ::= SEQUENCE {
423 algorithm OBJECT IDENTIFIER,
424 parameters ANY DEFINED BY algorithm OPTIONAL
425 }
426 AuthenticatedAttributes ::= SEQUENCE {
427 target CHARACTER STRING,
428 length INTEGER
429 }
Clay Murphy0d596682014-10-23 12:06:03 -0700430
Clay Murphybc8a22a2015-03-02 18:49:17 -0800431 Signature ::= OCTET STRING
432 END
Clay Murphy0d596682014-10-23 12:06:03 -0700433</pre>
434
Clay Murphybc8a22a2015-03-02 18:49:17 -0800435<p>The <code>Certificate</code> field is the full X.509 certificate containing
436the public key used for signing, as defined by <a
Clay Murphy0d596682014-10-23 12:06:03 -0700437href="http://tools.ietf.org/html/rfc5280#section-4.1.1.2">RFC5280</a> section
Clay Murphye25f9da2015-05-18 14:57:31 -07004384.1. When LOCKED, the bootloader must always use the OEM key for verification
439first, and only boot to YELLOW or RED states if the embedded certificate is
440used for verification instead.</p>
Clay Murphy0d596682014-10-23 12:06:03 -0700441
Clay Murphybc8a22a2015-03-02 18:49:17 -0800442<p>The remaining structure is similar to that defined by <a
443href="http://tools.ietf.org/html/rfc5280#section-4.1.1.2">RFC5280</a> sections
4444.1.1.2 and 4.1.1.3 with the exception of the
445<code>AuthenticatedAttributes</code> field. This field contains the length of
446the image to be verified as an integer and the partition where the image can
447be found (boot, recovery, etc.).</p>
Clay Murphy0d596682014-10-23 12:06:03 -0700448
449<h3 id=signing_and_verifying_an_image>Signing and verifying an image</h3>
450
451<p>To produce a signed image:</p>
Clay Murphy0d596682014-10-23 12:06:03 -0700452<ol>
453 <li>Generate the unsigned image.
Clay Murphybc8a22a2015-03-02 18:49:17 -0800454 <li>0-pad the image to the next page size boundary (omit this step if already
455aligned).
Clay Murphye25f9da2015-05-18 14:57:31 -0700456 <li>Populate the fields of the <code>AuthenticatedAttributes</code> section
457 above based on the padded image and desired target partition.
Clay Murphy0d596682014-10-23 12:06:03 -0700458 <li>Append the <code>AuthenticatedAttributes</code> structure above to the image.
459 <li>Sign the image.
460</ol>
461
462<p>To verify the image:</p>
Clay Murphy0d596682014-10-23 12:06:03 -0700463<ol>
Clay Murphybc8a22a2015-03-02 18:49:17 -0800464 <li>Determine the size of the image to be loaded including padding (eg, by reading
465a header).
Clay Murphy0d596682014-10-23 12:06:03 -0700466 <li>Read the signature located at the offset above.
Clay Murphybc8a22a2015-03-02 18:49:17 -0800467 <li>Validate the contents of the <code>AuthenticatedAttributes</code> field.
Clay Murphye25f9da2015-05-18 14:57:31 -0700468 If these values do not validate, treat it as a signature validation error.
Clay Murphy0d596682014-10-23 12:06:03 -0700469 <li>Verify the image and <code>AuthenticatedAttributes</code> sections.
470</ol>
471
Clay Murphybc8a22a2015-03-02 18:49:17 -0800472<h3 id=user_experience>User experience</h3>
473
474<p>A user in the GREEN boot state should see no additional user interaction besides that
Clay Murphye25f9da2015-05-18 14:57:31 -0700475required by normal device boot. In other boot states, the user must see a
Clay Murphybc8a22a2015-03-02 18:49:17 -0800476warning for at least five seconds. Should the user interact with the device during
Clay Murphye25f9da2015-05-18 14:57:31 -0700477this time, the warning must remain visible at least 30 seconds longer, or until
478the user dismisses the warning.</p>
Clay Murphybc8a22a2015-03-02 18:49:17 -0800479
480<p>Sample user interaction screens for other states are shown in the following table:</p>
Clay Murphye25f9da2015-05-18 14:57:31 -0700481
482<p class="table-caption" id="table5">
483 <strong>Table 5.</strong> Sample user interaction screens</p>
484
Clay Murphybc8a22a2015-03-02 18:49:17 -0800485<table>
486 <tr>
487 <td>
488<p><strong>Device state</strong></p>
489</td>
490 <td>
491<p><strong>Sample UX</strong></p>
492</td>
493 </tr>
494 <tr>
495 <td>
496<p>YELLOW (before and after user interaction)</p>
497</td>
498 <td>
499<img src="../images/boot_yellow1.png" alt="Yellow device state 1" id="figure4" />
Clay Murphy1c7cdd32015-05-26 12:27:45 -0700500<p class="img-caption"><strong>Figure 3.</strong> Yellow state example 1 UI</p>
Clay Murphybc8a22a2015-03-02 18:49:17 -0800501</td>
502 <td>
503<img src="../images/boot_yellow2.png" alt="Yellow device state 2" id="figure5" />
Clay Murphy1c7cdd32015-05-26 12:27:45 -0700504<p class="img-caption"><strong>Figure 4.</strong> Yellow state example 2 UI</p>
Clay Murphybc8a22a2015-03-02 18:49:17 -0800505</td>
506
507 </tr>
508 <tr>
509 <td>
510<p>ORANGE</p>
511</td>
512 <td>
513<img src="../images/boot_orange.png" alt="Orange device state" id="figure6" />
Clay Murphy1c7cdd32015-05-26 12:27:45 -0700514<p class="img-caption"><strong>Figure 5.</strong> Orange state example UI</p>
Clay Murphybc8a22a2015-03-02 18:49:17 -0800515</td>
516 </tr>
517 <tr>
518 <td>
519<p>RED</p>
520</td>
521 <td>
522<img src="../images/boot_red.png" alt="Red device state" id="figure7" />
Clay Murphy1c7cdd32015-05-26 12:27:45 -0700523<p class="img-caption"><strong>Figure 6.</strong> Red state example UI</p>
Clay Murphybc8a22a2015-03-02 18:49:17 -0800524</td>
525 </tr>
526</table>