Community
cancel
Showing results for 
Search instead for 
Did you mean: 
dai_c_
Beginner
65 Views

How to use Sgxsdk to protect the function in a class?

Jump to solution

Hello,I want to protect the function in a class,for exampe

class test{
public:
	void  test_fun(char *buf,size_t len)
        {
        const char *secret="Hello Enclave!";
	if(len>=0)
	     {
		memcpy(buf,secret,strlen(secret)+1);
	    }
        }

};

I want to protect    void test_fun(char *buf,size_t len)

also when I read the document:Intel_SGX_SDK_Developer_Reference_Linux_1.8_Open_Source,I notice that it suppouted to Call C++ class methods,but I can't find good way to protect the class function,Thank you very much!

0 Kudos
1 Solution
Haitao_H_Intel
Employee
65 Views

C++ is not supported at enclave interface level, but supported inside enclave.

Enclave interfaces are defined in EDL files. The SDK tool (edger8r) generate stubs and proxies in c only.  What you can do is to separate test_fun in a c file to be included in enclave for protection. Then define an ecall in EDL interface with the same/compatible signature as test_fun, call the untrusted stub from the class.

View solution in original post

3 Replies
Haitao_H_Intel
Employee
66 Views

C++ is not supported at enclave interface level, but supported inside enclave.

Enclave interfaces are defined in EDL files. The SDK tool (edger8r) generate stubs and proxies in c only.  What you can do is to separate test_fun in a c file to be included in enclave for protection. Then define an ecall in EDL interface with the same/compatible signature as test_fun, call the untrusted stub from the class.

View solution in original post

Hoang_N_Intel
Employee
65 Views

And when you said that you want to "protect this method", do you mean that you want to call this method only inside the Enclave? and not protect the visibility of the source code? It is because your example has hard-coded secret. The complete implementation of the method will be available as part of the DLL and it is unprotected.

dai_c_
Beginner
65 Views

ok,I put the class in enclave,not in the edl file,the problem solved

Reply