Skip to content

Upgrade to OE 0.12 #153

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Feb 12, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/scripts/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ echo "deb [arch=amd64] https://packages.microsoft.com/ubuntu/18.04/prod bionic m
wget -qO - https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key add -

sudo apt update
sudo apt -y install clang-7 libssl-dev gdb libsgx-enclave-common libsgx-enclave-common-dev libprotobuf10 libsgx-dcap-ql libsgx-dcap-ql-dev az-dcap-client open-enclave=0.9.0
sudo apt -y install clang-7 libssl-dev gdb libsgx-enclave-common libsgx-enclave-common-dev libprotobuf10 libsgx-dcap-ql libsgx-dcap-ql-dev az-dcap-client open-enclave=0.12.0

# Install Opaque Dependencies
sudo apt -y install wget build-essential openjdk-8-jdk python libssl-dev
Expand Down
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ before_install:
- sudo apt update
- sudo apt -y install clang-7 libssl-dev gdb libsgx-enclave-common libsgx-enclave-common-dev libprotobuf10 libsgx-dcap-ql libsgx-dcap-ql-dev
- sudo apt-get -y install wget build-essential openjdk-8-jdk python libssl-dev
- sudo apt-get -y install open-enclave=0.9.0
- sudo apt-get -y install open-enclave=0.12.0
- wget https://github.com/Kitware/CMake/releases/download/v3.15.6/cmake-3.15.6-Linux-x86_64.sh
- sudo bash cmake-3.15.6-Linux-x86_64.sh --skip-license --prefix=/usr/local
- export PATH=/usr/local/bin:"$PATH"
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ UDFs must be [implemented in C++](#user-defined-functions-udfs).

After downloading the Opaque codebase, build and test it as follows.

1. Install dependencies and the [OpenEnclave SDK](https://github.com/openenclave/openenclave/blob/v0.9.x/docs/GettingStartedDocs/install_oe_sdk-Ubuntu_18.04.md). We currently support OE version 0.9.0 (so please install with `open-enclave=0.9.0`) and Ubuntu 18.04.
1. Install dependencies and the [OpenEnclave SDK](https://github.com/openenclave/openenclave/blob/v0.12.0/docs/GettingStartedDocs/install_oe_sdk-Ubuntu_18.04.md). We currently support OE version 0.12.0 (so please install with `open-enclave=0.12.0`) and Ubuntu 18.04.

```sh
# For Ubuntu 18.04:
Expand Down
7 changes: 5 additions & 2 deletions src/enclave/App/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@ set(SOURCES
${CMAKE_CURRENT_BINARY_DIR}/Enclave_u.c)

add_custom_command(
COMMAND oeedger8r --untrusted ${CMAKE_SOURCE_DIR}/Enclave/Enclave.edl --search-path ${CMAKE_SOURCE_DIR}/Enclave
COMMAND oeedger8r --untrusted ${CMAKE_SOURCE_DIR}/Enclave/Enclave.edl
--search-path ${CMAKE_SOURCE_DIR}/Enclave
--search-path ${OE_INCLUDEDIR}
--search-path ${OE_INCLUDEDIR}/openenclave/edl/sgx
DEPENDS ${CMAKE_SOURCE_DIR}/Enclave/Enclave.edl
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/Enclave_u.h ${CMAKE_CURRENT_BINARY_DIR}/Enclave_u.c ${CMAKE_CURRENT_BINARY_DIR}/Enclave_args.h)

Expand All @@ -22,6 +25,6 @@ if ("$ENV{MODE}" STREQUAL "SIMULATE")
target_compile_definitions(enclave_jni PUBLIC -DSIMULATE)
endif()

target_link_libraries(enclave_jni openenclave::oehost openenclave::oehostverify)
target_link_libraries(enclave_jni openenclave::oehost)

install(TARGETS enclave_jni DESTINATION lib)
15 changes: 8 additions & 7 deletions src/enclave/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
cmake_minimum_required(VERSION 3.13)

project(OpaqueEnclave)

enable_language(ASM)

option(FLATBUFFERS_LIB_DIR "Location of Flatbuffers library headers.")
option(FLATBUFFERS_GEN_CPP_DIR "Location of Flatbuffers generated C++ files.")

find_package(OpenEnclave CONFIG REQUIRED)
set(OE_MIN_VERSION 0.12.0)
find_package(OpenEnclave ${OE_MIN_VERSION} CONFIG REQUIRED)

set(OE_CRYPTO_LIB
mbed
CACHE STRING "Crypto library used by enclaves.")

include_directories(App)
include_directories(${CMAKE_BINARY_DIR}/App)
Expand All @@ -18,7 +22,7 @@ include_directories(${CMAKE_BINARY_DIR}/Enclave)
include_directories(ServiceProvider)
include_directories(${FLATBUFFERS_LIB_DIR})
include_directories(${FLATBUFFERS_GEN_CPP_DIR})
include_directories("/opt/openenclave/include")
include_directories(${OE_INCLUDEDIR})

if(CMAKE_SIZEOF_VOID_P EQUAL 4)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -m32")
Expand All @@ -31,14 +35,11 @@ set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -O0 -g -DDEBUG -UNDEBUG -UED
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O2 -DNDEBUG -DEDEBUG -UDEBUG")
set(CMAKE_CXX_FLAGS_PROFILE "${CMAKE_CXX_FLAGS_PROFILE} -O2 -DNDEBUG -DEDEBUG -UDEBUG -DPERF")

message("openssl rsa -in $ENV{OPAQUE_HOME}/private_key.pem -pubout -out $ENV{OPAQUE_HOME}/public_key.pub")
message("$ENV{OPAQUE_HOME}/public_key.pub")

add_custom_target(run ALL
DEPENDS $ENV{OPAQUE_HOME}/public_key.pub)

add_custom_command(
COMMAND openssl rsa -in $ENV{OPAQUE_HOME}/private_key.pem -pubout -out $ENV{OPAQUE_HOME}/public_key.pub
COMMAND openssl rsa -in $ENV{PRIVATE_KEY_PATH} -pubout -out $ENV{OPAQUE_HOME}/public_key.pub
OUTPUT $ENV{OPAQUE_HOME}/public_key.pub)

add_subdirectory(App)
Expand Down
22 changes: 12 additions & 10 deletions src/enclave/Enclave/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@ set(SOURCES
${CMAKE_CURRENT_BINARY_DIR}/Enclave_t.c)

add_custom_command(
COMMAND oeedger8r --trusted ${CMAKE_SOURCE_DIR}/Enclave/Enclave.edl --search-path ${CMAKE_SOURCE_DIR}/Enclave
COMMAND oeedger8r --trusted ${CMAKE_SOURCE_DIR}/Enclave/Enclave.edl
--search-path ${CMAKE_SOURCE_DIR}/Enclave
--search-path ${OE_INCLUDEDIR}
--search-path ${OE_INCLUDEDIR}/openenclave/edl/sgx
DEPENDS ${CMAKE_SOURCE_DIR}/Enclave/Enclave.edl
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/Enclave_t.h ${CMAKE_CURRENT_BINARY_DIR}/Enclave_t.c ${CMAKE_CURRENT_BINARY_DIR}/Enclave_args.h)

Expand All @@ -41,22 +44,21 @@ endif()
target_compile_definitions(enclave_trusted PUBLIC OE_API_VERSION=2)

# Need for the generated file Enclave_t.h
target_include_directories(enclave_trusted PRIVATE ${CMAKE_CURRENT_BINARY_DIR})
target_include_directories(enclave_trusted PRIVATE ${CMAKE_CURRENT_BINARY_DIR} ${OE_INCLUDEDIR}/openenclave/3rdparty)

target_link_libraries(enclave_trusted
openenclave::oeenclave
openenclave::oelibc
link_directories(${OE_LIBDIR} ${OE_LIBDIR}/openenclave/enclave)
target_link_libraries(enclave_trusted
openenclave::oeenclave
openenclave::oecrypto${OE_CRYPTO_LIB}
openenclave::oelibc
openenclave::oelibcxx
openenclave::oehostsock
openenclave::oehostresolver)
openenclave::oecore)

add_custom_command(
COMMAND oesign sign -e $<TARGET_FILE:enclave_trusted> -c ${CMAKE_CURRENT_SOURCE_DIR}/Enclave.conf -k $ENV{PRIVATE_KEY_PATH}
COMMAND openenclave::oesign sign -e $<TARGET_FILE:enclave_trusted> -c ${CMAKE_CURRENT_SOURCE_DIR}/Enclave.conf -k $ENV{PRIVATE_KEY_PATH}
DEPENDS enclave_trusted ${CMAKE_CURRENT_SOURCE_DIR}/Enclave.conf
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/enclave_trusted.signed)

# TODO: Use the user-generated private key to sign the enclave code.
# Currently we use the sample private key from the Intel SGX SDK.
add_custom_command(
COMMAND mv ${CMAKE_CURRENT_BINARY_DIR}/libenclave_trusted.so.signed ${CMAKE_CURRENT_BINARY_DIR}/libenclave_trusted_signed.so
DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/enclave_trusted.signed
Expand Down
3 changes: 3 additions & 0 deletions src/enclave/Enclave/Enclave.edl
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@

enclave {

from "openenclave/edl/syscall.edl" import *;
from "platform.edl" import *;

include "stdbool.h"

trusted {
Expand Down
9 changes: 5 additions & 4 deletions src/enclave/ServiceProvider/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@ set(SOURCES
iasrequest.cpp
sp_crypto.cpp)

link_directories("$ENV{OE_SDK_PATH}/lib/openenclave/enclave")
include_directories("$ENV{OE_SDK_PATH}/include")
include_directories("$ENV{OE_SDK_PATH}/include/openenclave/3rdparty")
link_directories(${OE_LIBDIR})
link_directories(${OE_LIBDIR}/openenclave/enclave)
include_directories(${OE_INCLUDEDIR})
include_directories(${OE_INCLUDEDIR}/openenclave/3rdparty)

set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC -Wno-attributes")
set(CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS} ${CMAKE_CXX_FLAGS}")
Expand All @@ -27,6 +28,6 @@ endif()

find_library(CRYPTO_LIB crypto)
find_library(SSL_LIB ssl)
target_link_libraries(ra_jni "${CRYPTO_LIB}" "${SSL_LIB}" mbedcrypto mbedtls openenclave::oehost openenclave::oehostverify)
target_link_libraries(ra_jni ${CRYPTO_LIB} ${SSL_LIB} mbedcrypto mbedtls openenclave::oehost)

install(TARGETS ra_jni DESTINATION lib)
2 changes: 1 addition & 1 deletion src/enclave/ServiceProvider/sp_crypto.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@

#include <stdint.h>
#include <cstring>
#include <sys/errno.h>
#include <errno.h>

#include "openssl/evp.h"
#include "openssl/pem.h"
Expand Down