Skip to content

Commit 1eb735c

Browse files
committed
attester: fiz az-vtpm quote encoding
Since the 0.8.1 crates are exposing the signature, we don't require a fallible conversion any more. Signed-off-by: Magnus Kulke <magnuskulke@microsoft.com>
1 parent ae3f3db commit 1eb735c

2 files changed

Lines changed: 11 additions & 12 deletions

File tree

  • attestation-agent/attester/src

attestation-agent/attester/src/az_snp_vtpm/mod.rs

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,15 @@ pub(crate) struct TpmQuote {
4545
pcrs: Vec<Vec<u8>>,
4646
}
4747

48-
impl TryFrom<vtpm::Quote> for TpmQuote {
49-
type Error = serde_json::Error;
50-
51-
fn try_from(q: vtpm::Quote) -> Result<Self, Self::Error> {
52-
// Re-serialize through JSON to access private fields
53-
let json = serde_json::to_value(&q)?;
54-
serde_json::from_value(json)
48+
impl From<vtpm::Quote> for TpmQuote {
49+
fn from(quote: vtpm::Quote) -> Self {
50+
let pcrs = quote.pcrs_sha256().map(|p| p.to_vec()).collect();
51+
52+
TpmQuote {
53+
signature: quote.signature(),
54+
message: quote.message(),
55+
pcrs,
56+
}
5557
}
5658
}
5759

@@ -92,8 +94,7 @@ fn pem_to_der(pem: &str) -> Result<Vec<u8>> {
9294
impl Attester for AzSnpVtpmAttester {
9395
async fn get_evidence(&self, report_data: Vec<u8>) -> anyhow::Result<TeeEvidence> {
9496
let hcl_report = vtpm::get_report()?;
95-
let quote = vtpm::get_quote(&report_data)?;
96-
let tpm_quote = TpmQuote::try_from(quote)?;
97+
let tpm_quote = vtpm::get_quote(&report_data)?.into();
9798
let certs = imds::get_certs()?;
9899
let vcek = pem_to_der(&certs.vcek)?;
99100

attestation-agent/attester/src/az_tdx_vtpm/mod.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,7 @@ impl Attester for AzTdxVtpmAttester {
5858
let hcl_report = hcl::HclReport::new(hcl_report_bytes.clone())?;
5959
let td_report = hcl_report.try_into()?;
6060
let td_quote = imds::get_td_quote(&td_report)?;
61-
62-
let quote = vtpm::get_quote(&report_data)?;
63-
let tpm_quote = TpmQuote::try_from(quote)?;
61+
let tpm_quote = vtpm::get_quote(&report_data)?.into();
6462

6563
let evidence = Evidence {
6664
version: EVIDENCE_VERSION,

0 commit comments

Comments
 (0)