Skip to content

Commit

Permalink
AS/Verifier: add report_data and init_data_hash field for SGX/TDX
Browse files Browse the repository at this point in the history
Related to confidential-containers#228. This is the implementation for SGX/TDX/Sample

Signed-off-by: Xynnn007 <xynnn@linux.alibaba.com>
  • Loading branch information
Xynnn007 committed Dec 1, 2023
1 parent 64c49a3 commit 9a560d8
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 2 deletions.
6 changes: 6 additions & 0 deletions attestation-service/verifier/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,12 @@ pub trait Verifier {
/// instance is created. It is always provided by untrusted host,
/// but its integrity will be protected by the tee evidence.
/// Typical `init_data_hash` is `HOSTDATA` for SNP.
///
///
/// There will be two claims by default regardless of architectures:
/// - `init_data_hash`: init data hash of the evidence
/// - `report_data`: report data of the evidence
/// TODO: See https://github.com/confidential-containers/kbs/issues/228
async fn evaluate(
&self,
evidence: &[u8],
Expand Down
6 changes: 4 additions & 2 deletions attestation-service/verifier/src/sample/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ struct SampleTeeEvidence {
report_data: String,

#[serde(default = "String::default")]
init_data_hash: String,
init_data: String,
}

#[derive(Debug, Default)]
Expand Down Expand Up @@ -64,7 +64,7 @@ async fn verify_tee_evidence(
if let InitDataHash::Value(expected_init_data_hash) = expected_init_data_hash {
debug!("Check the binding of init_data_digest.");
let ev_init_data_hash = base64::engine::general_purpose::STANDARD
.decode(&evidence.init_data_hash)
.decode(&evidence.init_data)
.context("base64 decode init data hash for sample evidence")?;
if *expected_init_data_hash != ev_init_data_hash {
bail!("INIT DATA HASH is different from that in Sample Quote");
Expand All @@ -79,6 +79,8 @@ async fn verify_tee_evidence(
fn parse_tee_evidence(quote: &SampleTeeEvidence) -> Result<TeeEvidenceParsedClaim> {
let claims_map = json!({
"svn": quote.svn,
"report_data": quote.report_data,
"init_data": quote.init_data,
});

Ok(claims_map as TeeEvidenceParsedClaim)
Expand Down
2 changes: 2 additions & 0 deletions attestation-service/verifier/src/sgx/claims.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,8 @@ pub fn generate_parsed_claims(quote: sgx_quote3_t) -> Result<TeeEvidenceParsedCl
let mut claims = Map::new();
parse_claim!(claims, "header", quote_header);
parse_claim!(claims, "body", quote_body);
parse_claim!(claims, "report_data", quote.report_body.report_data);
parse_claim!(claims, "init_data", quote.report_body.config_id);

log::info!("\nParsed Evidence claims map: \n{:?}\n", &claims);

Expand Down
4 changes: 4 additions & 0 deletions attestation-service/verifier/src/tdx/claims.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,10 @@ pub fn generate_parsed_claim(
let mut claims = Map::new();
parse_claim!(claims, "quote", quote_map);
parse_claim!(claims, "ccel", ccel_map);

parse_claim!(claims, "report_data", quote.report_body.report_data);
parse_claim!(claims, "init_data", quote.report_body.mr_config_id);

log::info!("\nParsed Evidence claims map: \n{:?}\n", &claims);

Ok(Value::Object(claims) as TeeEvidenceParsedClaim)
Expand Down

0 comments on commit 9a560d8

Please sign in to comment.