-
Notifications
You must be signed in to change notification settings - Fork 99
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 IBM Secure Execution evidence driver framework
Signed-off-by: Qi Feng Huo <[email protected]>
- Loading branch information
Qi Feng Huo
committed
Mar 11, 2024
1 parent
917097b
commit 8cc2716
Showing
14 changed files
with
116 additions
and
4 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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,58 @@ | ||
// Copyright (C) Copyright IBM Corp. 2024 | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// | ||
|
||
use super::Attester; | ||
use crate::se::seattest::FakeSeAttest; | ||
use crate::se::seattest::SeImplAttester; | ||
use anyhow::*; | ||
use base64::prelude::*; | ||
use serde::{Deserialize, Serialize}; | ||
|
||
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, _challenge: Vec<u8>) -> Result<String> { | ||
// TODO replace FakeSeAttest with real crate | ||
let attester = FakeSeAttest::default(); | ||
|
||
// TODO, append attesttaion request in KBS payload | ||
// We want get challenge.extra_params from the input challenge, hashed string is not good. | ||
let attestation_request_bin = Vec::new(); | ||
let userdata = Vec::new(); | ||
let evidence = attester.perform(attestation_request_bin, userdata).await?; | ||
|
||
Ok(BASE64_STANDARD.encode(evidence)) | ||
} | ||
} | ||
|
||
#[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,27 @@ | ||
// 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 SeImplAttester { | ||
fn is_se_guest(&self) -> bool; | ||
async fn perform(&self, _request: Vec<u8>, _userdata: Vec<u8>) -> Result<Vec<u8>>; | ||
} | ||
|
||
#[async_trait::async_trait] | ||
impl SeImplAttester for FakeSeAttest { | ||
fn is_se_guest(&self) -> bool { | ||
true | ||
} | ||
|
||
async fn perform(&self, _request: Vec<u8>, _userdata: Vec<u8>) -> Result<Vec<u8>> { | ||
Result::Ok("test".as_bytes().to_vec()) | ||
} | ||
} |
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 |
---|---|---|
|
@@ -5,3 +5,7 @@ default allow = false | |
allow { | ||
input["tee"] == "sample" | ||
} | ||
|
||
allow { | ||
input["tee"] == "se" | ||
} |