Is there a way to load an existing application into an Intel SGX
enclave directly?
Intel SGX
is designed for securing data and not loading the entire application. You can perform secure computations inside the SGX
enclaves on your data by sending temporary buffers from the user space program (app.cpp
) to your SGX
enclave (Enclave.cpp
). But why?
open
for opening a file.Thus, if your application is large or contains some syscalls or even some forbidden standard C library functions by SGX
implementation, it is impossible to import it entirely inside an enclave. But, if your application is doing some primitive operations without the need for any special syscall or function call, you can freely port it inside an enclave. Still, you can't directly load it inside an enclave you have to change your implementation to make it as a trusted enclave call inside the Enclave.cpp
.
As an example, I've implemented a set of cryptographic operations e.g. SHA-2, HMAC SHA-2, AES, and etc. inside an enclave. I send/receive temporary buffers of pliantext/ciphertext data to/from enclave performing the encryption/decryption operations inside the enclave and storing the results of computation like a hash digest, or ciphertexts in userspace. In this way, I ensure that no one can tamper the results of operations because they're running inside the enclave which is secured by CPU instructions.
You can read more about this example here and check the implementation here.