-
Notifications
You must be signed in to change notification settings - Fork 98
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
aa/attester: add s390x z16 evidence driver framework
Signed-off-by: Qi Feng Huo <[email protected]>
- Loading branch information
Qi Feng Huo
committed
Mar 6, 2024
1 parent
05b981d
commit f82d20b
Showing
11 changed files
with
127 additions
and
1 deletion.
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
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,71 @@ | ||
// Copyright (C) Copyright IBM Corp. 2024 | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// | ||
|
||
use super::Attester; | ||
use anyhow::*; | ||
use base64::prelude::*; | ||
use serde::{Deserialize, Serialize}; | ||
use crate::se::seattest::FakeSeAttest; | ||
use crate::se::seattest::SeAttester; | ||
|
||
pub mod seattest; | ||
|
||
pub fn detect_platform() -> bool { | ||
// TODO replace FakeSeAttest with real crate | ||
let attester = FakeSeAttest::default(); | ||
attester.is_se_guest() | ||
} | ||
|
||
#[derive(Serialize, Deserialize)] | ||
struct SeEvidence { | ||
quote: Vec<u8>, | ||
} | ||
|
||
#[derive(Debug, Default)] | ||
pub struct SeAttester {} | ||
|
||
#[async_trait::async_trait] | ||
impl Attester for SeAttester { | ||
async fn get_evidence(&self, mut report_data: Vec<u8>) -> Result<String> { | ||
/// TODO replace FakeSeAttest with real crate | ||
let attester = FakeSeAttest::default(); | ||
/// TODO, append attesttaion request in KBS payload | ||
let attestation-request-bin = Vec::new(); /// get attesttaion request from payload report_data | ||
let userdata = Vec::new(); | ||
let evidence = attester.perform( | ||
attestation-request-bin, | ||
userdata | ||
).await?; | ||
|
||
Ok(BASE64_STANDARD.encode(evidence)) | ||
} | ||
|
||
async fn extend_runtime_measurement( | ||
&self, | ||
_events: Vec<Vec<u8>>, | ||
_register_index: Option<u64>, | ||
) -> Result<()> { | ||
bail!("Unimplemented") | ||
} | ||
|
||
async fn check_init_data(&self, _init_data: &[u8]) -> Result<()> { | ||
bail!("Unimplemented"); | ||
} | ||
} | ||
|
||
#[cfg(test)] | ||
mod tests { | ||
use super::*; | ||
|
||
#[ignore] | ||
#[tokio::test] | ||
async fn test_se_get_evidence() { | ||
let attester = SeAttester::default(); | ||
let report_data: Vec<u8> = vec![0; 64]; | ||
|
||
let evidence = attester.get_evidence(report_data).await; | ||
assert!(evidence.is_ok()); | ||
} | ||
} |
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,36 @@ | ||
// Copyright (C) Copyright IBM Corp. 2024 | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// | ||
|
||
use anyhow::*; | ||
use async_trait; | ||
|
||
#[derive(Default)] | ||
pub struct FakeSeAttest {} | ||
|
||
#[async_trait::async_trait] | ||
pub trait SeAttester { | ||
fn is_se_guest(&self) -> bool; | ||
|
||
async fn perform( | ||
&self, | ||
request: Vec<u8>, | ||
userdata: Vec<u8> | ||
) -> Result<Vec<u8>>; | ||
} | ||
|
||
#[async_trait::async_trait] | ||
impl SeAttester for FakeSeAttest { | ||
fn is_se_guest(&self) -> bool { | ||
true | ||
} | ||
|
||
async fn perform( | ||
&self, | ||
request: Vec<u8>, | ||
userdata: Vec<u8> | ||
) -> Result<Vec<u8>> { | ||
Result::Ok(Vec::new()) | ||
} | ||
} |
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