Lazily initializing QUOTE as static

This commit is contained in:
Noor 2024-10-09 12:18:39 +00:00 committed by Valentyn Faychuk
parent b535df88d5
commit 33a93193c0
3 changed files with 19 additions and 2 deletions

@ -1,7 +1,7 @@
use crate::{RaTlsConfigBuilder, RaTlsError};
#[cfg(feature = "occlum")]
use crate::quote::Quote;
use crate::quote::{Quote, STATIC_QUOTE};
use rustls::{ClientConfig, ServerConfig};
@ -56,6 +56,11 @@ impl InstanceMeasurement {
}
}
fn generate_static_empty_quote() -> Result<&'static Quote, RaTlsError> {
Ok(STATIC_QUOTE.as_ref().map_err(|e| e.clone())?)
}
pub(crate) fn check_quote_measurements(&self, quote: &Quote) -> bool {
let mut result = false;
if let Some(mrsigners) = &self.mrsigners {

@ -1,6 +1,6 @@
use std::{error::Error, fmt::Display};
#[derive(Debug)]
#[derive(Debug, Clone)]
pub enum RaTlsError {
CertificateBuildError(String),
QuoteError(String),

@ -143,6 +143,18 @@ lazy_static! {
};
}
// lazy_static! {
// pub static ref STATIC_QUOTE: once_cell::sync::OnceCell<Quote> =
// OnceCell::with_value(Quote::from_report_data([0u8; 64]).unwrap());
// }
// unsafe impl Send for Quote {}
lazy_static! {
pub static ref STATIC_QUOTE: Result<Quote, RaTlsError> = Quote::from_report_data([0u8; 64]);
}
unsafe impl Sync for Quote {}
pub struct IoctlClient {
fd: HandleType,
quote_size: Option<u32>,