|
| 1 | +# Attestation |
| 2 | + |
| 3 | +Please note that attestation is a deeply technical process and readers |
| 4 | +should be familiar with some [prerequisite concepts](./prerequisites.md) |
| 5 | +before reading this document. |
| 6 | + |
| 7 | +### Colors |
| 8 | + |
| 9 | +In process diagrams, colors mean the following: |
| 10 | + |
| 11 | +* Green: Implicitly Trusted |
| 12 | +* Red: Untrusted |
| 13 | +* Yellow: Trusted via a Cryptographic Root of Trust |
| 14 | +* Orange: Trusted via Cryptographic Measurement |
| 15 | + |
| 16 | +In certificate chain diagrams, colors mean the following: |
| 17 | + |
| 18 | +* Blue: The private key is accessable only by hardware. |
| 19 | + |
| 20 | +The AMD SEV attestation process is a series of cryptographic transactions between a tenant (entity that wants a |
| 21 | +secure virtual machine) and a host (the entity that provides the virtual machine on their infrastructure). |
| 22 | +This attestation process establishes the following: |
| 23 | + |
| 24 | +* A guarantee that the tenant's secure virtual machine (the guest) is running on an authentic AMD processor which |
| 25 | + correctly implements AMD's Secure Encrypted Virtualization (SEV) technology in microcode. This demonstrates |
| 26 | + that the host's processor is capable of supporting an SEV-enabled guest and the guest can be assured it is |
| 27 | + receiving the protections advertised by the SEV featureset once attestation is complete. |
| 28 | +* A guarantee that the platform that tenant's virtual machine will be running on is actually owned by the host. |
| 29 | +* The host-provided virtual machine image matches exactly what the tenant is expecting. That is, both the tenant |
| 30 | + and the host calculate the same measurement of the image. |
| 31 | +* A secure channel to inject a secret (or secrets) into the encrypted guest so that its workload is entirely |
| 32 | + private and known only to the guest itself. |
| 33 | + |
| 34 | +AMD SEV seeks to provide these guarantees even with the presence of a potentially hostile or compromised host. |
| 35 | + |
| 36 | +#### Establishing Trust |
| 37 | + |
| 38 | +The public-key cryptography employed in the attestation for AMD SEV forms a tree-like structure that can be traced |
| 39 | +all the way back to two roots of trust (an authoritative, completely trusted entity): |
| 40 | + |
| 41 | + |
| 42 | + |
| 43 | +The above diagram illustrates the two roots of trust from which two chains of trust are established, each terminating |
| 44 | +at the Platform Diffie-Hellman (PDH) node at the bottom. This relationship is important because it shows how trust |
| 45 | +is traced back to what is known as a "root of trust", or in other words: a completely trusted, authoritative entity. |
| 46 | +For AMD SEV, the roots of trust are Advanced Micro Devices (AMD) and the owner of the platform (the entity providing |
| 47 | +the host or a group of hosts). A chain of trust is formed when a trusted entity uses its key to sign another entity's |
| 48 | +key. When an entity's key is signed by a trusted entity, then the newly-signed key is also trusted. |
| 49 | + |
| 50 | +Let's step through the two chains of trust shown in the above diagram: |
| 51 | + |
| 52 | +The first root of trust is the **Owner Certificate Authority (OCA) signing key**. The OCA is exclusively owned |
| 53 | +by the owner of the platform (the entity that provides the host). It is used to sign the Platform Endorsement Key |
| 54 | +(PEK) to indicate that the owner controls the platform. The only exception to this is if the platform is considered |
| 55 | +"self-owned". In this case, the SEV firmware will generate both the public and private OCA keys and store them. The |
| 56 | +"self-owned" state is the default state. |
| 57 | + |
| 58 | +The second root of trust is the **AMD Root Key (ARK)**. The ARK is used to sign the AMD SEV Signing Key (ASK) to mark |
| 59 | +it as an authentic AMD key in the chain of trust. The ARK is an offline key, carefully protected and controlled by |
| 60 | +AMD. This key is used to sign the AMD Signing Key (ASK), which is online. |
| 61 | + |
| 62 | +The **AMD SEV Signing Key (ASK)** is signed by the ARK and is therefore branded as an authentic and trusted AMD key. |
| 63 | +This key is used to sign the Chip Endorsement Key (CEK). |
| 64 | + |
| 65 | +The **Chip Endorsement Key (CEK)** is a unique key stored within the fuses of the chip itself. This key is signed by |
| 66 | +the ASK to officially associate the processor with the AMD chain of trust. The ASK's signature indicates that the chip |
| 67 | +is an authentic AMD processor. This key is signed during provisioning, a process by which a platform owner takes |
| 68 | +control over the platform. The platform owner exports this key, submits a POST request to an online service, and |
| 69 | +AMD returns the key with an ASK signature on it. |
| 70 | + |
| 71 | +The two chains of trust intersect at the **Platform Endorsement Key (PEK)** which is signed by both the OCA and the |
| 72 | +CEK. This means that the PEK derives trust from both roots of trust: AMD and the platform owner. Any key signed by |
| 73 | +the PEK is considered to be trusted by both the platform owner and AMD. This key is generated by the SEV firmware |
| 74 | +(the software that controls the Platform Secure Processor). |
| 75 | + |
| 76 | +Finally, the chain of trust terminates at the aforementioned **Platform Diffie-Hellman (PDH)** key. This key is used |
| 77 | +to enable a key exchange between the PSP firmware and the tenant to create a master key. |
| 78 | + |
| 79 | +#### Attestation Overview |
| 80 | + |
| 81 | +1. **Validation:** Tenant will validate the certificate chain (described above) provided by the host. |
| 82 | + |
| 83 | +1. **Secure Channel Establishment:** Tenant and Platform Secure Processor (PSP) will negotiate an encrypted channel. |
| 84 | + |
| 85 | +1. **Measurement:** Tenant will validate the measurement of the VM provided by the PSP. |
| 86 | + |
| 87 | +1. **Launch:** Attestation is successful. The tenant will inject secrets into the guest and the guest is launched. |
| 88 | + |
| 89 | +#### Performing Attestation |
| 90 | + |
| 91 | +Now let's examine how the keys are used in practice to perform attestation and safely establish the guarantees that |
| 92 | +were described earlier in the document with a tenant. |
| 93 | + |
| 94 | +First, have a quick look at the following diagram, then we'll unpack it: |
| 95 | + |
| 96 | + |
| 97 | + |
| 98 | +##### Validation |
| 99 | + |
| 100 | +1. To begin, the tenant will ask the host for the certificate chain. The host will route this request to the PSP which |
| 101 | + will export the certificate chain. The certificate chain is the chain of trust that can be traced all the way to |
| 102 | + the two roots of trust described above. The PSP's response contains the certificate chain and the firmware version |
| 103 | + that drives the PSP. The host will relay this response to the tenant. |
| 104 | + |
| 105 | +1. The tenant will verify the certificate chain. The components of the AMD signing keys can be obtained individually |
| 106 | + to confirm the authenticity of the signatures on the certificate. Similarly, the owner's signature on the PEK |
| 107 | + derived from the OCA can be used to verify that the expected owner is in control of the platform. |
| 108 | + |
| 109 | +1. The tenant will verify the firmware version advertised by the PSP. Some SEV features are only available in certain |
| 110 | + firmware revisions. |
| 111 | + |
| 112 | +1. The tenant will build an execution policy. The execution policy contains configuration information. For example: |
| 113 | + requiring SEV-ES support, disabling the ability to transmit the guest to another platform, or a minimum firmware |
| 114 | + version. This policy will be delivered to the PSP in a secure channel, which will be established next. |
| 115 | + |
| 116 | +##### Secure Channel Establishment |
| 117 | + |
| 118 | +1. The tenant will create a trusted channel between itself and the PSP to facilitate attestation: |
| 119 | + |
| 120 | + 1. The tenant generates a random Transport Integrity Key ("tik") and random Transport Encryption Key ("tek"). |
| 121 | + |
| 122 | + 1. The tenant already has the host's Platform Diffie-Hellman (PDH) key from the certificate chain it requested. |
| 123 | + |
| 124 | + 1. The tenant generates its own random Elliptic Curve Diffie-Hellman (ECDH) key pair. |
| 125 | + |
| 126 | + 1. The tenant derives a shared secret ("Z") from its own PDH and the host's PDH. |
| 127 | + |
| 128 | + 1. The tenant generates a random nonce ("N"). |
| 129 | + |
| 130 | + 1. The tenant generates a random initialization vector ("IV"). |
| 131 | + |
| 132 | + 1. The tenant derives the master key ("M") from the shared secret ("Z") and the nonce ("N") and from the string |
| 133 | + "sev-master-secret". |
| 134 | + |
| 135 | + 1. The tenant derives a Key Encryption Key ("kek") from the master key and the string "sev-kek". |
| 136 | + |
| 137 | + 1. The tenant derives a Key Integrity Key ("kik") from the master key and the string "sev-kik". |
| 138 | + |
| 139 | + 1. The tenant concatenates the Transport Encryption Key ("tek") and the Transport Integrity Key ("tik") and wraps |
| 140 | + the result with the Key Encryption Key ("kek"), which is then wrapped by the Key Integrity Key ("kik"). |
| 141 | + |
| 142 | + 1. The Key Integrity Key ("kik") is used to hash and sign the wrapped data with HMAC-SHA256, seeded from the |
| 143 | + initialization vector ("IV"). |
| 144 | + |
| 145 | + 1. The Transport Integrity Key ("tik") is used to hash and sign (HMAC-SHA256) the guest's execution policy that |
| 146 | + was crafted above. |
| 147 | + |
| 148 | +1. Finally, the tenant has prepared everything that is required to establish a secure channel between itself |
| 149 | + and the PSP. The tenant will transmit the following to the host (which will relay it to the PSP): the |
| 150 | + tenant's PDH public key, the TIK-protected policy, KIK-protected KEK (TEK, TIK), the nonce ("N"), the |
| 151 | + initialization vector ("IV"). This is everything the PSP needs to securely derive its own understanding |
| 152 | + of the shared secret and decrypt the buffers. This initiates attestation and foreshadows a virtual machine |
| 153 | + launch. |
| 154 | + |
| 155 | + | transmitted as | component | |
| 156 | + | --------------: | - | |
| 157 | + | plaintext | N, IV, tenant's PDH (public key) | |
| 158 | + | ciphertext | (KEK: TEK\|TIK) | |
| 159 | + | integrity-protected | (TIK: guest policy), (KIK: KEK) | |
| 160 | + |
| 161 | +1. The PSP will receive the tenant's request for a secure channel and decrypt it. |
| 162 | + |
| 163 | + 1. The PSP will use the nonce ("N"), its PDH and the tenant's PDH to derive the shared secret ("Z") that the |
| 164 | + tenant had derived. |
| 165 | + |
| 166 | + 1. The PSP will derive the master secret ("M") using the shared secret it had just derived. |
| 167 | + |
| 168 | + 1. The PSP will derive the Key Encryption Key ("kek") and the Key Integrity Key ("kik") from the master |
| 169 | + key ("M"). |
| 170 | + |
| 171 | + 1. The PSP will decrypt the KIK-protected buffer sent by the tenant which contains the KEK (which itself wraps |
| 172 | + around the concatenated TEK and TIK data). |
| 173 | + |
| 174 | + 1. The PSP will decrypt the KEK-wrapped buffer to reveal the TEK/TIK concatenated buffer. |
| 175 | + |
| 176 | +##### Measurement |
| 177 | + |
| 178 | +1. The PSP will create an SEV context for the tenant's virtual machine (guest) and begin bootstrapping an encrypted |
| 179 | + environment for the it. |
| 180 | + |
| 181 | + 1. The PSP will use the TIK to decrypt the policy and associate the policy with the guest for the entirety |
| 182 | + of its lifetime. |
| 183 | + |
| 184 | + 1. The PSP will create a cryptographic measurement of the pages provided by the host. |
| 185 | + |
| 186 | + 1. The PSP will encrypt the guest's pages. |
| 187 | + |
| 188 | + 1. The PSP will use the TIK to hash and sign the measurement it took of the pages prior to encryption and |
| 189 | + send this reply to the host which then routes it to the tenant. |
| 190 | + |
| 191 | + | transmitted as | component | |
| 192 | + | --------------: | - | |
| 193 | + | integrity-protected | (TIK: measurement) | |
| 194 | + |
| 195 | +1. The tenant will digest the response from the PSP containing the measurement of the virtual machine image. |
| 196 | + |
| 197 | +1. The tenant will perform its own measurement of the pages. If it calculates the same measurement, then the image is |
| 198 | + exactly what the tenant was expecting. If not, attestation has failed, and the tenant should assume the image has |
| 199 | + been tampered with. |
| 200 | + |
| 201 | +##### Launch |
| 202 | + |
| 203 | +1. If the tenant agrees with the PSP's measurement of the pages, the guest is now ready to securely receive any |
| 204 | + secret metadata. |
| 205 | + |
| 206 | + 1. The tenant will generate a new initialization vector ("IV") to seed AES-128 encryption used to protect |
| 207 | + the transmission of the secret. |
| 208 | + |
| 209 | + 1. The secret will be encrypted with AES 128 using the TEK to calculate the ciphertext. |
| 210 | + |
| 211 | + 1. The secret ciphertext will be hashed and signed by the TIK with HMAC-SHA256. |
| 212 | + |
| 213 | +1. The tenant will send the encrypted metadata (secret) to the host which will then relay it to the PSP. |
| 214 | + |
| 215 | + | transmitted as | component | |
| 216 | + | --------------: | - | |
| 217 | + | ciphertext | (TEK: secret metadata) | |
| 218 | + | integrity-protected | (TIK: TEK) | |
| 219 | + |
| 220 | +1. The PSP will decrypt the ciphertext containing the secret and place it into the guest's memory. |
| 221 | + |
| 222 | +1. Finally, attestation has successfully concluded and the virtual machine's launch is complete. The virtual |
| 223 | + machine is now ready to run under the protection of AMD SEV. |
| 224 | + |
| 225 | +Please note that attestation for SEV-ES and SEV-SNP will be documented at a later date. |
| 226 | + |
| 227 | +#### Protections |
| 228 | + |
| 229 | +After attestation completes successfully, a guest is assured to receive [a number of protections]( |
| 230 | +./protections.md). |
| 231 | + |
| 232 | +#### References |
| 233 | + |
| 234 | +This document relies on a number of resources to accurately summarize the deeply technical process of attestation. |
| 235 | +Please note that **this document will defer to AMD's official documentation if any component here is found to be in |
| 236 | +disagreement with the AMD SEV's documentation.** If a discrepency is found, please reach out to file an issue and/or |
| 237 | +open a pull request to notify the Enarx team. Your assistance is sincerely appreciated. |
| 238 | + |
| 239 | +* [AMD Secure Encrypted Virtualization (SEV) API, revision 0.22](https://developer.amd.com/wp-content/resources/55766.PDF) |
0 commit comments