Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@jxu023
Copy link
Collaborator

@jxu023 jxu023 commented Oct 16, 2025

SVSM e-vTPM currently can only attest to an EK, so we need EK-based key attestation for the TPM.

This PR implements https://trustedcomputinggroup.org/wp-content/uploads/EK-Based-Key-Attestation-with-TPM-Firmware-Version-V1-RC1_9July2025.pdf#page=8 and is based on the reference code https://github.com/TrustedComputingGroup/tpm-fw-attestation-reference-code

@google-cla
Copy link

google-cla bot commented Oct 16, 2025

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

Copy link
Member

@chrisfenner chrisfenner left a comment

Choose a reason for hiding this comment

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

No serious complaints from my end, although I focused my review on the crypto & attestation flow rather than the proto design.

Copy link
Contributor

@alexmwu alexmwu left a comment

Choose a reason for hiding this comment

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

Can we add tests for these new additions? I remember go-sev-guest supports a mock https://github.com/google/go-sev-guest/blob/main/testing/test_cases.go#L304 but I'm not too familiar with it tbh

I'll need to do another round on the library crypto; thankfully Chris has already taken a look.

@jxu023
Copy link
Collaborator Author

jxu023 commented Oct 22, 2025

Can we add tests for these new additions? I remember go-sev-guest supports a mock https://github.com/google/go-sev-guest/blob/main/testing/test_cases.go#L304 but I'm not too familiar with it tbh

I'll need to do another round on the library crypto; thankfully Chris has already taken a look.

I've uploaded another revision, still working on unit tests. I'll be updating the SVSMOpts to include configfsi and LeveledQuoteProvider interfaces so that I can inject a test double there

@jxu023
Copy link
Collaborator Author

jxu023 commented Oct 28, 2025

Updated with unit tests

// for reference: https://github.com/TrustedComputingGroup/tpm-fw-attestation-reference-code

