Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
81 commits
Select commit Hold shift + click to select a range
f17d8a8
Support for multiple branched CaseWhen
Oct 2, 2020
366e92c
Interval (#116)
eric-feng-2011 Nov 22, 2020
c7fcd98
Remove partition ID argument from enclaves
chester-leung Nov 23, 2020
93dbf5e
Fix comments
chester-leung Nov 24, 2020
f357ab2
updates
chester-leung Nov 24, 2020
bb4018a
Merge serialization of ecall string as int
chester-leung Nov 30, 2020
56ace17
Modifications to integrate crumb, log-mac, and all-outputs_mac, wip
chester-leung Dec 2, 2020
21bbbfb
Store log mac after each output buffer, add all-outputs-mac to each e…
chester-leung Dec 4, 2020
549566f
Add all_outputs_mac to all EncryptedBlocks once all log_macs have bee…
chester-leung Dec 7, 2020
55ee664
Almost builds
chester-leung Dec 9, 2020
057caec
cpp builds
chester-leung Dec 10, 2020
db54c44
Use ubyte for all_outputs_mac
chester-leung Dec 10, 2020
e77f1eb
use Mac for all_outputs_mac
chester-leung Dec 10, 2020
736b8f6
Hopefully this works for flatbuffers all_outputs_mac mutation, cpp bu…
chester-leung Dec 10, 2020
cbb2373
merge
Dec 10, 2020
0351b5d
Merge branch 'comp-integrity' of https://github.com/mc2-project/opaqu…
Dec 10, 2020
3002bd3
Scala builds now too, running into error with union
chester-leung Dec 11, 2020
dc54741
Stuff builds, error with all outputs mac serialization. this commit u…
chester-leung Dec 11, 2020
5be9b7c
Fixed bug, basic encryption / show works
chester-leung Dec 12, 2020
86fab02
All single partition tests pass, multiple partiton passes until tpch-9
chester-leung Dec 12, 2020
8b1a1d1
All tests pass except tpch-9 and skew join
chester-leung Dec 12, 2020
18f45d6
comment tpch back in
chester-leung Dec 12, 2020
123fa1f
Merge branch 'crumb-path' of http://github.com/chester-leung/opaque i…
Dec 13, 2020
bfc06ba
Check same number of ecalls per partition - exception for scanCollect…
Dec 14, 2020
c818a41
First attempt at constructing executed DAG
Dec 14, 2020
39a4945
Fix typos
Dec 14, 2020
c970965
Rework graph
Dec 14, 2020
43ccd2e
Add log macs to graph nodes
Dec 15, 2020
69fc49e
Construct expected DAG and refactor JobNode.
Dec 16, 2020
35691ff
Implement 'paths to sink' for a DAG
Dec 17, 2020
98d5fc4
add crumb for last ecall
Dec 18, 2020
29e3312
Fix NULL handling for aggregation (#130)
wzheng Dec 18, 2020
51b621b
Changing operator matching from logical to physical (#129)
wzheng Dec 21, 2020
e9fe7bb
Aggregation rewrite (#132)
wzheng Jan 21, 2021
1ee8d5b
Merge new aggregate
Jan 25, 2021
4a97c66
updated build/sbt file (#135)
octaviansima Jan 26, 2021
2400a94
Travis update (#137)
wzheng Jan 29, 2021
6031a4a
update breeze (#138)
octaviansima Jan 29, 2021
0a20d71
TPC-H test suite added (#136)
octaviansima Jan 29, 2021
2fec4ad
Separate IN PR (#124)
Chenyu-Shi Jan 30, 2021
7cb2f9a
Merge new aggregate
Feb 1, 2021
c3b3f33
Uncomment log_mac_lst clear
Feb 1, 2021
f41ba90
Clean up comments
Feb 2, 2021
b78b4a4
Separate Concat PR (#125)
Chenyu-Shi Feb 2, 2021
2bb2e8d
Clean up comments in other files
Feb 4, 2021
2685530
Update pathsEqual to be less conservative
Feb 4, 2021
7efb677
Remove print statements from unit tests
Feb 4, 2021
0519def
Removed calls to toSet in TPC-H tests (#140)
octaviansima Feb 5, 2021
0d69b7b
Documentation update (#148)
wzheng Feb 5, 2021
0f877d4
Cluster Remote Attestation Fix (#146)
octaviansima Feb 8, 2021
c215a99
upgrade to 3.0.1 (#144)
octaviansima Feb 8, 2021
8bd1e09
Update two TPC-H queries (#149)
wzheng Feb 8, 2021
823d95d
TPC-H 20 Fix (#142)
octaviansima Feb 8, 2021
fbe324c
Add expected operator DAG generation from executedPlan string
Feb 8, 2021
f822784
Rebase
Feb 8, 2021
40e8e13
Merge comp-integrity
Feb 9, 2021
6e60c7c
Merge master
Feb 9, 2021
1321eaa
Merge branch 'expected-dag' of https://github.com/andrewlawhh/opaque …
Feb 9, 2021
b4ba2db
Join update (#145)
wzheng Feb 9, 2021
375de7f
Merge join update
Feb 9, 2021
8682f22
Integrate new join
Feb 9, 2021
c21cb7b
Add expected operator for sortexec
Feb 10, 2021
c1adf85
Merge comp-integrity with join update
Feb 10, 2021
9391435
Merge comp-integrity with join update
Feb 10, 2021
2b37dab
Merge join integration with expected dag update
Feb 10, 2021
8a93c6c
Remove some print statements
Feb 10, 2021
c190aae
Migrate from Travis CI to Github Actions (#156)
octaviansima Feb 10, 2021
41ea7b9
Upgrade to OE 0.12 (#153)
wzheng Feb 12, 2021
29da474
Update README.md
wzheng Feb 13, 2021
4d89ecb
Support for scalar subquery (#157)
wzheng Feb 18, 2021
96e6285
Add TPC-H Benchmarks (#139)
octaviansima Feb 19, 2021
b350992
Construct expected DAG from dataframe physical plan
Feb 23, 2021
20f4749
Refactor collect and add integrity checking helper function to Opaque…
Feb 23, 2021
3c28b5f
Float expressions (#160)
wzheng Feb 23, 2021
a4a6ff9
Broadcast Nested Loop Join - Left Anti and Left Semi (#159)
octaviansima Feb 24, 2021
e9b075b
Remove addExpectedOperator from JobVerificationEngine, add comments
Mar 4, 2021
dabc178
Implement expected DAG construction by doing graph manipulation on da…
Mar 4, 2021
38c9da5
Merge
Mar 15, 2021
98bcfdb
Fix merge errors in the test cases
Mar 15, 2021
592ec17
Fix merge errors
Mar 15, 2021
e3e140d
Merge BNLJ into integrity branch
Apr 2, 2021
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
25 changes: 25 additions & 0 deletions .github/scripts/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Install OpenEnclave 0.9.0
echo 'deb [arch=amd64] https://download.01.org/intel-sgx/sgx_repo/ubuntu bionic main' | sudo tee /etc/apt/sources.list.d/intel-sgx.list
wget -qO - https://download.01.org/intel-sgx/sgx_repo/ubuntu/intel-sgx-deb.key | sudo apt-key add -
echo "deb http://apt.llvm.org/bionic/ llvm-toolchain-bionic-7 main" | sudo tee /etc/apt/sources.list.d/llvm-toolchain-bionic-7.list
wget -qO - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add -
echo "deb [arch=amd64] https://packages.microsoft.com/ubuntu/18.04/prod bionic main" | sudo tee /etc/apt/sources.list.d/msprod.list
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.12.0

# Install Opaque Dependencies
sudo apt -y install wget build-essential openjdk-8-jdk python libssl-dev

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

# Generate keypair for attestation
openssl genrsa -out ./private_key.pem -3 3072

source opaqueenv
source /opt/openenclave/share/openenclave/openenclaverc
export MODE=SIMULATE

build/sbt test
40 changes: 40 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: CI

# Controls when the action will run.
on:
# Triggers the workflow on push or pull request events but only for the master branch
push:
branches: [ master ]
pull_request:
branches: [ master ]

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
build:
# Define the OS to run on
runs-on: ubuntu-18.04
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v2
# Specify the version of Java that is installed
- uses: actions/setup-java@v1
with:
java-version: '8'
# Caching (from https://www.scala-sbt.org/1.x/docs/GitHub-Actions-with-sbt.html)
- uses: coursier/cache-action@v5
# Run the test
- name: Install dependencies, set environment variables, and run sbt tests
run: |
./.github/scripts/build.sh

rm -rf "$HOME/.ivy2/local" || true
find $HOME/Library/Caches/Coursier/v1 -name "ivydata-*.properties" -delete || true
find $HOME/.ivy2/cache -name "ivydata-*.properties" -delete || true
find $HOME/.cache/coursier/v1 -name "ivydata-*.properties" -delete || true
find $HOME/.sbt -name "*.lock" -delete || true
shell: bash

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
6 changes: 1 addition & 5 deletions 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 Expand Up @@ -206,7 +206,3 @@ Now we can port this UDF to Opaque as follows:
```

3. Finally, implement the UDF in C++. In [`FlatbuffersExpressionEvaluator#eval_helper`](src/enclave/Enclave/ExpressionEvaluation.h), add a case for `tuix::ExprUnion_DotProduct`. Within that case, cast the expression to a `tuix::DotProduct`, recursively evaluate the left and right children, perform the dot product computation on them, and construct a `DoubleField` containing the result.

## Contact

If you want to know more about our project or have questions, please contact Wenting ([email protected]) and/or Ankur ([email protected]).
44 changes: 44 additions & 0 deletions src/enclave/App/App.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -555,6 +555,50 @@ Java_edu_berkeley_cs_rise_opaque_execution_SGXEnclave_NonObliviousSortMergeJoin(
return ret;
}

JNIEXPORT jbyteArray JNICALL
Java_edu_berkeley_cs_rise_opaque_execution_SGXEnclave_BroadcastNestedLoopJoin(
JNIEnv *env, jobject obj, jlong eid, jbyteArray join_expr, jbyteArray outer_rows, jbyteArray inner_rows) {
(void)obj;

jboolean if_copy;

uint32_t join_expr_length = (uint32_t) env->GetArrayLength(join_expr);
uint8_t *join_expr_ptr = (uint8_t *) env->GetByteArrayElements(join_expr, &if_copy);

uint32_t outer_rows_length = (uint32_t) env->GetArrayLength(outer_rows);
uint8_t *outer_rows_ptr = (uint8_t *) env->GetByteArrayElements(outer_rows, &if_copy);

uint32_t inner_rows_length = (uint32_t) env->GetArrayLength(inner_rows);
uint8_t *inner_rows_ptr = (uint8_t *) env->GetByteArrayElements(inner_rows, &if_copy);

uint8_t *output_rows = nullptr;
size_t output_rows_length = 0;

if (outer_rows_ptr == nullptr) {
ocall_throw("BroadcastNestedLoopJoin: JNI failed to get inner byte array.");
} else if (inner_rows_ptr == nullptr) {
ocall_throw("BroadcastNestedLoopJoin: JNI failed to get outer byte array.");
} else {
oe_check_and_time("Broadcast Nested Loop Join",
ecall_broadcast_nested_loop_join(
(oe_enclave_t*)eid,
join_expr_ptr, join_expr_length,
outer_rows_ptr, outer_rows_length,
inner_rows_ptr, inner_rows_length,
&output_rows, &output_rows_length));
}

jbyteArray ret = env->NewByteArray(output_rows_length);
env->SetByteArrayRegion(ret, 0, output_rows_length, (jbyte *) output_rows);
free(output_rows);

env->ReleaseByteArrayElements(join_expr, (jbyte *) join_expr_ptr, 0);
env->ReleaseByteArrayElements(outer_rows, (jbyte *) outer_rows_ptr, 0);
env->ReleaseByteArrayElements(inner_rows, (jbyte *) inner_rows_ptr, 0);

return ret;
}

JNIEXPORT jobject JNICALL
Java_edu_berkeley_cs_rise_opaque_execution_SGXEnclave_NonObliviousAggregate(
JNIEnv *env, jobject obj, jlong eid, jbyteArray agg_op, jbyteArray input_rows, jboolean isPartial) {
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)
4 changes: 4 additions & 0 deletions src/enclave/App/SGXEnclave.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ extern "C" {
Java_edu_berkeley_cs_rise_opaque_execution_SGXEnclave_NonObliviousSortMergeJoin(
JNIEnv *, jobject, jlong, jbyteArray, jbyteArray);

JNIEXPORT jbyteArray JNICALL
Java_edu_berkeley_cs_rise_opaque_execution_SGXEnclave_BroadcastNestedLoopJoin(
JNIEnv *, jobject, jlong, jbyteArray, jbyteArray, jbyteArray);

JNIEXPORT jobject JNICALL
Java_edu_berkeley_cs_rise_opaque_execution_SGXEnclave_NonObliviousAggregate(
JNIEnv *, jobject, jlong, jbyteArray, jbyteArray, jboolean);
Expand Down
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
54 changes: 54 additions & 0 deletions src/enclave/Enclave/BroadcastNestedLoopJoin.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#include "BroadcastNestedLoopJoin.h"

#include "ExpressionEvaluation.h"
#include "FlatbuffersReaders.h"
#include "FlatbuffersWriters.h"
#include "common.h"

/** C++ implementation of a broadcast nested loop join.
* Assumes outer_rows is streamed and inner_rows is broadcast.
* DOES NOT rely on rows to be tagged primary or secondary, and that
* assumption will break the implementation.
*/
void broadcast_nested_loop_join(
uint8_t *join_expr, size_t join_expr_length,
uint8_t *outer_rows, size_t outer_rows_length,
uint8_t *inner_rows, size_t inner_rows_length,
uint8_t **output_rows, size_t *output_rows_length) {

FlatbuffersJoinExprEvaluator join_expr_eval(join_expr, join_expr_length);
const tuix::JoinType join_type = join_expr_eval.get_join_type();

RowReader outer_r(BufferRefView<tuix::EncryptedBlocks>(outer_rows, outer_rows_length));
RowWriter w;

while (outer_r.has_next()) {
const tuix::Row *outer = outer_r.next();
bool o_i_match = false;

RowReader inner_r(BufferRefView<tuix::EncryptedBlocks>(inner_rows, inner_rows_length));
const tuix::Row *inner;
while (inner_r.has_next()) {
inner = inner_r.next();
o_i_match |= join_expr_eval.eval_condition(outer, inner);
}

switch(join_type) {
case tuix::JoinType_LeftAnti:
if (!o_i_match) {
w.append(outer);
}
break;
case tuix::JoinType_LeftSemi:
if (o_i_match) {
w.append(outer);
}
break;
default:
throw std::runtime_error(
std::string("Join type not supported: ")
+ std::string(to_string(join_type)));
}
}
w.output_buffer(output_rows, output_rows_length, std::string("broadcastNestedLoopJoin"));
}
8 changes: 8 additions & 0 deletions src/enclave/Enclave/BroadcastNestedLoopJoin.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#include <cstddef>
#include <cstdint>

void broadcast_nested_loop_join(
uint8_t *join_expr, size_t join_expr_length,
uint8_t *outer_rows, size_t outer_rows_length,
uint8_t *inner_rows, size_t inner_rows_length,
uint8_t **output_rows, size_t *output_rows_length);
25 changes: 14 additions & 11 deletions src/enclave/Enclave/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ set(SOURCES
FlatbuffersReaders.cpp
FlatbuffersWriters.cpp
IntegrityUtils.cpp
Join.cpp
NonObliviousSortMergeJoin.cpp
BroadcastNestedLoopJoin.cpp
Limit.cpp
Project.cpp
Sort.cpp
Expand All @@ -23,7 +24,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 @@ -42,22 +46,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
26 changes: 24 additions & 2 deletions src/enclave/Enclave/Enclave.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
#include "Aggregate.h"
#include "Crypto.h"
#include "Filter.h"
#include "Join.h"
#include "NonObliviousSortMergeJoin.h"
#include "BroadcastNestedLoopJoin.h"
#include "Limit.h"
#include "Project.h"
#include "Sort.h"
Expand Down Expand Up @@ -196,7 +197,6 @@ void ecall_non_oblivious_sort_merge_join(uint8_t *join_expr, size_t join_expr_le
__builtin_ia32_lfence();

try {
debug("Ecall: NonObliviousSortMergJoin\n");
non_oblivious_sort_merge_join(join_expr, join_expr_length,
input_rows, input_rows_length,
output_rows, output_rows_length);
Expand All @@ -208,6 +208,28 @@ void ecall_non_oblivious_sort_merge_join(uint8_t *join_expr, size_t join_expr_le
}
}

void ecall_broadcast_nested_loop_join(uint8_t *join_expr, size_t join_expr_length,
uint8_t *outer_rows, size_t outer_rows_length,
uint8_t *inner_rows, size_t inner_rows_length,
uint8_t **output_rows, size_t *output_rows_length) {
// Guard against operating on arbitrary enclave memory
assert(oe_is_outside_enclave(outer_rows, outer_rows_length) == 1);
assert(oe_is_outside_enclave(inner_rows, inner_rows_length) == 1);
__builtin_ia32_lfence();

try {
broadcast_nested_loop_join(join_expr, join_expr_length,
outer_rows, outer_rows_length,
inner_rows, inner_rows_length,
output_rows, output_rows_length);
complete_encrypted_blocks(*output_rows);
EnclaveContext::getInstance().finish_ecall();
} catch (const std::runtime_error &e) {
EnclaveContext::getInstance().finish_ecall();
ocall_throw(e.what());
}
}

void ecall_non_oblivious_aggregate(
uint8_t *agg_op, size_t agg_op_length,
uint8_t *input_rows, size_t input_rows_length,
Expand Down
Loading