Skip to content
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

feat: Wasm append #10

Draft
wants to merge 2 commits into
base: wasm-binaries
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ SRC_WASM_MEAN_INT= get-mean-int-wasm/
SRC_WASM_MEAN_FLOAT= get-mean-float-wasm/
SRC_WASM_SD_INT= get-sd-int-wasm/
SRC_WASM_SD_FLOAT= get-sd-float-wasm/
SRC_WASM_APPEND= wasm-append/

# Compilation process, will call the appropriate makefiles.

Expand All @@ -32,6 +33,7 @@ wasm:
@make -C $(SRC_WASM_MEAN_FLOAT)
@make -C $(SRC_WASM_SD_INT)
@make -C $(SRC_WASM_SD_FLOAT)
@make -C $(SRC_WASM_APPEND)

clean:
@make -C $(SRC_U) clean
Expand All @@ -42,6 +44,7 @@ clean:
@make -C $(SRC_WASM_MEAN_FLOAT) clean
@make -C $(SRC_WASM_SD_INT) clean
@make -C $(SRC_WASM_SD_FLOAT) clean
@make -C $(SRC_WASM_APPEND) clean

fclean:
@make -C $(SRC_U) fclean
Expand Down
151 changes: 151 additions & 0 deletions app/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 24 additions & 0 deletions app/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ static WASM_FILE_MEAN_FLOAT: &str = "get_mean_float.wasm";
static WASM_FILE_SD_INT: &str = "get_sd_int.wasm";
static WASM_FILE_SD_FLOAT: &str = "get_sd_float.wasm";

static WASM_FILE_APPEND: &str = "wasm_append.wasm";

static ENCLAVE_FILE: &str = "enclave.signed.so";

extern "C" {
Expand Down Expand Up @@ -83,6 +85,14 @@ extern "C" {
result_out: *mut f32,
) -> sgx_status_t;

fn exec_wasm_append(
eid: sgx_enclave_id_t,
retval: *mut sgx_status_t,
binary: *const u8,
binary_len: usize,
result_out: *mut i32,
) -> sgx_status_t;

}

fn init_enclave() -> SgxResult<SgxEnclave> {
Expand Down Expand Up @@ -127,6 +137,8 @@ fn main() {
let binary_sd_int = fs::read(WASM_FILE_SD_INT).unwrap();
let binary_sd_float = fs::read(WASM_FILE_SD_FLOAT).unwrap();

let binary_wasm_append = fs::read(WASM_FILE_APPEND).unwrap();

let mut result_out_median_int = 0i32;
let mut result_out_median_float = 0f32;

Expand All @@ -136,6 +148,8 @@ fn main() {
let mut result_out_sd_int = 0f32;
let mut result_out_sd_float = 0f32;

let mut result_append_out = 0i32;

let result = unsafe {
exec_wasm_median_int(
enclave.geteid(),
Expand Down Expand Up @@ -183,6 +197,14 @@ fn main() {
binary_sd_float.as_ptr(),
binary_sd_float.len(),
&mut result_out_sd_float,
);

exec_wasm_append(
enclave.geteid(),
&mut retval,
binary_wasm_append.as_ptr(),
binary_wasm_append.len(),
&mut result_append_out,
)
};

Expand All @@ -202,6 +224,8 @@ fn main() {
println!();
println!("[+] ecall_test success, SD Int result - {:?}", result_out_sd_int);
println!("[+] ecall_test success, SD Float result - {:?}", result_out_sd_float);
println!();
println!("[+] ecall_test success, WASM Append successful - {:?}", result_append_out);

enclave.destroy();
}
Loading