将C ++结构传递给Intel SGX中的应用程序 [英] Passing C++ struct to enclave from app in Intel SGX
问题描述
我有一个像这样的C ++结构:
I have a C++ struct like this:
struct node
{
string splitOn;
string label;
bool isLeaf;
vector<string> childrenValues;
vector<node*> children;
};
我想将此内容从App传递或阅读到英特尔SGX飞地.根据此处提到的内容: https://software.intel.com/zh-CN/forums/intel-software-guard-extensions-intel-sgx/topic/703489
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
我尝试过:
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);
飞地:
int ecall_my_dtree(void *data2)
node* root2 = static_cast<node*>(data2);
但是似乎root2无法正确初始化,并且指向垃圾.
But it seems, the root2 is not able to initialize properly and it points to garbage.
关于user_check: https://software.intel.com/zh-cn/node /708978
About user_check: https://software.intel.com/en-us/node/708978
有关如何正确读取安全区内数据的任何帮助. PS:Intel SGX enclave不支持任何序列化库.
Any help regarding how I could properly read the data inside the enclave. PS: Intel SGX enclave does not support any serialization library.
我在这里也曾问过类似的问题,但对于我的小脑袋却没有真正有用的答案. https://github.com/intel/linux-sgx/issues/229
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
推荐答案
您不应这样做:
struct node
{
string splitOn;
string label;
bool isLeaf;
vector<string> childrenValues;
vector<node*> children;
};
可能的问题:
-
STL不保证大多数类型的二进制兼容性:即
std::string
或std::vector
.
SGX对STL的实现只是其修改/精简的子集.
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.
这篇关于将C ++结构传递给Intel SGX中的应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!