Passing C++ struct to enclave from app in Intel SGX

做~自己de王妃 提交于 2019-12-09 09:10:43

问题


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 or std::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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!