vSphere uses two levels of encryption in the form of a Key Encryption Key (KEK) and a Data Encryption Key (DEK). An ESXi host generates a DEK to encrypt VMs and disks. The KEK is provided by a key server, and encrypts (or wraps) the DEK.
The KEK is encrypted using the AES256 algorithm and the DEK is encrypted using the XTS-AES-256 algorithm. Depending on the type of key provider, different methods are used to create and manage the DEK and KEK.
Standard key provider operation:
The ESXi host generates and uses internal keys to encrypt VMs and disks. These keys are used as DEKs.
vCenter Server requests keys from the key server (KMS). These keys are used as the KEKs. vCenter Server stores only the ID of each KEK, but not the key itself.
ESXi uses the KEK to encrypt internal keys, and stores the encrypted internal keys on a disk. ESXi does not store the KEK on a disk. If a host reboots, vCenter Server requests the KEK with the corresponding ID from the key server and makes it available to ESXi. ESXi can then decrypt the internal keys as required.
vSphere Trust Authority trusted key provider operation:
The vCenter Server of the Trusted Cluster checks if the default trusted key provider is accessible to the ESXi host where the encrypted VM is to be created.
The vCenter Server of the Trusted Cluster adds the trusted key provider to the VM ConfigSpec.
The VM creation request is sent to the ESXi host.
If an attestation token is not already available to the ESXi host, it requests one from the Attestation Service.
The Key Provider Service validates the attestation token and creates a KEK to be sent to the ESXi host. The KEK is wrapped (encrypted) with the primary key that is configured on the key provider. Both the KEK ciphertext and KEK plaintext are returned to the Trusted Host.
The ESXi host generates a DEK to encrypt the VM disks.
The KEK is used to wrap the DEK generated by the ESXi host, and the ciphertext from the key provider is stored alongside the encrypted data.
The VM is encrypted and written to storage.
If an encrypted VM is deleted or unregistered, the ESXi host and the cluster remove the KEK from cache. The ESXi host can no longer use the KEK. This behavior is the same for standard key providers and trusted key providers.
vSphere Native Key Provider operation:
When a key provider is created, vCenter Server generates a primary key and pushes it to the ESXi hosts in the cluster. (No external key server is involved.)
The ESXi hosts generate a DEK on demand.
When an encryption activity is performed, data is encrypted with the DEK.
Encrypted DEKs are stored alongside the encrypted data.
When data is decrypted, the primary key is first used to decrypt the DEK and then the data.