Intel SGX将int从应用程序传递到Enclave

问题描述 投票:1回答:1

我正在尝试将两个整数传递给SGX飞地,将它们合并,然后将结果返回给应用程序。但是,除了创建安全区外,编译代码似乎什么都没有发生。没有给出错误,并且似乎永远不会到达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;                                                                                                                                                                                                                                                                             }
c++ intel sgx enclave
1个回答
0
投票

请参见下面的更正。可信函数in_enclave接收ab,计算总和,然后返回结果。在(不受信任的)应用程序代码中,功能结果位于point中。

调用函数时,请检查返回值。从主应用程序代码的角度来看,返回值是sgx_status_t类型,其中OK是SGX_SUCCESS。 SGX开发人员参考中提供了错误代码列表,或在源代码中查找sgx_error.h。在此示例中,我们可以使用sgx_error.h的值来查找调用失败的原因。

EDL

status

飞地

    trusted {
        public int in_enclave(int a, int b);
    };

应用程序

    int in_enclave(int a, int b){
        return a + b;
    }
© www.soinside.com 2019 - 2024. All rights reserved.