Skip to content

Add TDX CCEL support to token command and refactor flags#620

Open
yanchengchen7 wants to merge 1 commit intogoogle:mainfrom
yanchengchen7:tdx-ccel
Open

Add TDX CCEL support to token command and refactor flags#620
yanchengchen7 wants to merge 1 commit intogoogle:mainfrom
yanchengchen7:tdx-ccel

Conversation

@yanchengchen7
Copy link
Copy Markdown
Collaborator

@yanchengchen7 yanchengchen7 commented Dec 9, 2025

  • Move teeTechnology flag to flags.go to share it between attest and token commands.
  • Update token command to support TDX CCEL attestation by reading CCEL data and ACPI tables.
  • Populate the GceInstance field in VerifyAttestationRequest using MDS data for the token command.

Example usage: gotpm token --tee-technology tdx

@yanchengchen7
Copy link
Copy Markdown
Collaborator Author

/gcbrun

1 similar comment
@jessieqliu
Copy link
Copy Markdown
Contributor

/gcbrun

Comment thread cmd/token.go Outdated
Comment on lines +141 to +147
// If teeTechnology is not set, try to detect it from the attestation.
if teeTechnology == "" {
if attestation.GetTdxAttestation() != nil {
teeTechnology = Tdx
}
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should remove the detection. The caller should specify the TEE attestation to verify, just like with the gotpm attest command

@yanchengchen7 yanchengchen7 force-pushed the tdx-ccel branch 2 times, most recently from 1d077ed to cec9607 Compare December 31, 2025 01:47
@yanchengchen7
Copy link
Copy Markdown
Collaborator Author

/gcbrun

Comment thread cmd/token.go
Comment on lines +138 to +161
// Add logic to open other hardware devices when required.
switch teeTechnology {
case SevSnp:
attestOpts.TEEDevice, err = client.CreateSevSnpQuoteProvider()
if err != nil {
return fmt.Errorf("failed to open %s device: %v", SevSnp, err)
}
attestOpts.TEENonce = teeNonce
case Tdx:
attestOpts.TEEDevice, err = client.CreateTdxQuoteProvider()
if err != nil {
return fmt.Errorf("failed to create %s quote provider: %v", Tdx, err)
}
attestOpts.TEENonce = teeNonce
case "":
if len(teeNonce) != 0 {
return fmt.Errorf("use of --tee-nonce requires specifying TEE hardware type with --tee-technology")
}
default:
// Change the return statement when more devices are added
return fmt.Errorf("tee-technology should be either empty or should have values %s or %s", SevSnp, Tdx)
}

attestation, err := ak.Attest(attestOpts)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is duplicated with https://github.com/google/go-tpm-tools/blob/main/cmd/attest.go#L84-L105. Please refactor into a helper like func addTEEOpts(opts client.AttestOpts) error

Comment thread cmd/token.go
return fmt.Errorf("tee-technology should be either empty or should have values %s or %s", SevSnp, Tdx)
}

attestation, err := ak.Attest(attestOpts)
Copy link
Copy Markdown
Collaborator

@yawangwang yawangwang Jan 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Currently there's no binding b/w TPM and TDX attestation, so it's premature to enable tee-nonce and tee-technology flags for the token command.

Comment thread cmd/token.go
Comment on lines +188 to +194
req.TDCCELAttestation = &verifier.TDCCELAttestation{
TdQuote: rawQuote,
CcelAcpiTable: ccelTable,
CcelData: ccelData,
AkCert: attestation.AkCert,
IntermediateCerts: attestation.IntermediateCerts,
}
Copy link
Copy Markdown
Collaborator

@yawangwang yawangwang Jan 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This enables sending TDX CVM attestation to GCA for verification. However, since TDX CVM support is not yet GA, users will likely encounter errors when using the CLI.

This PR should be held until TDX CVM and hardware binding reach GA.

@yanchengchen7 yanchengchen7 force-pushed the tdx-ccel branch 3 times, most recently from b0ddfb2 to 5f710b7 Compare April 8, 2026 00:17
* Move `teeTechnology` flag to flags.go to share it between `attest` and `token` commands.
* Update `token` command to support TDX CCEL attestation by reading CCEL data and ACPI tables.
* Enable `tee-technology` flag for the `token` command.
* Populate the `GceInstance` field in `VerifyAttestationRequest` using MDS data (project number, zone, and instance ID) for the `token` command.
* Ensure the `token` command uses the challenge nonce for TEE attestation, ignoring any user-provided `--tee-nonce`.
Comment thread agent/agent.go
ccelData = bytes.TrimRight(ccelData, "\xff")

ccelTable, err := os.ReadFile("/sys/firmware/acpi/tables/CCEL")
ccelTable, err := os.ReadFile(internal.AcpiTableFile)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants