This repository has been archived by the owner on Jul 2, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 58
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
An attester for SEV-SNP that retrieves the attestation report directly using virtee/sev crate. On its own this attester does not cover the full CoCo TCB. Extension to the launch digest (such as with kernel hashes) is required. Signed-off-by: Tobin Feldman-Fitzthum <tobin@ibm.com>
- Loading branch information
Showing
8 changed files
with
71 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
// Copyright (c) 2022 IBM | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// | ||
|
||
use super::Attester; | ||
use anyhow::*; | ||
use serde::{Deserialize, Serialize}; | ||
use sev::firmware::guest::types::{AttestationReport, SnpReportReq}; | ||
use sev::firmware::guest::Firmware; | ||
use sev::firmware::host::types::CertTableEntry; | ||
use std::path::Path; | ||
|
||
pub fn detect_platform() -> bool { | ||
Path::new("/sys/devices/platform/sev-guest").exists() | ||
} | ||
|
||
#[derive(Serialize, Deserialize)] | ||
struct SnpEvidence { | ||
attestation_report: AttestationReport, | ||
cert_chain: Vec<CertTableEntry>, | ||
} | ||
|
||
#[derive(Debug, Default)] | ||
pub struct SnpAttester {} | ||
|
||
impl Attester for SnpAttester { | ||
fn get_evidence(&self, report_data: String) -> Result<String> { | ||
let mut report_data_bin = base64::decode(report_data)?; | ||
|
||
if report_data_bin.len() != 48 { | ||
bail!("Malformed SNP Evidence"); | ||
} | ||
|
||
report_data_bin.extend([0; 16]); | ||
|
||
let mut firmware = Firmware::open()?; | ||
let report_request = SnpReportReq::new(Some(report_data_bin.as_slice().try_into()?), 0); | ||
|
||
let (report, certs) = firmware | ||
.snp_get_ext_report(None, report_request) | ||
.context("Failed to get attestation report")?; | ||
|
||
let evidence = SnpEvidence { | ||
attestation_report: report, | ||
cert_chain: certs, | ||
}; | ||
|
||
serde_json::to_string(&evidence).context("Serialize SNP evidence failed") | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters