1use alloc::string::ToString;
4use rand_core::{CryptoRng, RngCore};
5
6use crate::{FramedBytes, MsgError, MsgFromHost, MsgToHost};
7
8pub trait EnclaveClient {
11 type Error: core::error::Error + core::fmt::Display;
12
13 fn verify_quote(report: &[u8], nonce: u64) -> Result<[u8; 64], Self::Error>;
17}
18
19pub trait RemoteAttestation: Clone {
21 fn init() -> Self;
22 fn get_quote(&self, report_data: [u8; 64]) -> alloc::vec::Vec<u8>;
23}
24
25pub trait EnclaveComm: FramedBytes {
28 fn init() -> Self;
30
31 fn read(&mut self) -> Result<MsgFromHost, MsgError> {
33 let frame = self.get_frame()?;
34 frame.deserialize()
35 }
36
37 fn write(&mut self, msg: &MsgToHost) {
39 self.write_frame(msg)
40 }
41
42 fn write_err(&mut self, err: &str) {
45 self.write(&MsgToHost::Error(err.to_string()))
46 }
47
48 fn write_client_err(&mut self, err: &str) {
51 self.write(&MsgToHost::ErrorForClient(err.to_string()))
52 }
53}
54
55pub trait EnclaveRNG: RngCore + CryptoRng + Clone {
57 fn init() -> Self;
58}