use alloc::string::ToString;
use rand_core::{CryptoRng, RngCore};
use crate::{FramedBytes, MsgError, MsgFromHost, MsgToHost};
pub trait EnclaveClient {
type Error: core::error::Error + core::fmt::Display;
fn verify_quote(report: &[u8], nonce: u64) -> Result<[u8; 64], Self::Error>;
}
pub trait RemoteAttestation: Clone {
fn init() -> Self;
fn get_quote(&self, report_data: [u8; 64]) -> alloc::vec::Vec<u8>;
}
pub trait EnclaveComm: FramedBytes {
fn init() -> Self;
fn read(&mut self) -> Result<MsgFromHost, MsgError> {
let frame = self.get_frame()?;
frame.deserialize()
}
fn write(&mut self, msg: &MsgToHost) {
self.write_frame(msg)
}
fn write_err(&mut self, err: &str) {
self.write(&MsgToHost::Error(err.to_string()))
}
fn write_client_err(&mut self, err: &str) {
self.write(&MsgToHost::ErrorForClient(err.to_string()))
}
}
pub trait EnclaveRNG: RngCore + CryptoRng + Clone {
fn init() -> Self;
}