-
Notifications
You must be signed in to change notification settings - Fork 46
Return encoded extrinsics without padding #1505
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -144,8 +144,9 @@ mod impl_ffi { | |
| let mut retval = sgx_status_t::SGX_SUCCESS; | ||
|
|
||
| let mut unchecked_extrinsic: Vec<u8> = vec![0u8; EXTRINSIC_MAX_SIZE]; | ||
| let mut unchecked_extrinsic_size: u32 = 0; | ||
|
|
||
| trace!("Generating dcap_ra_extrinsic with URL: {}", w_url); | ||
| trace!("Generating ias_ra_extrinsic with URL: {}", w_url); | ||
|
|
||
| let url = w_url.encode(); | ||
|
|
||
|
|
@@ -157,14 +158,15 @@ mod impl_ffi { | |
| url.len() as u32, | ||
| unchecked_extrinsic.as_mut_ptr(), | ||
| unchecked_extrinsic.len() as u32, | ||
| &mut unchecked_extrinsic_size as *mut u32, | ||
| skip_ra.into(), | ||
| ) | ||
| }; | ||
|
|
||
| ensure!(result == sgx_status_t::SGX_SUCCESS, Error::Sgx(result)); | ||
| ensure!(retval == sgx_status_t::SGX_SUCCESS, Error::Sgx(retval)); | ||
|
|
||
| Ok(unchecked_extrinsic) | ||
| Ok(Vec::from(&unchecked_extrinsic[..unchecked_extrinsic_size as usize])) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this needs a check that
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this is implicitly guaranteed by the ffi impl, isn't it If it's out of index, it should have error'ed out within
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmm, yes and no. If we have implemented everything correctly, yes, but the compiler can't make any checks across the ffi-boundaries. So I prefer being defensive here, as it just needs an error of some programmer in the future to introduce potential panics here. Sorry, for being nitpicky here. 🙏
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmm, on the other hand the panic is on the untrusted side, so returning an error or panicking here, is essentially the same from the enclave's perspective. hmm, still I would like to push the best practices as much as possible, so please fix it. :)
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmm, it is actually not the same, one case writes it in the, |
||
| } | ||
| fn generate_dcap_ra_extrinsic_from_quote( | ||
| &self, | ||
|
|
@@ -173,6 +175,7 @@ mod impl_ffi { | |
| ) -> EnclaveResult<Vec<u8>> { | ||
| let mut retval = sgx_status_t::SGX_SUCCESS; | ||
| let mut unchecked_extrinsic: Vec<u8> = vec![0u8; EXTRINSIC_MAX_SIZE]; | ||
| let mut unchecked_extrinsic_size: u32 = 0; | ||
| let url = url.encode(); | ||
|
|
||
| let result = unsafe { | ||
|
|
@@ -185,13 +188,14 @@ mod impl_ffi { | |
| quote.len() as u32, | ||
| unchecked_extrinsic.as_mut_ptr(), | ||
| unchecked_extrinsic.len() as u32, | ||
| &mut unchecked_extrinsic_size as *mut u32, | ||
| ) | ||
| }; | ||
|
|
||
| ensure!(result == sgx_status_t::SGX_SUCCESS, Error::Sgx(result)); | ||
| ensure!(retval == sgx_status_t::SGX_SUCCESS, Error::Sgx(retval)); | ||
|
|
||
| Ok(unchecked_extrinsic.to_vec()) | ||
| Ok(Vec::from(&unchecked_extrinsic[..unchecked_extrinsic_size as usize])) | ||
| } | ||
|
|
||
| fn generate_dcap_ra_quote(&self, skip_ra: bool) -> EnclaveResult<Vec<u8>> { | ||
|
|
@@ -250,7 +254,7 @@ mod impl_ffi { | |
| trace!("Generating dcap_ra_extrinsic with URL: {}", w_url); | ||
|
|
||
| let mut unchecked_extrinsic: Vec<u8> = vec![0u8; EXTRINSIC_MAX_SIZE]; | ||
|
|
||
| let mut unchecked_extrinsic_size: u32 = 0; | ||
| let url = w_url.encode(); | ||
|
|
||
| let result = unsafe { | ||
|
|
@@ -261,6 +265,7 @@ mod impl_ffi { | |
| url.len() as u32, | ||
| unchecked_extrinsic.as_mut_ptr(), | ||
| unchecked_extrinsic.len() as u32, | ||
| &mut unchecked_extrinsic_size as *mut u32, | ||
| skip_ra.into(), | ||
| quoting_enclave_target_info.as_ref(), | ||
| quote_size.as_ref(), | ||
|
|
@@ -270,7 +275,7 @@ mod impl_ffi { | |
| ensure!(result == sgx_status_t::SGX_SUCCESS, Error::Sgx(result)); | ||
| ensure!(retval == sgx_status_t::SGX_SUCCESS, Error::Sgx(retval)); | ||
|
|
||
| Ok(unchecked_extrinsic) | ||
| Ok(Vec::from(&unchecked_extrinsic[..unchecked_extrinsic_size as usize])) | ||
| } | ||
|
|
||
| fn generate_register_quoting_enclave_extrinsic( | ||
|
|
@@ -279,6 +284,7 @@ mod impl_ffi { | |
| ) -> EnclaveResult<Vec<u8>> { | ||
| let mut retval = sgx_status_t::SGX_SUCCESS; | ||
| let mut unchecked_extrinsic: Vec<u8> = vec![0u8; EXTRINSIC_MAX_SIZE]; | ||
| let mut unchecked_extrinsic_size: u32 = 0; | ||
|
|
||
| trace!("Generating register quoting enclave"); | ||
|
|
||
|
|
@@ -291,6 +297,7 @@ mod impl_ffi { | |
| collateral_ptr, | ||
| unchecked_extrinsic.as_mut_ptr(), | ||
| unchecked_extrinsic.len() as u32, | ||
| &mut unchecked_extrinsic_size as *mut u32, | ||
| ) | ||
| }; | ||
| let free_status = unsafe { sgx_ql_free_quote_verification_collateral(collateral_ptr) }; | ||
|
|
@@ -301,12 +308,13 @@ mod impl_ffi { | |
| Error::SgxQuote(free_status) | ||
| ); | ||
|
|
||
| Ok(unchecked_extrinsic) | ||
| Ok(Vec::from(&unchecked_extrinsic[..unchecked_extrinsic_size as usize])) | ||
| } | ||
|
|
||
| fn generate_register_tcb_info_extrinsic(&self, fmspc: Fmspc) -> EnclaveResult<Vec<u8>> { | ||
| let mut retval = sgx_status_t::SGX_SUCCESS; | ||
| let mut unchecked_extrinsic: Vec<u8> = vec![0u8; EXTRINSIC_MAX_SIZE]; | ||
| let mut unchecked_extrinsic_size: u32 = 0; | ||
|
|
||
| trace!("Generating tcb_info registration"); | ||
|
|
||
|
|
@@ -319,6 +327,7 @@ mod impl_ffi { | |
| collateral_ptr, | ||
| unchecked_extrinsic.as_mut_ptr(), | ||
| unchecked_extrinsic.len() as u32, | ||
| &mut unchecked_extrinsic_size as *mut u32, | ||
| ) | ||
| }; | ||
| let free_status = unsafe { sgx_ql_free_quote_verification_collateral(collateral_ptr) }; | ||
|
|
@@ -329,7 +338,7 @@ mod impl_ffi { | |
| Error::SgxQuote(free_status) | ||
| ); | ||
|
|
||
| Ok(unchecked_extrinsic) | ||
| Ok(Vec::from(&unchecked_extrinsic[..unchecked_extrinsic_size as usize])) | ||
| } | ||
|
|
||
| fn dump_ias_ra_cert_to_disk(&self) -> EnclaveResult<()> { | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.