Skip to content
This repository has been archived by the owner on May 9, 2022. It is now read-only.

Commit

Permalink
style(rtc_uenclave): cargo fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
PiDelport committed Jun 25, 2021
1 parent 29357d7 commit 9d18ca2
Show file tree
Hide file tree
Showing 14 changed files with 50 additions and 48 deletions.
5 changes: 3 additions & 2 deletions rtc_uenclave/auth-sys/build.rs
Original file line number Diff line number Diff line change
@@ -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());
Expand Down
5 changes: 2 additions & 3 deletions rtc_uenclave/auth-sys/src/lib.rs
Original file line number Diff line number Diff line change
@@ -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::*;
Expand Down
5 changes: 2 additions & 3 deletions rtc_uenclave/data-ocalls/src/lib.rs
Original file line number Diff line number Diff line change
@@ -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
///
Expand Down
5 changes: 3 additions & 2 deletions rtc_uenclave/data-sys/build.rs
Original file line number Diff line number Diff line change
@@ -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());
Expand Down
5 changes: 2 additions & 3 deletions rtc_uenclave/data-sys/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::*;
Expand Down
5 changes: 3 additions & 2 deletions rtc_uenclave/exec-sys/build.rs
Original file line number Diff line number Diff line change
@@ -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());
Expand Down
5 changes: 2 additions & 3 deletions rtc_uenclave/exec-sys/src/lib.rs
Original file line number Diff line number Diff line change
@@ -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::*;
Expand Down
9 changes: 5 additions & 4 deletions rtc_uenclave/src/azure_attestation.rs
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down Expand Up @@ -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() {
Expand Down
4 changes: 2 additions & 2 deletions rtc_uenclave/src/ecalls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::*;
Expand Down Expand Up @@ -68,9 +67,10 @@ impl<T: RtcEnclaveEcalls> RtcEcalls for T {

#[cfg(test)]
mod test {
use super::*;
use rtc_ecalls::MockRtcEnclaveEcalls;

use super::*;

#[test]
fn it_works() {
let eid = 12u64;
Expand Down
3 changes: 2 additions & 1 deletion rtc_uenclave/src/enclaves/rtc_auth.rs
Original file line number Diff line number Diff line change
@@ -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<TCfg>(RtcEnclave<TCfg, AuthSys>)
where
Expand Down
3 changes: 2 additions & 1 deletion rtc_uenclave/src/enclaves/rtc_exec.rs
Original file line number Diff line number Diff line change
@@ -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<TCfg>(RtcEnclave<TCfg, ExecSys>)
where
Expand Down
5 changes: 2 additions & 3 deletions rtc_uenclave/src/http_client.rs
Original file line number Diff line number Diff line change
@@ -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;

Expand Down
1 change: 0 additions & 1 deletion rtc_uenclave/src/quote.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ mod qe_functions {

#[cfg(test)]
use self::mock_qe_functions::*;

#[cfg(not(test))]
use self::qe_functions::*;

Expand Down
38 changes: 20 additions & 18 deletions rtc_uenclave/src/rtc_enclave.rs
Original file line number Diff line number Diff line change
@@ -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::*;
Expand All @@ -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)]
Expand Down Expand Up @@ -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 {}
Expand Down

0 comments on commit 9d18ca2

Please sign in to comment.