forked from openenclave/openenclave
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
2888: add enclave loading testing in simulation mode r=mingweishih a=jinghe-INTC Co-authored-by: Jing He <[email protected]>
- Loading branch information
Showing
10 changed files
with
138 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# Copyright (c) Open Enclave SDK contributors. | ||
# Licensed under the MIT License. | ||
|
||
add_subdirectory(host) | ||
if (BUILD_ENCLAVES) | ||
add_subdirectory(enc) | ||
endif() | ||
|
||
add_enclave_test(tests/sim-signed sim_host enc_signed) | ||
add_enclave_test(tests/sim-unsigned sim_host enc_unsigned) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
This directory tests loading enclave with simulation mode, with: | ||
1. A signed enclave image | ||
2. A unsigned enclave image |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# Copyright (c) Open Enclave SDK contributors. | ||
# Licensed under the MIT License. | ||
|
||
set (EDL_FILE ../sim_mode.edl) | ||
|
||
add_custom_command( | ||
OUTPUT sim_mode_t.h sim_mode_t.c | ||
DEPENDS ${EDL_FILE} edger8r | ||
COMMAND edger8r --trusted ${EDL_FILE} --search-path ${CMAKE_CURRENT_SOURCE_DIR}) | ||
|
||
add_enclave(TARGET enc_unsigned UUID 6771bad2-805a-11ea-bc55-0242ac130003 SOURCES enc.c props.c ${CMAKE_CURRENT_BINARY_DIR}/sim_mode_t.c) | ||
|
||
add_enclave(TARGET enc UUID 82fc6d38-805a-11ea-bc55-0242ac130003 CONFIG sign.conf SOURCES enc.c props.c ${CMAKE_CURRENT_BINARY_DIR}/sim_mode_t.c) | ||
|
||
enclave_include_directories(enc_unsigned PRIVATE | ||
${CMAKE_CURRENT_BINARY_DIR} | ||
${CMAKE_CURRENT_SOURCE_DIR}) | ||
enclave_link_libraries(enc_unsigned oelibc) | ||
|
||
enclave_include_directories(enc PRIVATE | ||
${CMAKE_CURRENT_BINARY_DIR} | ||
${CMAKE_CURRENT_SOURCE_DIR}) | ||
enclave_link_libraries(enc oelibc) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
// Copyright (c) Open Enclave SDK contributors. | ||
// Licensed under the MIT License. | ||
|
||
#include <openenclave/edger8r/enclave.h> | ||
#include <openenclave/enclave.h> | ||
#include "sim_mode_t.h" | ||
|
||
int test(void) | ||
{ | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
// Copyright (c) Open Enclave SDK contributors. | ||
// Licensed under the MIT License. | ||
|
||
#include <openenclave/enclave.h> | ||
|
||
OE_SET_ENCLAVE_SGX( | ||
1234, /* ProductID */ | ||
5678, /* SecurityVersion */ | ||
false, /* AllowDebug */ | ||
1024, /* HeapPageCount */ | ||
512, /* StackPageCount */ | ||
4); /* TCSCount */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# Copyright (c) Open Enclave SDK contributors. | ||
# Licensed under the MIT License. | ||
|
||
# Enclave settings: | ||
Debug=0 | ||
NumHeapPages=1024 | ||
NumStackPages=1024 | ||
NumTCS=2 | ||
ProductID=1 | ||
SecurityVersion=1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# Copyright (c) Open Enclave SDK contributors. | ||
# Licensed under the MIT License. | ||
|
||
set (EDL_FILE ../sim_mode.edl) | ||
|
||
add_custom_command( | ||
OUTPUT sim_mode_u.h sim_mode_u.c | ||
DEPENDS ${EDL_FILE} edger8r | ||
COMMAND edger8r --untrusted ${EDL_FILE} --search-path ${CMAKE_CURRENT_SOURCE_DIR}) | ||
|
||
add_executable(sim_host host.c sim_mode_u.c) | ||
|
||
target_include_directories(sim_host PRIVATE ${CMAKE_CURRENT_BINARY_DIR}) | ||
|
||
target_link_libraries(sim_host oehostapp) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
// Copyright (c) Open Enclave SDK contributors. | ||
// Licensed under the MIT License. | ||
|
||
#include <openenclave/host.h> | ||
#include <openenclave/internal/calls.h> | ||
#include <openenclave/internal/error.h> | ||
#include <openenclave/internal/tests.h> | ||
#include <stdio.h> | ||
#include <stdlib.h> | ||
#include <string.h> | ||
#include "sim_mode_u.h" | ||
|
||
static void _launch_enclave_success(const char* path, const uint32_t flags) | ||
{ | ||
oe_result_t result; | ||
oe_enclave_t* enclave = NULL; | ||
|
||
result = oe_create_sim_mode_enclave( | ||
path, OE_ENCLAVE_TYPE_SGX, flags, NULL, 0, &enclave); | ||
|
||
if (result != OE_OK) | ||
oe_put_err("oe_create_sim_mode_enclave(): result=%u", result); | ||
|
||
int ret; | ||
if ((result = test(enclave, &ret)) != OE_OK) | ||
oe_put_err("test: result=%u", result); | ||
|
||
if ((result = oe_terminate_enclave(enclave)) != OE_OK) | ||
oe_put_err("oe_terminate_enclave(): result=%u", result); | ||
} | ||
|
||
int main(int argc, const char* argv[]) | ||
{ | ||
if (argc != 2) | ||
{ | ||
fprintf(stderr, "Usage: %s ENCLAVE\n", argv[0]); | ||
exit(1); | ||
} | ||
|
||
const uint32_t flags = OE_ENCLAVE_FLAG_SIMULATE; | ||
|
||
_launch_enclave_success(argv[1], flags); | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
// Copyright (c) Open Enclave SDK contributors. | ||
// Licensed under the MIT License. | ||
|
||
enclave { | ||
trusted { | ||
public int test(); | ||
}; | ||
}; |