我编写了一个非常简单的测试来学习如何在飞地内使用椭圆曲线密码术。但是 key 创建方法失败并显示 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;
}
结果是 error = 1 on step = 2.
知道我做错了什么或者我可能配置不正确吗?我正在使用 Visual Studio Community 2015 和英特尔 C++ 编译器 17.0。
P.S:这是 my post on an Intel forum 的拷贝.如果在每个平台上都得到了正确的回答,我会将答案发布到另一个平台上,同时引用其作者。
最佳答案
使用下面的语句代替 status = sgx_ecc256_create_key_pair(&sk, &pk, &handle);
status = sgx_ecc256_create_key_pair(&sk, &pk, handle);
关于c++ - sgx_ecc256_create_key_pair 失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42015168/