style(project_template): cargo fmt
diff --git a/samplecode/project_template/app/build.rs b/samplecode/project_template/app/build.rs
index 65a322e..76c1d87 100644
--- a/samplecode/project_template/app/build.rs
+++ b/samplecode/project_template/app/build.rs
@@ -17,12 +17,9 @@
use std::env;
-fn main () {
-
- let sdk_dir = env::var("SGX_SDK")
- .unwrap_or_else(|_| "/opt/sgxsdk".to_string());
- let is_sim = env::var("SGX_MODE")
- .unwrap_or_else(|_| "HW".to_string());
+fn main() {
+ let sdk_dir = env::var("SGX_SDK").unwrap_or_else(|_| "/opt/sgxsdk".to_string());
+ let is_sim = env::var("SGX_MODE").unwrap_or_else(|_| "HW".to_string());
println!("cargo:rustc-link-search=native=../lib");
println!("cargo:rustc-link-lib=static=Enclave_u");
@@ -31,6 +28,6 @@
match is_sim.as_ref() {
"SW" => println!("cargo:rustc-link-lib=dylib=sgx_urts_sim"),
"HW" => println!("cargo:rustc-link-lib=dylib=sgx_urts"),
- _ => println!("cargo:rustc-link-lib=dylib=sgx_urts"), // Treat undefined as HW
+ _ => println!("cargo:rustc-link-lib=dylib=sgx_urts"), // Treat undefined as HW
}
}
diff --git a/samplecode/project_template/app/src/main.rs b/samplecode/project_template/app/src/main.rs
index 51de899..0d2f48a 100644
--- a/samplecode/project_template/app/src/main.rs
+++ b/samplecode/project_template/app/src/main.rs
@@ -22,37 +22,44 @@
static ENCLAVE_FILE: &'static str = "enclave.signed.so";
-extern {
- fn ecall_test(eid: sgx_enclave_id_t, retval: *mut sgx_status_t,
- some_string: *const u8, len: usize) -> sgx_status_t;
+extern "C" {
+ fn ecall_test(
+ eid: sgx_enclave_id_t,
+ retval: *mut sgx_status_t,
+ some_string: *const u8,
+ len: usize,
+ ) -> sgx_status_t;
}
fn init_enclave() -> SgxResult<SgxEnclave> {
-
let mut launch_token: sgx_launch_token_t = [0; 1024];
let mut launch_token_updated: i32 = 0;
// call sgx_create_enclave to initialize an enclave instance
// Debug Support: set 2nd parameter to 1
let debug = 1;
- let mut misc_attr = sgx_misc_attribute_t {secs_attr: sgx_attributes_t { flags:0, xfrm:0}, misc_select:0};
- SgxEnclave::create(ENCLAVE_FILE,
- debug,
- &mut launch_token,
- &mut launch_token_updated,
- &mut misc_attr)
+ let mut misc_attr = sgx_misc_attribute_t {
+ secs_attr: sgx_attributes_t { flags: 0, xfrm: 0 },
+ misc_select: 0,
+ };
+ SgxEnclave::create(
+ ENCLAVE_FILE,
+ debug,
+ &mut launch_token,
+ &mut launch_token_updated,
+ &mut misc_attr,
+ )
}
fn main() {
-
let enclave = match init_enclave() {
Ok(r) => {
println!("[+] Init Enclave Successful {}!", r.geteid());
r
- },
+ }
Err(x) => {
println!("[-] Init Enclave Failed {}!", x.as_str());
return;
- },
+ }
};
let input_string = String::from("Sending this string to the enclave then printing it\n");
@@ -60,14 +67,16 @@
let mut retval = sgx_status_t::SGX_SUCCESS;
let result = unsafe {
- ecall_test(enclave.geteid(),
- &mut retval,
- input_string.as_ptr() as * const u8,
- input_string.len())
+ ecall_test(
+ enclave.geteid(),
+ &mut retval,
+ input_string.as_ptr() as *const u8,
+ input_string.len(),
+ )
};
match result {
- sgx_status_t::SGX_SUCCESS => {},
+ sgx_status_t::SGX_SUCCESS => {}
_ => {
println!("[-] ECALL Enclave Failed {}!", result.as_str());
return;
diff --git a/samplecode/project_template/enclave/src/lib.rs b/samplecode/project_template/enclave/src/lib.rs
index 4c2c791..4b7ca33 100644
--- a/samplecode/project_template/enclave/src/lib.rs
+++ b/samplecode/project_template/enclave/src/lib.rs
@@ -17,7 +17,6 @@
#![crate_name = "sample"]
#![crate_type = "staticlib"]
-
#![cfg_attr(not(target_env = "sgx"), no_std)]
#![cfg_attr(target_env = "sgx", feature(rustc_private))]
@@ -32,7 +31,6 @@
#[no_mangle]
pub extern "C" fn ecall_test(some_string: *const u8, some_len: usize) -> sgx_status_t {
-
let str_slice = unsafe { slice::from_raw_parts(some_string, some_len) };
let _ = io::stdout().write(str_slice);