c++ - sgx_ecc256_create_key_pair 失败

标签 c++ visual-studio elliptic-curve sgx

我编写了一个非常简单的测试来学习如何在飞地内使用椭圆曲线密码术。但是 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/

相关文章:

visual-studio-2010 - Resharper 与 Coderush - 2010 重制版

visual-studio - .Net XML注释到API文档中

java - 无法使用椭圆曲线 (EC) 加密技术签署 JWT

python - Python中有限域上的椭圆曲线点加法

java - java中如何使用secp256r1椭圆曲线 key 对进行加解密?

c++ - 为什么我不能像 someClassObject++5 那样在后缀 operator++ 中使用虚拟参数?

具有平台 API 的 C++ 全局热键

c++ - 右循环

c++ - 用 C++ 或 C 语言打印 fibo 大数字

visual-studio - "Class emulation may be converted to class"提示在 Visual Studio 中意味着什么,它来自哪里?