blob: 5c746f2e959fd1572695f9d86d9db1f52d7a7a00 [file] [log] [blame] [view]
Darren Krahn0762a2e2021-02-05 15:41:20 -08001# Open Profile for DICE
2
3v2.3
4
5[TOC]
6
7## Background
8
9The Trusted Computing Group (TCG) specifies
10[Hardware Requirements for a Device Identifier Composition Engine](https://trustedcomputinggroup.org/wp-content/uploads/Hardware-Requirements-for-Device-Identifier-Composition-Engine-r78_For-Publication.pdf)
11(DICE) which provides the context for this document. We'll call this TCG
12document the _TCG DICE specification_. Concepts like a Unique Device Secret
13(UDS) and a Compound Device Identifier (CDI) are used as defined in the TCG DICE
14specification.
15
16#### A Note on Nomenclature
17
18This document uses the term _hardware_ to refer to anything that is immutable by
19design after manufacturing. Code in mask ROM, for example, is _hardware_. The
20terms _firmware_, _software_ and _program_ are all interchangeable; they all
21refer to mutable code. Often we say _firmware_ for code that runs early in boot,
22and _program_ for a particular unit of code, but it's really all _software_.
23
24#### DICE Primer
25
26For those not familiar with DICE, here is a quick primer on the concepts:
27
28* **UDS** - Unique Device Secret. This is a per-device hardware-level secret
29 accessible to the DICE but not accessible after the DICE runs. This is one
30 of the DICE inputs. Note that when [layering](#layering-details) DICE
31 computations the UDS is only used for the first computation when
32 transitioning from hardware to software. Mutable software must never have
33 access to the hardware UDS.
34* **CDI** - Compound Device Identifier. This value represents the
35 hardware/software combination measured by the DICE. This is the DICE output
36 and is passed to the software which has been measured. This is a secret.
37* **DICE** - Device Identifier Composition Engine. This is a process which
38 mixes the UDS with software hashes and other inputs to produce a CDI and
39 locks down further access to the UDS. This computation occurs at the point
40 of transition from hardware (e.g. ROM) to software (e.g. first bootloader),
41 but we can perform the same computation at the point of transition from one
42 program to another in general to extend CDIs throughout a system.
43
44DICE can be implemented with a simple HMAC with the UDS as the key, attributes
45of the target code or system as the input, and the output is the CDI. However,
46for a particular implementation there are questions that need to be addressed
47such as "what is in the input, exactly?", and "how should we use the CDI once we
48have it?". That's where this profile comes in, it fills in many of these
49details.
50
51## Overview
52
53This document specifies a DICE profile suitable for use in a variety of products
54and platforms. The [TCG DICE specification](#background) intentionally allows
55for flexibility in implementation; this document specifies many of these
56implementation details. This document also fills in various details the TCG DICE
57specification considers out of scope. In particular, this document specifies:
58
59* Cryptographic mechanisms
60* UDS size and provisioning
61* DICE input details, including how DICE interacts with verified boot
62* Additional requirements, including asymmetric key derivation and
63 certification
64
65#### Goals
66
67The main goals of this document are:
68
69* Make it **easier to implement** DICE well, with quality and confidence.
70* **Consistency for DICE implementers**, whether in hardware, firmware, or
71 software.
72* **Consistency for attestation verifiers**. There will always be some details
73 in the certificate extensions that are specific to the target system, but
74 those differences can be minimized by adopting some conventions when
75 generating the certificates.
76
77#### Non-Goals
78
79This document is not intended to:
80
81* Be a formal standard
82* Limit the use of DICE-style mechanisms not described here
83
84## Architecture Diagram
85
86This architecture diagram shows the first DICE transition from hardware to
87software, and uses the UDS in the derivation of both the Attestation CDI and
88Sealing CDI. Subsequent DICE transitions would use the current CDI values in
89place of the UDS to compute the subsequent CDI values. See
90[Layering Details](#layering-details).
91
Darren Krahn163cfb32021-02-05 17:34:51 -080092![Architecture Diagram](../images/architecture.png)
Darren Krahn0762a2e2021-02-05 15:41:20 -080093
94## Use Cases
95
96This design is motivated by two use cases: **attestation** and **sealing**.
97_Attestation_ allows a computing device or program to provide verifiable
98evidence of its identity and operating state, including hardware identity,
99software image, security-relevant configuration, operating environment, etc.
100_Sealing_ allows a computing device or program to encrypt data in such a way
101that it can only be decrypted by the same device or program operating in the
102same state as at the time of encryption.
103
104With this design, sealing only works well in combination with some kind of
105verified boot system. For a more sophisticated example of sealing key
106generation, see
107[Appendix C: Versioned Sealing Keys](#appendix-c-versioned-sealing-keys).
108
109# Profile Design
110
111## Input Values
112
113For attestation, DICE inputs should represent all security-relevant properties
114of the target program. The target program is the program to which control will
115be passed, along with DICE outputs, after the DICE computations are complete.
116This profile defines the following types of input, each of which is represented
117by a fixed length value:
118
1191. **Code (64 bytes)** - This input is computed by hashing the target code.
120 This is the traditional input described most clearly in the
121 [TCG DICE specification](#background). If a software image is too large to
122 load and hash entirely, then a descriptor of the code (like the root hash of
123 a hash tree) may be used instead. Note that this approach requires
124 additional ongoing enforcement to verify pages as they are loaded. A
125 canonical example of this is
126 [dm-verity](https://source.android.com/security/verifiedboot/dm-verity).
1272. **Configuration Data (64 bytes)** - This input is a catch-all for any
128 security-relevant configuration or environment properties that characterize
129 the integrity of the system and can be used by an external party to validate
130 its identity and/or its operating state. This may capture verified boot
131 authority selection, device mode, boot location, chip status information,
132 instance identifiers, etc. This value may or may not be a hash of the actual
133 configuration data. When it is a hash, the original data must also be
134 included in certificates. It's ok for this input to be _not stable_, it may
135 change from one boot to the next.
1363. **Authority Data (64 bytes)** - This input is computed by hashing a
137 representation of the verified boot trusted authority. For example, this may
138 be a public key, a hash of a public key, or a hash of a descriptor
139 containing a set of public keys. For many SoCs, this representation of the
140 trusted authority is programmed into one-time-programmable (OTP) memory. If
141 a code authorization mechanism is disabled or not supported, this input
142 should be 64 zero bytes. If multiple public keys are supported with runtime
143 selection, this input value must represent all of them. (This is so the
144 value remains stable across a key change, the actual key that was used
145 during boot should be included in the configuration data input value). The
146 authority input value is designed to be stable, it is very unlikely to
147 change during a device lifecycle.
1484. **Mode Decision (1 byte)** - This input value is a single-byte mode value.
149 Valid mode values are: **0**: Not Configured, **1**: Normal, **2**: Debug,
150 **3**: Recovery. The mode is determined at runtime based on the other
151 inputs, and only the other inputs. This input is designed to capture a
152 configuration signal in a stable way, and to reflect important decisions a
153 device makes at runtime. In the sealing use case, this enables data to be
154 sealed separately under each mode. See
155 [Mode Value Details](#mode-value-details).
1565. **Hidden Inputs (64 bytes)** - This optional input value is _hidden_ in the
157 sense that it does not appear in any certificate. It is used for both
158 attestation and sealing CDI derivation so it is expected to be stable; it
159 should not change under normal operation except when that change is an
160 intentional part of the device lifecycle. If not used, this value should be
161 all zero bytes. While this value can be anything, intended use cases
162 include:
163
164 * Mixing in an additional secret which may be changed as part of the
165 device lifecycle, for example ownership transfer
166 * Mixing in a rotation nonce or counter to control the rotation of
167 attestation keys and sealing keys
168 * Mixing in stable instance IDs or other internal IDs which may provide
169 differentiation for sealing CDIs
170 * Mixing in stable configuration inputs which appear in Configuration Data
171 but also should be used in the sealing CDI derivation
172
173## CDI Values
174
175The [TCG DICE specification](#background) refers to a single CDI, but this
176profile defines multiple CDIs with different characteristics which can be used
177for different use cases:
178
1791. **Attestation CDI** - This CDI is derived from the combination of all input
180 values and will change across software updates or configuration changes.
181 This CDI is appropriate for attestation and is _mandatory_ for
182 implementations of this profile.
1832. **Sealing CDI** - This CDI is derived from only the authority data, mode
184 decision, and hidden inputs because these are stable. It will reflect this
185 stability and will remain the same across software updates and some
186 configuration changes. This CDI is appropriate for sealing and is _optional_
187 for implementations of this profile.
188
189### CDI Certificates
190
191This profile requires the generation of a CDI certificate as part of the DICE
192flow. The subject key pair is derived from the Attestation CDI value for the
193target code. The authority key pair which signs the certificate is derived from
194the UDS or, after the initial hardware to software transition, from the
195Attestation CDI value for the current code (see
196[Layering Details](#layering-details)). The DICE flow outputs the CDI values and
197the generated certificate; the private key associated with the certificate may
198be optionally passed along with the CDI values to avoid the need for
199re-derivation by the target code. The UDS-derived public key is certified by an
200external authority during manufacturing to complete the certificate chain. See
201[Certificate Details](#certificate-details).
202
203As an example, if the CDI private key were used to sign a leaf certificate for
204an attestation key, the certificate chain may look like this:
205
Darren Krahn163cfb32021-02-05 17:34:51 -0800206![Single Layer Certificate Chain Diagram](../images/single-layer-cert-chain.png)
Darren Krahn0762a2e2021-02-05 15:41:20 -0800207
208## High-level DICE Flow
209
210The [TCG DICE specification](#background) outlines a four stage flow: measure,
211compute CDI, lock UDS, and transfer control. This profile expands on this to
212include operations for CDI certification. The expanded flow has the following
213steps:
214
2151. Measure CDI input values and compute CDI values
2162. Derive an asymmetric key pair from the UDS
2173. Lock UDS
2184. Derive an asymmetric key pair from the Attestation CDI
2195. Generate a CDI certificate
2206. Destroy the UDS-derived private key from step (2)
2217. Transfer control to the target code, passing on the certificate and all CDI
222 values
223
224## Cryptography
225
226This profile requires three cryptographic primitives: a hash function, a key
227derivation function, and an asymmetric digital signature. The recommended
228defaults are [SHA-512](https://en.wikipedia.org/wiki/SHA-2),
229[HKDF](https://en.wikipedia.org/wiki/HKDF) (using SHA-512) and
230[Ed25519](https://en.wikipedia.org/wiki/EdDSA#Ed25519). Since Ed25519 uses
231SHA-512 under the hood, using this combination means implementing only one hash
232function. See below for the full list of
233[acceptable algorithms](#acceptable-cryptographic-algorithms).
234
235The following pseudocode operations are used throughout this document:
236
237```py
238# A hash function. The input can be any length.
239hash = H(input)
240
241# Random salt values used as the 'salt' KDF argument (hex encoded).
242ASYM_SALT = 63B6A04D2C077FC10F639F21DA793844356CC2B0B441B3A77124035C03F8E1BE
243 6035D31F282821A7450A02222AB1B3CFF1679B05AB1CA5D1AFFB789CCD2B0B3B
244ID_SALT = DBDBAEBC8020DA9FF0DD5A24C83AA5A54286DFC263031E329B4DA148430659FE
245 62CDB5B7E1E00FC680306711EB444AF77209359496FCFF1DB9520BA51C7B29EA
246
247# A KDF operation with the given desired output length, input key material,
248# salt, and info.
249output = KDF(length, ikm, salt, info)
250
251# An asymmetric key pair derivation, either Ed25519 or ECDSA.
252# * The private key is derived using KDF(32, input, ASYM_SALT, "Key Pair").
253# * The public key is derived from the private key (per the chosen algorithm).
254private_key, public_key = ASYM_KDF(input)
255```
256
257### Computing CDI Values
258
259Each CDI value is 32 bytes in length and is computed using a KDF operation with
260the UDS or previous CDI value as the input key material argument and the
261relevant input measurement as the salt argument. The KDF info argument differs
262for each type of CDI.
263
264#### Attestation CDI
265
266The Attestation CDI input measurement is derived from the combination of all
267input values. The [input values](#input-values) are hashed in this order: code,
268config, authority, mode, hidden.
269
270```py
271CDI_Attest = KDF(32, UDS, H(code + config + authority + mode + hidden),
272 "CDI_Attest")
273```
274
275#### Sealing CDI
276
277The Sealing CDI input measurement is similar but is derived from only the stable
278inputs. The [input values](#input-values) are hashed in this order: authority,
279mode, hidden.
280
281```py
282CDI_Seal = KDF(32, UDS, H(authority + mode + hidden), "CDI_Seal")
283```
284
285### Deriving Asymmetric Key Pairs
286
287There are two key pair derivations; one to derive from the UDS, and the other to
288derive from the Attestation CDI. When deriving from the UDS, the KDF input is
289simply the UDS.
290
291```py
292UDS_Private, UDS_Public = ASYM_KDF(UDS)
293```
294
295When deriving from Attestation CDI, the KDF input is simply the
296[CDI\_Attest](#attestation-cdi) value.
297
298```py
299CDI_Private, CDI_Public = ASYM_KDF(CDI_Attest)
300```
301
302Note: It is important that these two derivations remain consistent except for
303the input key material; this is what makes [layering](#layering-details)
304possible.
305
306### Deriving Identifiers
307
308There are a few cases where the DICE needs to generate an identifier for use in
309certificates. To ensure these identifiers are deterministic and require no
310additional DICE inputs, the identifiers are derived from the associated public
311key. The identifiers are 20 octets so they fit in the RFC 5280 serialNumber
312field constraints and the X520SerialNumber type when hex encoded. The big-endian
313high-order bit is cleared so the ASN.1 integer representation is always positive
314without padding.
315
316```py
317UDS_ID = KDF(20, UDS_Public, ID_SALT, "ID")
318CDI_ID = KDF(20, CDI_Public, ID_SALT, "ID")
319```
320
321Note: Like the public key derivations, it is important that the ID derivations
322remain consistent except for the input key material. This is because these are
323used in certificate issuer and subject fields and need to match when
324[layering](#layering-details).
325
326### Acceptable Cryptographic Algorithms
327
328#### Hash Algorithms
329
330Acceptable hash algorithms are:
331
332* SHA-256, SHA-384, SHA-512
333* SHA3-256, SHA3-384, SHA3-512
334
335#### Key Derivation Functions
336
337##### HKDF
338
339[HKDF](https://en.wikipedia.org/wiki/HKDF) can be used with any acceptable hash
340algorithm. The KDF inputs map exactly to HKDF parameters, by design. This is the
341recommended default.
342
343##### DRBG
344
345A
346[DRBG](https://nvlpubs.nist.gov/nistpubs/SpecialPublications/NIST.SP.800-90Ar1.pdf)
347can be used to implement the KDF operation. Depending on the DRBG implementation
348this may require UDS and CDI values larger than 256 bits to provide both _nonce_
349and _entropy_ inputs when instantiating the DRBG. The DRBG should be
350instantiated with a security strength of 256 bits. The sequence of DRBG
351functions {instantiate, generate, uninstantiate}, are used as a KDF operation.
352The mapping of inputs is as shown in the following table.
353
354HKDF Input | Corresponding DRBG Input
355---------- | ------------------------------------
356ikm | Instantiate: Entropy Input and Nonce
357salt | Generate: Additional Input
358info | Instantiate: Personalization String
359
360##### OpenTitan Key Manager
361
362The
363[OpenTitan Key Manager](https://docs.opentitan.org/hw/ip/keymgr/doc/index.html)
364can be used as a KDF. See the OpenTitan documentation for details.
365
366#### Digital Signatures
367
368##### Ed25519
369
370[Ed25519](https://en.wikipedia.org/wiki/EdDSA#Ed25519) is the recommended
371default.
372
373##### ECDSA
374
375[ECDSA](https://en.wikipedia.org/wiki/Elliptic_Curve_Digital_Signature_Algorithm)
376can be used instead of Ed25519. When signing the CDI certificate, the random _k_
377required by ECDSA may be generated deterministically per
378[RFC6979](https://tools.ietf.org/html/rfc6979). One weakness of Ed25519 is that
379implementations may be susceptible to error injection
380([example](https://www.romailler.ch/ddl/10.1109_FDTC.2017.12_eddsa.pdf)).
381Another disadvantage of Ed25519 is that it is not [currently] FIPS 140-2
382certifiable. In any case, either algorithm is acceptable for this profile.
383
384The following [NIST](https://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.186-4.pdf)
385curves are acceptable for use with ECDSA:
386
387* P-256
388* P-384
389
390## Layering Details
391
392This DICE profile is designed to be layered. That is, software that receives CDI
393values can in turn execute a DICE flow using those CDI values in place of the
394UDS value. The certificate generated by the next DICE layer can chain to the
395certificate generated by the previous DICE layer because the asymmetric key
396derivation is consistent across layers for authority and subject keys.
397
398### Computing Layered CDI Values
399
400When computing CDI values, the previous Attestation CDI or Sealing CDI is used
401as the input key material instead of the hardware UDS:
402
403```py
404CDI_Attest[n+1] = KDF(32, CDI_Attest[n], H(code + config + authority + mode + hidden), "CDI_Attest")
405CDI_Seal[n+1] = KDF(32, CDI_Seal[n], H(authority + mode + hidden), "CDI_Seal")
406```
407
408### Protecting Layered CDI Values
409
410Just like the UDS is locked in the DICE [flow](#high-level-dice-flow), previous
411layer CDIs must be destroyed, locked, or otherwise protected before control is
412passed to the next layer. Layer[n+1] must never obtain access to CDI[n] values
413and must not be able to use CDI[n] in any computation. For example, a layer[n]
414program cannot offer a service that uses CDI[n] to layer[n+1] programs. In some
415cases a layer[n] program will stay active and spawn multiple programs (for
416example, a kernel, TEE, or hypervisor). In these cases the CDI[n] values must be
417protected from all layer[n+1] programs for the duration they are in operation,
418and must be destroyed when no longer needed.
419
420### Generating Layered Certificates
421
422When generating certificates, the authority is the previous CDI key pair and the
423certificates chain together. So the certificate chain may look like this:
424
Darren Krahn163cfb32021-02-05 17:34:51 -0800425![Multi Layer Certificate Chain Diagram](../images/multi-layer-cert-chain.png)
Darren Krahn0762a2e2021-02-05 15:41:20 -0800426
427## UDS Details
428
429### Requirements
430
431In addition to the requirements described in the
432[TCG DICE specification](#background), this profile requires the following:
433
434* The UDS is at least 256 bits in size and is full-entropy. This means the UDS
435 value has been conditioned from at least 512 bits of entropy.
436* If a UDS has not been provisioned, a value of all zero bytes is used. This
437 convention enables provisioning testability since running a DICE on an
438 unprovisioned UDS will yield predictable outputs.
439* UDS values and certificates must use one of the provisioning schemes
440 described in this section. The provisioning process is expected to occur
441 very seldom, likely once per device during manufacture. Hardware may or may
442 not support re-provisioning of the UDS.
443
444### Provisioning Scheme 1: Pre-generation
445
446In this scheme, the UDS and an associated certificate are pre-generated and
447injected during a manufacturing process in a controlled environment appropriate
448for the implementation or product. The pre-generation infrastructure does not
449retain UDS values after provisioning. This approach is designed to balance the
450risks and costs associated with provisioning between security and scale.
451Rationale is not described here in detail, but the primary benefits are:
452
453* No in-factory CAs (which make revocation as difficult as pre-generation)
454* On-device certificates (which enable offline use cases)
455
456Note: If the UDS is integrated with an SoC at the time of SoC manufacture, the
457issuer may be the SoC vendor. If the UDS is integrated at the time of device
458manufacture, the issuer may be the OEM.
459
460#### Provisioning Flow
461
4621. [Pre-generation] Generate a random UDS
4632. [Pre-generation] Derive UDS\_Public and generate an associated certificate
464 which has a subject matching the expected issuer field generated for CDI
465 certificates (see [X.509 UDS Certificates](#x_509-uds-certificates)).
4663. [Manufacturing] Program the UDS to the hardware (and destroy the source
467 copy)
4684. [Manufacturing] Test the DICE to ensure:
469 1. The UDS certificate correctly chains to the CDI certificate
470 2. The CDI values cannot be reproduced using a zero UDS
4715. [Manufacturing] Write the certificate to device storage
472
473### Provisioning Scheme 2: Factory CA
474
475In some cases, it may be feasible and preferable to install a CA for UDS
476provisioning during an SoC or device manufacturing stage. In this scheme, the
477UDS is derived on-chip from internal and external entropy, at least 256 bits
478each. Internal entropy may be generated using a
479[PUF](https://en.wikipedia.org/wiki/Physical_unclonable_function), or generated
480once using an internal hardware RNG and stored, for example, in OTP memory.
481External entropy is injected once during manufacturing and stored, for example,
482in OTP memory. The UDS is derived at runtime on every boot from the combined
483entropy. The UDS derivation (i.e. conditioning) from internal and external
484entropy uses a KDF:
485
486```py
487UDS = KDF(32, internal_entropy, external_entropy, "UDS")
488```
489
490With this provisioning scheme, the device must output UDS\_Public so
491provisioning software can read the public key and issue a certificate.
492
493#### Provisioning Flow
494
495All steps occur during manufacturing.
496
4971. Generate and inject external entropy; do not retain or inject to multiple
498 devices
4992. Run the DICE flow and read the UDS\_Public key
5003. Issue a certificate for UDS\_Public
5014. Test the DICE to ensure:
502 1. The UDS certificate correctly chains to the CDI certificate
503 2. The CDI values cannot be reproduced using a zero UDS
5045. Write the certificate to device storage
505
506### Provisioning Scheme 3: On-Demand Certification
507
508In some cases, the certificate may not need to be stored on the device or the
509device may not be capable of storing a certificate. In this scheme the UDS is
510derived in the same way as
511[Provisioning Scheme 2](#provisioning-scheme-2-factory-ca), and the UDS\_Public
512key must similarly be output by the device. A SHA-512 hash of the UDS\_Public
513key is retained in a secure database by the manufacturer.
514
515The manufacturer then operates or coordinates with an online CA to provide
516on-demand certification of UDS public keys. Acceptable approaches include but
517are not limited to:
518
519* Manufacturer provides the list of UDS public key hashes to the CA. This has
520 the downside of revealing the total number of devices.
521* Manufacturer operates a simple web service on a dedicated domain over HTTPS
522 which takes as input the hash of a UDS public key and provides as output a
523 boolean indicating whether or not the hash is valid and should be certified.
524
525The CA issues certificates for any valid UDS public key without requiring
526proof-of-possession from the caller, only requiring a signal of approval from
527the manufacturer. This allows a certificate chain to be requested by a CDI
528certificate verifier that received an incomplete chain from a device. The UDS
529certificate may be cached indefinitely by the device or by a verifier.
530
531#### Provisioning Flow
532
5331. [Manufacturing] Generate and inject external entropy; do not retain or
534 inject to multiple devices
5352. [Manufacturing] Run the DICE flow and read the UDS\_Public key
5363. [Manufacturing] Retain H(UDS\_Public) in a secure database
5374. [On-Demand] Send UDS\_Public to the CA (no proof-of-possession necessary)
5385. [CA] Check that H(UDS\_Public) is approved by the manufacturer
5396. [CA] Issue a certificate for UDS\_Public
540
541## Mode Value Details
542
543The following table describes the semantics of each mode.
544
545Mode | Value | Description
546-------------- | ----- | -----------
547Not Configured | 0 | This mode indicates that at least one security mechanism has not been configured. This mode also acts as a catch-all for configurations which do not fit the other modes. Invalid mode values -- values not defined here -- should be treated like this mode.
548Normal | 1 | This mode indicates the device is operating normally under secure configuration. This may mean, for example: Verified boot is enabled, verified boot authorities used for development or debug have been disabled, debug ports or other debug facilities have been disabled, and the device booted software from the normal primary source, for example, eMMC, not USB, network, or removable storage.
549Debug | 2 | This mode indicates at least one criteria for Normal mode is not met and the device is not in a secure state.
550Recovery | 3 | This mode indicates a recovery or maintenance mode of some kind. This may mean software is being loaded from an alternate source, or the device is configured to trigger recovery logic instead of a normal boot flow.
551
552## Configuration Input Value Details (Optional)
553
554The format and meaning of the 64-byte configuration input value is
555implementation dependent and may be a hash of more configuration data.
556Implementers may choose to use the following convention for the configuration
557input which covers a set of common security-relevant configuration.
558
559Field | Byte/Bits (MSB=0) | Description
560------------------------------- | ----------------- | -----------
561Verified Boot Enabled | 0/0 | This bit indicates whether a verified boot feature is enabled. The bit is set if enabled, clear if disabled or not supported.
562Verified Boot Authority Enabled | 0/1-7 | These bits indicate which of the verified boot authorities available are enabled. The bit is set if the authority is enabled, clear if disabled. If a verified boot system is disabled or not supported, all bits are clear. The mapping of these bits to particular authorities is implementation dependent.
563Debug Ports Enabled | 1 | The bits of this byte each indicate that a debug port or feature is enabled. A bit is set if the port or feature is enabled, clear if disabled. The mapping of these bits to particular ports or features is implementation dependent.
564Boot Source | 2 | This value indicates the boot source; that is, where the target software was loaded from. The mapping of this value to particular boot sources is implementation dependent but by convention 0 is used for the default boot source.
565Version | 3-4 | This value encodes target software version information. The format and interpretation of this value is implementation dependent.
566Reserved | 5-31 | These are reserved for future versions of this profile.
567Implementation Specific | 32-63 | An implementation can use these bytes to represent any other security-relevant configuration.
568
569## Certificate Details
570
571This profile allows for two certificate options: standard X.509, or CBOR. The
572certificate type does not need to be consistent for all certificates in a
573certificate chain. Any certificate in the chain may be any type. Attestation
574infrastructure may place additional constraints on certificate type, but this
575profile does not.
576
577Regardless of type, UDS and CDI certificates are always semantically _CA
578certificates_ to enable use cases for certifying subsequent DICE
579[layers](#layering-details) or certifying attestation keys of some kind; the
580UDS\_Private and CDI\_Private keys are not intended to be used for any purpose
581other than signing certificates. In particular, this means CDI\_Private should
582not participate directly in attestation protocols, but should rather certify an
583attestation key. If a target software component does not launch additional
584software, the _pathLenConstraint_ field can be set to zero so certification of a
585subsequent CDI\_Public is not possible.
586
587When UDS and CDI certificates are standard X.509 certificates, they follow the
588profile specified in [RFC 5280](https://tools.ietf.org/html/rfc5280). When they
589are CBOR, they follow the IETF
590[CBOR Web Token](https://tools.ietf.org/html/rfc8392) (CWT) specification, and
591the [CBOR Object Signing and Encryption](https://tools.ietf.org/html/rfc8152)
592(COSE) specification.
593
594### X.509 UDS Certificates
595
596The following table describes all standard fields of a UDS certificate's
597tbsCertificate field that this profile requires. Fields omitted are
598implementation dependent, but must not break the ability to chain to a CDI
599Certificate.
600
601Field | Description
602-------------------- | -----------
603version | v3
604subject | "SERIALNUMBER=\<UDS\_ID\>" where UDS\_ID is hex encoded lower case
605subjectPublicKeyInfo | When using Ed25519, the info per [RFC 8410](https://tools.ietf.org/html/rfc8410) and [RFC 8032](https://tools.ietf.org/html/rfc8032)
606extensions | The standard extensions described below are included.
607
608##### UDS Standard Extensions
609
610Extension | Critical | Description
611-------------------- | ------------ | -----------
612subjectKeyIdentifier | non-critical | Set to UDS\_ID
613keyUsage | critical | Contains only keyCertSign
614basicConstraints | critical | The cA field is set to TRUE. The pathLenConstraint field is normally not included, but may be included and set to zero if it is known that no additional DICE [layers](#layering-details) exist.
615
616### X.509 CDI Certificates
617
618All standard fields of a CDI certificate and the tbsCertificate field are
619described in the following table. Notably, this certificate can be generated
620deterministically given a CDI\_Public key and the DICE input value details.
621
622Field | Description
623-------------------- | -----------
624signatureAlgorithm | id-Ed25519 per [RFC 8410](https://tools.ietf.org/html/rfc8410)
625signatureValue | 64 byte Ed25519 signature per [RFC 8032](https://tools.ietf.org/html/rfc8032), using UDS\_Private or a previous CDI\_Private as the signing key
626version | v3
627serialNumber | CDI\_ID in ASN.1 INTEGER form
628signature | id-Ed25519 per [RFC 8410](https://tools.ietf.org/html/rfc8410)
629issuer | "SERIALNUMBER=\<UDS\_ID\>" where UDS\_ID is hex encoded lower case
630validity | The DICE is not expected to have a reliable source of time when generating a certificate. The validity values are populated as follows: _notBefore_ can be any time known to be in the past; in the absence of a better value, "180322235959Z" can be used which is the date of publication of the [TCG DICE specification](#background), and _notAfter_ is set to the standard value used to indicate no well-known expiry date, "99991231235959Z".
631subject | "SERIALNUMBER=\<CDI\_ID\>" where CDI\_ID is hex encoded lower case
632subjectPublicKeyInfo | When using Ed25519, the info per [RFC 8410](https://tools.ietf.org/html/rfc8410) and [RFC 8032](https://tools.ietf.org/html/rfc8032)
633issuerUniqueID | Omitted
634subjectUniqueID | Omitted
635extensions | Standard extensions are included as well as a custom extension which holds information about the measurements used to derive CDI values. Both are described below.
636
637##### CDI Standard Extensions
638
639Extension | Critical | Description
640---------------------- | ------------ | -----------
641authorityKeyIdentifier | non-critical | Contains only keyIdentifier set to UDS\_ID
642subjectKeyIdentifier | non-critical | Set to CDI\_ID
643keyUsage | critical | Contains only keyCertSign
644basicConstraints | critical | The cA field is set to TRUE. The pathLenConstraint field is normally not included, but may be included and set to zero if it is known that no additional DICE [layers](#layering-details) exist.
645
646##### CDI Custom Extension Fields
647
648Field | Value
649--------- | -----
650extnID | 1.3.6.1.4.1.11129.2.1.24 (The 1.3.6.1.4.1 is the [enterprise number](https://www.iana.org/assignments/enterprise-numbers/enterprise-numbers), the 11129.2.1 is google.googleSecurity.certificateExtensions, and 24 is diceAttestationData assigned for this profile).
651critical | FALSE
652extnValue | A [OpenDiceInput](#custom-extension-format) sequence
653
654#### Custom Extension Format
655
656The custom extension follows this ASN.1 format:
657
658```
659Mode ::= INTEGER (0..3)
660OpenDiceInput ::= SEQUENCE {
661 codeHash [0] EXPLICIT OCTET STRING OPTIONAL,
662 codeDescriptor [1] EXPLICIT OCTET STRING OPTIONAL,
663 configurationHash [2] EXPLICIT OCTET STRING OPTIONAL,
664 configurationDescriptor [3] EXPLICIT OCTET STRING OPTIONAL,
665 authorityHash [4] EXPLICIT OCTET STRING OPTIONAL,
666 authorityDescriptor [5] EXPLICIT OCTET STRING OPTIONAL,
667 mode [6] EXPLICIT Mode OPTIONAL,
668}
669```
670
671All fields are explicitly tagged and optional to allow for flexibility and
672extensibility in the format itself. The actual semantics are as follows:
673
674* **codeHash** - Required. This is the exact 64-byte code input value used to
675 compute CDI values.
676* **codeDescriptor** - Optional. This field contains additional information
677 about the code input value. The format of this field is
678 implementation-specific. If this field is included then all the information
679 here must have been used to compute codeHash; i.e. a change in this value
680 implies a change in codeHash.
681* **configurationHash** - Optional. If the configuration input is a hash, this
682 field contains that hash. If the configuration is not a hash, this field is
683 omitted. If present, this value is the exact configuration input used to
684 compute CDI values, and also matches H(configurationDescriptor).
685* **configurationDescriptor** - Required. If the configuration input is a hash
686 this field contains the original configuration data that was hashed. If it
687 is not a hash, this field contains the exact 64-byte configuration input
688 value used to compute CDI values.
689* **authorityHash** - Required. This is the exact 64-byte authority input
690 value used to compute CDI values.
691* **authorityDescriptor** - Optional. This field contains additional
692 information about the authority input value. The format of this field is
693 implementation-specific. If this field is included then all the information
694 here must have been used to compute authorityHash; i.e. a change in this
695 value implies a change in authorityHash.
696* **mode** - Required. This is the mode input value.
697
698### CBOR UDS Certificates
699
700A CBOR UDS certificate is a standard signed CWT. The following table lists all
701field constraints required by this profile in addition to the standard. The
702certificate is _untagged_, and it must be a _COSE\_Sign1_ message.
703
704Field | Description
705----- | -----------
706iss | Required: The value is implementation dependent.
707sub | Required: The value must be "\<UDS\_ID\>" where UDS\_ID is hex encoded lower case.
708aud | Omitted
709
710#### Additional Fields
711
712The following table lists additional entries in the CWT. Note these have the
713same labels and semantics as the corresponding fields in
714[CBOR CDI certificates](#cbor-cdi-certificates).
715
716Field | CBOR Label
717---------------- | ----------
718subjectPublicKey | -4670552
719keyUsage | -4670553
720
721The _subjectPublicKey_ field contains the public key associated with the subject
722in the form of a COSE\_Key structure encoded to a CBOR byte string.
723
724The _keyUsage_ field contains a CBOR byte string the bits of which correspond to
725the [X.509 KeyUsage bits](https://tools.ietf.org/html/rfc5280#section-4.2.1.3)
726in little-endian byte order (i.e. bit 0 is the low-order bit of the first byte).
727For UDS certificates this should have only the keyCertSign bit set.
728
729### CBOR CDI Certificates
730
731A CBOR CDI certificate is a standard signed CWT with additional fields. The
732certificate is _untagged_, and it must be a _COSE\_Sign1_ message. The following
733table lists all constraints on standard fields required by this profile.
734
735Field | Description
736----- | -----------
737iss | Required: The value must be "\<UDS\_ID\>" where UDS\_ID is hex encoded lower case.
738sub | Required: The value must be "\<CDI\_ID\>" where CDI\_ID is hex encoded lower case.
739aud | Omitted
740exp | Omitted
741nbf | Omitted when a reliable time source is not available
742iat | Omitted when a reliable time source is not available
743cti | Omitted
744
745#### Additional Fields
746
747The following table lists additional entries in the CWT. By convention, the
748private fields in the map are labeled using negative integers starting at
749-4670545.
750
751Field | CBOR Label
752----------------------- | ----------
753codeHash | -4670545
754codeDescriptor | -4670546
755configurationHash | -4670547
756configurationDescriptor | -4670548
757authorityHash | -4670549
758authorityDescriptor | -4670550
759mode | -4670551
760subjectPublicKey | -4670552
761keyUsage | -4670553
762
763The _subjectPublicKey_ field contains the public key associated with the subject
764in the form of a COSE\_Key structure encoded to a CBOR byte string.
765
766The _keyUsage_ field contains a CBOR byte string the bits of which correspond to
767the [X.509 KeyUsage bits](https://tools.ietf.org/html/rfc5280#section-4.2.1.3)
768in little-endian byte order (i.e. bit 0 is the low-order bit of the first byte).
769For CDI certificates this should have only the keyCertSign bit set.
770
771All other fields have identical semantics to their counterparts in the
772[X.509 custom extension](#custom-extension-format). The encoding for each is a
773CBOR byte string including _mode_ which is a CBOR byte string holding a single
774byte (the advantage to using a byte string here is a consistent encoding size
775regardless of the value of mode).
776
777# Appendix A: Implementing on Existing Hardware
778
779This profile requires hardware changes to implement fully. However, there is
780still value in implementing it in software on top of existing hardware.
781Depending on the existing hardware capabilities, the security of the DICE root
782may be equivalent to a full hardware implementation.
783
784## Implementing with Standard DICE Support
785
786If hardware supports a standard DICE mechanism but does not support this profile
787directly, this profile can be implemented in firmware and can use the firmware
788CDI from the standard DICE as a UDS. The provisioned certificate would then
789cover both the hardware and the firmware implementing this profile.
790
791However, this only works if the firmware that implements this profile is
792unmodified during normal operation. It becomes a _ROM extension_ in the sense
793that if it is modified, the firmware CDI changes, and the certificate chain
794provisioned for the device is no longer valid. In an ARM Trusted Firmware
795architecture, it would likely be BL2 firmware that implements this profile.
796
797If the firmware implementing this profile is the first firmware to run on the
798system, this approach has equivalent security to a full hardware implementation.
799
800## Implementing with Lockable Persistent Storage
801
802If hardware supports a lockable persistent storage mechanism early in boot, this
803profile can be implemented in firmware and can use a secret stored using this
804mechanism as a UDS. This firmware should run as early in boot as possible. The
805storage could be lockable OTP memory, lockable NVRAM, a one-time derivation, or
806similar. Security chips like a TPM or SE often have an appropriate capability.
807
808However, this only works along with a robust verified boot system to verify the
809firmware that implements this profile and any other firmware that runs before
810it. It also has the downside that changes to the firmware, or any other firmware
811that runs before it, are not reflected in the CDIs.
812
813The security of this approach is not equivalent to a full hardware
814implementation, but may still be acceptable for many applications. If the
815firmware implementing this profile is the first firmware to run on the system,
816this approach has equivalent security to a full hardware implementation which
817employs a hardware modification mechanism like an FPGA or microcode.
818
819This approach can also be used later in boot, for example in a TEE. However, the
820more code that runs without being covered by a DICE flow, the lower the security
821of the implementation.
822
823## Other Hardware Implementations
824
825With a robust verified boot system, there are many other possible
826implementations as long as (1) A UDS can be made available by some means early
827in boot, and (2) that UDS can be made subsequently unavailable until the next
828boot. These implementations meet the requirements of the TCG DICE specification
829as an _updatable DICE_ per section 6.2.
830
831# Appendix B: Hardware Implementation Checklist
832
833The following is a list of capabilities that a full hardware implementation must
834have. This is intended for the convenience of hardware designers, and is not
835intended to add any additional requirements or constraints.
836
8371. Provide a UDS capability as required by this profile and the TCG DICE
838 specification. Usually this _cannot_ be implemented in mask ROM but requires
839 additional hardware capabilities. See [UDS Details](#uds-details).
8401. Reserve on the order of 8KB of mask ROM for DICE, not including crypto
841 primitives. The rest of this list can usually be implemented entirely in
842 ROM.
8431. Choose crypto primitives and provide implementations, ideally with hardware
844 acceleration. See [Cryptography](#cryptography).
8451. Provide a code input. At this level a simple code hash is recommended,
846 without an additional descriptor. Often the verified boot system already has
847 a code hash it verifies, and using the same hash as input to DICE is
848 recommended. See [Input Values](#input-values).
8491. Provide a configuration input. At this level, using the 64-bit value
850 described in this profile is recommended. See [Input Values](#input-values)
851 and
852 [Configuration Input Value Details](#configuration-input-value-details-optional).
8531. Provide a verified boot authority input. This should be very simple and
854 stable, often copied directly out of OTP memory. At this level a simple hash
855 is recommended, without an additional descriptor. See
856 [Input Values](#input-values).
8571. Provide a mode input. Determining the mode is a runtime decision so a bit of
858 logic will have to be coded. The 64-bit configuration value should have all
859 the information necessary to make this decision. See
860 [Input Values](#input-values) and [Mode Value Details](#mode-value-details).
8611. Provide a hidden input value if necessary. At this level it is not
862 recommended.
8631. Implement the [DICE flow](#high-level-dice-flow) and certificate generation;
864 reference code is available. If recommendations in this list are followed
865 for simple inputs, the certificate will be a constant size and layout and a
866 template can be used (avoiding the need for X.509 or CBOR code). See
867 [Certificate Details](#certificate-details).
8681. Make DICE outputs available to firmware (CDIs and certificate).
8691. Depending on which provisioning model is used, make the UDS-derived public
870 key available.
871
872# Appendix C: Versioned Sealing Keys
873
874A versioned sealing key is a key that is derived from a secret seed and one or
875more software versions. The versions cannot be higher than the current software
876version. In other words, a versioned sealing key can be derived for the current
877software version and each previous version, but not for future versions. These
878keys can be used to seal data in a rollback-protected way, that is, in a way
879that current and future software can unseal but older software cannot. Each time
880software is upgraded, the data can be re-sealed to be bound to the latest
881version.
882
883The Sealing CDIs derived by using DICE in layers as described in this profile
884are not versioned; rather they are stable across versions. To achieve versioned
885sealing keys, an additional hardware mechanism is required: a versioned KDF
886(V-KDF). There are many possible implementations but in general it must be
887possible to seed the V-KDF with one or more secrets that it will not expose, and
888one or more maximum versions that it will not allow to be subsequently modified.
889After seeding, the V-KDF accepts version info as input (likely along with other
890inputs), and the output is a key that may be used as a versioned sealing key.
891
892Given such a V-KDF, versioned keys can be derived from a Sealing CDI by adding a
893few steps to precede the [DICE flow](#high-level-dice-flow):
894
895* Derive a V-KDF seed from the current sealing CDI (or UDS if this is the
896 initial DICE instance) and the same inputs used for deriving the next layer
897 sealing CDI. The derivation differs from the sealing CDI derivation only by
898 the info string:
899
900```py
901VKDF_SEED = KDF(32, CDI_Seal_or_UDS, H(authority + mode + hidden), "VKDF_SEED")
902```
903
904* Seed the V-KDF with the output of (1) and the version of the target code
905 (the code to which control will be transferred at the end of the DICE flow)
906* Destroy any copy of the V-KDF seed, so it's only available to the V-KDF
907* Run the DICE flow as usual
908
909Note that the V-KDF seed is derived from the _current_ sealing CDI; this value
910is _not_ passed to target code but is locked / destroyed as part of the DICE
911flow. As a result the target code can only generate versioned keys as seeded by
912the previous layer.
913
914When multiple layers are involved, the V-KDF should use the seed inputs
915cumulatively:
916
917* The seed value should be mixed into the current state, it should not reset
918 the state.
919* The max version value should be retained in addition to the existing max
920 version values. The version info supplied as KDF input must then contain one
921 version for each maximum version configured. The number of layers supported
922 may be limited by the V-KDF hardware; support for at least 8 maximum
923 versions is recommended.