Closed victorzz0 closed 3 years ago
Your understanding is correct. You must put the trusted part and the untrusted part in two different crates. xxx_t.c and xxx_u.c generated by edger8r are linked with trusted and untrusted library.
Thanks! I tried this out the other day by compiling the untrusted crate as a static lib and compiling the trusted crate as a dynamic lib. It worked but I forgot to resolve this issue...
Hi everyone,
Context
I'm trying to port Timely Dataflow to work in SGX using this SDK as part of my dissertation. An experimental (and perhaps stupid) idea I have is too run some of the dataflow operations and store their associated data in untrusted environment. Therefore, I am trying to develop a library where the majority runs in SGX with
sgx_tstd as std
but will use some ocalls to do some things outside SGX (Eg. using remote attestation to set up an encrypted communication channel with a remote worker process), where these ocalls potentially use the untrustedstd
and perhaps things that ultimately depend on untrustedstd
.Question
I have tried out the examples in this repo, looked at their make files, but I'm still not sure what's the best way to structure a reusable Rust library that contains ocalls and want to use both
std
andsgx_tstd
. In addition, I'm also confused to how the compilation should go for such a library and someone who uses such a library. Tho I'm quite sure that I can reused the structure (and the make files) in the examples if I were to simply make an application.Example
A more concrete example would be as the following:
I have a crate called timely with the following structure:
lib.rs
enclave_timely.rs
untrusted_timely.rs
timely.edl
Then I would have someone who uses this like
This example obviously does not work because enclave_timely wants
[no_std]
but untrusted_timely wants astd
environment and the compiler complains about duplicated definitions. From my understanding, to make this work, I have to put the trusted part in one crate, and to put the untrusted part in another crate. Then the untrusted crate will be compiled as a library and linked with theenclave_u
files generated by edger8r and the trusted crate will be compiled as a library and linked with theenclave_t
files. I'm not sure if this is correct and if this is the best way to do this.I'm new to SGX and Rust (and a compiler noob) so I might be missing some obvious things here. I would also really appreciate if someone could point me to additional resources for self-help.