问题
I have a C++ struct like this:
struct node
{
string splitOn;
string label;
bool isLeaf;
vector<string> childrenValues;
vector<node*> children;
};
I wanted to pass or read this from App to the Intel SGX enclave. Based on what is mentioned here: https://software.intel.com/en-us/forums/intel-software-guard-extensions-intel-sgx/topic/703489
I tried this:
APP:
node *root = new node;
root = buildDecisionTree(dataTable, root, *tableInfo); //this initializes the root
void *data3 = static_cast<void*>(root);
ecall_my_dtree(global_eid, &ecall_return, data3);
EDL:
public int ecall_my_dtree([user_check] void* data);
Enclave:
int ecall_my_dtree(void *data2)
node* root2 = static_cast<node*>(data2);
But it seems, the root2 is not able to initialize properly and it points to garbage.
About user_check: https://software.intel.com/en-us/node/708978
Any help regarding how I could properly read the data inside the enclave. PS: Intel SGX enclave does not support any serialization library.
I have asked the similar question here too but no real helpful answer for my small brain. https://github.com/intel/linux-sgx/issues/229
回答1:
You shouldn't do this:
struct node
{
string splitOn;
string label;
bool isLeaf;
vector<string> childrenValues;
vector<node*> children;
};
Possible problems:
The STL does not guarantee binary compatibility on most of its types: i.e.
std::string
orstd::vector
.SGX's implementation of the STL is just a modified/reduced subset of it.
You may face problems related to memory alignment.
You should implement custom serialization for this instead.
来源:https://stackoverflow.com/questions/49327022/passing-c-struct-to-enclave-from-app-in-intel-sgx