1*60b67249SAndroid Build Coastguard Worker# Open Profile for DICE 2*60b67249SAndroid Build Coastguard Worker 3*60b67249SAndroid Build Coastguard Workerv2.5 4*60b67249SAndroid Build Coastguard Worker 5*60b67249SAndroid Build Coastguard Worker[TOC] 6*60b67249SAndroid Build Coastguard Worker 7*60b67249SAndroid Build Coastguard Worker## Background 8*60b67249SAndroid Build Coastguard Worker 9*60b67249SAndroid Build Coastguard WorkerThe Trusted Computing Group (TCG) specifies 10*60b67249SAndroid Build Coastguard Worker[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*60b67249SAndroid Build Coastguard Worker(DICE) which provides the context for this document. We'll call this TCG 12*60b67249SAndroid Build Coastguard Workerdocument the *TCG DICE specification*. Concepts like a Unique Device Secret 13*60b67249SAndroid Build Coastguard Worker(UDS) and a Compound Device Identifier (CDI) are used as defined in the TCG DICE 14*60b67249SAndroid Build Coastguard Workerspecification. 15*60b67249SAndroid Build Coastguard Worker 16*60b67249SAndroid Build Coastguard Worker#### A Note on Nomenclature 17*60b67249SAndroid Build Coastguard Worker 18*60b67249SAndroid Build Coastguard WorkerThis document uses the term *hardware* to refer to anything that is immutable by 19*60b67249SAndroid Build Coastguard Workerdesign after manufacturing. Code in mask ROM, for example, is *hardware*. The 20*60b67249SAndroid Build Coastguard Workerterms *firmware*, *software* and *program* are all interchangeable; they all 21*60b67249SAndroid Build Coastguard Workerrefer to mutable code. Often we say *firmware* for code that runs early in boot, 22*60b67249SAndroid Build Coastguard Workerand *program* for a particular unit of code, but it's really all *software*. 23*60b67249SAndroid Build Coastguard Worker 24*60b67249SAndroid Build Coastguard Worker#### DICE Primer 25*60b67249SAndroid Build Coastguard Worker 26*60b67249SAndroid Build Coastguard WorkerFor those not familiar with DICE, here is a quick primer on the concepts: 27*60b67249SAndroid Build Coastguard Worker 28*60b67249SAndroid Build Coastguard Worker* **UDS** - Unique Device Secret. This is a per-device hardware-level secret 29*60b67249SAndroid Build Coastguard Worker accessible to the DICE but not accessible after the DICE runs. This is one 30*60b67249SAndroid Build Coastguard Worker of the DICE inputs. Note that when [layering](#layering-details) DICE 31*60b67249SAndroid Build Coastguard Worker computations the UDS is only used for the first computation when 32*60b67249SAndroid Build Coastguard Worker transitioning from hardware to software. Mutable software must never have 33*60b67249SAndroid Build Coastguard Worker access to the hardware UDS. 34*60b67249SAndroid Build Coastguard Worker* **CDI** - Compound Device Identifier. This value represents the 35*60b67249SAndroid Build Coastguard Worker hardware/software combination measured by the DICE. This is the DICE output 36*60b67249SAndroid Build Coastguard Worker and is passed to the software which has been measured. This is a secret. 37*60b67249SAndroid Build Coastguard Worker* **DICE** - Device Identifier Composition Engine. This is a process which 38*60b67249SAndroid Build Coastguard Worker mixes the UDS with software hashes and other inputs to produce a CDI and 39*60b67249SAndroid Build Coastguard Worker locks down further access to the UDS. This computation occurs at the point 40*60b67249SAndroid Build Coastguard Worker of transition from hardware (e.g. ROM) to software (e.g. first bootloader), 41*60b67249SAndroid Build Coastguard Worker but we can perform the same computation at the point of transition from one 42*60b67249SAndroid Build Coastguard Worker program to another in general to extend CDIs throughout a system. 43*60b67249SAndroid Build Coastguard Worker 44*60b67249SAndroid Build Coastguard WorkerDICE can be implemented with a simple HMAC with the UDS as the key, attributes 45*60b67249SAndroid Build Coastguard Workerof the target code or system as the input, and the output is the CDI. However, 46*60b67249SAndroid Build Coastguard Workerfor a particular implementation there are questions that need to be addressed 47*60b67249SAndroid Build Coastguard Workersuch as "what is in the input, exactly?", and "how should we use the CDI once we 48*60b67249SAndroid Build Coastguard Workerhave it?". That's where this profile comes in, it fills in many of these 49*60b67249SAndroid Build Coastguard Workerdetails. 50*60b67249SAndroid Build Coastguard Worker 51*60b67249SAndroid Build Coastguard Worker## Overview 52*60b67249SAndroid Build Coastguard Worker 53*60b67249SAndroid Build Coastguard WorkerThis document specifies a DICE profile suitable for use in a variety of products 54*60b67249SAndroid Build Coastguard Workerand platforms. The [TCG DICE specification](#background) intentionally allows 55*60b67249SAndroid Build Coastguard Workerfor flexibility in implementation; this document specifies many of these 56*60b67249SAndroid Build Coastguard Workerimplementation details. This document also fills in various details the TCG DICE 57*60b67249SAndroid Build Coastguard Workerspecification considers out of scope. In particular, this document specifies: 58*60b67249SAndroid Build Coastguard Worker 59*60b67249SAndroid Build Coastguard Worker* Cryptographic mechanisms 60*60b67249SAndroid Build Coastguard Worker* UDS size and provisioning 61*60b67249SAndroid Build Coastguard Worker* DICE input details, including how DICE interacts with verified boot 62*60b67249SAndroid Build Coastguard Worker* Additional requirements, including asymmetric key derivation and 63*60b67249SAndroid Build Coastguard Worker certification 64*60b67249SAndroid Build Coastguard Worker 65*60b67249SAndroid Build Coastguard WorkerKnown specializations of this profile include: 66*60b67249SAndroid Build Coastguard Worker 67*60b67249SAndroid Build Coastguard Worker* [Android Profile for DICE](android.md) 68*60b67249SAndroid Build Coastguard Worker 69*60b67249SAndroid Build Coastguard Worker#### Goals 70*60b67249SAndroid Build Coastguard Worker 71*60b67249SAndroid Build Coastguard WorkerThe main goals of this document are: 72*60b67249SAndroid Build Coastguard Worker 73*60b67249SAndroid Build Coastguard Worker* Make it **easier to implement** DICE well, with quality and confidence. 74*60b67249SAndroid Build Coastguard Worker* **Consistency for DICE implementers**, whether in hardware, firmware, or 75*60b67249SAndroid Build Coastguard Worker software. 76*60b67249SAndroid Build Coastguard Worker* **Consistency for attestation verifiers**. There will always be some details 77*60b67249SAndroid Build Coastguard Worker in the certificate extensions that are specific to the target system, but 78*60b67249SAndroid Build Coastguard Worker those differences can be minimized by adopting some conventions when 79*60b67249SAndroid Build Coastguard Worker generating the certificates. 80*60b67249SAndroid Build Coastguard Worker 81*60b67249SAndroid Build Coastguard Worker#### Non-Goals 82*60b67249SAndroid Build Coastguard Worker 83*60b67249SAndroid Build Coastguard WorkerThis document is not intended to: 84*60b67249SAndroid Build Coastguard Worker 85*60b67249SAndroid Build Coastguard Worker* Be a formal standard 86*60b67249SAndroid Build Coastguard Worker* Limit the use of DICE-style mechanisms not described here 87*60b67249SAndroid Build Coastguard Worker 88*60b67249SAndroid Build Coastguard Worker## Architecture Diagram 89*60b67249SAndroid Build Coastguard Worker 90*60b67249SAndroid Build Coastguard WorkerThis architecture diagram shows the first DICE transition from hardware to 91*60b67249SAndroid Build Coastguard Workersoftware, and uses the UDS in the derivation of both the Attestation CDI and 92*60b67249SAndroid Build Coastguard WorkerSealing CDI. Subsequent DICE transitions would use the current CDI values in 93*60b67249SAndroid Build Coastguard Workerplace of the UDS to compute the subsequent CDI values. See 94*60b67249SAndroid Build Coastguard Worker[Layering Details](#layering-details). See the [Cryptography](#cryptography) 95*60b67249SAndroid Build Coastguard Workersection for details on the primitives referenced in the diagram. 96*60b67249SAndroid Build Coastguard Worker 97*60b67249SAndroid Build Coastguard Worker 98*60b67249SAndroid Build Coastguard Worker 99*60b67249SAndroid Build Coastguard Worker## Use Cases 100*60b67249SAndroid Build Coastguard Worker 101*60b67249SAndroid Build Coastguard WorkerThis design is motivated by two use cases: **attestation** and **sealing**. 102*60b67249SAndroid Build Coastguard Worker*Attestation* allows a computing device or program to provide verifiable 103*60b67249SAndroid Build Coastguard Workerevidence of its identity and operating state, including hardware identity, 104*60b67249SAndroid Build Coastguard Workersoftware image, security-relevant configuration, operating environment, etc. 105*60b67249SAndroid Build Coastguard Worker*Sealing* allows a computing device or program to encrypt data in such a way 106*60b67249SAndroid Build Coastguard Workerthat it can only be decrypted by the same device or program operating in the 107*60b67249SAndroid Build Coastguard Workersame state as at the time of encryption. 108*60b67249SAndroid Build Coastguard Worker 109*60b67249SAndroid Build Coastguard WorkerWith this design, sealing only works well in combination with some kind of 110*60b67249SAndroid Build Coastguard Workerverified boot system. For a more sophisticated example of sealing key 111*60b67249SAndroid Build Coastguard Workergeneration, see 112*60b67249SAndroid Build Coastguard Worker[Appendix C: Versioned Sealing Keys](#appendix-c-versioned-sealing-keys). 113*60b67249SAndroid Build Coastguard Worker 114*60b67249SAndroid Build Coastguard Worker# Profile Design 115*60b67249SAndroid Build Coastguard Worker 116*60b67249SAndroid Build Coastguard Worker## Input Values 117*60b67249SAndroid Build Coastguard Worker 118*60b67249SAndroid Build Coastguard WorkerFor attestation, DICE inputs should represent all security-relevant properties 119*60b67249SAndroid Build Coastguard Workerof the target program. The target program is the program to which control will 120*60b67249SAndroid Build Coastguard Workerbe passed, along with DICE outputs, after the DICE computations are complete. 121*60b67249SAndroid Build Coastguard WorkerThis profile defines the following types of input, each of which is represented 122*60b67249SAndroid Build Coastguard Workerby a fixed length value: 123*60b67249SAndroid Build Coastguard Worker 124*60b67249SAndroid Build Coastguard Worker1. **Code (64 bytes)** - This input is computed by hashing the target code. 125*60b67249SAndroid Build Coastguard Worker This is the traditional input described most clearly in the 126*60b67249SAndroid Build Coastguard Worker [TCG DICE specification](#background). If a software image is too large to 127*60b67249SAndroid Build Coastguard Worker load and hash entirely, then a descriptor of the code (like the root hash of 128*60b67249SAndroid Build Coastguard Worker a hash tree) may be used instead. Note that this approach requires 129*60b67249SAndroid Build Coastguard Worker additional ongoing enforcement to verify pages as they are loaded. A 130*60b67249SAndroid Build Coastguard Worker canonical example of this is 131*60b67249SAndroid Build Coastguard Worker [dm-verity](https://source.android.com/security/verifiedboot/dm-verity). 132*60b67249SAndroid Build Coastguard Worker2. **Configuration Data (64 bytes)** - This input is a catch-all for any 133*60b67249SAndroid Build Coastguard Worker security-relevant configuration or environment properties that characterize 134*60b67249SAndroid Build Coastguard Worker the integrity of the system and can be used by an external party to validate 135*60b67249SAndroid Build Coastguard Worker its identity and/or its operating state. This may capture verified boot 136*60b67249SAndroid Build Coastguard Worker authority selection, device mode, boot location, chip status information, 137*60b67249SAndroid Build Coastguard Worker instance identifiers, etc. This value may or may not be a hash of the actual 138*60b67249SAndroid Build Coastguard Worker configuration data. When it is a hash, the original data must also be 139*60b67249SAndroid Build Coastguard Worker included in certificates. It's ok for this input to be *not stable*, it may 140*60b67249SAndroid Build Coastguard Worker change from one boot to the next. 141*60b67249SAndroid Build Coastguard Worker3. **Authority Data (64 bytes)** - This input is computed by hashing a 142*60b67249SAndroid Build Coastguard Worker representation of the verified boot trusted authority. For example, this may 143*60b67249SAndroid Build Coastguard Worker be a public key, a hash of a public key, or a hash of a descriptor 144*60b67249SAndroid Build Coastguard Worker containing a set of public keys. For many SoCs, this representation of the 145*60b67249SAndroid Build Coastguard Worker trusted authority is programmed into one-time-programmable (OTP) memory. If 146*60b67249SAndroid Build Coastguard Worker a code authorization mechanism is disabled or not supported, this input 147*60b67249SAndroid Build Coastguard Worker should be 64 zero bytes. If multiple public keys are supported with runtime 148*60b67249SAndroid Build Coastguard Worker selection, this input value must represent all of them. (This is so the 149*60b67249SAndroid Build Coastguard Worker value remains stable across a key change, the actual key that was used 150*60b67249SAndroid Build Coastguard Worker during boot should be included in the configuration data input value). The 151*60b67249SAndroid Build Coastguard Worker authority input value is designed to be stable, it is very unlikely to 152*60b67249SAndroid Build Coastguard Worker change during a device lifecycle. 153*60b67249SAndroid Build Coastguard Worker4. **Mode Decision (1 byte)** - This input value is a single-byte mode value. 154*60b67249SAndroid Build Coastguard Worker Valid mode values are: **0**: Not Configured, **1**: Normal, **2**: Debug, 155*60b67249SAndroid Build Coastguard Worker **3**: Recovery. The mode is determined at runtime based on the other 156*60b67249SAndroid Build Coastguard Worker inputs, and only the other inputs. This input is designed to capture a 157*60b67249SAndroid Build Coastguard Worker configuration signal in a stable way, and to reflect important decisions a 158*60b67249SAndroid Build Coastguard Worker device makes at runtime. In the sealing use case, this enables data to be 159*60b67249SAndroid Build Coastguard Worker sealed separately under each mode. See 160*60b67249SAndroid Build Coastguard Worker [Mode Value Details](#mode-value-details). 161*60b67249SAndroid Build Coastguard Worker5. **Hidden Inputs (64 bytes)** - This optional input value is *hidden* in the 162*60b67249SAndroid Build Coastguard Worker sense that it does not appear in any certificate. It is used for both 163*60b67249SAndroid Build Coastguard Worker attestation and sealing CDI derivation so it is expected to be stable; it 164*60b67249SAndroid Build Coastguard Worker should not change under normal operation except when that change is an 165*60b67249SAndroid Build Coastguard Worker intentional part of the device lifecycle. If not used, this value should be 166*60b67249SAndroid Build Coastguard Worker all zero bytes. While this value can be anything, intended use cases 167*60b67249SAndroid Build Coastguard Worker include: 168*60b67249SAndroid Build Coastguard Worker 169*60b67249SAndroid Build Coastguard Worker * Mixing in an additional secret which may be changed as part of the 170*60b67249SAndroid Build Coastguard Worker device lifecycle, for example ownership transfer 171*60b67249SAndroid Build Coastguard Worker * Mixing in a rotation nonce or counter to control the rotation of 172*60b67249SAndroid Build Coastguard Worker attestation keys and sealing keys 173*60b67249SAndroid Build Coastguard Worker * Mixing in stable instance IDs or other internal IDs which may provide 174*60b67249SAndroid Build Coastguard Worker differentiation for sealing CDIs 175*60b67249SAndroid Build Coastguard Worker * Mixing in stable configuration inputs which appear in Configuration Data 176*60b67249SAndroid Build Coastguard Worker but also should be used in the sealing CDI derivation 177*60b67249SAndroid Build Coastguard Worker 178*60b67249SAndroid Build Coastguard Worker## CDI Values 179*60b67249SAndroid Build Coastguard Worker 180*60b67249SAndroid Build Coastguard WorkerThe [TCG DICE specification](#background) refers to a single CDI, but this 181*60b67249SAndroid Build Coastguard Workerprofile defines multiple CDIs with different characteristics which can be used 182*60b67249SAndroid Build Coastguard Workerfor different use cases: 183*60b67249SAndroid Build Coastguard Worker 184*60b67249SAndroid Build Coastguard Worker1. **Attestation CDI** - This CDI is derived from the combination of all input 185*60b67249SAndroid Build Coastguard Worker values and will change across software updates or configuration changes. 186*60b67249SAndroid Build Coastguard Worker This CDI is appropriate for attestation and is *mandatory* for 187*60b67249SAndroid Build Coastguard Worker implementations of this profile. 188*60b67249SAndroid Build Coastguard Worker2. **Sealing CDI** - This CDI is derived from only the authority data, mode 189*60b67249SAndroid Build Coastguard Worker decision, and hidden inputs because these are stable. It will reflect this 190*60b67249SAndroid Build Coastguard Worker stability and will remain the same across software updates and some 191*60b67249SAndroid Build Coastguard Worker configuration changes. This CDI is appropriate for sealing and is *optional* 192*60b67249SAndroid Build Coastguard Worker for implementations of this profile. 193*60b67249SAndroid Build Coastguard Worker 194*60b67249SAndroid Build Coastguard Worker### CDI Certificates 195*60b67249SAndroid Build Coastguard Worker 196*60b67249SAndroid Build Coastguard WorkerThis profile requires the generation of a CDI certificate as part of the DICE 197*60b67249SAndroid Build Coastguard Workerflow. The subject key pair is derived from the Attestation CDI value for the 198*60b67249SAndroid Build Coastguard Workertarget code. The authority key pair which signs the certificate is derived from 199*60b67249SAndroid Build Coastguard Workerthe UDS or, after the initial hardware to software transition, from the 200*60b67249SAndroid Build Coastguard WorkerAttestation CDI value for the current code (see 201*60b67249SAndroid Build Coastguard Worker[Layering Details](#layering-details)). The DICE flow outputs the CDI values and 202*60b67249SAndroid Build Coastguard Workerthe generated certificate; the private key associated with the certificate may 203*60b67249SAndroid Build Coastguard Workerbe optionally passed along with the CDI values to avoid the need for 204*60b67249SAndroid Build Coastguard Workerre-derivation by the target code. The UDS-derived public key is certified by an 205*60b67249SAndroid Build Coastguard Workerexternal authority during manufacturing to complete the certificate chain. See 206*60b67249SAndroid Build Coastguard Worker[Certificate Details](#certificate-details). 207*60b67249SAndroid Build Coastguard Worker 208*60b67249SAndroid Build Coastguard WorkerAs an example, if the CDI private key were used to sign a leaf certificate for 209*60b67249SAndroid Build Coastguard Workeran attestation key, the certificate chain may look like this: 210*60b67249SAndroid Build Coastguard Worker 211*60b67249SAndroid Build Coastguard Worker 212*60b67249SAndroid Build Coastguard Worker 213*60b67249SAndroid Build Coastguard Worker## High-level DICE Flow 214*60b67249SAndroid Build Coastguard Worker 215*60b67249SAndroid Build Coastguard WorkerThe [TCG DICE specification](#background) outlines a four stage flow: measure, 216*60b67249SAndroid Build Coastguard Workercompute CDI, lock UDS, and transfer control. This profile expands on this to 217*60b67249SAndroid Build Coastguard Workerinclude operations for CDI certification. The expanded flow has the following 218*60b67249SAndroid Build Coastguard Workersteps: 219*60b67249SAndroid Build Coastguard Worker 220*60b67249SAndroid Build Coastguard Worker1. Measure CDI input values and compute CDI values 221*60b67249SAndroid Build Coastguard Worker2. Derive an asymmetric key pair from the UDS 222*60b67249SAndroid Build Coastguard Worker3. Lock UDS 223*60b67249SAndroid Build Coastguard Worker4. Derive an asymmetric key pair from the Attestation CDI 224*60b67249SAndroid Build Coastguard Worker5. Generate a CDI certificate 225*60b67249SAndroid Build Coastguard Worker6. Destroy the UDS-derived private key from step (2) 226*60b67249SAndroid Build Coastguard Worker7. Transfer control to the target code, passing on the certificate and all CDI 227*60b67249SAndroid Build Coastguard Worker values 228*60b67249SAndroid Build Coastguard Worker 229*60b67249SAndroid Build Coastguard Worker## Cryptography 230*60b67249SAndroid Build Coastguard Worker 231*60b67249SAndroid Build Coastguard WorkerThis profile requires three cryptographic primitives: a hash function, a key 232*60b67249SAndroid Build Coastguard Workerderivation function, and an asymmetric digital signature. The recommended 233*60b67249SAndroid Build Coastguard Workerdefaults are [SHA-512](https://en.wikipedia.org/wiki/SHA-2), 234*60b67249SAndroid Build Coastguard Worker[HKDF](https://en.wikipedia.org/wiki/HKDF) (using SHA-512) and 235*60b67249SAndroid Build Coastguard Worker[Ed25519](https://en.wikipedia.org/wiki/EdDSA#Ed25519). Since Ed25519 uses 236*60b67249SAndroid Build Coastguard WorkerSHA-512 under the hood, using this combination means implementing only one hash 237*60b67249SAndroid Build Coastguard Workerfunction. See below for the full list of 238*60b67249SAndroid Build Coastguard Worker[acceptable algorithms](#acceptable-cryptographic-algorithms). 239*60b67249SAndroid Build Coastguard Worker 240*60b67249SAndroid Build Coastguard WorkerThe following pseudocode operations are used throughout this document: 241*60b67249SAndroid Build Coastguard Worker 242*60b67249SAndroid Build Coastguard Worker```py 243*60b67249SAndroid Build Coastguard Worker# A hash function. The input can be any length. 244*60b67249SAndroid Build Coastguard Workerhash = H(input) 245*60b67249SAndroid Build Coastguard Worker 246*60b67249SAndroid Build Coastguard Worker# Random salt values used as the 'salt' KDF argument (hex encoded). 247*60b67249SAndroid Build Coastguard WorkerASYM_SALT = 63B6A04D2C077FC10F639F21DA793844356CC2B0B441B3A77124035C03F8E1BE 248*60b67249SAndroid Build Coastguard Worker 6035D31F282821A7450A02222AB1B3CFF1679B05AB1CA5D1AFFB789CCD2B0B3B 249*60b67249SAndroid Build Coastguard WorkerID_SALT = DBDBAEBC8020DA9FF0DD5A24C83AA5A54286DFC263031E329B4DA148430659FE 250*60b67249SAndroid Build Coastguard Worker 62CDB5B7E1E00FC680306711EB444AF77209359496FCFF1DB9520BA51C7B29EA 251*60b67249SAndroid Build Coastguard Worker 252*60b67249SAndroid Build Coastguard Worker# A KDF operation with the given desired output length, input key material, 253*60b67249SAndroid Build Coastguard Worker# salt, and info. 254*60b67249SAndroid Build Coastguard Workeroutput = KDF(length, ikm, salt, info) 255*60b67249SAndroid Build Coastguard Worker 256*60b67249SAndroid Build Coastguard Worker# An asymmetric key pair derivation, either Ed25519 or ECDSA. 257*60b67249SAndroid Build Coastguard Worker# * The private key is derived using KDF(32, input, ASYM_SALT, "Key Pair"). 258*60b67249SAndroid Build Coastguard Worker# * The public key is derived from the private key (per the chosen algorithm). 259*60b67249SAndroid Build Coastguard Workerprivate_key, public_key = ASYM_KDF(input) 260*60b67249SAndroid Build Coastguard Worker``` 261*60b67249SAndroid Build Coastguard Worker 262*60b67249SAndroid Build Coastguard Worker### Computing CDI Values 263*60b67249SAndroid Build Coastguard Worker 264*60b67249SAndroid Build Coastguard WorkerEach CDI value is 32 bytes in length and is computed using a KDF operation with 265*60b67249SAndroid Build Coastguard Workerthe UDS or previous CDI value as the input key material argument and the 266*60b67249SAndroid Build Coastguard Workerrelevant input measurement as the salt argument. The KDF info argument differs 267*60b67249SAndroid Build Coastguard Workerfor each type of CDI. 268*60b67249SAndroid Build Coastguard Worker 269*60b67249SAndroid Build Coastguard Worker#### Attestation CDI 270*60b67249SAndroid Build Coastguard Worker 271*60b67249SAndroid Build Coastguard WorkerThe Attestation CDI input measurement is derived from the combination of all 272*60b67249SAndroid Build Coastguard Workerinput values. The [input values](#input-values) are hashed in this order: code, 273*60b67249SAndroid Build Coastguard Workerconfig, authority, mode, hidden. 274*60b67249SAndroid Build Coastguard Worker 275*60b67249SAndroid Build Coastguard Worker```py 276*60b67249SAndroid Build Coastguard WorkerCDI_Attest = KDF(32, UDS, H(code + config + authority + mode + hidden), 277*60b67249SAndroid Build Coastguard Worker "CDI_Attest") 278*60b67249SAndroid Build Coastguard Worker``` 279*60b67249SAndroid Build Coastguard Worker 280*60b67249SAndroid Build Coastguard Worker#### Sealing CDI 281*60b67249SAndroid Build Coastguard Worker 282*60b67249SAndroid Build Coastguard WorkerThe Sealing CDI input measurement is similar but is derived from only the stable 283*60b67249SAndroid Build Coastguard Workerinputs. The [input values](#input-values) are hashed in this order: authority, 284*60b67249SAndroid Build Coastguard Workermode, hidden. 285*60b67249SAndroid Build Coastguard Worker 286*60b67249SAndroid Build Coastguard Worker```py 287*60b67249SAndroid Build Coastguard WorkerCDI_Seal = KDF(32, UDS, H(authority + mode + hidden), "CDI_Seal") 288*60b67249SAndroid Build Coastguard Worker``` 289*60b67249SAndroid Build Coastguard Worker 290*60b67249SAndroid Build Coastguard Worker### Deriving Asymmetric Key Pairs 291*60b67249SAndroid Build Coastguard Worker 292*60b67249SAndroid Build Coastguard WorkerThere are two key pair derivations; one to derive from the UDS, and the other to 293*60b67249SAndroid Build Coastguard Workerderive from the Attestation CDI. When deriving from the UDS, the KDF input is 294*60b67249SAndroid Build Coastguard Workersimply the UDS. 295*60b67249SAndroid Build Coastguard Worker 296*60b67249SAndroid Build Coastguard Worker```py 297*60b67249SAndroid Build Coastguard WorkerUDS_Private, UDS_Public = ASYM_KDF(UDS) 298*60b67249SAndroid Build Coastguard Worker``` 299*60b67249SAndroid Build Coastguard Worker 300*60b67249SAndroid Build Coastguard WorkerWhen deriving from Attestation CDI, the KDF input is simply the 301*60b67249SAndroid Build Coastguard Worker[CDI\_Attest](#attestation-cdi) value. 302*60b67249SAndroid Build Coastguard Worker 303*60b67249SAndroid Build Coastguard Worker```py 304*60b67249SAndroid Build Coastguard WorkerCDI_Private, CDI_Public = ASYM_KDF(CDI_Attest) 305*60b67249SAndroid Build Coastguard Worker``` 306*60b67249SAndroid Build Coastguard Worker 307*60b67249SAndroid Build Coastguard WorkerNote: It is important that these two derivations remain consistent except for 308*60b67249SAndroid Build Coastguard Workerthe input key material; this is what makes [layering](#layering-details) 309*60b67249SAndroid Build Coastguard Workerpossible. 310*60b67249SAndroid Build Coastguard Worker 311*60b67249SAndroid Build Coastguard Worker### Deriving Identifiers 312*60b67249SAndroid Build Coastguard Worker 313*60b67249SAndroid Build Coastguard WorkerThere are a few cases where the DICE needs to generate an identifier for use in 314*60b67249SAndroid Build Coastguard Workercertificates. To ensure these identifiers are deterministic and require no 315*60b67249SAndroid Build Coastguard Workeradditional DICE inputs, the identifiers are derived from the associated public 316*60b67249SAndroid Build Coastguard Workerkey. The identifiers are 20 octets so they fit in the RFC 5280 serialNumber 317*60b67249SAndroid Build Coastguard Workerfield constraints and the X520SerialNumber type when hex encoded. The big-endian 318*60b67249SAndroid Build Coastguard Workerhigh-order bit is cleared so the ASN.1 integer representation is always positive 319*60b67249SAndroid Build Coastguard Workerwithout padding. 320*60b67249SAndroid Build Coastguard Worker 321*60b67249SAndroid Build Coastguard Worker```py 322*60b67249SAndroid Build Coastguard WorkerUDS_ID = KDF(20, UDS_Public, ID_SALT, "ID") 323*60b67249SAndroid Build Coastguard WorkerCDI_ID = KDF(20, CDI_Public, ID_SALT, "ID") 324*60b67249SAndroid Build Coastguard Worker``` 325*60b67249SAndroid Build Coastguard Worker 326*60b67249SAndroid Build Coastguard WorkerNote: Like the public key derivations, it is important that the ID derivations 327*60b67249SAndroid Build Coastguard Workerremain consistent except for the input key material. This is because these are 328*60b67249SAndroid Build Coastguard Workerused in certificate issuer and subject fields and need to match when 329*60b67249SAndroid Build Coastguard Worker[layering](#layering-details). 330*60b67249SAndroid Build Coastguard Worker 331*60b67249SAndroid Build Coastguard Worker### Acceptable Cryptographic Algorithms 332*60b67249SAndroid Build Coastguard Worker 333*60b67249SAndroid Build Coastguard Worker#### Hash Algorithms 334*60b67249SAndroid Build Coastguard Worker 335*60b67249SAndroid Build Coastguard WorkerAcceptable hash algorithms are: 336*60b67249SAndroid Build Coastguard Worker 337*60b67249SAndroid Build Coastguard Worker* SHA-256, SHA-384, SHA-512 338*60b67249SAndroid Build Coastguard Worker* SHA3-256, SHA3-384, SHA3-512 339*60b67249SAndroid Build Coastguard Worker 340*60b67249SAndroid Build Coastguard Worker#### Key Derivation Functions 341*60b67249SAndroid Build Coastguard Worker 342*60b67249SAndroid Build Coastguard Worker##### HKDF 343*60b67249SAndroid Build Coastguard Worker 344*60b67249SAndroid Build Coastguard Worker[HKDF](https://en.wikipedia.org/wiki/HKDF) can be used with any acceptable hash 345*60b67249SAndroid Build Coastguard Workeralgorithm. The KDF inputs map exactly to HKDF parameters, by design. This is the 346*60b67249SAndroid Build Coastguard Workerrecommended default. 347*60b67249SAndroid Build Coastguard Worker 348*60b67249SAndroid Build Coastguard WorkerPer the HKDF 349*60b67249SAndroid Build Coastguard Worker[specification](https://datatracker.ietf.org/doc/html/rfc5869#section-3.3) the 350*60b67249SAndroid Build Coastguard Workerextract step can be skipped in some cases, and since all KDFs used in this 351*60b67249SAndroid Build Coastguard Workerspecification use cryptographically strong ikm values, doing so is acceptable 352*60b67249SAndroid Build Coastguard Workerhere. 353*60b67249SAndroid Build Coastguard Worker 354*60b67249SAndroid Build Coastguard Worker##### DRBG 355*60b67249SAndroid Build Coastguard Worker 356*60b67249SAndroid Build Coastguard WorkerA 357*60b67249SAndroid Build Coastguard Worker[DRBG](https://nvlpubs.nist.gov/nistpubs/SpecialPublications/NIST.SP.800-90Ar1.pdf) 358*60b67249SAndroid Build Coastguard Workercan be used to implement the KDF operation. Depending on the DRBG implementation 359*60b67249SAndroid Build Coastguard Workerthis may require UDS and CDI values larger than 256 bits to provide both *nonce* 360*60b67249SAndroid Build Coastguard Workerand *entropy* inputs when instantiating the DRBG. The DRBG should be 361*60b67249SAndroid Build Coastguard Workerinstantiated with a security strength of 256 bits. The sequence of DRBG 362*60b67249SAndroid Build Coastguard Workerfunctions {instantiate, generate, uninstantiate}, are used as a KDF operation. 363*60b67249SAndroid Build Coastguard WorkerThe mapping of inputs is as shown in the following table. 364*60b67249SAndroid Build Coastguard Worker 365*60b67249SAndroid Build Coastguard WorkerHKDF Input | Corresponding DRBG Input 366*60b67249SAndroid Build Coastguard Worker---------- | ------------------------------------ 367*60b67249SAndroid Build Coastguard Workerikm | Instantiate: Entropy Input and Nonce 368*60b67249SAndroid Build Coastguard Workersalt | Generate: Additional Input 369*60b67249SAndroid Build Coastguard Workerinfo | Instantiate: Personalization String 370*60b67249SAndroid Build Coastguard Worker 371*60b67249SAndroid Build Coastguard Worker##### OpenTitan Key Manager 372*60b67249SAndroid Build Coastguard Worker 373*60b67249SAndroid Build Coastguard WorkerThe 374*60b67249SAndroid Build Coastguard Worker[OpenTitan Key Manager](https://docs.opentitan.org/hw/ip/keymgr/doc/index.html) 375*60b67249SAndroid Build Coastguard Workercan be used as a KDF. See the OpenTitan documentation for details. 376*60b67249SAndroid Build Coastguard Worker 377*60b67249SAndroid Build Coastguard Worker##### SP800-108 378*60b67249SAndroid Build Coastguard Worker 379*60b67249SAndroid Build Coastguard WorkerThe KDFs described in NIST's 380*60b67249SAndroid Build Coastguard Worker[SP800-108](https://nvlpubs.nist.gov/nistpubs/Legacy/SP/nistspecialpublication800-108.pdf) 381*60b67249SAndroid Build Coastguard Workercan be used. 382*60b67249SAndroid Build Coastguard Worker 383*60b67249SAndroid Build Coastguard Worker#### Digital Signatures 384*60b67249SAndroid Build Coastguard Worker 385*60b67249SAndroid Build Coastguard Worker##### Ed25519 386*60b67249SAndroid Build Coastguard Worker 387*60b67249SAndroid Build Coastguard Worker[Ed25519](https://en.wikipedia.org/wiki/EdDSA#Ed25519) is the recommended 388*60b67249SAndroid Build Coastguard Workerdefault. 389*60b67249SAndroid Build Coastguard Worker 390*60b67249SAndroid Build Coastguard WorkerWhen deriving Ed25519 key pairs, using the output of ASYM_KDF directly as the 391*60b67249SAndroid Build Coastguard Workerprivate key is acceptable. 392*60b67249SAndroid Build Coastguard Worker 393*60b67249SAndroid Build Coastguard Worker##### ECDSA 394*60b67249SAndroid Build Coastguard Worker 395*60b67249SAndroid Build Coastguard Worker[ECDSA](https://en.wikipedia.org/wiki/Elliptic_Curve_Digital_Signature_Algorithm) 396*60b67249SAndroid Build Coastguard Workercan be used instead of Ed25519. When signing the CDI certificate, the random *k* 397*60b67249SAndroid Build Coastguard Workerrequired by ECDSA may be generated deterministically per 398*60b67249SAndroid Build Coastguard Worker[RFC6979](https://tools.ietf.org/html/rfc6979). One weakness of Ed25519 is that 399*60b67249SAndroid Build Coastguard Workerimplementations may be susceptible to error injection 400*60b67249SAndroid Build Coastguard Worker([example](https://www.romailler.ch/ddl/10.1109_FDTC.2017.12_eddsa.pdf)). 401*60b67249SAndroid Build Coastguard WorkerAnother disadvantage of Ed25519 is that it is not [currently] FIPS 140-2 402*60b67249SAndroid Build Coastguard Workercertifiable. In any case, either algorithm is acceptable for this profile. 403*60b67249SAndroid Build Coastguard Worker 404*60b67249SAndroid Build Coastguard WorkerThe following [NIST](https://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.186-4.pdf) 405*60b67249SAndroid Build Coastguard Workercurves are acceptable for use with ECDSA: 406*60b67249SAndroid Build Coastguard Worker 407*60b67249SAndroid Build Coastguard Worker* P-256 408*60b67249SAndroid Build Coastguard Worker* P-384 409*60b67249SAndroid Build Coastguard Worker 410*60b67249SAndroid Build Coastguard WorkerWhen deriving ECDSA key pairs the output of ASYM_KDF cannot be used directly. 411*60b67249SAndroid Build Coastguard WorkerFollowing the process described in 412*60b67249SAndroid Build Coastguard Worker[RFC 6979](https://datatracker.ietf.org/doc/html/rfc6979#section-3.3) is 413*60b67249SAndroid Build Coastguard Workerrecommended. In this process the seed, in this case the output of ASYM_KDF, is 414*60b67249SAndroid Build Coastguard Workerused to seed an HMAC_DRBG instance and then the private key is generated from 415*60b67249SAndroid Build Coastguard Workerthe DRBG. See the RFC for details. 416*60b67249SAndroid Build Coastguard Worker 417*60b67249SAndroid Build Coastguard Worker## Layering Details 418*60b67249SAndroid Build Coastguard Worker 419*60b67249SAndroid Build Coastguard WorkerThis DICE profile is designed to be layered. That is, software that receives CDI 420*60b67249SAndroid Build Coastguard Workervalues can in turn execute a DICE flow using those CDI values in place of the 421*60b67249SAndroid Build Coastguard WorkerUDS value. The certificate generated by the next DICE layer can chain to the 422*60b67249SAndroid Build Coastguard Workercertificate generated by the previous DICE layer because the asymmetric key 423*60b67249SAndroid Build Coastguard Workerderivation is consistent across layers for authority and subject keys. 424*60b67249SAndroid Build Coastguard Worker 425*60b67249SAndroid Build Coastguard Worker### Computing Layered CDI Values 426*60b67249SAndroid Build Coastguard Worker 427*60b67249SAndroid Build Coastguard WorkerWhen computing CDI values, the previous Attestation CDI or Sealing CDI is used 428*60b67249SAndroid Build Coastguard Workeras the input key material instead of the hardware UDS: 429*60b67249SAndroid Build Coastguard Worker 430*60b67249SAndroid Build Coastguard Worker```py 431*60b67249SAndroid Build Coastguard WorkerCDI_Attest[n+1] = KDF(32, CDI_Attest[n], H(code + config + authority + mode + hidden), "CDI_Attest") 432*60b67249SAndroid Build Coastguard WorkerCDI_Seal[n+1] = KDF(32, CDI_Seal[n], H(authority + mode + hidden), "CDI_Seal") 433*60b67249SAndroid Build Coastguard Worker``` 434*60b67249SAndroid Build Coastguard Worker 435*60b67249SAndroid Build Coastguard Worker### Protecting Layered CDI Values 436*60b67249SAndroid Build Coastguard Worker 437*60b67249SAndroid Build Coastguard WorkerJust like the UDS is locked in the DICE [flow](#high-level-dice-flow), previous 438*60b67249SAndroid Build Coastguard Workerlayer CDIs must be destroyed, locked, or otherwise protected before control is 439*60b67249SAndroid Build Coastguard Workerpassed to the next layer. Layer[n+1] must never obtain access to CDI[n] values 440*60b67249SAndroid Build Coastguard Workerand must not be able to use CDI[n] in any computation. For example, a layer[n] 441*60b67249SAndroid Build Coastguard Workerprogram cannot offer a service that uses CDI[n] to layer[n+1] programs. In some 442*60b67249SAndroid Build Coastguard Workercases a layer[n] program will stay active and spawn multiple programs (for 443*60b67249SAndroid Build Coastguard Workerexample, a kernel, TEE, or hypervisor). In these cases the CDI[n] values must be 444*60b67249SAndroid Build Coastguard Workerprotected from all layer[n+1] programs for the duration they are in operation, 445*60b67249SAndroid Build Coastguard Workerand must be destroyed when no longer needed. 446*60b67249SAndroid Build Coastguard Worker 447*60b67249SAndroid Build Coastguard Worker### Generating Layered Certificates 448*60b67249SAndroid Build Coastguard Worker 449*60b67249SAndroid Build Coastguard WorkerWhen generating certificates, the authority is the previous CDI key pair and the 450*60b67249SAndroid Build Coastguard Workercertificates chain together. So the certificate chain may look like this: 451*60b67249SAndroid Build Coastguard Worker 452*60b67249SAndroid Build Coastguard Worker 453*60b67249SAndroid Build Coastguard Worker 454*60b67249SAndroid Build Coastguard Worker## UDS Details 455*60b67249SAndroid Build Coastguard Worker 456*60b67249SAndroid Build Coastguard Worker### Requirements 457*60b67249SAndroid Build Coastguard Worker 458*60b67249SAndroid Build Coastguard WorkerIn addition to the requirements described in the 459*60b67249SAndroid Build Coastguard Worker[TCG DICE specification](#background), this profile requires the following: 460*60b67249SAndroid Build Coastguard Worker 461*60b67249SAndroid Build Coastguard Worker* The UDS is at least 256 bits in size and is full-entropy. This means the UDS 462*60b67249SAndroid Build Coastguard Worker value has been conditioned from at least 512 bits of entropy. 463*60b67249SAndroid Build Coastguard Worker* If a UDS has not been provisioned, a value of all zero bytes is used. This 464*60b67249SAndroid Build Coastguard Worker convention enables provisioning testability since running a DICE on an 465*60b67249SAndroid Build Coastguard Worker unprovisioned UDS will yield predictable outputs. 466*60b67249SAndroid Build Coastguard Worker* UDS values and certificates must use one of the provisioning schemes 467*60b67249SAndroid Build Coastguard Worker described in this section. The provisioning process is expected to occur 468*60b67249SAndroid Build Coastguard Worker very seldom, likely once per device during manufacture. Hardware may or may 469*60b67249SAndroid Build Coastguard Worker not support re-provisioning of the UDS. 470*60b67249SAndroid Build Coastguard Worker 471*60b67249SAndroid Build Coastguard Worker### Provisioning Scheme 1: Pre-generation 472*60b67249SAndroid Build Coastguard Worker 473*60b67249SAndroid Build Coastguard WorkerIn this scheme, the UDS and an associated certificate are pre-generated and 474*60b67249SAndroid Build Coastguard Workerinjected during a manufacturing process in a controlled environment appropriate 475*60b67249SAndroid Build Coastguard Workerfor the implementation or product. The pre-generation infrastructure does not 476*60b67249SAndroid Build Coastguard Workerretain UDS values after provisioning. This approach is designed to balance the 477*60b67249SAndroid Build Coastguard Workerrisks and costs associated with provisioning between security and scale. 478*60b67249SAndroid Build Coastguard WorkerRationale is not described here in detail, but the primary benefits are: 479*60b67249SAndroid Build Coastguard Worker 480*60b67249SAndroid Build Coastguard Worker* No in-factory CAs (which make revocation as difficult as pre-generation) 481*60b67249SAndroid Build Coastguard Worker* On-device certificates (which enable offline use cases) 482*60b67249SAndroid Build Coastguard Worker 483*60b67249SAndroid Build Coastguard WorkerNote: If the UDS is integrated with an SoC at the time of SoC manufacture, the 484*60b67249SAndroid Build Coastguard Workerissuer may be the SoC vendor. If the UDS is integrated at the time of device 485*60b67249SAndroid Build Coastguard Workermanufacture, the issuer may be the OEM. 486*60b67249SAndroid Build Coastguard Worker 487*60b67249SAndroid Build Coastguard Worker#### Provisioning Flow 488*60b67249SAndroid Build Coastguard Worker 489*60b67249SAndroid Build Coastguard Worker1. [Pre-generation] Generate a random UDS 490*60b67249SAndroid Build Coastguard Worker2. [Pre-generation] Derive UDS\_Public and generate an associated certificate 491*60b67249SAndroid Build Coastguard Worker which has a subject matching the expected issuer field generated for CDI 492*60b67249SAndroid Build Coastguard Worker certificates (see [X.509 UDS Certificates](#x_509-uds-certificates)). 493*60b67249SAndroid Build Coastguard Worker3. [Manufacturing] Program the UDS to the hardware (and destroy the source 494*60b67249SAndroid Build Coastguard Worker copy) 495*60b67249SAndroid Build Coastguard Worker4. [Manufacturing] Test the DICE to ensure: 496*60b67249SAndroid Build Coastguard Worker 1. The UDS certificate correctly chains to the CDI certificate 497*60b67249SAndroid Build Coastguard Worker 2. The CDI values cannot be reproduced using a zero UDS 498*60b67249SAndroid Build Coastguard Worker5. [Manufacturing] Write the certificate to device storage 499*60b67249SAndroid Build Coastguard Worker 500*60b67249SAndroid Build Coastguard Worker### Provisioning Scheme 2: Factory CA 501*60b67249SAndroid Build Coastguard Worker 502*60b67249SAndroid Build Coastguard WorkerIn some cases, it may be feasible and preferable to install a CA for UDS 503*60b67249SAndroid Build Coastguard Workerprovisioning during an SoC or device manufacturing stage. In this scheme, the 504*60b67249SAndroid Build Coastguard WorkerUDS is derived on-chip from internal and external entropy, at least 256 bits 505*60b67249SAndroid Build Coastguard Workereach. Internal entropy may be generated using a 506*60b67249SAndroid Build Coastguard Worker[PUF](https://en.wikipedia.org/wiki/Physical_unclonable_function), or generated 507*60b67249SAndroid Build Coastguard Workeronce using an internal hardware TRNG and stored, for example, in OTP memory. 508*60b67249SAndroid Build Coastguard WorkerExternal entropy is injected once during manufacturing and stored, for example, 509*60b67249SAndroid Build Coastguard Workerin OTP memory. The UDS is derived at runtime on every boot from the combined 510*60b67249SAndroid Build Coastguard Workerentropy. The UDS derivation (i.e. conditioning) from internal and external 511*60b67249SAndroid Build Coastguard Workerentropy uses a KDF: 512*60b67249SAndroid Build Coastguard Worker 513*60b67249SAndroid Build Coastguard Worker```py 514*60b67249SAndroid Build Coastguard WorkerUDS = KDF(32, internal_entropy, external_entropy, "UDS") 515*60b67249SAndroid Build Coastguard Worker``` 516*60b67249SAndroid Build Coastguard Worker 517*60b67249SAndroid Build Coastguard WorkerWith this provisioning scheme, the device must output UDS\_Public so 518*60b67249SAndroid Build Coastguard Workerprovisioning software can read the public key and issue a certificate. 519*60b67249SAndroid Build Coastguard Worker 520*60b67249SAndroid Build Coastguard Worker#### Provisioning Flow 521*60b67249SAndroid Build Coastguard Worker 522*60b67249SAndroid Build Coastguard WorkerAll steps occur during manufacturing. 523*60b67249SAndroid Build Coastguard Worker 524*60b67249SAndroid Build Coastguard Worker1. Generate and inject external entropy; do not retain or inject to multiple 525*60b67249SAndroid Build Coastguard Worker devices 526*60b67249SAndroid Build Coastguard Worker2. Run the DICE flow and read the UDS\_Public key 527*60b67249SAndroid Build Coastguard Worker3. Issue a certificate for UDS\_Public 528*60b67249SAndroid Build Coastguard Worker4. Test the DICE to ensure: 529*60b67249SAndroid Build Coastguard Worker 1. The UDS certificate correctly chains to the CDI certificate 530*60b67249SAndroid Build Coastguard Worker 2. The CDI values cannot be reproduced using a zero UDS 531*60b67249SAndroid Build Coastguard Worker5. Write the certificate to device storage 532*60b67249SAndroid Build Coastguard Worker 533*60b67249SAndroid Build Coastguard Worker### Provisioning Scheme 3: On-Demand Certification 534*60b67249SAndroid Build Coastguard Worker 535*60b67249SAndroid Build Coastguard WorkerIn some cases, the certificate may not need to be stored on the device or the 536*60b67249SAndroid Build Coastguard Workerdevice may not be capable of storing a certificate. In this scheme the UDS is 537*60b67249SAndroid Build Coastguard Workerderived in the same way as 538*60b67249SAndroid Build Coastguard Worker[Provisioning Scheme 2](#provisioning-scheme-2-factory-ca), and the UDS\_Public 539*60b67249SAndroid Build Coastguard Workerkey must similarly be output by the device. A SHA-512 hash of the UDS\_Public 540*60b67249SAndroid Build Coastguard Workerkey is retained in a secure database by the manufacturer. 541*60b67249SAndroid Build Coastguard Worker 542*60b67249SAndroid Build Coastguard WorkerThe manufacturer then operates or coordinates with an online CA to provide 543*60b67249SAndroid Build Coastguard Workeron-demand certification of UDS public keys. Acceptable approaches include but 544*60b67249SAndroid Build Coastguard Workerare not limited to: 545*60b67249SAndroid Build Coastguard Worker 546*60b67249SAndroid Build Coastguard Worker* Manufacturer provides the list of UDS public key hashes to the CA. This has 547*60b67249SAndroid Build Coastguard Worker the downside of revealing the total number of devices. 548*60b67249SAndroid Build Coastguard Worker* Manufacturer operates a simple web service on a dedicated domain over HTTPS 549*60b67249SAndroid Build Coastguard Worker which takes as input the hash of a UDS public key and provides as output a 550*60b67249SAndroid Build Coastguard Worker boolean indicating whether or not the hash is valid and should be certified. 551*60b67249SAndroid Build Coastguard Worker 552*60b67249SAndroid Build Coastguard WorkerThe CA issues certificates for any valid UDS public key without requiring 553*60b67249SAndroid Build Coastguard Workerproof-of-possession from the caller, only requiring a signal of approval from 554*60b67249SAndroid Build Coastguard Workerthe manufacturer. This allows a certificate chain to be requested by a CDI 555*60b67249SAndroid Build Coastguard Workercertificate verifier that received an incomplete chain from a device. The UDS 556*60b67249SAndroid Build Coastguard Workercertificate may be cached indefinitely by the device or by a verifier. 557*60b67249SAndroid Build Coastguard Worker 558*60b67249SAndroid Build Coastguard Worker#### Provisioning Flow 559*60b67249SAndroid Build Coastguard Worker 560*60b67249SAndroid Build Coastguard Worker1. [Manufacturing] Generate and inject external entropy; do not retain or 561*60b67249SAndroid Build Coastguard Worker inject to multiple devices 562*60b67249SAndroid Build Coastguard Worker2. [Manufacturing] Run the DICE flow and read the UDS\_Public key 563*60b67249SAndroid Build Coastguard Worker3. [Manufacturing] Retain H(UDS\_Public) in a secure database 564*60b67249SAndroid Build Coastguard Worker4. [On-Demand] Send UDS\_Public from the device to the CA (no 565*60b67249SAndroid Build Coastguard Worker proof-of-possession necessary) 566*60b67249SAndroid Build Coastguard Worker5. [CA] Check that H(UDS\_Public) is approved by the manufacturer 567*60b67249SAndroid Build Coastguard Worker6. [CA] Issue a certificate for UDS\_Public 568*60b67249SAndroid Build Coastguard Worker 569*60b67249SAndroid Build Coastguard Worker## Mode Value Details 570*60b67249SAndroid Build Coastguard Worker 571*60b67249SAndroid Build Coastguard WorkerThe following table describes the semantics of each mode. 572*60b67249SAndroid Build Coastguard Worker 573*60b67249SAndroid Build Coastguard WorkerMode | Value | Description 574*60b67249SAndroid Build Coastguard Worker-------------- | ----- | ----------- 575*60b67249SAndroid Build Coastguard WorkerNot 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. 576*60b67249SAndroid Build Coastguard WorkerNormal | 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. 577*60b67249SAndroid Build Coastguard WorkerDebug | 2 | This mode indicates at least one criteria for Normal mode is not met and the device is not in a secure state. 578*60b67249SAndroid Build Coastguard WorkerRecovery | 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. 579*60b67249SAndroid Build Coastguard Worker 580*60b67249SAndroid Build Coastguard Worker## Configuration Input Value Details (Optional) 581*60b67249SAndroid Build Coastguard Worker 582*60b67249SAndroid Build Coastguard WorkerThe format and meaning of the 64-byte configuration input value is 583*60b67249SAndroid Build Coastguard Workerimplementation dependent and may be a hash of more configuration data. 584*60b67249SAndroid Build Coastguard WorkerImplementers may choose to use the following convention for the configuration 585*60b67249SAndroid Build Coastguard Workerinput which covers a set of common security-relevant configuration. 586*60b67249SAndroid Build Coastguard Worker 587*60b67249SAndroid Build Coastguard WorkerField | Byte/Bits (MSB=0) | Description 588*60b67249SAndroid Build Coastguard Worker------------------------------- | ----------------- | ----------- 589*60b67249SAndroid Build Coastguard WorkerVerified 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. 590*60b67249SAndroid Build Coastguard WorkerVerified 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. 591*60b67249SAndroid Build Coastguard WorkerDebug 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. 592*60b67249SAndroid Build Coastguard WorkerBoot 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. 593*60b67249SAndroid Build Coastguard WorkerVersion | 3-4 | This value encodes target software version information. The format and interpretation of this value is implementation dependent. 594*60b67249SAndroid Build Coastguard WorkerReserved | 5-31 | These are reserved for future versions of this profile. 595*60b67249SAndroid Build Coastguard WorkerImplementation Specific | 32-63 | An implementation can use these bytes to represent any other security-relevant configuration. 596*60b67249SAndroid Build Coastguard Worker 597*60b67249SAndroid Build Coastguard Worker## Certificate Details 598*60b67249SAndroid Build Coastguard Worker 599*60b67249SAndroid Build Coastguard WorkerThis profile allows for two certificate options: standard X.509, or CBOR. The 600*60b67249SAndroid Build Coastguard Workercertificate type does not need to be consistent for all certificates in a 601*60b67249SAndroid Build Coastguard Workercertificate chain. Any certificate in the chain may be any type. Attestation 602*60b67249SAndroid Build Coastguard Workerinfrastructure may place additional constraints on certificate type, but this 603*60b67249SAndroid Build Coastguard Workerprofile does not. 604*60b67249SAndroid Build Coastguard Worker 605*60b67249SAndroid Build Coastguard WorkerRegardless of type, UDS and CDI certificates are always semantically *CA 606*60b67249SAndroid Build Coastguard Workercertificates* to enable use cases for certifying subsequent DICE 607*60b67249SAndroid Build Coastguard Worker[layers](#layering-details) or certifying attestation keys of some kind; the 608*60b67249SAndroid Build Coastguard WorkerUDS\_Private and CDI\_Private keys are not intended to be used for any purpose 609*60b67249SAndroid Build Coastguard Workerother than signing certificates. In particular, this means CDI\_Private should 610*60b67249SAndroid Build Coastguard Workernot participate directly in attestation protocols, but should rather certify an 611*60b67249SAndroid Build Coastguard Workerattestation key. If a target software component does not launch additional 612*60b67249SAndroid Build Coastguard Workersoftware, the *pathLenConstraint* field can be set to zero so certification of a 613*60b67249SAndroid Build Coastguard Workersubsequent CDI\_Public is not possible. 614*60b67249SAndroid Build Coastguard Worker 615*60b67249SAndroid Build Coastguard WorkerWhen UDS and CDI certificates are standard X.509 certificates, they follow the 616*60b67249SAndroid Build Coastguard Workerprofile specified in [RFC 5280](https://tools.ietf.org/html/rfc5280). When they 617*60b67249SAndroid Build Coastguard Workerare CBOR, they follow the IETF 618*60b67249SAndroid Build Coastguard Worker[CBOR Web Token](https://tools.ietf.org/html/rfc8392) (CWT) specification, and 619*60b67249SAndroid Build Coastguard Workerthe [CBOR Object Signing and Encryption](https://tools.ietf.org/html/rfc8152) 620*60b67249SAndroid Build Coastguard Worker(COSE) specification. 621*60b67249SAndroid Build Coastguard Worker 622*60b67249SAndroid Build Coastguard Worker### X.509 UDS Certificates 623*60b67249SAndroid Build Coastguard Worker 624*60b67249SAndroid Build Coastguard WorkerX.509 UDS certificates generally follow 625*60b67249SAndroid Build Coastguard Worker[RFC 5280](https://datatracker.ietf.org/doc/html/rfc5280). The following table 626*60b67249SAndroid Build Coastguard Workerdescribes all standard fields of a UDS certificate's tbsCertificate field that 627*60b67249SAndroid Build Coastguard Workerthis profile requires. Fields omitted are implementation dependent, but must not 628*60b67249SAndroid Build Coastguard Workerbreak the ability to chain to a CDI Certificate. 629*60b67249SAndroid Build Coastguard Worker 630*60b67249SAndroid Build Coastguard WorkerField | Description 631*60b67249SAndroid Build Coastguard Worker-------------------- | ----------- 632*60b67249SAndroid Build Coastguard Workerversion | v3 633*60b67249SAndroid Build Coastguard Workersubject | "SERIALNUMBER=\<UDS\_ID\>" where UDS\_ID is hex encoded lower case 634*60b67249SAndroid Build Coastguard WorkersubjectPublicKeyInfo | When using Ed25519, the info per [RFC 8410](https://tools.ietf.org/html/rfc8410) and [RFC 8032](https://tools.ietf.org/html/rfc8032) 635*60b67249SAndroid Build Coastguard Workerextensions | The standard extensions described below are included. 636*60b67249SAndroid Build Coastguard Worker 637*60b67249SAndroid Build Coastguard Worker##### UDS Standard Extensions 638*60b67249SAndroid Build Coastguard Worker 639*60b67249SAndroid Build Coastguard WorkerExtension | Critical | Description 640*60b67249SAndroid Build Coastguard Worker-------------------- | ------------ | ----------- 641*60b67249SAndroid Build Coastguard WorkersubjectKeyIdentifier | non-critical | Set to UDS\_ID 642*60b67249SAndroid Build Coastguard WorkerkeyUsage | critical | Contains only keyCertSign 643*60b67249SAndroid Build Coastguard WorkerbasicConstraints | 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. 644*60b67249SAndroid Build Coastguard Worker 645*60b67249SAndroid Build Coastguard Worker### X.509 CDI Certificates 646*60b67249SAndroid Build Coastguard Worker 647*60b67249SAndroid Build Coastguard WorkerX.509 CDI certificates generally follow 648*60b67249SAndroid Build Coastguard Worker[RFC 5280](https://datatracker.ietf.org/doc/html/rfc5280). All standard fields 649*60b67249SAndroid Build Coastguard Workerof a CDI certificate and the tbsCertificate field are described in the following 650*60b67249SAndroid Build Coastguard Workertable. Notably, this certificate can be generated deterministically given a 651*60b67249SAndroid Build Coastguard WorkerCDI\_Public key and the DICE input value details. 652*60b67249SAndroid Build Coastguard Worker 653*60b67249SAndroid Build Coastguard WorkerField | Description 654*60b67249SAndroid Build Coastguard Worker-------------------- | ----------- 655*60b67249SAndroid Build Coastguard WorkersignatureAlgorithm | When using Ed25519, id-Ed25519 per [RFC 8410](https://tools.ietf.org/html/rfc8410) 656*60b67249SAndroid Build Coastguard WorkersignatureValue | When using Ed25519, 64 byte Ed25519 signature per [RFC 8032](https://tools.ietf.org/html/rfc8032), using UDS\_Private or the current CDI\_Private as the signing key 657*60b67249SAndroid Build Coastguard Workerversion | v3 658*60b67249SAndroid Build Coastguard WorkerserialNumber | CDI\_ID in ASN.1 INTEGER form 659*60b67249SAndroid Build Coastguard Workersignature | When using Ed25519, id-Ed25519 per [RFC 8410](https://tools.ietf.org/html/rfc8410) 660*60b67249SAndroid Build Coastguard Workerissuer | "SERIALNUMBER=\<UDS\_ID\>" where UDS\_ID is hex encoded lower case. When layering, UDS\_ID becomes CDI\_ID of the current layer. 661*60b67249SAndroid Build Coastguard Workervalidity | 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". 662*60b67249SAndroid Build Coastguard Workersubject | "SERIALNUMBER=\<CDI\_ID\>" where CDI\_ID is hex encoded lower case. When layering this is the CDI\_ID of the next layer. 663*60b67249SAndroid Build Coastguard WorkersubjectPublicKeyInfo | When using Ed25519, the info per [RFC 8410](https://tools.ietf.org/html/rfc8410) and [RFC 8032](https://tools.ietf.org/html/rfc8032) 664*60b67249SAndroid Build Coastguard WorkerissuerUniqueID | Omitted 665*60b67249SAndroid Build Coastguard WorkersubjectUniqueID | Omitted 666*60b67249SAndroid Build Coastguard Workerextensions | 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. 667*60b67249SAndroid Build Coastguard Worker 668*60b67249SAndroid Build Coastguard Worker##### CDI Standard Extensions 669*60b67249SAndroid Build Coastguard Worker 670*60b67249SAndroid Build Coastguard WorkerExtension | Critical | Description 671*60b67249SAndroid Build Coastguard Worker---------------------- | ------------ | ----------- 672*60b67249SAndroid Build Coastguard WorkerauthorityKeyIdentifier | non-critical | Contains only keyIdentifier set to UDS\_ID 673*60b67249SAndroid Build Coastguard WorkersubjectKeyIdentifier | non-critical | Set to CDI\_ID 674*60b67249SAndroid Build Coastguard WorkerkeyUsage | critical | Contains only keyCertSign 675*60b67249SAndroid Build Coastguard WorkerbasicConstraints | 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. 676*60b67249SAndroid Build Coastguard Worker 677*60b67249SAndroid Build Coastguard Worker##### CDI Custom Extension Fields 678*60b67249SAndroid Build Coastguard Worker 679*60b67249SAndroid Build Coastguard WorkerField | Value 680*60b67249SAndroid Build Coastguard Worker--------- | ----- 681*60b67249SAndroid Build Coastguard WorkerextnID | 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). 682*60b67249SAndroid Build Coastguard Workercritical | TRUE 683*60b67249SAndroid Build Coastguard WorkerextnValue | A [OpenDiceInput](#custom-extension-format) sequence 684*60b67249SAndroid Build Coastguard Worker 685*60b67249SAndroid Build Coastguard Worker#### Custom Extension Format 686*60b67249SAndroid Build Coastguard Worker 687*60b67249SAndroid Build Coastguard WorkerThe custom extension follows this ASN.1 format: 688*60b67249SAndroid Build Coastguard Worker 689*60b67249SAndroid Build Coastguard Worker``` 690*60b67249SAndroid Build Coastguard WorkerMode ::= INTEGER (0..3) 691*60b67249SAndroid Build Coastguard WorkerOpenDiceInput ::= SEQUENCE { 692*60b67249SAndroid Build Coastguard Worker codeHash [0] EXPLICIT OCTET STRING OPTIONAL, 693*60b67249SAndroid Build Coastguard Worker codeDescriptor [1] EXPLICIT OCTET STRING OPTIONAL, 694*60b67249SAndroid Build Coastguard Worker configurationHash [2] EXPLICIT OCTET STRING OPTIONAL, 695*60b67249SAndroid Build Coastguard Worker configurationDescriptor [3] EXPLICIT OCTET STRING OPTIONAL, 696*60b67249SAndroid Build Coastguard Worker authorityHash [4] EXPLICIT OCTET STRING OPTIONAL, 697*60b67249SAndroid Build Coastguard Worker authorityDescriptor [5] EXPLICIT OCTET STRING OPTIONAL, 698*60b67249SAndroid Build Coastguard Worker mode [6] EXPLICIT Mode OPTIONAL, 699*60b67249SAndroid Build Coastguard Worker profileName [7] EXPLICIT UTF8String OPTIONAL, 700*60b67249SAndroid Build Coastguard Worker} 701*60b67249SAndroid Build Coastguard Worker``` 702*60b67249SAndroid Build Coastguard Worker 703*60b67249SAndroid Build Coastguard WorkerAll fields are explicitly tagged and optional to allow for flexibility and 704*60b67249SAndroid Build Coastguard Workerextensibility in the format itself. The actual semantics are as follows: 705*60b67249SAndroid Build Coastguard Worker 706*60b67249SAndroid Build Coastguard Worker* **codeHash** - Required. This is the exact 64-byte code input value used to 707*60b67249SAndroid Build Coastguard Worker compute CDI values. 708*60b67249SAndroid Build Coastguard Worker* **codeDescriptor** - Optional. This field contains additional information 709*60b67249SAndroid Build Coastguard Worker about the code input value. The format of this field is 710*60b67249SAndroid Build Coastguard Worker implementation-specific. If this field is included then all the information 711*60b67249SAndroid Build Coastguard Worker here must have been used to compute codeHash; i.e. a change in this value 712*60b67249SAndroid Build Coastguard Worker implies a change in codeHash. 713*60b67249SAndroid Build Coastguard Worker* **configurationHash** - Optional. If the configuration input is a hash, this 714*60b67249SAndroid Build Coastguard Worker field contains that hash. If the configuration is not a hash, this field is 715*60b67249SAndroid Build Coastguard Worker omitted. If present, this value is the exact configuration input used to 716*60b67249SAndroid Build Coastguard Worker compute CDI values, and also matches H(configurationDescriptor). 717*60b67249SAndroid Build Coastguard Worker* **configurationDescriptor** - Required. If the configuration input is a hash 718*60b67249SAndroid Build Coastguard Worker this field contains the original configuration data that was hashed. If it 719*60b67249SAndroid Build Coastguard Worker is not a hash, this field contains the exact 64-byte configuration input 720*60b67249SAndroid Build Coastguard Worker value used to compute CDI values. 721*60b67249SAndroid Build Coastguard Worker* **authorityHash** - Required. This is the exact 64-byte authority input 722*60b67249SAndroid Build Coastguard Worker value used to compute CDI values. 723*60b67249SAndroid Build Coastguard Worker* **authorityDescriptor** - Optional. This field contains additional 724*60b67249SAndroid Build Coastguard Worker information about the authority input value. The format of this field is 725*60b67249SAndroid Build Coastguard Worker implementation-specific. If this field is included then all the information 726*60b67249SAndroid Build Coastguard Worker here must have been used to compute authorityHash; i.e. a change in this 727*60b67249SAndroid Build Coastguard Worker value implies a change in authorityHash. 728*60b67249SAndroid Build Coastguard Worker* **mode** - Required. This is the mode input value. 729*60b67249SAndroid Build Coastguard Worker* **profileName** - Optional. This is the name of the DICE profile that 730*60b67249SAndroid Build Coastguard Worker defines the contents of this certificate. 731*60b67249SAndroid Build Coastguard Worker 732*60b67249SAndroid Build Coastguard Worker### CBOR UDS Certificates 733*60b67249SAndroid Build Coastguard Worker 734*60b67249SAndroid Build Coastguard WorkerA CBOR UDS certificate is a standard signed CWT. The following table lists all 735*60b67249SAndroid Build Coastguard Workerfield constraints required by this profile in addition to the standard. The 736*60b67249SAndroid Build Coastguard Workercertificate is *untagged*, and it must be a *COSE\_Sign1* message. 737*60b67249SAndroid Build Coastguard Worker 738*60b67249SAndroid Build Coastguard WorkerField | Description 739*60b67249SAndroid Build Coastguard Worker----- | ----------- 740*60b67249SAndroid Build Coastguard Workeriss | Required: The value is implementation dependent. 741*60b67249SAndroid Build Coastguard Workersub | Required: The value must be "\<UDS\_ID\>" where UDS\_ID is hex encoded lower case. 742*60b67249SAndroid Build Coastguard Worker 743*60b67249SAndroid Build Coastguard Worker#### Additional Fields 744*60b67249SAndroid Build Coastguard Worker 745*60b67249SAndroid Build Coastguard WorkerThe following table lists additional entries in the CWT. Note these have the 746*60b67249SAndroid Build Coastguard Workersame labels and semantics as the corresponding fields in 747*60b67249SAndroid Build Coastguard Worker[CBOR CDI certificates](#cbor-cdi-certificates). 748*60b67249SAndroid Build Coastguard Worker 749*60b67249SAndroid Build Coastguard WorkerField | CBOR Label 750*60b67249SAndroid Build Coastguard Worker---------------- | ---------- 751*60b67249SAndroid Build Coastguard WorkersubjectPublicKey | -4670552 752*60b67249SAndroid Build Coastguard WorkerkeyUsage | -4670553 753*60b67249SAndroid Build Coastguard Worker 754*60b67249SAndroid Build Coastguard WorkerThe *subjectPublicKey* field contains the public key associated with the subject 755*60b67249SAndroid Build Coastguard Workerin the form of a COSE\_Key structure encoded to a CBOR byte string. 756*60b67249SAndroid Build Coastguard Worker 757*60b67249SAndroid Build Coastguard WorkerThe *keyUsage* field contains a CBOR byte string the bits of which correspond to 758*60b67249SAndroid Build Coastguard Workerthe [X.509 KeyUsage bits](https://tools.ietf.org/html/rfc5280#section-4.2.1.3) 759*60b67249SAndroid Build Coastguard Workerin little-endian byte order (i.e. bit 0 is the low-order bit of the first byte). 760*60b67249SAndroid Build Coastguard WorkerFor UDS certificates this should have only the keyCertSign bit set. 761*60b67249SAndroid Build Coastguard Worker 762*60b67249SAndroid Build Coastguard Worker### CBOR CDI Certificates 763*60b67249SAndroid Build Coastguard Worker 764*60b67249SAndroid Build Coastguard WorkerA CBOR CDI certificate is a standard signed CWT with additional fields. The 765*60b67249SAndroid Build Coastguard Workercertificate is *untagged*, and it must be a *COSE\_Sign1* message. The following 766*60b67249SAndroid Build Coastguard Workertable lists all constraints on standard fields required by this profile. 767*60b67249SAndroid Build Coastguard Worker 768*60b67249SAndroid Build Coastguard WorkerField | Description 769*60b67249SAndroid Build Coastguard Worker----- | ----------- 770*60b67249SAndroid Build Coastguard Workeriss | Required: The value must be "\<UDS\_ID\>" where UDS\_ID is hex encoded lower case. When layering, UDS\_ID becomes CDI\_ID of the current layer. 771*60b67249SAndroid Build Coastguard Workersub | Required: The value must be "\<CDI\_ID\>" where CDI\_ID is hex encoded lower case. When layering this is the CDI\_ID of the next layer. 772*60b67249SAndroid Build Coastguard Workerexp | Omitted when a reliable time source is not available 773*60b67249SAndroid Build Coastguard Workernbf | Omitted when a reliable time source is not available 774*60b67249SAndroid Build Coastguard Workeriat | Omitted when a reliable time source is not available 775*60b67249SAndroid Build Coastguard Worker 776*60b67249SAndroid Build Coastguard Worker#### Additional Fields 777*60b67249SAndroid Build Coastguard Worker 778*60b67249SAndroid Build Coastguard WorkerThe following table lists additional entries in the CWT. By convention, the 779*60b67249SAndroid Build Coastguard Workerprivate fields in the map are labeled using negative integers starting at 780*60b67249SAndroid Build Coastguard Worker-4670545. 781*60b67249SAndroid Build Coastguard Worker 782*60b67249SAndroid Build Coastguard WorkerField | CBOR Label | Major Type 783*60b67249SAndroid Build Coastguard Worker----------------------- | ---------- | ---------- 784*60b67249SAndroid Build Coastguard WorkercodeHash | -4670545 | 2 (bstr) 785*60b67249SAndroid Build Coastguard WorkercodeDescriptor | -4670546 | 2 (bstr) 786*60b67249SAndroid Build Coastguard WorkerconfigurationHash | -4670547 | 2 (bstr) 787*60b67249SAndroid Build Coastguard WorkerconfigurationDescriptor | -4670548 | 2 (bstr) 788*60b67249SAndroid Build Coastguard WorkerauthorityHash | -4670549 | 2 (bstr) 789*60b67249SAndroid Build Coastguard WorkerauthorityDescriptor | -4670550 | 2 (bstr) 790*60b67249SAndroid Build Coastguard Workermode | -4670551 | 2 (bstr) 791*60b67249SAndroid Build Coastguard WorkersubjectPublicKey | -4670552 | 2 (bstr) 792*60b67249SAndroid Build Coastguard WorkerkeyUsage | -4670553 | 2 (bstr) 793*60b67249SAndroid Build Coastguard WorkerprofileName | -4670554 | 3 (tstr) 794*60b67249SAndroid Build Coastguard Worker 795*60b67249SAndroid Build Coastguard WorkerThe *subjectPublicKey* field contains the public key associated with the subject 796*60b67249SAndroid Build Coastguard Workerin the form of a COSE\_Key structure encoded to a CBOR byte string. 797*60b67249SAndroid Build Coastguard Worker 798*60b67249SAndroid Build Coastguard WorkerThe *keyUsage* field contains a CBOR byte string the bits of which correspond to 799*60b67249SAndroid Build Coastguard Workerthe [X.509 KeyUsage bits](https://tools.ietf.org/html/rfc5280#section-4.2.1.3) 800*60b67249SAndroid Build Coastguard Workerin little-endian byte order (i.e. bit 0 is the low-order bit of the first byte). 801*60b67249SAndroid Build Coastguard WorkerFor CDI certificates this should have only the keyCertSign bit set. 802*60b67249SAndroid Build Coastguard Worker 803*60b67249SAndroid Build Coastguard WorkerAll other fields have identical semantics to their counterparts in the 804*60b67249SAndroid Build Coastguard Worker[X.509 custom extension](#custom-extension-format). The *mode* field is encoded 805*60b67249SAndroid Build Coastguard Workeras a byte string holding a single byte. The advantage of using a byte string as 806*60b67249SAndroid Build Coastguard Workeropposed to an integer type is a consistent encoding size for all possible 807*60b67249SAndroid Build Coastguard Workervalues. 808*60b67249SAndroid Build Coastguard Worker 809*60b67249SAndroid Build Coastguard Worker# Appendix A: Implementing on Existing Hardware 810*60b67249SAndroid Build Coastguard Worker 811*60b67249SAndroid Build Coastguard WorkerThis profile requires hardware changes to implement fully. However, there is 812*60b67249SAndroid Build Coastguard Workerstill value in implementing it in software on top of existing hardware. 813*60b67249SAndroid Build Coastguard WorkerDepending on the existing hardware capabilities, the security of the DICE root 814*60b67249SAndroid Build Coastguard Workermay be equivalent to a full hardware implementation. 815*60b67249SAndroid Build Coastguard Worker 816*60b67249SAndroid Build Coastguard Worker## Implementing with Standard DICE Support 817*60b67249SAndroid Build Coastguard Worker 818*60b67249SAndroid Build Coastguard WorkerIf hardware supports a standard DICE mechanism but does not support this profile 819*60b67249SAndroid Build Coastguard Workerdirectly, this profile can be implemented in firmware and can use the firmware 820*60b67249SAndroid Build Coastguard WorkerCDI from the standard DICE as a UDS. The provisioned certificate would then 821*60b67249SAndroid Build Coastguard Workercover both the hardware and the firmware implementing this profile. 822*60b67249SAndroid Build Coastguard Worker 823*60b67249SAndroid Build Coastguard WorkerHowever, this only works if the firmware that implements this profile is 824*60b67249SAndroid Build Coastguard Workerunmodified during normal operation. It becomes a *ROM extension* in the sense 825*60b67249SAndroid Build Coastguard Workerthat if it is modified, the firmware CDI changes, and the certificate chain 826*60b67249SAndroid Build Coastguard Workerprovisioned for the device is no longer valid. In an ARM Trusted Firmware 827*60b67249SAndroid Build Coastguard Workerarchitecture, it would likely be BL2 firmware that implements this profile. 828*60b67249SAndroid Build Coastguard Worker 829*60b67249SAndroid Build Coastguard WorkerIf the firmware implementing this profile is the first firmware to run on the 830*60b67249SAndroid Build Coastguard Workersystem, this approach has equivalent security to a full hardware implementation. 831*60b67249SAndroid Build Coastguard Worker 832*60b67249SAndroid Build Coastguard Worker## Implementing with Lockable Persistent Storage 833*60b67249SAndroid Build Coastguard Worker 834*60b67249SAndroid Build Coastguard WorkerIf hardware supports a lockable persistent storage mechanism early in boot, this 835*60b67249SAndroid Build Coastguard Workerprofile can be implemented in firmware and can use a secret stored using this 836*60b67249SAndroid Build Coastguard Workermechanism as a UDS. This firmware should run as early in boot as possible. The 837*60b67249SAndroid Build Coastguard Workerstorage could be lockable OTP memory, lockable NVRAM, a one-time derivation, or 838*60b67249SAndroid Build Coastguard Workersimilar. Security chips like a TPM or SE often have an appropriate capability. 839*60b67249SAndroid Build Coastguard Worker 840*60b67249SAndroid Build Coastguard WorkerHowever, this only works along with a robust verified boot system to verify the 841*60b67249SAndroid Build Coastguard Workerfirmware that implements this profile and any other firmware that runs before 842*60b67249SAndroid Build Coastguard Workerit. It also has the downside that changes to the firmware, or any other firmware 843*60b67249SAndroid Build Coastguard Workerthat runs before it, are not reflected in the CDIs. 844*60b67249SAndroid Build Coastguard Worker 845*60b67249SAndroid Build Coastguard WorkerThe security of this approach is not equivalent to a full hardware 846*60b67249SAndroid Build Coastguard Workerimplementation, but may still be acceptable for many applications. If the 847*60b67249SAndroid Build Coastguard Workerfirmware implementing this profile is the first firmware to run on the system, 848*60b67249SAndroid Build Coastguard Workerthis approach has equivalent security to a full hardware implementation which 849*60b67249SAndroid Build Coastguard Workeremploys a hardware modification mechanism like an FPGA or microcode. 850*60b67249SAndroid Build Coastguard Worker 851*60b67249SAndroid Build Coastguard WorkerThis approach can also be used later in boot, for example in a TEE. However, the 852*60b67249SAndroid Build Coastguard Workermore code that runs without being covered by a DICE flow, the lower the security 853*60b67249SAndroid Build Coastguard Workerof the implementation. 854*60b67249SAndroid Build Coastguard Worker 855*60b67249SAndroid Build Coastguard Worker## Other Hardware Implementations 856*60b67249SAndroid Build Coastguard Worker 857*60b67249SAndroid Build Coastguard WorkerWith a robust verified boot system, there are many other possible 858*60b67249SAndroid Build Coastguard Workerimplementations as long as (1) A UDS can be made available by some means early 859*60b67249SAndroid Build Coastguard Workerin boot, and (2) that UDS can be made subsequently unavailable until the next 860*60b67249SAndroid Build Coastguard Workerboot. These implementations meet the requirements of the TCG DICE specification 861*60b67249SAndroid Build Coastguard Workeras an *updatable DICE* per section 6.2. 862*60b67249SAndroid Build Coastguard Worker 863*60b67249SAndroid Build Coastguard Worker# Appendix B: Hardware Implementation Checklist 864*60b67249SAndroid Build Coastguard Worker 865*60b67249SAndroid Build Coastguard WorkerThe following is a list of capabilities that a full hardware implementation must 866*60b67249SAndroid Build Coastguard Workerhave. This is intended for the convenience of hardware designers, and is not 867*60b67249SAndroid Build Coastguard Workerintended to add any additional requirements or constraints. 868*60b67249SAndroid Build Coastguard Worker 869*60b67249SAndroid Build Coastguard Worker1. Provide a UDS capability as required by this profile and the TCG DICE 870*60b67249SAndroid Build Coastguard Worker specification. Usually this *cannot* be implemented in mask ROM but requires 871*60b67249SAndroid Build Coastguard Worker additional hardware capabilities. See [UDS Details](#uds-details). 872*60b67249SAndroid Build Coastguard Worker1. Reserve on the order of 8KB of mask ROM for DICE, not including crypto 873*60b67249SAndroid Build Coastguard Worker primitives. The rest of this list can usually be implemented entirely in 874*60b67249SAndroid Build Coastguard Worker ROM. 875*60b67249SAndroid Build Coastguard Worker1. Choose crypto primitives and provide implementations, ideally with hardware 876*60b67249SAndroid Build Coastguard Worker acceleration. See [Cryptography](#cryptography). 877*60b67249SAndroid Build Coastguard Worker1. Provide a code input. At this level a simple code hash is recommended, 878*60b67249SAndroid Build Coastguard Worker without an additional descriptor. Often the verified boot system already has 879*60b67249SAndroid Build Coastguard Worker a code hash it verifies, and using the same hash as input to DICE is 880*60b67249SAndroid Build Coastguard Worker recommended. See [Input Values](#input-values). 881*60b67249SAndroid Build Coastguard Worker1. Provide a configuration input. At this level, using the 64-bit value 882*60b67249SAndroid Build Coastguard Worker described in this profile is recommended. See [Input Values](#input-values) 883*60b67249SAndroid Build Coastguard Worker and 884*60b67249SAndroid Build Coastguard Worker [Configuration Input Value Details](#configuration-input-value-details-optional). 885*60b67249SAndroid Build Coastguard Worker1. Provide a verified boot authority input. This should be very simple and 886*60b67249SAndroid Build Coastguard Worker stable, often copied directly out of OTP memory. At this level a simple hash 887*60b67249SAndroid Build Coastguard Worker is recommended, without an additional descriptor. See 888*60b67249SAndroid Build Coastguard Worker [Input Values](#input-values). 889*60b67249SAndroid Build Coastguard Worker1. Provide a mode input. Determining the mode is a runtime decision so a bit of 890*60b67249SAndroid Build Coastguard Worker logic will have to be coded. The 64-bit configuration value should have all 891*60b67249SAndroid Build Coastguard Worker the information necessary to make this decision. See 892*60b67249SAndroid Build Coastguard Worker [Input Values](#input-values) and [Mode Value Details](#mode-value-details). 893*60b67249SAndroid Build Coastguard Worker1. Provide a hidden input value if necessary. At this level it is not 894*60b67249SAndroid Build Coastguard Worker recommended. 895*60b67249SAndroid Build Coastguard Worker1. Implement the [DICE flow](#high-level-dice-flow) and certificate generation; 896*60b67249SAndroid Build Coastguard Worker reference code is available. If recommendations in this list are followed 897*60b67249SAndroid Build Coastguard Worker for simple inputs, the certificate will be a constant size and layout and a 898*60b67249SAndroid Build Coastguard Worker template can be used (avoiding the need for X.509 or CBOR code). See 899*60b67249SAndroid Build Coastguard Worker [Certificate Details](#certificate-details). 900*60b67249SAndroid Build Coastguard Worker1. Make DICE outputs available to firmware (CDIs and certificate). 901*60b67249SAndroid Build Coastguard Worker1. Depending on which provisioning model is used, make the UDS-derived public 902*60b67249SAndroid Build Coastguard Worker key available. 903*60b67249SAndroid Build Coastguard Worker 904*60b67249SAndroid Build Coastguard Worker# Appendix C: Versioned Sealing Keys 905*60b67249SAndroid Build Coastguard Worker 906*60b67249SAndroid Build Coastguard WorkerA versioned sealing key is a key that is derived from a secret seed and one or 907*60b67249SAndroid Build Coastguard Workermore software versions. The versions cannot be higher than the current software 908*60b67249SAndroid Build Coastguard Workerversion. In other words, a versioned sealing key can be derived for the current 909*60b67249SAndroid Build Coastguard Workersoftware version and each previous version, but not for future versions. These 910*60b67249SAndroid Build Coastguard Workerkeys can be used to seal data in a rollback-protected way, that is, in a way 911*60b67249SAndroid Build Coastguard Workerthat current and future software can unseal but older software cannot. Each time 912*60b67249SAndroid Build Coastguard Workersoftware is upgraded, the data can be re-sealed to be bound to the latest 913*60b67249SAndroid Build Coastguard Workerversion. 914*60b67249SAndroid Build Coastguard Worker 915*60b67249SAndroid Build Coastguard WorkerThe Sealing CDIs derived by using DICE in layers as described in this profile 916*60b67249SAndroid Build Coastguard Workerare not versioned; rather they are stable across versions. To achieve versioned 917*60b67249SAndroid Build Coastguard Workersealing keys, an additional hardware mechanism is required: a versioned KDF 918*60b67249SAndroid Build Coastguard Worker(V-KDF). There are many possible implementations but in general it must be 919*60b67249SAndroid Build Coastguard Workerpossible to seed the V-KDF with one or more secrets that it will not expose, and 920*60b67249SAndroid Build Coastguard Workerone or more maximum versions that it will not allow to be subsequently modified. 921*60b67249SAndroid Build Coastguard WorkerAfter seeding, the V-KDF accepts version info as input (likely along with other 922*60b67249SAndroid Build Coastguard Workerinputs), and the output is a key that may be used as a versioned sealing key. 923*60b67249SAndroid Build Coastguard Worker 924*60b67249SAndroid Build Coastguard WorkerGiven such a V-KDF, versioned keys can be derived from a Sealing CDI by adding a 925*60b67249SAndroid Build Coastguard Workerfew steps to precede the [DICE flow](#high-level-dice-flow): 926*60b67249SAndroid Build Coastguard Worker 927*60b67249SAndroid Build Coastguard Worker* Derive a V-KDF seed from the current sealing CDI (or UDS if this is the 928*60b67249SAndroid Build Coastguard Worker initial DICE instance) and the same inputs used for deriving the next layer 929*60b67249SAndroid Build Coastguard Worker sealing CDI. The derivation differs from the sealing CDI derivation only by 930*60b67249SAndroid Build Coastguard Worker the info string: 931*60b67249SAndroid Build Coastguard Worker 932*60b67249SAndroid Build Coastguard Worker```py 933*60b67249SAndroid Build Coastguard WorkerVKDF_SEED = KDF(32, CDI_Seal_or_UDS, H(authority + mode + hidden), "VKDF_SEED") 934*60b67249SAndroid Build Coastguard Worker``` 935*60b67249SAndroid Build Coastguard Worker 936*60b67249SAndroid Build Coastguard Worker* Seed the V-KDF with the output of (1) and the version of the target code 937*60b67249SAndroid Build Coastguard Worker (the code to which control will be transferred at the end of the DICE flow) 938*60b67249SAndroid Build Coastguard Worker* Destroy any copy of the V-KDF seed, so it's only available to the V-KDF 939*60b67249SAndroid Build Coastguard Worker* Run the DICE flow as usual 940*60b67249SAndroid Build Coastguard Worker 941*60b67249SAndroid Build Coastguard WorkerNote that the V-KDF seed is derived from the *current* sealing CDI; this value 942*60b67249SAndroid Build Coastguard Workeris *not* passed to target code but is locked / destroyed as part of the DICE 943*60b67249SAndroid Build Coastguard Workerflow. As a result the target code can only generate versioned keys as seeded by 944*60b67249SAndroid Build Coastguard Workerthe previous layer. 945*60b67249SAndroid Build Coastguard Worker 946*60b67249SAndroid Build Coastguard WorkerWhen multiple layers are involved, the V-KDF should use the seed inputs 947*60b67249SAndroid Build Coastguard Workercumulatively: 948*60b67249SAndroid Build Coastguard Worker 949*60b67249SAndroid Build Coastguard Worker* The seed value should be mixed into the current state, it should not reset 950*60b67249SAndroid Build Coastguard Worker the state. 951*60b67249SAndroid Build Coastguard Worker* The max version value should be retained in addition to the existing max 952*60b67249SAndroid Build Coastguard Worker version values. The version info supplied as KDF input must then contain one 953*60b67249SAndroid Build Coastguard Worker version for each maximum version configured. The number of layers supported 954*60b67249SAndroid Build Coastguard Worker may be limited by the V-KDF hardware; support for at least 8 maximum 955*60b67249SAndroid Build Coastguard Worker versions is recommended. 956