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

Link openenclave project with sgxsdk project #4943

Open
sjrrr13 opened this issue Mar 31, 2024 · 6 comments
Open

Link openenclave project with sgxsdk project #4943

sjrrr13 opened this issue Mar 31, 2024 · 6 comments

Comments

@sjrrr13
Copy link

sjrrr13 commented Mar 31, 2024

I'm try to link two projects, from which A is built on top of Open Enclave while B is built on top of SGX SDK. Specifically, B is executable and A is a library, and I want to call function enclave_helloworld in A from B. Unfortunately, I've encountered the following issue:

error: openenclave/edl/sgx/attestation.edl:104:46: unexpected token: expiration_check_date

make: *** [Makefile:220: App/Enclave_u.c] Error 255

Here is part of my Enclave.edl:

    from "openenclave/edl/syscall.edl" import *;
    from "openenclave/edl/sgx/platform.edl" import *;
    from "openenclave/edl/ertlibc.edl" import *;

    trusted {
        public void enclave_helloworld();
    };

And I'm working on a SGX server with Ubuntu 20.04. What can I do to link those projects successfully?

@anakrish
Copy link
Contributor

anakrish commented Apr 1, 2024

Are you using oeedger8r on your Enclave.edl or are you using sgxedger8r

@sjrrr13
Copy link
Author

sjrrr13 commented Apr 1, 2024

Hello, I'm using sgxedger8r on my Enclave.edl.

@sjrrr13
Copy link
Author

sjrrr13 commented Apr 2, 2024

Use oeedger8r on Enclave.edl, the ECALL function needs an argument oe_enclave_t* (aka _oe_enclave*). But use sgxedger8r, the ECALL function needs an argument sgx_enclave_id_t (aka long unsigned int). If I want to call an Open Enclave ECALL in a SGXSDK project, what can I do to merge the difference between function arguments?

@anakrish
Copy link
Contributor

anakrish commented Apr 2, 2024

You need to use oeedger8r for EDL files intended for use with openenclave. Since the enclave is written using OpenEnclave, on the host side, the EDL must be processed using oeedger8r.

@sjrrr13
Copy link
Author

sjrrr13 commented Apr 2, 2024

Thanks first! In fact, I have two EDL files, Enclave.edl (use sgx sdk) and helloworld.edl (use open enclave). I defined a ECALL enclave_helloworld() in helloworld.edl, and I use oeedger8r to process helloworld.edl. After that, I got a function

oe_result_t enclave_helloworld(oe_enclave_t* enclave);

Now I'm trying to call this function in the host side in my sgx sdk project. Specifically, in the host side in the sgx sdk project, named App.cpp, I import helloworld_u.h generated by oeedger8r and call enclave_helloworld.

// App.cpp in sgx sdk project
#include "helloworld_u.h"    // generated by oeedger8r

...
enclave_helloworld()    // what arg can I pass to this function?
...

However, sgx sdk does not support struct oe_enclave_t*. So I wonder is there any thing I can do to solve this problem?

@anakrish
Copy link
Contributor

anakrish commented Apr 2, 2024

On the host-side you need to link with liboehost.a. The hellworld_u.h will have the declaration for a create_helloworld_enclave function. Calling that will create and enclave and get you a oe_enclave_t.
See

result = oe_create_helloworld_enclave(

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants