Skip to content
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

intel-trust-authority-as: add runtime data to attestation request #406

Merged
merged 1 commit into from
Jun 21, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion kbs/src/api/src/attestation/intel_trust_authority/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@
use super::Attest;
use anyhow::*;
use async_trait::async_trait;
use base64::{engine::general_purpose::STANDARD, Engine};
use jsonwebtoken::{decode, decode_header, jwk, Algorithm, DecodingKey, Validation};
use kbs_types::{Attestation, Tee};
use reqwest::header::{ACCEPT, CONTENT_TYPE};
use serde::{Deserialize, Serialize};
use serde_json::json;
use std::fs::File;
use std::io::BufReader;
use std::str::FromStr;
Expand All @@ -23,6 +25,7 @@ struct IntelTrustAuthorityTeeEvidence {
#[derive(Serialize, Debug)]
struct AttestReqData {
quote: String,
runtime_data: String,
}

#[derive(Deserialize, Debug)]
Expand Down Expand Up @@ -50,7 +53,7 @@ pub struct IntelTrustAuthority {

#[async_trait]
impl Attest for IntelTrustAuthority {
async fn verify(&self, tee: Tee, _nonce: &str, attestation: &str) -> Result<String> {
async fn verify(&self, tee: Tee, nonce: &str, attestation: &str) -> Result<String> {
if tee != Tee::Tdx && tee != Tee::Sgx {
bail!("Intel Trust Authority: TEE {tee:?} is not supported.");
}
Expand All @@ -61,9 +64,16 @@ impl Attest for IntelTrustAuthority {
serde_json::from_str::<IntelTrustAuthorityTeeEvidence>(&attestation.tee_evidence)
.map_err(|e| anyhow!("Deserialize supported TEE Evidence failed: {:?}", e))?;

let runtime_data = json!({
"tee-pubkey": attestation.tee_pubkey,
"nonce": nonce,
})
.to_string();

// construct attest request data
let req_data = AttestReqData {
quote: evidence.quote,
runtime_data: STANDARD.encode(runtime_data),
};

let attest_req_body = serde_json::to_string(&req_data)
Expand Down
Loading