Intel® Software Guard Extensions (Intel® SGX)
Discussion board focused on hardware-based isolation and memory encryption to provide extended code protection in solutions.
1448 Discussions

How to call other enclave function from an enclave function?

Gokhale__Sushant
Beginner
735 Views

Lets say I have following  functions belonging to the same enclave:

int foo(){}

int display() {}

I want to make ecall to display() from my application and from display(), call the foo() function(Note that foo() is an enclave function).How can that be done?

Please explain the following things:

1. What should be the interface of foo() in EDL file?

2. What should be the definition of foo() in enclave.cpp file?

3. How to call the foo() from display() ? Expecting the exact format.

 

0 Kudos
1 Solution
Scott_R_Intel
Employee
735 Views

Hello.

For your example:

1. In EDL, you simply need the following in the "trusted" section to allow your app to call into the enclave:

     public int display();

2. and 3. The definitions of display() and foo() in the enclave.cpp file are just like normal c/c++ function definitions.  The below code shows display() calling foo():

    int foo()
    {
        return 1;
    }

    int display()
    {
        return foo();
    }

 

Regards.

Scott

 

View solution in original post

0 Kudos
3 Replies
Scott_R_Intel
Employee
736 Views

Hello.

For your example:

1. In EDL, you simply need the following in the "trusted" section to allow your app to call into the enclave:

     public int display();

2. and 3. The definitions of display() and foo() in the enclave.cpp file are just like normal c/c++ function definitions.  The below code shows display() calling foo():

    int foo()
    {
        return 1;
    }

    int display()
    {
        return foo();
    }

 

Regards.

Scott

 

0 Kudos
Holodov__Dmitry
Beginner
735 Views

Answers:

(1) Only ecalls and ocalls (calls that cross the enclave boundary) need to be in the edl file.  If function foo() is only used inside the enclave, it does not need to be in the edl

(2+3) Define foo() however you like.  You'll call invoke it exactly as you would invoke any function in a program not using the Intel SGX SDK.  Since invocation is not crossing the enclave boundary, it's signature will not be modified.  No eid needs to be added to the invocation and no sgx_status_t value will be returned by default.

0 Kudos
bashar__golam
Beginner
735 Views

How to call an encalve from another enclave in same application?

0 Kudos
Reply