我编写了一个非常简单的测试来学习在飞地内使用椭圆曲线密码学。但密钥创建方法因 SGX_ERROR_UNEXPECTED 而失败。
这是我的飞地:
#include "Enc_t.h"
#include "sgx_trts.h"
#include "sgx_tcrypto.h"
int Test(sgx_status_t *error)
{
sgx_ecc_state_handle_t handle;
sgx_ec256_private_t sk;
sgx_ec256_public_t pk;
sgx_status_t status;
status = sgx_ecc256_open_context(&handle);
if (status)
{
*error = status;
return 1;
}
status = sgx_ecc256_create_key_pair(&sk, &pk, &handle);
if (status)
{
*error = status;
return 2;
}
*error = SGX_SUCCESS;
return 0;
}
这是我的主机应用程序:
#include "Enc_u.h"
#include "sgx_urts.h"
#include <cstdio>
#include <tchar.h>
#define ENC _T("../Debug/Enc.signed.dll")
int main()
{
sgx_status_t error;
sgx_enclave_id_t eid;
sgx_launch_token_t token;
int updated = 0;
int step;
error = sgx_create_enclave(ENC, SGX_DEBUG_FLAG, &token, &updated, &eid, nullptr);
if (error)
printf("Failed to create enclave\n");
Test(eid, &step, &error);
if (error)
printf("Failed on step %d\n", step);
return 0;
}
结果是 step = 2 上的 error = 1。
任何想法我做错了什么或我可能配置不正确?我正在使用 Visual Studio Community 2015 和 Intel C++ Compiler 17.0。
PS:这是我在英特尔论坛上的帖子的复制品。如果在每个平台上都得到了正确的回答,我会将答案发布给另一个,同时引用它的作者。