2017-01-07 43 views
0

我試圖執行兩個不同的應用程序創建的兩個飛地之間的本地證明。本地證明與英特爾SGX

所提供的Linux here示例代碼創建3個不同的飛地,然後建立它們之間的安全連接。但是這些飛地都是由同一個應用程序創建的,因此它知道所有的飛地ID。

如果兩個不同的應用程序創建了應該彼此通信的自己的飛地,那麼源飛地將如何知道目的地飛地的ID?該ID是否必須以「通用」方式(IPC)從一個應用程序傳輸到飛地?

我已經開始目的地飛地並打印其ID嘗試了一些簡單的測試:「26ce00000002」

然後我用本地認證例如這個ID來嘗試連接到該目的地的運行飛地:

uint64_t wrapper(const char *c) { 
    errno = 0; 
    uint64_t result = strtoull(c, NULL, 16); 

    if (errno == EINVAL) { 
     cout << "WRONG NUMBER" << endl; 
    } else if (errno == ERANGE) { 
     cout << "Too big\n"; 
    } 

    return result; 
} 

uint32_t load_enclaves() { 
    uint32_t enclave_temp_no; 
    int ret, launch_token_updated; 
    sgx_launch_token_t launch_token; 

    enclave_temp_no = 0; 

    ret = sgx_create_enclave(ENCLAVE1_PATH, SGX_DEBUG_FLAG, &launch_token, &launch_token_updated, &e1_enclave_id, NULL); 
    if (ret != SGX_SUCCESS) { 
     return ret; 
    } 
    enclave_temp_no++; 
    g_enclave_id_map.insert(std::pair<sgx_enclave_id_t, uint32_t>(e1_enclave_id, enclave_temp_no)); 

const char *test = "26ce00000002"; 
e2_enclave_id = wrapper(test); 

    enclave_temp_no++; 
    g_enclave_id_map.insert(std::pair<sgx_enclave_id_t, uint32_t>(e2_enclave_id, enclave_temp_no)); 

    return SGX_SUCCESS; 
} 

int main(int argc, char **argv) { 
    uint32_t ret_status; 
    sgx_status_t status; 


    if(load_enclaves() != SGX_SUCCESS) { 
     printf("\nLoad Enclave Failure"); 
    } 

    printf("\nAvaliable Enclaves"); 
    printf("\nEnclave1 - EnclaveID %lx",e1_enclave_id); 
    printf("\nEnclave2 - EnclaveID %lx",e2_enclave_id); 

    do { 
     //Test Create session between Enclave1(Source) and Enclave2(Destination) 
     status = Enclave1_test_create_session(e1_enclave_id, &ret_status, e1_enclave_id, e2_enclave_id); 
     if (status!=SGX_SUCCESS) 
     { 
      printf("Enclave1_test_create_session Ecall failed: Error status code is %x", status); 
      print_error_message(status); 
      break; 
     } 
     else 
     { 
      if(ret_status==0) 
      { 
       printf("\n\nSecure Channel Establishment between Source (E1) and Destination (E2) Enclaves successful !!!"); 
      } 
      else 
      { 
       printf("\nSession establishment and key exchange failure between Source (E1) and Destination (E2): Error return status is %x\n", ret_status); 
       break; 
      } 
     } 

當執行本地認證程序與源飛地時,我收到一個「SGX_ERROR_INVALID_ENCLAVE_ID」錯誤?這個錯誤不是由本地證明示例程序引發的,而是來自SGX庫中的某處,我不知道爲什麼自目的地飛地仍在運行,因此ID應該存在!?

回答

3

我們不需要安全連接來交換飛地ID。應用程序可以將飛地ID存儲在註冊表或光盤上以及可以由相應的應用程序檢索的飛地名稱以獲得所需飛地的ID。然後,應用程序通過在源域中執行一個ECALL命令,在源域和目的地域之間啓動會話,傳入目的地域的飛地ID。在收到目的地飛地的飛地ID後,源飛地將一個OCALL做成核心不可信代碼,然後ECALL進入目的地飛域以交換使用ECDH密鑰交換協議建立會話所需的消息。