Skip to content

Commit

Permalink
aa/attester: IBM Secure Execution driver fix comments
Browse files Browse the repository at this point in the history
Signed-off-by: Qi Feng Huo <[email protected]>
  • Loading branch information
Qi Feng Huo committed Jun 7, 2024
1 parent c6dc4fd commit 0bf8618
Showing 1 changed file with 3 additions and 20 deletions.
23 changes: 3 additions & 20 deletions attestation-agent/attester/src/se/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use super::Attester;
use anyhow::*;
use log::debug;
use pv::{
misc,
request::BootHdrTags,
uv::{AttestationCmd, ConfigUid, UvDevice},
};
Expand All @@ -15,17 +16,7 @@ use serde_json;
use serde_with::{base64::Base64, serde_as};

pub fn detect_platform() -> bool {
// run always on s390x machine
let v = std::fs::read("/sys/firmware/uv/prot_virt_guest").unwrap_or_else(|_| vec![0]);
let v: u8 = String::from_utf8_lossy(&v[..1]).parse().unwrap_or(0);
v == 1
}

#[serde_as]
#[derive(Clone, Debug, Serialize, Deserialize)]
pub struct UserData {
#[serde_as(as = "Base64")]
image_btph: Vec<u8>,
misc::pv_guest_bit_set
}

#[repr(C)]
Expand Down Expand Up @@ -70,14 +61,6 @@ pub struct SeAttester {}
#[async_trait::async_trait]
impl Attester for SeAttester {
async fn get_evidence(&self, req: Vec<u8>) -> Result<String> {
// req is serialized SeAttestationRequest String bytes
// TODO, optionally calculate image boot partition hash (btph).
let image_btph = "optional check";
let userdata = UserData {
image_btph: image_btph.into(),
};

debug!("userdata json: {userdata:#?}");
// req is serialized SeAttestationRequest String bytes
let request: SeAttestationRequest = serde_json::from_slice(&req)?;
let SeAttestationRequest {
Expand All @@ -88,7 +71,7 @@ impl Attester for SeAttester {
encr_request_nonce,
image_hdr_tags,
} = request;
let user_data = serde_json::to_vec(&userdata)?;
let user_data = vec![0];
let mut uvc: AttestationCmd = AttestationCmd::new_request(
request_blob.into(),
Some(user_data.to_vec()),
Expand Down

0 comments on commit 0bf8618

Please sign in to comment.