我试图将两个整数传递给SGX enclave,将它们组合在一起,然后将结果返回给应用程序。但是,除了创建的enclave之外,编译代码时似乎什么也不会发生。没有给出错误,而且它似乎永远达不到ECALL函数。
如果有人知道这样做的教程,我可以作为参考,那么这将是非常感谢。
EDL:
enclave {
from "sgx_tae_service.edl" import *;
/* enum definition */
enum TEE_ERROR {
TEE_ERROR_INVALID_SIGNATURE = 0,
TEE_ERROR_INVALID_COUNTER = 1,
TEE_ERROR_INVALID_SECRET = 2
};
trusted {
/* define ECALLs here. */
public int in_enclave([in] int* a, [in] int* b);
};
untrusted {
/* define OCALLs here. */
void ocall_print_int([out] int* i);
};
};Enclave.cpp
int in_enclave(int* a, int* b){
ocall_print("In the Enclave.");
int result =0;
result = a + b;
ocall_print_int(&result);
}App.cpp
int test(void) {
if (initialize_enclave(&global_eid, "enclave.token", "enclave.signed.so") < 0) {
std::cout << "Fail to initialize enclave." << std::endl;
return 1;
}else{
std::cout<<"Enclave made. "<<"\n";
}
int a =34, b =23,point = 0;
in_enclave(global_eid,&point,&a,&b);
return 0; }发布于 2020-05-29 13:52:04
请参阅下面的更正。受信任函数in_enclave接收a和b,计算和,并返回结果。在(不受信任的)应用程序代码中,函数结果放在point中。
调用函数时,检查返回值。从主应用程序代码的角度来看,返回值为sgx_status_t类型,OK为SGX_SUCCESS。SGX引用中有一个错误代码列表,或者在源代码中查找sgx_error.h。在本例中,我们可以使用status的值来查找ecall失败的原因。
EDL
trusted {
public int in_enclave(int a, int b);
};飞地
int in_enclave(int a, int b){
return a + b;
}应用程序
int a = 34, b = 23, point = 0;
sgx_status_t status = in_enclave(global_eid, &point, a, b);
if (SGX_SUCCESS != status) {
// error occurred!
}
printf("%d\n", point);https://stackoverflow.com/questions/61648303
复制相似问题