Skip to content

Fix legacy attestation report validation #293

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 3, 2025

Conversation

rouming
Copy link
Contributor

@rouming rouming commented Mar 26, 2025

Hi folks,

For a couple of weeks, I've been investigating AMD SEV technology and experimenting with the sev/sevctl tool. I noticed that legacy report validation was only drafted (rewritten from the deprecated sev-tool) but actually does not work as expected. I've fixed that and tried to mimic the spirit of the sevctl tool as much as possible. This is my first contribution in Rust, so your feedback is highly appreciated.

What has been done in this PR:

  • Corrected signature verification to use the SHA256 digest instead of raw data.
  • Fixed signature size in LegacyAttestationReport by defining it as an Array<u8, 144> instead of an EcdsaSignature structure, which is 512 bytes.
  • Fixed digest size in LegacyAttestationReport, ensuring launch_digest uses DIGEST_SIZE instead of POLICY_SIZE.

There should be another PR for sevctl itself coming soon, I'll provide a link to that PR once I push it.
Update: the sevctl part virtee/sevctl#205

Copy link
Member

@DGonzalezVillal DGonzalezVillal left a comment

Choose a reason for hiding this comment

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

It looks correct to me, did you have any issues @larrydewey

@rouming
Copy link
Contributor Author

rouming commented Mar 31, 2025

Please let me know, if there is anything to address from my side. Also I would really appreciate, if you review the sevctl part virtee/sevctl#205.

@DGonzalezVillal
Copy link
Member

@rouming Could you squash into one commit, besides that it looks good, we can merge right after.

Copy link
Member

@tylerfanelli tylerfanelli left a comment

Choose a reason for hiding this comment

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

LGTM. Can you squash into one commit?

This commit fixes legacy attestation report verification by addressing
a few problems:

1. Fix typo of `launch_digest` definition for the
`LegacyAttestationReport` structure: should be `DIGEST_SIZE` not
`POLICY_SIZE`.

2. Signature verification should be performed on the SHA256 digest,
not on the raw data. Additionally, the return value of `sig.verify()`
should be properly converted to the `Result` type.

3. The `EcdsaSignature` structure has a size of 512 bytes, but the
`LegacyAttestationReport` defines the signature as 144 bytes. Change
the type of the signature to an `Array<u8, 144>` with an appropriate
conversion trait.

Signed-off-by: Roman Penyaev <[email protected]>
@rouming
Copy link
Contributor Author

rouming commented Apr 3, 2025

@DGonzalezVillal @tylerfanelli squashed, please take a look.

Copy link
Member

@tylerfanelli tylerfanelli left a comment

Choose a reason for hiding this comment

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

LGTM

@tylerfanelli tylerfanelli merged commit 71beb7a into virtee:main Apr 3, 2025
123 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.

4 participants