int get_alpha()
{
std::string sealed_alpha_file = "/home/roshan/thesis/osn_server/sealed_alpha";
long fsize;
ocall_get_textsize(sealed_alpha_file.c_str(), &fsize, 0);
unsigned char sealed_data[fsize];
size_t ocall_return;
ocall_load_file(&ocall_return, sealed_alpha_file.c_str(), fsize, sealed_data, 0);
char resecret[12];
uint64_t resecret_size = sizeof(resecret);
sgx_status_t ret;
ret = sgx_unseal_data(
(sgx_sealed_data_t*)sealed_data,
NULL,
NULL,
(uint8_t*)&resecret,
(uint32_t*)&resecret_size);
if(ret != SGX_SUCCESS)
{
mbedtls_printf("Enclave: Unsealing sealed_alpha failed %#x\n", ret);
return -1;
}
mbedtls_printf("Enclave: Unsealing sealed_alpha success");
mbedtls_printf("Enclave: After unsealing alpha number: %llu\n", *(char *)resecret);
return 0;
}
我想从另一个函数调用get_alpha()函数并从resecret char数组中获取值。 我试图将get_alpha()更改为get_alpha(char * resecret)并注释char resecret [12];在get_alpha函数中也做了uint64_t resecret_size = sizeof(resecret);到uint64_t resecret_size =(12);.
从其他功能
中调用它char resecret[12];
get_alpha(resecret);
mbedtls_printf("Enclave: After unsealing alpha number: %llu\n", *(char *)resecret);
但我没有得到正确的答案。似乎sgx_unseal_data失败了。
sgx_unseal_data的签名:
sgx_status_t SGXAPI sgx_unseal_data(const sgx_sealed_data_t *p_sealed_data,
uint8_t *p_additional_MACtext,
uint32_t *p_additional_MACtext_length,
uint8_t *p_decrypted_text,
uint32_t *p_decrypted_text_length);
答案 0 :(得分:0)
标记的行似乎很奇怪:
ret = sgx_unseal_data(
(sgx_sealed_data_t*)sealed_data,
NULL,
NULL,
(uint8_t*)&resecret, // Probably shouldn't use address-of (&) here?
(uint32_t*)&resecret_size);
我相信电话应该是:
ret = sgx_unseal_data(
(sgx_sealed_data_t*)sealed_data,
NULL,
NULL,
(uint8_t*)resecret,
(uint32_t*)&resecret_size);