Attestor abstraction
This commit is contained in:
parent
f7acb4629b
commit
cdd83e657d
3 changed files with 51 additions and 33 deletions
27
enclaves/quartz/src/attestor.rs
Normal file
27
enclaves/quartz/src/attestor.rs
Normal file
|
@ -0,0 +1,27 @@
|
|||
use std::{
|
||||
fs::{read, File},
|
||||
io::{Error as IoError, Write},
|
||||
};
|
||||
|
||||
use quartz_cw::msg::execute::attested::HasUserData;
|
||||
|
||||
pub trait Attestor {
|
||||
type Error: ToString;
|
||||
|
||||
fn quote(&self, user_data: impl HasUserData) -> Result<Vec<u8>, Self::Error>;
|
||||
}
|
||||
|
||||
#[derive(Clone, PartialEq, Debug)]
|
||||
pub struct EpidAttestor;
|
||||
|
||||
impl Attestor for EpidAttestor {
|
||||
type Error = IoError;
|
||||
|
||||
fn quote(&self, user_data: impl HasUserData) -> Result<Vec<u8>, Self::Error> {
|
||||
let user_data = user_data.user_data();
|
||||
let mut user_report_data = File::create("/dev/attestation/user_report_data")?;
|
||||
user_report_data.write_all(user_data.as_slice())?;
|
||||
user_report_data.flush()?;
|
||||
read("/dev/attestation/quote")
|
||||
}
|
||||
}
|
|
@ -14,6 +14,7 @@
|
|||
unused_qualifications
|
||||
)]
|
||||
|
||||
mod attestor;
|
||||
mod cli;
|
||||
mod server;
|
||||
|
||||
|
@ -24,7 +25,7 @@ use quartz_cw::state::{Config, LightClientOpts};
|
|||
use quartz_proto::quartz::core_server::CoreServer;
|
||||
use tonic::transport::Server;
|
||||
|
||||
use crate::{cli::Cli, server::CoreService};
|
||||
use crate::{attestor::EpidAttestor, cli::Cli, server::CoreService};
|
||||
|
||||
#[tokio::main(flavor = "current_thread")]
|
||||
async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
|
@ -46,7 +47,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|||
);
|
||||
|
||||
Server::builder()
|
||||
.add_service(CoreServer::new(CoreService::new(config)))
|
||||
.add_service(CoreServer::new(CoreService::new(config, EpidAttestor)))
|
||||
.serve(args.rpc_addr)
|
||||
.await?;
|
||||
|
||||
|
|
File diff suppressed because one or more lines are too long
Loading…
Reference in a new issue