Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Gokhale__Sushant
Beginner
186 Views

How to call other enclave function from an enclave function?

Jump to solution

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
186 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

3 Replies
Scott_R_Intel
Employee
187 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

Holodov__Dmitry
Beginner
186 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.

bashar__golam
Beginner
186 Views

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

Reply