var (
errCertifiedWrongName = errors.New("incorrect name")
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: capitalize name or call it a TPM name

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I wasn't clear on what to do here, could you clarify?

Copy link
Contributor

Choose a reason for hiding this comment

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

"incorrect TPM name"

Copy link
Contributor

@jkl73 jkl73 left a comment

Choose a reason for hiding this comment

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

lgtm two overall thoughts:

  • The cmd looks a bit complicated, we might think how to streamline it.
  • svsm specific code in client/server might be more suitable to put into go-sev-guest repo

@jxu023
Copy link
Collaborator Author

jxu023 commented Nov 5, 2025

The cmd looks a bit complicated, we might think how to streamline it.

I've removed SVSM logic from tpm registration, so hopefully it's a bit simpler now.

svsm specific code in client/server might be more suitable to put into go-sev-guest repo

I've moved svsm specific code to the cmd package instead of client/server. This way we can do a drop-in replacement when i move some of that to either go-sev-guest or tcb-verifier

I've uploaded a new revision which includes these changes:

  • added go-sev-guest v0.14.0 to deps so that i can abandon update go-sev-guest from v0.13.0 to v0.14.0 #608 if we merge this
  • added 2 second sleep prior to SVSM attestation report request (since Coconut SVSM will crash on hitting the guest request ratelimit)
  • made svsm subcommands for gotpm attest/verify
  • added gce-tcb-endorsement attestation/verification into svsm subcommands

@alexmwu @jkl73 lemme know how the changes look

Notably we no longer need to separately call gce-tcb-verifier CLI
full example usage:

TEE_NONCE="123456789012345678901234567890123456789012345678901234567890123456789012345
"
ALGO="ecc"

"${gotpm}" pubkey endorsement --key-format=tpmt-public \
  --algo=rsa --output=ek.bin
"${gotpm}" register create-challenge --input=ek.bin \
  --output=challenge.bin --secret-output=secret.bin
"${gotpm}" register solve-challenge --input=challenge.bin --algo=${ALGO} \
  --output=certified_blob.bin
"${gotpm}" register verify-challenge --input=certified_blob.bin \
  --secret-input=secret.bin

"${gotpm}" attest svsm --nonce=1234 --output=svsm_attestation.bin \
  --algo=${ALGO} --key=AK --tee-nonce="${TEE_NONCE}" \
  --tee-technology=sev-snp
"${gotpm}" verify debug svsm --nonce=1234 --input=svsm_attestation.bin \
  --tee-technology=sev-snp --certified-ak-blob=certified_blob.bin \
  --ek-pub=ek.bin --tee-nonce="${TEE_NONCE}"

@jkl73
Copy link
Contributor

jkl73 commented Nov 5, 2025

/gcbrun

@jxu023 jxu023 force-pushed the main branch 2 times, most recently from 24e2ac1 to 14ca5bd Compare November 5, 2025 20:08
@mayafleischer
Copy link
Collaborator

/gcbrun

1 similar comment
@mayafleischer
Copy link
Collaborator

/gcbrun

@mayafleischer
Copy link
Collaborator

/gcbrun

Jacob Xu added 6 commits November 5, 2025 23:05
These two messages are needed for TPM registration and SVSM support in
the next patches.

The generated code is the result of running `go generate ./...` inside
proto/
gce-tcb-verifier is used to verify the launch measurement in the SNP
attestation report, and also to verify the endorsement that is used to
verify the launch measurement.

go-sev-guest is updated so as to avoid an attestation report parsing
error for the v4 SNP attestation report format.

go-tpm is updated to make use of new commands needed by TPM
registration.

go-configfs-tsm updated to retrieve the manifest blob which will contain
the vtpm service manifest for SVSM attestation.

the go.mod and go.sum updates were generated by running these commands:

go get github.com/google/[email protected]
go get github.com/google/[email protected]

pushd cmd/
go get github.com/google/[email protected]
go get github.com/google/[email protected]
go get github.com/google/gce-tcb-verifier/gcetcbendorsement@latest
popd

go mod tidy

pushd cmd
go mod tidy
popd

pushd verifier
go mod tidy
popd

pushd launcher
go mod tidy
popd
The client server files for import_certify.go corresponds to the spec
for EK-based Key attestation with firmware version.
See https://trustedcomputinggroup.org/wp-content/uploads/EK-Based-Key-Attestation-with-TPM-Firmware-Version-V1-RC1_9July2025.pdf#page=8

This will be used for SVSM attestation in the next patches. This is
required for SVSM attestation because Coconut SVSM currently only
attests to a single EK.
EK-based TPM registration consists of requesting a challenge, creating a
challenge, solving the challenge, and verifying the challenge.

Requesting a challenge corresponds to getting the EK public key via
cmd/pubkey.go.

Creating, solving and verifying the challenge correspond to subcommands
defined in cmd/register.go.

We also add some helpers for reading and writing files to flags.go and use
them.
`gotpm attest svsm` and `gotpm verify debug svsm` add svsm specific
logic for verifying an SNP attestation report that is requested by
Coconut SVSM on behalf of the linux guest. The SVSM spec defines a vTPM
single service attestation protocol which allows the SNP attestation
report instead of an EK certificate for creating trust in the TPM EK.

We use SVSM's service attestation and the SNP hardware
attestation report to create trust for the EK, instead of an EK
certificate.
See https://github.com/coconut-svsm/svsm for Coconut SVSM code which
implements the SVSM spec interface.
SVSM spec is found at https://www.amd.com/en/developer/sev.html

We add the SevSnp attestation inside the SevSnpSvsmAttestation message
instead of the Attestation message. AttestOpts is modified to allow
running attest in a CVM without attempting to add the tee technology
attestation.

The full SVSM attestation flow follows these example commands:

TEE_NONCE="123456789012345678901234567890123456789012345678901234567890123456789012345
"
ALGO="ecc"

"${gotpm}" pubkey endorsement --key-format=tpmt-public \
  --algo=rsa --output=ek.bin
"${gotpm}" register create-challenge --input=ek.bin \
  --output=challenge.bin --secret-output=secret.bin
"${gotpm}" register solve-challenge --input=challenge.bin --algo=${ALGO} \
  --output=certified_blob.bin
"${gotpm}" register verify-challenge --input=certified_blob.bin \
  --secret-input=secret.bin

"${gotpm}" attest svsm --nonce=1234 --output=svsm_attestation.bin \
  --algo=${ALGO} --key=AK --tee-nonce="${TEE_NONCE}" \
  --tee-technology=sev-snp
"${gotpm}" verify debug svsm --nonce=1234 --input=svsm_attestation.bin \
  --tee-technology=sev-snp --certified-ak-blob=certified_blob.bin \
  --ek-pub=ek.bin --tee-nonce="${TEE_NONCE}"
made these manual edits to auto generated files
the presubmit runs go generate commands and then checks for diffs with:
git diff -G'^[^/]' --exit-code

however, these are comment lines? and i think the diff command shoulda
skipped those?

oh well, let's try it now.
@mayafleischer
Copy link
Collaborator

/gcbrun

{"RSA", tpm2.TPMAlgRSA},
{"ECC", tpm2.TPMAlgECC},
}
for _, tc := range testcases {
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: could the CreateCertifiedAKBlob be a receiver method on the ek Key. You can then call ek.PublicArea() below and ek.CreateCertifiedAKBlob(tpm, challenge, tc.keyAlgo)

// for reference: https://github.com/TrustedComputingGroup/tpm-fw-attestation-reference-code

var (
errCertifiedWrongName = errors.New("incorrect name")
Copy link
Contributor

Choose a reason for hiding this comment

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

"incorrect TPM name"

bytes certify_info = 2;
// TPM2 signature, encoded as a TPMT_Signature
bytes raw_sig = 3;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: newline at end of file

// constraints.
SevSnpPolicy sev_snp = 3;
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: newline at end of file.

@jxu023 jxu023 merged commit d94cf98 into google:main Nov 6, 2025
10 checks passed
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.

6 participants