From aca4366ae060ce8e88d4b6e8d509996ea8160eb2 Mon Sep 17 00:00:00 2001 From: Jun Kimura Date: Tue, 19 Nov 2024 17:48:11 +0900 Subject: [PATCH 1/3] fix incorrect comment Signed-off-by: Jun Kimura --- modules/lcp-client/src/client_def.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/lcp-client/src/client_def.rs b/modules/lcp-client/src/client_def.rs index a632ea40..c15c5546 100644 --- a/modules/lcp-client/src/client_def.rs +++ b/modules/lcp-client/src/client_def.rs @@ -104,7 +104,7 @@ impl LCPClient { Ok(()) } - // verify_client_message verifies a client message + /// update_client verifies a client message and updates the state of the client pub fn update_client( &self, ctx: &mut dyn HostClientKeeper, From c19587285c58afc5e3e43242dbbe8ad47ae23cf1 Mon Sep 17 00:00:00 2001 From: Jun Kimura Date: Tue, 19 Nov 2024 18:10:14 +0900 Subject: [PATCH 2/3] fix to use `quote_size` instead of hardcoded quote size Signed-off-by: Jun Kimura --- modules/remote-attestation/src/ias_utils.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/remote-attestation/src/ias_utils.rs b/modules/remote-attestation/src/ias_utils.rs index 3b335145..bd3346e2 100644 --- a/modules/remote-attestation/src/ias_utils.rs +++ b/modules/remote-attestation/src/ias_utils.rs @@ -87,7 +87,7 @@ pub(crate) fn get_quote( info!("quote size = {}", quote_size); let mut qe_report = sgx_report_t::default(); - let quote = [0u8; 2048]; + let quote: Vec = vec![0; quote_size as usize]; let p_quote = quote.as_ptr(); let ret = unsafe { sgx_get_quote( @@ -105,7 +105,7 @@ pub(crate) fn get_quote( if ret != sgx_status_t::SGX_SUCCESS { return Err(Error::sgx_error(ret, "failed to sgx_get_quote".into())); } - (quote[..quote_size as usize].to_vec(), qe_report) + (quote, qe_report) }; // Check qe_report to defend against replay attack From 010fbf9dccd423069cca7bbb1282e9dfaa7330a4 Mon Sep 17 00:00:00 2001 From: Jun Kimura Date: Tue, 19 Nov 2024 18:26:31 +0900 Subject: [PATCH 3/3] fix to remove unnecessary slicing Signed-off-by: Jun Kimura --- modules/remote-attestation/src/ias_utils.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/modules/remote-attestation/src/ias_utils.rs b/modules/remote-attestation/src/ias_utils.rs index bd3346e2..23bec347 100644 --- a/modules/remote-attestation/src/ias_utils.rs +++ b/modules/remote-attestation/src/ias_utils.rs @@ -415,6 +415,7 @@ pub(crate) fn decode_spid(spid_str: &str) -> Result { } }; let mut spid = sgx_spid_t::default(); - spid.id.copy_from_slice(&decoded_vec[..16]); + // the length of `decoded_vec` is 16 because each byte is represented by 2 characters + spid.id.copy_from_slice(&decoded_vec); Ok(spid) }