From 9d18ca2606bc11670c2bccb38b676e00e3982c6a Mon Sep 17 00:00:00 2001 From: Pi Delport Date: Tue, 15 Jun 2021 17:01:25 +0200 Subject: [PATCH] style(rtc_uenclave): cargo fmt --- rtc_uenclave/auth-sys/build.rs | 5 ++-- rtc_uenclave/auth-sys/src/lib.rs | 5 ++-- rtc_uenclave/data-ocalls/src/lib.rs | 5 ++-- rtc_uenclave/data-sys/build.rs | 5 ++-- rtc_uenclave/data-sys/src/lib.rs | 5 ++-- rtc_uenclave/exec-sys/build.rs | 5 ++-- rtc_uenclave/exec-sys/src/lib.rs | 5 ++-- rtc_uenclave/src/azure_attestation.rs | 9 ++++--- rtc_uenclave/src/ecalls.rs | 4 +-- rtc_uenclave/src/enclaves/rtc_auth.rs | 3 ++- rtc_uenclave/src/enclaves/rtc_exec.rs | 3 ++- rtc_uenclave/src/http_client.rs | 5 ++-- rtc_uenclave/src/quote.rs | 1 - rtc_uenclave/src/rtc_enclave.rs | 38 ++++++++++++++------------- 14 files changed, 50 insertions(+), 48 deletions(-) diff --git a/rtc_uenclave/auth-sys/build.rs b/rtc_uenclave/auth-sys/build.rs index 81e40bdd..a62a2188 100644 --- a/rtc_uenclave/auth-sys/build.rs +++ b/rtc_uenclave/auth-sys/build.rs @@ -1,7 +1,8 @@ +use std::env; +use std::path::{Path, PathBuf}; + use bindgen::{self, CodegenConfig}; use cc; -use std::path::PathBuf; -use std::{env, path::Path}; fn main() { let sdk_dir = env::var("SGX_SDK").unwrap_or_else(|_| "/opt/sgxsdk".to_string()); diff --git a/rtc_uenclave/auth-sys/src/lib.rs b/rtc_uenclave/auth-sys/src/lib.rs index 1b9ceca6..13234a1a 100644 --- a/rtc_uenclave/auth-sys/src/lib.rs +++ b/rtc_uenclave/auth-sys/src/lib.rs @@ -1,11 +1,10 @@ -#[allow(unused_imports)] -pub use sgx_urts; - use rtc_ecalls::RtcEnclaveEcalls; use rtc_types::dh::*; use rtc_types::*; use rtc_udh; use sgx_types::*; +#[allow(unused_imports)] +pub use sgx_urts; pub mod ffi { use super::*; diff --git a/rtc_uenclave/data-ocalls/src/lib.rs b/rtc_uenclave/data-ocalls/src/lib.rs index 82d30945..56d57e62 100644 --- a/rtc_uenclave/data-ocalls/src/lib.rs +++ b/rtc_uenclave/data-ocalls/src/lib.rs @@ -1,12 +1,11 @@ #![deny(unsafe_op_in_unsafe_fn)] -use std::fs; use std::fs::OpenOptions; use std::io::Write; -use std::slice; -use uuid::Uuid; +use std::{fs, slice}; use sgx_types::*; +use uuid::Uuid; /// Saves a blob of data received from the enclave /// diff --git a/rtc_uenclave/data-sys/build.rs b/rtc_uenclave/data-sys/build.rs index 8f413937..478c55e5 100644 --- a/rtc_uenclave/data-sys/build.rs +++ b/rtc_uenclave/data-sys/build.rs @@ -1,7 +1,8 @@ +use std::env; +use std::path::{Path, PathBuf}; + use bindgen::{self, CodegenConfig}; use cc; -use std::path::PathBuf; -use std::{env, path::Path}; fn main() { let sdk_dir = env::var("SGX_SDK").unwrap_or_else(|_| "/opt/sgxsdk".to_string()); diff --git a/rtc_uenclave/data-sys/src/lib.rs b/rtc_uenclave/data-sys/src/lib.rs index 76cc786d..90ca8fd6 100644 --- a/rtc_uenclave/data-sys/src/lib.rs +++ b/rtc_uenclave/data-sys/src/lib.rs @@ -5,14 +5,13 @@ #[allow(unused_imports)] use data_ocalls; -#[allow(unused_imports)] -use sgx_urts; - use rtc_ecalls::RtcEnclaveEcalls; use rtc_types::dh::*; use rtc_types::*; use rtc_udh; use sgx_types::*; +#[allow(unused_imports)] +use sgx_urts; pub mod ffi { use super::*; diff --git a/rtc_uenclave/exec-sys/build.rs b/rtc_uenclave/exec-sys/build.rs index bb6d8143..fef5aa96 100644 --- a/rtc_uenclave/exec-sys/build.rs +++ b/rtc_uenclave/exec-sys/build.rs @@ -1,7 +1,8 @@ +use std::env; +use std::path::{Path, PathBuf}; + use bindgen::{self, CodegenConfig}; use cc; -use std::path::PathBuf; -use std::{env, path::Path}; fn main() { let sdk_dir = env::var("SGX_SDK").unwrap_or_else(|_| "/opt/sgxsdk".to_string()); diff --git a/rtc_uenclave/exec-sys/src/lib.rs b/rtc_uenclave/exec-sys/src/lib.rs index 1daf0722..64e4a266 100644 --- a/rtc_uenclave/exec-sys/src/lib.rs +++ b/rtc_uenclave/exec-sys/src/lib.rs @@ -1,11 +1,10 @@ -#[allow(unused_imports)] -pub use sgx_urts; - use rtc_ecalls::RtcEnclaveEcalls; use rtc_types::dh::*; use rtc_types::*; use rtc_udh; use sgx_types::*; +#[allow(unused_imports)] +pub use sgx_urts; pub mod ffi { use super::*; diff --git a/rtc_uenclave/src/azure_attestation.rs b/rtc_uenclave/src/azure_attestation.rs index aa5030e1..b7689842 100644 --- a/rtc_uenclave/src/azure_attestation.rs +++ b/rtc_uenclave/src/azure_attestation.rs @@ -1,13 +1,14 @@ // TODO: Change some of this to use https://github.com/Azure/azure-sdk-for-rust // once the api have been stabilized -use crate::http_client::HttpClient; -use crate::http_client::HttpRequestError; +use std::time::Duration; + use base64::{self, encode_config}; use serde::{Deserialize, Serialize}; -use std::time::Duration; use ureq::AgentBuilder; +use crate::http_client::{HttpClient, HttpRequestError}; + // Types from: https://docs.microsoft.com/en-us/rest/api/attestation/attestation/attestsgxenclave#definitions #[derive(Serialize, Deserialize, Eq, PartialEq, Clone, Debug)] pub struct QuoteRuntimeData { @@ -80,10 +81,10 @@ pub(crate) struct AttestationResponse { #[cfg(test)] mod test { - use crate::http_client::MockHttpClient; use base64::decode_config; use super::*; + use crate::http_client::MockHttpClient; #[test] fn from_quote_works() { diff --git a/rtc_uenclave/src/ecalls.rs b/rtc_uenclave/src/ecalls.rs index 8090d259..7529a94f 100644 --- a/rtc_uenclave/src/ecalls.rs +++ b/rtc_uenclave/src/ecalls.rs @@ -4,7 +4,6 @@ use mockall::automock; use mockall::mock; #[cfg(test)] use mockall::predicate::*; - use rtc_ecalls::RtcEnclaveEcalls; use rtc_types::*; use sgx_types::*; @@ -68,9 +67,10 @@ impl RtcEcalls for T { #[cfg(test)] mod test { - use super::*; use rtc_ecalls::MockRtcEnclaveEcalls; + use super::*; + #[test] fn it_works() { let eid = 12u64; diff --git a/rtc_uenclave/src/enclaves/rtc_auth.rs b/rtc_uenclave/src/enclaves/rtc_auth.rs index 579a706c..a1fd4552 100644 --- a/rtc_uenclave/src/enclaves/rtc_auth.rs +++ b/rtc_uenclave/src/enclaves/rtc_auth.rs @@ -1,10 +1,11 @@ use std::borrow::Borrow; -use crate::{AttestationError, EnclaveConfig, EnclaveReportResult, RtcEnclave}; use auth_sys::AuthSys; use rtc_types::{EcallError, EncryptedMessage, ExecReqMetadata, ExecTokenError}; use sgx_types::*; +use crate::{AttestationError, EnclaveConfig, EnclaveReportResult, RtcEnclave}; + /// Wraps all the functionality for interacting with the auth enclave pub struct RtcAuthEnclave(RtcEnclave) where diff --git a/rtc_uenclave/src/enclaves/rtc_exec.rs b/rtc_uenclave/src/enclaves/rtc_exec.rs index 492f8dec..d9baead8 100644 --- a/rtc_uenclave/src/enclaves/rtc_exec.rs +++ b/rtc_uenclave/src/enclaves/rtc_exec.rs @@ -1,9 +1,10 @@ use std::borrow::Borrow; -use crate::{AttestationError, EnclaveConfig, EnclaveReportResult, RtcEnclave}; use exec_sys::ExecSys; use sgx_types::*; +use crate::{AttestationError, EnclaveConfig, EnclaveReportResult, RtcEnclave}; + /// Wraps all the functionality for interacting with the exec enclave pub struct RtcExecEnclave(RtcEnclave) where diff --git a/rtc_uenclave/src/http_client.rs b/rtc_uenclave/src/http_client.rs index 701cb30b..97d15d24 100644 --- a/rtc_uenclave/src/http_client.rs +++ b/rtc_uenclave/src/http_client.rs @@ -1,12 +1,11 @@ +#[cfg(test)] +use mockall::*; use serde::de::DeserializeOwned; use serde::Serialize; use thiserror::Error; use ureq; use ureq::Agent; -#[cfg(test)] -use mockall::*; - // 200 KB const ERR_RESPONSE_READ_LIMIT: usize = 200 * 1_024; diff --git a/rtc_uenclave/src/quote.rs b/rtc_uenclave/src/quote.rs index f4805a8f..11b96cd8 100644 --- a/rtc_uenclave/src/quote.rs +++ b/rtc_uenclave/src/quote.rs @@ -26,7 +26,6 @@ mod qe_functions { #[cfg(test)] use self::mock_qe_functions::*; - #[cfg(not(test))] use self::qe_functions::*; diff --git a/rtc_uenclave/src/rtc_enclave.rs b/rtc_uenclave/src/rtc_enclave.rs index 0f76b553..61681a41 100644 --- a/rtc_uenclave/src/rtc_enclave.rs +++ b/rtc_uenclave/src/rtc_enclave.rs @@ -1,8 +1,5 @@ use std::borrow::Borrow; -use crate::{ - azure_attestation::AttestSgxEnclaveRequest, ecalls::RtcEcalls, http_client::HttpRequestError, -}; use ecalls::EnclaveReportResult; #[cfg(test)] use mockall::predicate::*; @@ -12,22 +9,22 @@ use mockall_double::double; use rtc_udh::{self, ResponderSys}; use serde::Deserialize; use sgx_types::*; -use thiserror::Error; - -use crate::{ecalls, CreateReportError}; - -#[double] -use crate::quote::QuotingEnclave; - -#[cfg(test)] -pub use self::MockSgxEnclave as SgxEnclave; #[cfg(not(test))] pub use sgx_urts::SgxEnclave; +use thiserror::Error; #[cfg(test)] use self::MockAzureAttestationClient as AzureAttestationClient; +#[cfg(test)] +pub use self::MockSgxEnclave as SgxEnclave; +use crate::azure_attestation::AttestSgxEnclaveRequest; #[cfg(not(test))] use crate::azure_attestation::AzureAttestationClient; +use crate::ecalls::RtcEcalls; +use crate::http_client::HttpRequestError; +#[double] +use crate::quote::QuotingEnclave; +use crate::{ecalls, CreateReportError}; /// Configuration for a RtcEnclave #[derive(Default, Clone, Deserialize, Debug)] @@ -206,19 +203,24 @@ mock! { #[cfg(test)] mod tests { - use super::*; - use crate::azure_attestation::AttestationResponse; + use std::convert::TryInto; + use num_bigint; use num_traits::FromPrimitive; use proptest::collection::size_range; use proptest::prelude::*; use rtc_ecalls::MockRtcEnclaveEcalls; use rtc_types::dh::{ExchangeReportResult, SessionRequestResult}; - use rtc_types::CreateReportResult; - use rtc_types::EnclaveHeldData; - use rtc_types::{ENCLAVE_HELD_DATA_SIZE, RSA3072_PKCS8_DER_SIZE}; + use rtc_types::{ + CreateReportResult, + EnclaveHeldData, + ENCLAVE_HELD_DATA_SIZE, + RSA3072_PKCS8_DER_SIZE, + }; use simple_asn1::{to_der, ASN1Block, BigInt, BigUint, OID}; - use std::convert::TryInto; + + use super::*; + use crate::azure_attestation::AttestationResponse; mock! { TEcalls {}