|
| 1 | +# GCP & GoTPM Tools |
| 2 | + |
| 3 | +## Table of Contents |
| 4 | + |
| 5 | +- [GCP \& GoTPM Tools](#gcp--gotpm-tools) |
| 6 | + - [Table of Contents](#table-of-contents) |
| 7 | + - [Variables](#variables) |
| 8 | + - [Create an AMD SEV-SNP Instance](#create-an-amd-sev-snp-instance) |
| 9 | + - [Create an Intel TDX Instance](#create-an-intel-tdx-instance) |
| 10 | + - [Connecting to the Instance](#connecting-to-the-instance) |
| 11 | + - [Useful Commands](#useful-commands) |
| 12 | + - [List Available Machine Types](#list-available-machine-types) |
| 13 | + - [Generate Random Nonces](#generate-random-nonces) |
| 14 | + - [Run `gotpm` Attestation](#run-gotpm-attestation) |
| 15 | + - [Notes](#notes) |
| 16 | + |
| 17 | +## Variables |
| 18 | + |
| 19 | +```sh |
| 20 | +export GCI_NAME=PETES-SEV-SNP-TEST-0 |
| 21 | +export GCI_PROJECT=arweave-437622 |
| 22 | +export GCI_IMAGE=packer-1730219529 |
| 23 | +export GCI_ZONE=us-central1-a |
| 24 | +``` |
| 25 | + |
| 26 | +## Create an AMD SEV-SNP Instance |
| 27 | + |
| 28 | +```sh |
| 29 | +gcloud compute instances create $GCI_NAME \ |
| 30 | + --zone=$GCI_ZONE \ |
| 31 | + --machine-type=n2d-standard-2 \ |
| 32 | + --min-cpu-platform="AMD Milan" \ |
| 33 | + --confidential-compute-type=SEV_SNP \ |
| 34 | + --maintenance-policy=TERMINATE \ |
| 35 | + --image-family=ubuntu-2404-lts-amd64 \ |
| 36 | + --image-project=ubuntu-os-cloud \ |
| 37 | + --project=$GCI_PROJECT \ |
| 38 | + --network-interface=network-tier=PREMIUM,nic-type=GVNIC,stack-type=IPV4_ONLY,subnet=default \ |
| 39 | + --tags=http-server,https-server \ |
| 40 | + --shielded-secure-boot \ |
| 41 | + --shielded-vtpm \ |
| 42 | + --shielded-integrity-monitoring \ |
| 43 | + --create-disk=auto-delete=yes,boot=yes,device-name=instance-20241030-131350,image=projects/$GCI_PROJECT/global/images/$GCI_IMAGE,mode=rw,size=20,type=pd-balanced |
| 44 | +``` |
| 45 | + |
| 46 | +## Create an Intel TDX Instance |
| 47 | + |
| 48 | +```sh |
| 49 | +gcloud compute instances create $GCI_NAME \ |
| 50 | + --zone=$GCI_ZONE \ |
| 51 | + --machine-type=c3-standard-4 \ |
| 52 | + --confidential-compute-type=TDX \ |
| 53 | + --maintenance-policy=TERMINATE \ |
| 54 | + --image-family=ubuntu-2204-lts \ |
| 55 | + --image-project=ubuntu-os-cloud \ |
| 56 | + --project=$GCI_PROJECT \ |
| 57 | + --network-interface=network-tier=PREMIUM,nic-type=GVNIC,stack-type=IPV4_ONLY,subnet=default \ |
| 58 | + --tags=http-server,https-server \ |
| 59 | + --shielded-secure-boot \ |
| 60 | + --shielded-vtpm \ |
| 61 | + --shielded-integrity-monitoring \ |
| 62 | + --create-disk=auto-delete=yes,boot=yes,device-name=instance-20241030-131350,image=projects/$GCI_PROJECT/global/images/$GCI_IMAGE,mode=rw,size=20,type=pd-balanced |
| 63 | +``` |
| 64 | + |
| 65 | +## Connecting to the Instance |
| 66 | + |
| 67 | +```sh |
| 68 | +gcloud compute ssh --zone "$GCI_ZONE" "$GCI_NAME" --project "$GCI_PROJECT" |
| 69 | +``` |
| 70 | + |
| 71 | +## Useful Commands |
| 72 | + |
| 73 | +### List Available Machine Types |
| 74 | + |
| 75 | +```sh |
| 76 | +gcloud compute machine-types list --zones=$GCI_ZONE |
| 77 | +``` |
| 78 | + |
| 79 | +### Generate Random Nonces |
| 80 | + |
| 81 | +- **32-byte Nonce** (for `--nonce`): |
| 82 | + |
| 83 | + ```sh |
| 84 | + head -c 32 /dev/urandom | xxd -p -c 64 |
| 85 | + ``` |
| 86 | + |
| 87 | +- **64-byte TEE Nonce** (for `--tee-nonce`): |
| 88 | + |
| 89 | + ```sh |
| 90 | + head -c 64 /dev/urandom | xxd -p -c 128 |
| 91 | + ``` |
| 92 | + |
| 93 | +### Run `gotpm` Attestation |
| 94 | + |
| 95 | +```sh |
| 96 | +sudo gotpm attest --key AK --nonce <32 bytes (64 hex characters)> --tee-nonce <64 bytes (128 hex characters)> --tee-technology <sev-snp/tdx> |
| 97 | +``` |
| 98 | + |
| 99 | +## Notes |
| 100 | + |
| 101 | +> [!NOTE] |
| 102 | +> The requirement to include both `--nonce` and `--tee-nonce` for the `gotpm attest` command, even when `--tee-technology` (e.g., `sev-snp` or `tdx`) is specified, indicates that **both TPM and TEE layers** of attestation are being validated in this command. Here’s why this is the case: |
| 103 | +> |
| 104 | +> ### Dual-Layer Attestation in Confidential VMs |
| 105 | +> |
| 106 | +> **TPM Attestation Layer**: |
| 107 | +> |
| 108 | +> - The **`--nonce`** parameter is required for the **TPM (Trusted Platform Module) attestation**. It acts as a freshness mechanism for the TPM-based portion of the attestation, preventing replay attacks by ensuring the response is unique to each request. |
| 109 | +> - Even when the TEE technology is specified, `gotpm` still performs TPM-based attestation, which includes the TPM nonce (`--nonce`) in the attestation report. |
| 110 | +> |
| 111 | +> **TEE-Specific Attestation Layer**: |
| 112 | +> |
| 113 | +> - The **`--tee-nonce`** parameter is required for the **TEE (Trusted Execution Environment) attestation**. This layer provides hardware-backed isolation (e.g., Intel TDX or AMD SEV-SNP), and the larger 64-byte nonce uniquely identifies the TEE attestation report. |
| 114 | +> - The `--tee-technology` option (e.g., `sev-snp` or `tdx`) specifies which TEE environment to use, and `--tee-nonce` is essential for proving the freshness of the TEE report in that specific environment. |
| 115 | +> |
| 116 | +> ### Why Both Nonces Are Required Together |
| 117 | +> |
| 118 | +> Since the command produces an attestation report containing **both TPM and TEE layers**, each layer requires its own nonce: |
| 119 | +> |
| 120 | +> - **`--nonce` (TPM layer)**: Required for the general TPM quote in the attestation. |
| 121 | +> - **`--tee-nonce` (TEE layer)**: Required specifically for the TEE report tied to `sev-snp` or `tdx`. |
| 122 | +> |
| 123 | +> This design ensures that the attestation report is comprehensive and includes **freshness proofs** for both the TPM and TEE components, preventing replay attacks across both security layers. This dual nonce requirement is specific to environments where both TPM and TEE attestation are requested together, as in a Confidential VM using TEE. |
| 124 | +
|
| 125 | +--- |
0 commit comments