Unverified Commit 4d1a8f85 authored by Stan Kladko's avatar Stan Kladko Committed by GitHub

Merge branch 'develop' into bug/update-spec

parents 3b0388e3 8338b3a1
name: Build, test and push SGX container
name: Build and push SGX container
on:
workflow_dispatch:
push:
......@@ -17,7 +17,7 @@ jobs:
- uses: actions/checkout@v1
- name: submodule update
run: git submodule update --init --recursive
- name: build
- name: build and deploy test image
run: python3 scripts/docker_build.py Dockerfile sgxwallet ${GITHUB_SHA}
- name: deploy docker image
if: |
......
name: Build, test and push release SGX container
name: Build and push release SGX container
on:
workflow_dispatch:
push:
......
......@@ -18,11 +18,15 @@ jobs:
- uses: actions/checkout@v1
- name: submodule update
run: git submodule update --init --recursive
- name: build container for testing
- name: Build and publish container for testing
run: python3 scripts/docker_build.py DockerfileSimulation sgxwallet_sim ${GITHUB_SHA}
- name: test
run: python3 scripts/docker_test.py DockerfileSimulation sgxwallet_sim
- name: build and deploy docker image
if: |
contains(github.ref, 'develop') || contains(github.ref, 'beta') ||
contains(github.ref, 'master') ||
contains(github.ref, 'SECURE_ENCLAVE_CHANGES')
run : |
sudo rm -rf /home/runner/work/sgxwallet/sgxwallet/sgx_data
export BRANCH=${GITHUB_REF##*/}
......
FROM ubuntu:bionic
FROM ubuntu:18.04
RUN apt-get update && apt-get install -y \
autoconf \
automake \
build-essential \
cmake \
curl \
debhelper \
git \
libcurl4-openssl-dev \
libprotobuf-dev \
libssl-dev \
libtool \
lsb-release \
ocaml \
ocamlbuild \
protobuf-compiler \
python \
wget \
libcurl4 \
libprotobuf10 \
libssl1.1 \
make \
module-init-tools \
unzip
RUN git clone -b sgx_2.13 --depth 1 https://github.com/intel/linux-sgx
RUN cd linux-sgx && make preparation
WORKDIR /linux-sgx
COPY . .
RUN make sdk_install_pkg_no_mitigation
WORKDIR /opt/intel
RUN sh -c 'echo yes | /linux-sgx/linux/installer/bin/sgx_linux_x64_sdk_*.bin'
WORKDIR /linux-sgx
RUN make psw_install_pkg
WORKDIR /opt/intel
RUN cp /linux-sgx/linux/installer/bin/sgx_linux_x64_psw*.bin .
RUN ./sgx_linux_x64_psw*.bin --no-start-aesm
COPY . /usr/src/sdk
RUN ls /usr/src/sdk/autoconf.bash
WORKDIR /usr/src/sdk
COPY docker/install-psw.patch ./
RUN apt update && \
apt install -yq apt-utils && \
apt install -yq --no-install-recommends python-yaml vim \
telnet git ca-certificates build-essential ocaml ocamlbuild \
automake autoconf libtool wget python libssl-dev libssl-dev \
libcurl4-openssl-dev protobuf-compiler git libprotobuf-dev libboost-all-dev \
alien cmake debhelper uuid-dev libxml2-dev ccache vim libprotobuf10 \
yasm cmake flex bison libprocps-dev ccache autoconf texinfo libssl-dev \
libboost-all-dev libjsonrpccpp-dev curl libjsonrpccpp-tools && \
telnet git ca-certificates perl \
reprepro libboost-all-dev alien uuid-dev libxml2-dev ccache \
yasm flex bison libprocps-dev ccache texinfo \
libjsonrpccpp-dev curl libjsonrpccpp-tools && \
ln -s /usr/bin/ccache /usr/local/bin/clang && \
ln -s /usr/bin/ccache /usr/local/bin/clang++ && \
ln -s /usr/bin/ccache /usr/local/bin/gcc && \
ln -s /usr/bin/ccache /usr/local/bin/g++ && \
ln -s /usr/bin/ccache /usr/local/bin/cc && \
ln -s /usr/bin/ccache /usr/local/bin/c++ && \
git clone -b sgx_2.5 --depth 1 https://github.com/intel/linux-sgx && \
cd linux-sgx && \
patch -p1 -i ../install-psw.patch && \
./download_prebuilt.sh 2> /dev/null && \
make -s -j$(nproc) sdk_install_pkg psw_install_pkg && \
./linux/installer/bin/sgx_linux_x64_sdk_2.5.100.49891.bin --prefix=/opt/intel && \
./linux/installer/bin/sgx_linux_x64_psw_2.5.100.49891.bin && \
cd .. && rm -rf linux-sgx/ && cd scripts && ./build_deps.py && \
ln -s /usr/bin/ccache /usr/local/bin/c++
RUN cd scripts && ./build_deps.py && \
wget --progress=dot:mega -O - https://github.com/intel/dynamic-application-loader-host-interface/archive/072d233296c15d0dcd1fb4570694d0244729f87b.tar.gz | tar -xz && \
cd dynamic-application-loader-host-interface-072d233296c15d0dcd1fb4570694d0244729f87b && \
cmake . -DCMAKE_BUILD_TYPE=Release -DINIT_SYSTEM=SysVinit && \
......@@ -37,5 +70,5 @@ RUN apt update && \
cd .. && rm -rf dynamic-application-loader-host-interface-072d233296c15d0dcd1fb4570694d0244729f87b && \
cd /usr/src/sdk && \
./autoconf.bash && \
./configure && \
./configure && \
bash -c "make -j$(nproc)"
1.73.0
1.75.0
\ No newline at end of file
diff --git a/linux/installer/bin/install-sgx-psw.bin.tmpl b/linux/installer/bin/install-sgx-psw.bin.tmpl
index 3510e97c..751831ab 100755
index 7d19987..7386ce7 100755
--- a/linux/installer/bin/install-sgx-psw.bin.tmpl
+++ b/linux/installer/bin/install-sgx-psw.bin.tmpl
@@ -30,34 +30,10 @@
@@ -30,33 +30,10 @@
#
#
......@@ -12,7 +12,7 @@ index 3510e97c..751831ab 100755
- if [[ $? != "0" ]]; then
- /sbin/modinfo intel_sgx &> /dev/null
- if [[ $? != "0" ]]; then
- lsmod | grep 'isgx\|intel_sgx' &> /dev/null
- /sbin/lsmod 2> /dev/null | grep 'isgx\|intel_sgx'
- if [[ $? = "0" ]]; then
- echo "Warning: You did not follow the document to install the driver package."
- echo
......@@ -33,45 +33,46 @@ index 3510e97c..751831ab 100755
- exit 4
-fi
-
-
PKG_ARCH=@arch@
ARCH=$(uname -m)
diff --git a/linux/installer/common/libsgx-enclave-common/install.sh b/linux/installer/common/libsgx-enclave-common/install.sh
index 296879af..851d520b 100755
--- a/linux/installer/common/libsgx-enclave-common/install.sh
+++ b/linux/installer/common/libsgx-enclave-common/install.sh
@@ -33,11 +33,6 @@
set -e
-if test $(id -u) -ne 0; then
- echo "Root privilege is required."
- exit 1
-fi
-
SCRIPT_DIR=$(dirname "$0")
source ${SCRIPT_DIR}/installConfig
@@ -95,7 +90,7 @@ elif [ -d /etc/init/ ]; then
else
echo " failed."
echo "Unsupported platform - neither systemctl nor initctl is found."
- exit 5
+ retval=0
fi
if test $retval -ne 0; then
diff --git a/linux/installer/common/psw/install.sh b/linux/installer/common/psw/install.sh
index 59f3ed61..8ba940a3 100755
index 042f83c..3043ad1 100755
--- a/linux/installer/common/psw/install.sh
+++ b/linux/installer/common/psw/install.sh
@@ -96,7 +96,7 @@ elif [ -d /etc/init/ ]; then
else
echo " failed."
echo "Unsupported platform - neither systemctl nor initctl is found."
- exit 5
+ retval=0
@@ -106,7 +106,7 @@ else
echo "Warning: No systemctl/initctl to start AESM. You may start AESM manually, e.g., /opt/intel/sgxpsw/aesm/aesm_service --no-daemon"
else
echo "Error: Unsupported platform - neither systemctl nor initctl is found."
- exit 5
+ retval=0
fi
fi
if test $retval -ne 0; then
diff --git a/linux/installer/common/sgx-aesm-service/Makefile b/linux/installer/common/sgx-aesm-service/Makefile
index 89c5b21..2b4eb8f 100644
--- a/linux/installer/common/sgx-aesm-service/Makefile
+++ b/linux/installer/common/sgx-aesm-service/Makefile
@@ -48,7 +48,8 @@ AESMD_CONF_DEL=aesmd.conf
AESMD_CONF_PATH=/lib/systemd/system
$(warning "You may need to start aesmd manually after it's installed!")
else
-$(error "Unsupported platform - neither systemctl nor initctl is found!")
+# $(error "Unsupported platform - neither systemctl nor initctl is found!")
+exit 0
endif
endif
diff --git a/external/dcap_source/tools/SGXPlatformRegistration/package/installer/common/sgx-ra-service/Makefile b/external/dcap_source/tools/SGXPlatformRegistration/package/installer/common/sgx-ra-service/Makefile
index 1f3efdb..07ede24 100644
--- a/tools/SGXPlatformRegistration/package/installer/common/sgx-ra-service/Makefile
+++ b/tools/SGXPlatformRegistration/package/installer/common/sgx-ra-service/Makefile
@@ -47,7 +47,8 @@ RAD_CONF_NAME=mpa_registration_tool.service
RAD_CONF_DEL=mpa_registration.conf
RAD_CONF_PATH=/lib/systemd/system
else
-$(error "Unsupported platform - neither systemctl nor initctl is found!")
+# $(error "Unsupported platform - neither systemctl nor initctl is found!")
+exit 0
endif
endif
......@@ -35,7 +35,7 @@ pid=$!
sleep 2
echo "Checking that sgxwallet can connect to SGX whitelist update server whitelist.trustedservices.intel.com "
echo "If this test fails, you need to update your network config or firewall to allow this connection"
curl -I http://whitelist.trustedservices.intel.com/SGX/LCWL/Linux/sgx_white_list_cert.bin
curl -I http://whitelist.trustedservices.intel.com/SGX/LCWL/Linux/sgx_white_list_cert.bin
else
echo "Running in SGX simulation mode"
fi
......@@ -46,7 +46,7 @@ echo "Test run requested"
sleep 5
./testw.py
else
sleep 3
./sgxwallet $1 $2 $3 $4 $5
sleep 3
./sgxwallet $1 $2 $3 $4 $5
fi
......@@ -45,11 +45,11 @@ apt-get install build-essential
Run the following command:
```bash
cd scripts; sudo ./sgx_linux_x64_driver_2.5.0_2605efa.bin; cd ..
cd scripts; sudo ./sgx_linux_x64_driver_2.11.0_0373e2e.bin; cd ..
```
Alternatively, other driver versions may be downloaded from Intel.
Please note that version `2.5.0_2605efa` is what is currently supported.
Please note that version `2.11.0_0373e2e` is what is currently supported.
Reboot you machine after driver install. Do `ls /dev/isgx` to check that `isgx` device is properly installed.
If you do not see the `isgx` device, you need to troubleshoot your driver installation.
......
Subproject commit 8dc9f547c612010ea0b6257d86bcbd4ff7149565
Subproject commit a70a1b07fd1bbfd3797197654297f8aa010e269a
Subproject commit 95eaa6f6693cd86c35e10a22b4f8e483373c987c
Subproject commit 75bf89f7d6dd4598b9f8148bd6374a407f37105c
......@@ -77,7 +77,7 @@ print("Build LibBLS");
os.chdir(BLS_DIR + "/deps")
assert subprocess.call(["bash", "-c", "./build.sh"]) == 0
os.chdir(BLS_DIR)
assert subprocess.call(["bash", "-c", "cmake -H. -Bbuild"]) == 0
assert subprocess.call(["bash", "-c", "cmake -H. -Bbuild -DBUILD_TESTS=OFF"]) == 0
os.chdir(BLS_DIR + "/build")
assert subprocess.call(["bash", "-c", "make"]) == 0
......@@ -105,12 +105,12 @@ assert subprocess.call(["bash", "-c", "./build.sh"]) == 0
print("Install Linux SDK");
os.chdir(SCRIPTS_DIR)
assert subprocess.call(["bash", "-c", "./sgx_linux_x64_sdk_2.5.100.49891.bin --prefix=" + topDir + "/sgx-sdk-build"]) == 0
assert subprocess.call(["bash", "-c", "./sgx_linux_x64_sdk_2.13.100.4.bin --prefix=" + topDir + "/sgx-sdk-build"]) == 0
print("Make GMP");
os.chdir(GMP_DIR)
assert subprocess.call(["bash", "-c", "./configure --prefix=" + TGMP_BUILD_DIR + " --disable-shared --enable-static --with-pic --enable-sgx --with-sgxsdk=" + SDK_DIR + "/sgxsdk"]) == 0
assert subprocess.call(["bash", "-c", "./configure --prefix=" + TGMP_BUILD_DIR + " --disable-shared --enable-static --with-pic --enable-sgx --with-sgxsdk=" + SDK_DIR + "/sgxsdk"]) == 0
assert subprocess.call(["make", "install"]) == 0
assert subprocess.call(["make", "clean"]) == 0
......
......@@ -29,13 +29,14 @@ topDir = os.getcwd() + "/sgxwallet"
DOCKER_FILE_NAME = sys.argv[1]
IMAGE_NAME = sys.argv[2]
COMMIT_HASH = sys.argv[3]
TAG_POSTFIX = "latest_commit"
FULL_IMAGE_TAG = "skalenetwork/" + IMAGE_NAME + ":" + TAG_POSTFIX
FULL_IMAGE_TAG = "skalenetwork/" + IMAGE_NAME + ":" + COMMIT_HASH
print("Starting build", flush=True)
assert subprocess.call(["pwd"]) == 0
assert subprocess.call(["docker", "build", topDir, "--file", topDir + "/" + DOCKER_FILE_NAME, "--tag",
FULL_IMAGE_TAG]) == 0
\ No newline at end of file
FULL_IMAGE_TAG]) == 0
assert subprocess.call(["docker", "push", FULL_IMAGE_TAG]) == 0
\ No newline at end of file
/* config.h. Generated from config.h.in by configure. */
/* config.h.in. Generated from configure.ac by autoheader. */
/* Enable libcurl as a user agent */
#define AGENT_LIBCURL 1
/* Enable debugging */
#define DEBUG 1
/* Default CA bundle for OpenSSL-based applications */
#define DEFAULT_CA_BUNDLE_AUTO "/etc/ssl/certs/ca-certificates.crt"
/* Flag set for prerelease builds */
/* #undef EDEBUG */
/* Define to 1 if you have the <inttypes.h> header file. */
#define HAVE_INTTYPES_H 1
/* Define to 1 if you have the <memory.h> header file. */
#define HAVE_MEMORY_H 1
/* Define to 1 if you have the <openssl/evp.h> header file. */
#define HAVE_OPENSSL_EVP_H 1
/* Define to 1 if you have the <openssl/pem.h> header file. */
#define HAVE_OPENSSL_PEM_H 1
/* Define to 1 if you have the <openssl/x509.h> header file. */
#define HAVE_OPENSSL_X509_H 1
/* Define to 1 if you have the <stdint.h> header file. */
#define HAVE_STDINT_H 1
/* Define to 1 if you have the <stdlib.h> header file. */
#define HAVE_STDLIB_H 1
/* Define to 1 if you have the <strings.h> header file. */
#define HAVE_STRINGS_H 1
/* Define to 1 if you have the <string.h> header file. */
#define HAVE_STRING_H 1
/* Define to 1 if you have the <sys/stat.h> header file. */
#define HAVE_SYS_STAT_H 1
/* Define to 1 if you have the <sys/types.h> header file. */
#define HAVE_SYS_TYPES_H 1
/* Define to 1 if you have the <unistd.h> header file. */
#define HAVE_UNISTD_H 1
/* Flag set for prerelease and release builds */
/* #undef NDEBUG */
/* Name of package */
#define PACKAGE "sgxautosample"
/* Define to the address where bug reports for this package should be sent. */
#define PACKAGE_BUGREPORT "john.p.mechalas@intel.com"
/* Define to the full name of this package. */
#define PACKAGE_NAME "sgxautosample"
/* Define to the full name and version of this package. */
#define PACKAGE_STRING "sgxautosample 1.0"
/* Define to the one symbol short name of this package. */
#define PACKAGE_TARNAME "sgxautosample"
/* Define to the home page for this package. */
#define PACKAGE_URL ""
/* Define to the version of this package. */
#define PACKAGE_VERSION "1.0"
/* Enable hardware simulation mode */
/* #undef SGX_HW_SIM */
/* Define to 1 if you have the ANSI C header files. */
#define STDC_HEADERS 1
/* Define if sgx_uae_service.h uses the bool type */
/* #undef UAE_SERVICE_HAS_BOOL */
/* Version number of package */
#define VERSION "1.0"
......@@ -35,6 +35,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "third_party/intel/sgx_stub.h"
#include <limits.h>
#include <stdio.h>
#include <sgx_uae_quote_ex.h>
#include <sgx_urts.h>
#include <sys/stat.h>
#include <stdlib.h>
......@@ -108,7 +109,7 @@ int file_in_searchpath (const char *file, char *search, char *fullpath,
if ( search == NULL ) return 0;
if ( strlen(search) == 0 ) return 0;
str= strdup(search);
str = strdup(search);
if ( str == NULL ) return 0;
p= strtok(str, ":");
......
/*
Copyright 2018 Intel Corporation
Copyright 2017 Intel Corporation
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of the copyright holder nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
......@@ -28,16 +22,20 @@ PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
typedef int bool;
#include <dlfcn.h>
#include "config.h"
#ifdef UAE_SERVICE_HAS_BOOL
typedef unsigned char bool;
#endif
#ifdef _WIN32
# include <Windows.h>
#else
# include <dlfcn.h>
#endif
#include <stdlib.h>
#include <stdio.h>
#include "sgx_stub.h"
#include "sgx_detect.h"
#include <sgx_edger8r.h>
#include <sgx_uae_service.h>
#include <sgx_urts.h>
......@@ -49,12 +47,21 @@ static void _undefined_symbol (const char *symbol);
static void *_load_symbol(void *handle, const char *symbol, int *status);
#include <sys/types.h>
#include <inttypes.h>
void sgx_oc_cpuidex(int cpuinfo[4], int leaf, int subleaf);
int sgx_thread_wait_untrusted_event_ocall(const void *self);
int close_session_ocall(uint32_t sid, uint32_t timeout);
int create_session_ocall(uint32_t* sid, uint8_t* dh_msg1, uint32_t dh_msg1_size, uint32_t timeout);
int exchange_report_ocall(uint32_t sid, uint8_t* dh_msg2, uint32_t dh_msg2_size, uint8_t* dh_msg3, uint32_t dh_msg3_size, uint32_t timeout);
int invoke_service_ocall(uint8_t* pse_message_req, uint32_t pse_message_req_size, uint8_t* pse_message_resp, uint32_t pse_message_resp_size, uint32_t timeout);
int invoke_service_ocall(uint8_t* pse_message_req, uint32_t pse_message_req_size, uint8_t* pse_message_resp, uint32_t pse_message_resp_size, uint32_t timeout);
int sgx_thread_set_multiple_untrusted_events_ocall(const void **waiters, size_t total);
int sgx_thread_set_untrusted_event_ocall(const void *waiter);
int sgx_thread_setwait_untrusted_events_ocall(const void *waiter, const void *self);
int sgx_thread_set_multiple_untrusted_events_ocall(const void **waiters, size_t total);
int sgx_thread_wait_untrusted_event_ocall(const void *self);
void sgx_oc_cpuidex(int cpuinfo[4], int leaf, int subleaf);
;
static void *_load_libsgx_uae_service();
......@@ -65,55 +72,67 @@ static void *h_libsgx_urts= NULL;
static int l_libsgx_uae_service= 0;
static int l_libsgx_urts= 0;
static func p_sgx_thread_wait_untrusted_event_ocall= NULL;
static func p_sgx_report_attestation_status= NULL;
static func p_sgx_destroy_enclave= NULL;
static func p_sgx_create_encrypted_enclave= NULL;
static func p_sgx_thread_setwait_untrusted_events_ocall= NULL;
static func p_sgx_register_wl_cert_chain= NULL;
static func p_sgx_thread_set_multiple_untrusted_events_ocall= NULL;
static func p_sgx_ocall= NULL;
static func p_sgx_get_quote= NULL;
static func p_sgx_create_enclave= NULL;
static func p_sgx_init_quote= NULL;
static func p_invoke_service_ocall= NULL;
static func p_sgx_get_target_info= NULL;
static func p_sgx_thread_setwait_untrusted_events_ocall= NULL;
static func p_sgx_get_extended_epid_group_id= NULL;
static func p_close_session_ocall= NULL;
static func p_sgx_get_whitelist_size= NULL;
static func p_sgx_thread_set_untrusted_event_ocall= NULL;
static func p_sgx_get_ps_cap= NULL;
static func p_sgx_get_whitelist= NULL;
static func p_sgx_create_enclave_ex= NULL;
static func p_sgx_create_enclave= NULL;
static func p_sgx_get_quote_ex= NULL;
static func p_sgx_oc_cpuidex= NULL;
static func p_sgx_get_extended_epid_group_id= NULL;
static func p_sgx_destroy_enclave= NULL;
static func p_create_session_ocall= NULL;
static func p_sgx_report_attestation_status= NULL;
static func p_sgx_get_whitelist= NULL;
static func p_sgx_create_enclave_from_buffer_ex= NULL;
static func p_sgx_get_quote= NULL;
static func p_sgx_get_quote_size= NULL;
static func p_sgx_ocall= NULL;
static func p_sgx_init_quote= NULL;
static func p_sgx_calc_quote_size= NULL;
static func p_sgx_thread_wait_untrusted_event_ocall= NULL;
static func p_sgx_ecall_switchless= NULL;
static func p_sgx_init_quote_ex= NULL;
static func p_sgx_create_encrypted_enclave= NULL;
static func p_sgx_thread_set_untrusted_event_ocall= NULL;
static func p_sgx_get_quote_size_ex= NULL;
static func p_sgx_ecall= NULL;
static func p_sgx_get_quote_size= NULL;
static func p_sgx_thread_set_multiple_untrusted_events_ocall= NULL;
static func p_exchange_report_ocall= NULL;
static int l_sgx_thread_wait_untrusted_event_ocall= 0;
static int l_sgx_report_attestation_status= 0;
static int l_sgx_destroy_enclave= 0;
static int l_sgx_create_encrypted_enclave= 0;
static int l_sgx_thread_setwait_untrusted_events_ocall= 0;
static int l_sgx_register_wl_cert_chain= 0;
static int l_sgx_thread_set_multiple_untrusted_events_ocall= 0;
static int l_sgx_ocall= 0;
static int l_sgx_get_quote= 0;
static int l_sgx_create_enclave= 0;
static int l_sgx_init_quote= 0;
static int l_invoke_service_ocall= 0;
static int l_sgx_get_target_info= 0;
static int l_sgx_thread_setwait_untrusted_events_ocall= 0;
static int l_sgx_get_extended_epid_group_id= 0;
static int l_close_session_ocall= 0;
static int l_sgx_get_whitelist_size= 0;
static int l_sgx_thread_set_untrusted_event_ocall= 0;
static int l_sgx_get_ps_cap= 0;
static int l_sgx_get_whitelist= 0;
static int l_sgx_create_enclave_ex= 0;
static int l_sgx_create_enclave= 0;
static int l_sgx_get_quote_ex= 0;
static int l_sgx_oc_cpuidex= 0;
static int l_sgx_get_extended_epid_group_id= 0;
static int l_sgx_destroy_enclave= 0;
static int l_create_session_ocall= 0;
static int l_sgx_report_attestation_status= 0;
static int l_sgx_get_whitelist= 0;
static int l_sgx_create_enclave_from_buffer_ex= 0;
static int l_sgx_get_quote= 0;
static int l_sgx_get_quote_size= 0;
static int l_sgx_ocall= 0;
static int l_sgx_init_quote= 0;
static int l_sgx_calc_quote_size= 0;
static int l_sgx_thread_wait_untrusted_event_ocall= 0;
static int l_sgx_ecall_switchless= 0;
static int l_sgx_init_quote_ex= 0;
static int l_sgx_create_encrypted_enclave= 0;
static int l_sgx_thread_set_untrusted_event_ocall= 0;
static int l_sgx_get_quote_size_ex= 0;
static int l_sgx_ecall= 0;
static int l_sgx_get_quote_size= 0;
#ifdef SGX_HW_SIM
#define UAE_SERVICE_LIB "libsgx_uae_service_sim.so"
#define URTS_LIB "libsgx_urts_sim.so"
#else
#define UAE_SERVICE_LIB "libsgx_uae_service.so"
#define URTS_LIB "libsgx_urts.so"
#endif
static int l_sgx_thread_set_multiple_untrusted_events_ocall= 0;
static int l_exchange_report_ocall= 0;
static void _undefined_symbol (const char *symbol)
{
......@@ -125,10 +144,15 @@ static void *_load_symbol(void *handle, const char *symbol, int *status)
{
void *hsym;
#ifdef _WIN32
hsym = GetProcAddress((HMODULE)handle, symbol);
*status = (dlerr == NULL) ? 1 : -1;
#else
dlerr= dlerror();
hsym= dlsym(handle, symbol);
dlerr= dlerror();
*status= ( dlerr == NULL ) ? 1 : -1;
#endif
return hsym;
}
......@@ -137,12 +161,12 @@ static void *_load_symbol(void *handle, const char *symbol, int *status)
static void *_load_libsgx_uae_service()
{
if ( l_libsgx_uae_service == 0 ) {
dlerror();
h_libsgx_uae_service= dlopen(UAE_SERVICE_LIB, RTLD_GLOBAL|RTLD_NOW);
if ( h_libsgx_uae_service == NULL ) {
fprintf(stderr, "%s: %s\n", UAE_SERVICE_LIB, dlerror());
l_libsgx_uae_service= -1;
} else l_libsgx_uae_service= 1;
#ifdef SGX_HW_SIM
h_libsgx_uae_service= dlopen("libsgx_uae_service_sim.so", RTLD_GLOBAL|RTLD_NOW);
#else
h_libsgx_uae_service= dlopen("libsgx_uae_service.so", RTLD_GLOBAL|RTLD_NOW);
#endif
l_libsgx_uae_service= ( h_libsgx_uae_service == NULL ) ? -1 : 1;
}
return h_libsgx_uae_service;
......@@ -151,11 +175,12 @@ static void *_load_libsgx_uae_service()
static void *_load_libsgx_urts()
{
if ( l_libsgx_urts == 0 ) {
h_libsgx_urts= dlopen(URTS_LIB, RTLD_GLOBAL|RTLD_NOW);
if ( h_libsgx_urts == NULL ) {
fprintf(stderr, "%s: %s\n", URTS_LIB, dlerror());
l_libsgx_urts= -1;
} else l_libsgx_urts= 1;
#ifdef SGX_HW_SIM
h_libsgx_urts= dlopen("libsgx_urts_sim.so", RTLD_GLOBAL|RTLD_NOW);
#else
h_libsgx_urts= dlopen("libsgx_urts.so", RTLD_GLOBAL|RTLD_NOW);
#endif
l_libsgx_urts= ( h_libsgx_urts == NULL ) ? -1 : 1;
}
return h_libsgx_urts;
......@@ -169,53 +194,62 @@ int have_sgx_psw()
) ? 0 : 1;
}
int have_sgx_ufunction(const char *name)
{
int status = 0;
_load_symbol(h_libsgx_uae_service, name, &status);
if ( status == 1 ) return 1;
_load_symbol(h_libsgx_urts, name, &status);
return (status == 1) ? 1 : 0;
}
int sgx_thread_wait_untrusted_event_ocall(const void *self)
void *get_sgx_ufunction(const char *name)
{
if ( l_sgx_thread_wait_untrusted_event_ocall == 0 ) {
if ( h_libsgx_urts == 0 ) _load_libsgx_urts();
*(void **)(&p_sgx_thread_wait_untrusted_event_ocall)= _load_symbol(h_libsgx_urts, "sgx_thread_wait_untrusted_event_ocall", &l_sgx_thread_wait_untrusted_event_ocall);
}
void *hsym= NULL;
int status = 0;
if ( l_sgx_thread_wait_untrusted_event_ocall == -1 ) _undefined_symbol("sgx_thread_wait_untrusted_event_ocall");
hsym= _load_symbol(h_libsgx_uae_service, name, &status);
if ( status == 1 ) return hsym;
return (int) p_sgx_thread_wait_untrusted_event_ocall(self);
_load_symbol(h_libsgx_urts, name, &status);
return (status == 1) ? hsym : NULL;
}
sgx_status_t sgx_report_attestation_status(const sgx_platform_info_t *p_platform_info, int attestation_status, sgx_update_info_bit_t *p_update_info)
sgx_status_t sgx_register_wl_cert_chain(uint8_t *p_wl_cert_chain, uint32_t wl_cert_chain_size)
{
if ( l_sgx_report_attestation_status == 0 ) {
if ( l_sgx_register_wl_cert_chain == 0 ) {
if ( h_libsgx_uae_service == 0 ) _load_libsgx_uae_service();
*(void **)(&p_sgx_report_attestation_status)= _load_symbol(h_libsgx_uae_service, "sgx_report_attestation_status", &l_sgx_report_attestation_status);
*(void **)(&p_sgx_register_wl_cert_chain)= _load_symbol(h_libsgx_uae_service, "sgx_register_wl_cert_chain", &l_sgx_register_wl_cert_chain);
}
if ( l_sgx_report_attestation_status == -1 ) _undefined_symbol("sgx_report_attestation_status");
if ( l_sgx_register_wl_cert_chain == -1 ) _undefined_symbol("sgx_register_wl_cert_chain");
return (sgx_status_t) p_sgx_report_attestation_status(p_platform_info, attestation_status, p_update_info);
return (sgx_status_t) p_sgx_register_wl_cert_chain(p_wl_cert_chain, wl_cert_chain_size);
}
sgx_status_t sgx_destroy_enclave(const sgx_enclave_id_t enclave_id)
int invoke_service_ocall(uint8_t *pse_message_req, uint32_t pse_message_req_size, uint8_t *pse_message_resp, uint32_t pse_message_resp_size, uint32_t timeout)
{
if ( l_sgx_destroy_enclave == 0 ) {
if ( h_libsgx_urts == 0 ) _load_libsgx_urts();
*(void **)(&p_sgx_destroy_enclave)= _load_symbol(h_libsgx_urts, "sgx_destroy_enclave", &l_sgx_destroy_enclave);
if ( l_invoke_service_ocall == 0 ) {
if ( h_libsgx_uae_service == 0 ) _load_libsgx_uae_service();
*(void **)(&p_invoke_service_ocall)= _load_symbol(h_libsgx_uae_service, "invoke_service_ocall", &l_invoke_service_ocall);
}
if ( l_sgx_destroy_enclave == -1 ) _undefined_symbol("sgx_destroy_enclave");
if ( l_invoke_service_ocall == -1 ) _undefined_symbol("invoke_service_ocall");
return (sgx_status_t) p_sgx_destroy_enclave(enclave_id);
return (int) p_invoke_service_ocall(pse_message_req, pse_message_req_size, pse_message_resp, pse_message_resp_size, timeout);
}
sgx_status_t sgx_create_encrypted_enclave(const char *file_name, const int debug, sgx_launch_token_t *launch_token, int *launch_token_updated, sgx_enclave_id_t *enclave_id, sgx_misc_attribute_t *misc_attr, uint8_t *sealed_key)
sgx_status_t sgx_get_target_info(const sgx_enclave_id_t enclave_id, sgx_target_info_t *target_info)
{
if ( l_sgx_create_encrypted_enclave == 0 ) {
if ( l_sgx_get_target_info == 0 ) {
if ( h_libsgx_urts == 0 ) _load_libsgx_urts();
*(void **)(&p_sgx_create_encrypted_enclave)= _load_symbol(h_libsgx_urts, "sgx_create_encrypted_enclave", &l_sgx_create_encrypted_enclave);
*(void **)(&p_sgx_get_target_info)= _load_symbol(h_libsgx_urts, "sgx_get_target_info", &l_sgx_get_target_info);
}
if ( l_sgx_create_encrypted_enclave == -1 ) _undefined_symbol("sgx_create_encrypted_enclave");
if ( l_sgx_get_target_info == -1 ) _undefined_symbol("sgx_get_target_info");
return (sgx_status_t) p_sgx_create_encrypted_enclave(file_name, debug, launch_token, launch_token_updated, enclave_id, misc_attr, sealed_key);
return (sgx_status_t) p_sgx_get_target_info(enclave_id, target_info);
}
int sgx_thread_setwait_untrusted_events_ocall(const void *waiter, const void *self)
......@@ -230,52 +264,52 @@ int sgx_thread_setwait_untrusted_events_ocall(const void *waiter, const void *se
return (int) p_sgx_thread_setwait_untrusted_events_ocall(waiter, self);
}
sgx_status_t sgx_register_wl_cert_chain(uint8_t *p_wl_cert_chain, uint32_t wl_cert_chain_size)
sgx_status_t sgx_get_extended_epid_group_id(uint32_t *p_extended_epid_group_id)
{
if ( l_sgx_register_wl_cert_chain == 0 ) {
if ( l_sgx_get_extended_epid_group_id == 0 ) {
if ( h_libsgx_uae_service == 0 ) _load_libsgx_uae_service();
*(void **)(&p_sgx_register_wl_cert_chain)= _load_symbol(h_libsgx_uae_service, "sgx_register_wl_cert_chain", &l_sgx_register_wl_cert_chain);
*(void **)(&p_sgx_get_extended_epid_group_id)= _load_symbol(h_libsgx_uae_service, "sgx_get_extended_epid_group_id", &l_sgx_get_extended_epid_group_id);
}
if ( l_sgx_register_wl_cert_chain == -1 ) _undefined_symbol("sgx_register_wl_cert_chain");
if ( l_sgx_get_extended_epid_group_id == -1 ) _undefined_symbol("sgx_get_extended_epid_group_id");
return (sgx_status_t) p_sgx_register_wl_cert_chain(p_wl_cert_chain, wl_cert_chain_size);
return (sgx_status_t) p_sgx_get_extended_epid_group_id(p_extended_epid_group_id);
}
int sgx_thread_set_multiple_untrusted_events_ocall(const void **waiters, size_t total)
int close_session_ocall(uint32_t sid, uint32_t timeout)
{
if ( l_sgx_thread_set_multiple_untrusted_events_ocall == 0 ) {
if ( h_libsgx_urts == 0 ) _load_libsgx_urts();
*(void **)(&p_sgx_thread_set_multiple_untrusted_events_ocall)= _load_symbol(h_libsgx_urts, "sgx_thread_set_multiple_untrusted_events_ocall", &l_sgx_thread_set_multiple_untrusted_events_ocall);
if ( l_close_session_ocall == 0 ) {
if ( h_libsgx_uae_service == 0 ) _load_libsgx_uae_service();
*(void **)(&p_close_session_ocall)= _load_symbol(h_libsgx_uae_service, "close_session_ocall", &l_close_session_ocall);
}
if ( l_sgx_thread_set_multiple_untrusted_events_ocall == -1 ) _undefined_symbol("sgx_thread_set_multiple_untrusted_events_ocall");
if ( l_close_session_ocall == -1 ) _undefined_symbol("close_session_ocall");
return (int) p_sgx_thread_set_multiple_untrusted_events_ocall(waiters, total);
return (int) p_close_session_ocall(sid, timeout);
}
sgx_status_t sgx_ocall(const unsigned int index, void *ms)
sgx_status_t sgx_get_whitelist_size(uint32_t *p_whitelist_size)
{
if ( l_sgx_ocall == 0 ) {
if ( h_libsgx_urts == 0 ) _load_libsgx_urts();
*(void **)(&p_sgx_ocall)= _load_symbol(h_libsgx_urts, "sgx_ocall", &l_sgx_ocall);
if ( l_sgx_get_whitelist_size == 0 ) {
if ( h_libsgx_uae_service == 0 ) _load_libsgx_uae_service();
*(void **)(&p_sgx_get_whitelist_size)= _load_symbol(h_libsgx_uae_service, "sgx_get_whitelist_size", &l_sgx_get_whitelist_size);
}
if ( l_sgx_ocall == -1 ) _undefined_symbol("sgx_ocall");
if ( l_sgx_get_whitelist_size == -1 ) _undefined_symbol("sgx_get_whitelist_size");
return (sgx_status_t) p_sgx_ocall(index, ms);
return (sgx_status_t) p_sgx_get_whitelist_size(p_whitelist_size);
}
sgx_status_t sgx_get_quote(const sgx_report_t *p_report, sgx_quote_sign_type_t quote_type, const sgx_spid_t *p_spid, const sgx_quote_nonce_t *p_nonce, const uint8_t *p_sig_rl, uint32_t sig_rl_size, sgx_report_t *p_qe_report, sgx_quote_t *p_quote, uint32_t quote_size)
sgx_status_t sgx_create_enclave_ex(const char *file_name, const int debug, sgx_launch_token_t *launch_token, int *launch_token_updated, sgx_enclave_id_t *enclave_id, sgx_misc_attribute_t *misc_attr, const uint32_t ex_features, const void **ex_features_p)
{
if ( l_sgx_get_quote == 0 ) {
if ( h_libsgx_uae_service == 0 ) _load_libsgx_uae_service();
*(void **)(&p_sgx_get_quote)= _load_symbol(h_libsgx_uae_service, "sgx_get_quote", &l_sgx_get_quote);
if ( l_sgx_create_enclave_ex == 0 ) {
if ( h_libsgx_urts == 0 ) _load_libsgx_urts();
*(void **)(&p_sgx_create_enclave_ex)= _load_symbol(h_libsgx_urts, "sgx_create_enclave_ex", &l_sgx_create_enclave_ex);
}
if ( l_sgx_get_quote == -1 ) _undefined_symbol("sgx_get_quote");
if ( l_sgx_create_enclave_ex == -1 ) _undefined_symbol("sgx_create_enclave_ex");
return (sgx_status_t) p_sgx_get_quote(p_report, quote_type, p_spid, p_nonce, p_sig_rl, sig_rl_size, p_qe_report, p_quote, quote_size);
return (sgx_status_t) p_sgx_create_enclave_ex(file_name, debug, launch_token, launch_token_updated, enclave_id, misc_attr, ex_features, ex_features_p);
}
sgx_status_t sgx_create_enclave(const char *file_name, const int debug, sgx_launch_token_t *launch_token, int *launch_token_updated, sgx_enclave_id_t *enclave_id, sgx_misc_attribute_t *misc_attr)
......@@ -290,52 +324,64 @@ sgx_status_t sgx_create_enclave(const char *file_name, const int debug, sgx_laun
return (sgx_status_t) p_sgx_create_enclave(file_name, debug, launch_token, launch_token_updated, enclave_id, misc_attr);
}
sgx_status_t sgx_init_quote(sgx_target_info_t *p_target_info, sgx_epid_group_id_t *p_gid)
sgx_status_t sgx_get_quote_ex(const sgx_report_t *p_app_report, const sgx_att_key_id_t *p_att_key_id, sgx_qe_report_info_t *p_qe_report_info, uint8_t *p_quote, uint32_t quote_size)
{
if ( l_sgx_init_quote == 0 ) {
if ( l_sgx_get_quote_ex == 0 ) {
if ( h_libsgx_uae_service == 0 ) _load_libsgx_uae_service();
*(void **)(&p_sgx_init_quote)= _load_symbol(h_libsgx_uae_service, "sgx_init_quote", &l_sgx_init_quote);
*(void **)(&p_sgx_get_quote_ex)= _load_symbol(h_libsgx_uae_service, "sgx_get_quote_ex", &l_sgx_get_quote_ex);
}
if ( l_sgx_init_quote == -1 ) _undefined_symbol("sgx_init_quote");
if ( l_sgx_get_quote_ex == -1 ) _undefined_symbol("sgx_get_quote_ex");
return (sgx_status_t) p_sgx_init_quote(p_target_info, p_gid);
return (sgx_status_t) p_sgx_get_quote_ex(p_app_report, p_att_key_id, p_qe_report_info, p_quote, quote_size);
}
sgx_status_t sgx_get_whitelist_size(uint32_t *p_whitelist_size)
void sgx_oc_cpuidex(int *cpuinfo, int leaf, int subleaf)
{
if ( l_sgx_get_whitelist_size == 0 ) {
if ( h_libsgx_uae_service == 0 ) _load_libsgx_uae_service();
*(void **)(&p_sgx_get_whitelist_size)= _load_symbol(h_libsgx_uae_service, "sgx_get_whitelist_size", &l_sgx_get_whitelist_size);
if ( l_sgx_oc_cpuidex == 0 ) {
if ( h_libsgx_urts == 0 ) _load_libsgx_urts();
*(void **)(&p_sgx_oc_cpuidex)= _load_symbol(h_libsgx_urts, "sgx_oc_cpuidex", &l_sgx_oc_cpuidex);
}
if ( l_sgx_get_whitelist_size == -1 ) _undefined_symbol("sgx_get_whitelist_size");
if ( l_sgx_oc_cpuidex == -1 ) _undefined_symbol("sgx_oc_cpuidex");
return (sgx_status_t) p_sgx_get_whitelist_size(p_whitelist_size);
return (void) p_sgx_oc_cpuidex(cpuinfo, leaf, subleaf);
}
int sgx_thread_set_untrusted_event_ocall(const void *waiter)
sgx_status_t sgx_destroy_enclave(const sgx_enclave_id_t enclave_id)
{
if ( l_sgx_thread_set_untrusted_event_ocall == 0 ) {
if ( l_sgx_destroy_enclave == 0 ) {
if ( h_libsgx_urts == 0 ) _load_libsgx_urts();
*(void **)(&p_sgx_thread_set_untrusted_event_ocall)= _load_symbol(h_libsgx_urts, "sgx_thread_set_untrusted_event_ocall", &l_sgx_thread_set_untrusted_event_ocall);
*(void **)(&p_sgx_destroy_enclave)= _load_symbol(h_libsgx_urts, "sgx_destroy_enclave", &l_sgx_destroy_enclave);
}
if ( l_sgx_thread_set_untrusted_event_ocall == -1 ) _undefined_symbol("sgx_thread_set_untrusted_event_ocall");
if ( l_sgx_destroy_enclave == -1 ) _undefined_symbol("sgx_destroy_enclave");
return (int) p_sgx_thread_set_untrusted_event_ocall(waiter);
return (sgx_status_t) p_sgx_destroy_enclave(enclave_id);
}
sgx_status_t sgx_get_ps_cap(sgx_ps_cap_t *p_sgx_ps_cap)
int create_session_ocall(uint32_t *sid, uint8_t *dh_msg1, uint32_t dh_msg1_size, uint32_t timeout)
{
if ( l_sgx_get_ps_cap == 0 ) {
if ( l_create_session_ocall == 0 ) {
if ( h_libsgx_uae_service == 0 ) _load_libsgx_uae_service();
*(void **)(&p_sgx_get_ps_cap)= _load_symbol(h_libsgx_uae_service, "sgx_get_ps_cap", &l_sgx_get_ps_cap);
*(void **)(&p_create_session_ocall)= _load_symbol(h_libsgx_uae_service, "create_session_ocall", &l_create_session_ocall);
}
if ( l_sgx_get_ps_cap == -1 ) _undefined_symbol("sgx_get_ps_cap");
if ( l_create_session_ocall == -1 ) _undefined_symbol("create_session_ocall");
return (sgx_status_t) p_sgx_get_ps_cap(p_sgx_ps_cap);
return (int) p_create_session_ocall(sid, dh_msg1, dh_msg1_size, timeout);
}
sgx_status_t sgx_report_attestation_status(const sgx_platform_info_t *p_platform_info, int attestation_status, sgx_update_info_bit_t *p_update_info)
{
if ( l_sgx_report_attestation_status == 0 ) {
if ( h_libsgx_uae_service == 0 ) _load_libsgx_uae_service();
*(void **)(&p_sgx_report_attestation_status)= _load_symbol(h_libsgx_uae_service, "sgx_report_attestation_status", &l_sgx_report_attestation_status);
}
if ( l_sgx_report_attestation_status == -1 ) _undefined_symbol("sgx_report_attestation_status");
return (sgx_status_t) p_sgx_report_attestation_status(p_platform_info, attestation_status, p_update_info);
}
sgx_status_t sgx_get_whitelist(uint8_t *p_whitelist, uint32_t whitelist_size)
......@@ -350,28 +396,64 @@ sgx_status_t sgx_get_whitelist(uint8_t *p_whitelist, uint32_t whitelist_size)
return (sgx_status_t) p_sgx_get_whitelist(p_whitelist, whitelist_size);
}
void sgx_oc_cpuidex(int *cpuinfo, int leaf, int subleaf)
sgx_status_t sgx_create_enclave_from_buffer_ex(uint8_t *buffer, size_t buffer_size, const int debug, sgx_enclave_id_t *enclave_id, sgx_misc_attribute_t *misc_attr, const uint32_t ex_features, const void **ex_features_p)
{
if ( l_sgx_oc_cpuidex == 0 ) {
if ( l_sgx_create_enclave_from_buffer_ex == 0 ) {
if ( h_libsgx_urts == 0 ) _load_libsgx_urts();
*(void **)(&p_sgx_oc_cpuidex)= _load_symbol(h_libsgx_urts, "sgx_oc_cpuidex", &l_sgx_oc_cpuidex);
*(void **)(&p_sgx_create_enclave_from_buffer_ex)= _load_symbol(h_libsgx_urts, "sgx_create_enclave_from_buffer_ex", &l_sgx_create_enclave_from_buffer_ex);
}
if ( l_sgx_oc_cpuidex == -1 ) _undefined_symbol("sgx_oc_cpuidex");
if ( l_sgx_create_enclave_from_buffer_ex == -1 ) _undefined_symbol("sgx_create_enclave_from_buffer_ex");
return (void) p_sgx_oc_cpuidex(cpuinfo, leaf, subleaf);
return (sgx_status_t) p_sgx_create_enclave_from_buffer_ex(buffer, buffer_size, debug, enclave_id, misc_attr, ex_features, ex_features_p);
}
sgx_status_t sgx_get_extended_epid_group_id(uint32_t *p_extended_epid_group_id)
sgx_status_t sgx_get_quote(const sgx_report_t *p_report, sgx_quote_sign_type_t quote_type, const sgx_spid_t *p_spid, const sgx_quote_nonce_t *p_nonce, const uint8_t *p_sig_rl, uint32_t sig_rl_size, sgx_report_t *p_qe_report, sgx_quote_t *p_quote, uint32_t quote_size)
{
if ( l_sgx_get_extended_epid_group_id == 0 ) {
if ( l_sgx_get_quote == 0 ) {
if ( h_libsgx_uae_service == 0 ) _load_libsgx_uae_service();
*(void **)(&p_sgx_get_extended_epid_group_id)= _load_symbol(h_libsgx_uae_service, "sgx_get_extended_epid_group_id", &l_sgx_get_extended_epid_group_id);
*(void **)(&p_sgx_get_quote)= _load_symbol(h_libsgx_uae_service, "sgx_get_quote", &l_sgx_get_quote);
}
if ( l_sgx_get_extended_epid_group_id == -1 ) _undefined_symbol("sgx_get_extended_epid_group_id");
if ( l_sgx_get_quote == -1 ) _undefined_symbol("sgx_get_quote");
return (sgx_status_t) p_sgx_get_extended_epid_group_id(p_extended_epid_group_id);
return (sgx_status_t) p_sgx_get_quote(p_report, quote_type, p_spid, p_nonce, p_sig_rl, sig_rl_size, p_qe_report, p_quote, quote_size);
}
sgx_status_t sgx_get_quote_size(const uint8_t *p_sig_rl, uint32_t *p_quote_size)
{
if ( l_sgx_get_quote_size == 0 ) {
if ( h_libsgx_uae_service == 0 ) _load_libsgx_uae_service();
*(void **)(&p_sgx_get_quote_size)= _load_symbol(h_libsgx_uae_service, "sgx_get_quote_size", &l_sgx_get_quote_size);
}
if ( l_sgx_get_quote_size == -1 ) _undefined_symbol("sgx_get_quote_size");
return (sgx_status_t) p_sgx_get_quote_size(p_sig_rl, p_quote_size);
}
sgx_status_t sgx_ocall(const unsigned int index, void *ms)
{
if ( l_sgx_ocall == 0 ) {
if ( h_libsgx_urts == 0 ) _load_libsgx_urts();
*(void **)(&p_sgx_ocall)= _load_symbol(h_libsgx_urts, "sgx_ocall", &l_sgx_ocall);
}
if ( l_sgx_ocall == -1 ) _undefined_symbol("sgx_ocall");
return (sgx_status_t) p_sgx_ocall(index, ms);
}
sgx_status_t sgx_init_quote(sgx_target_info_t *p_target_info, sgx_epid_group_id_t *p_gid)
{
if ( l_sgx_init_quote == 0 ) {
if ( h_libsgx_uae_service == 0 ) _load_libsgx_uae_service();
*(void **)(&p_sgx_init_quote)= _load_symbol(h_libsgx_uae_service, "sgx_init_quote", &l_sgx_init_quote);
}
if ( l_sgx_init_quote == -1 ) _undefined_symbol("sgx_init_quote");
return (sgx_status_t) p_sgx_init_quote(p_target_info, p_gid);
}
sgx_status_t sgx_calc_quote_size(const uint8_t *p_sig_rl, uint32_t sig_rl_size, uint32_t *p_quote_size)
......@@ -386,6 +468,86 @@ sgx_status_t sgx_calc_quote_size(const uint8_t *p_sig_rl, uint32_t sig_rl_size,
return (sgx_status_t) p_sgx_calc_quote_size(p_sig_rl, sig_rl_size, p_quote_size);
}
int sgx_thread_wait_untrusted_event_ocall(const void *self)
{
if ( l_sgx_thread_wait_untrusted_event_ocall == 0 ) {
if ( h_libsgx_urts == 0 ) _load_libsgx_urts();
*(void **)(&p_sgx_thread_wait_untrusted_event_ocall)= _load_symbol(h_libsgx_urts, "sgx_thread_wait_untrusted_event_ocall", &l_sgx_thread_wait_untrusted_event_ocall);
}
if ( l_sgx_thread_wait_untrusted_event_ocall == -1 ) _undefined_symbol("sgx_thread_wait_untrusted_event_ocall");
return (int) p_sgx_thread_wait_untrusted_event_ocall(self);
}
sgx_status_t sgx_ecall_switchless(const sgx_enclave_id_t eid, const int index, const void *ocall_table, void *ms)
{
if ( l_sgx_ecall_switchless == 0 ) {
if ( h_libsgx_urts == 0 ) _load_libsgx_urts();
*(void **)(&p_sgx_ecall_switchless)= _load_symbol(h_libsgx_urts, "sgx_ecall_switchless", &l_sgx_ecall_switchless);
}
if ( l_sgx_ecall_switchless == -1 ) _undefined_symbol("sgx_ecall_switchless");
return (sgx_status_t) p_sgx_ecall_switchless(eid, index, ocall_table, ms);
}
#ifdef UAE_SERVICE_HAS_BOOL
sgx_status_t sgx_init_quote_ex(const sgx_att_key_id_t *p_att_key_id, sgx_target_info_t *p_qe_target_info, uint8_t refresh_att_key, size_t *p_pub_key_id_size, uint8_t *p_pub_key_id)
#else
sgx_status_t sgx_init_quote_ex(const sgx_att_key_id_t *p_att_key_id, sgx_target_info_t *p_qe_target_info, size_t *p_pub_key_id_size, uint8_t *p_pub_key_id)
#endif
{
if ( l_sgx_init_quote_ex == 0 ) {
if ( h_libsgx_uae_service == 0 ) _load_libsgx_uae_service();
*(void **)(&p_sgx_init_quote_ex)= _load_symbol(h_libsgx_uae_service, "sgx_init_quote_ex", &l_sgx_init_quote_ex);
}
if ( l_sgx_init_quote_ex == -1 ) _undefined_symbol("sgx_init_quote_ex");
#ifdef UAE_SERVICE_HAS_BOOL
return (sgx_status_t) p_sgx_init_quote_ex(p_att_key_id, p_qe_target_info, refresh_att_key, p_pub_key_id_size, p_pub_key_id);
#else
return (sgx_status_t) p_sgx_init_quote_ex(p_att_key_id, p_qe_target_info, p_pub_key_id_size, p_pub_key_id);
#endif
}
sgx_status_t sgx_create_encrypted_enclave(const char *file_name, const int debug, sgx_launch_token_t *launch_token, int *launch_token_updated, sgx_enclave_id_t *enclave_id, sgx_misc_attribute_t *misc_attr, uint8_t *sealed_key)
{
if ( l_sgx_create_encrypted_enclave == 0 ) {
if ( h_libsgx_urts == 0 ) _load_libsgx_urts();
*(void **)(&p_sgx_create_encrypted_enclave)= _load_symbol(h_libsgx_urts, "sgx_create_encrypted_enclave", &l_sgx_create_encrypted_enclave);
}
if ( l_sgx_create_encrypted_enclave == -1 ) _undefined_symbol("sgx_create_encrypted_enclave");
return (sgx_status_t) p_sgx_create_encrypted_enclave(file_name, debug, launch_token, launch_token_updated, enclave_id, misc_attr, sealed_key);
}
int sgx_thread_set_untrusted_event_ocall(const void *waiter)
{
if ( l_sgx_thread_set_untrusted_event_ocall == 0 ) {
if ( h_libsgx_urts == 0 ) _load_libsgx_urts();
*(void **)(&p_sgx_thread_set_untrusted_event_ocall)= _load_symbol(h_libsgx_urts, "sgx_thread_set_untrusted_event_ocall", &l_sgx_thread_set_untrusted_event_ocall);
}
if ( l_sgx_thread_set_untrusted_event_ocall == -1 ) _undefined_symbol("sgx_thread_set_untrusted_event_ocall");
return (int) p_sgx_thread_set_untrusted_event_ocall(waiter);
}
sgx_status_t sgx_get_quote_size_ex(const sgx_att_key_id_t *p_att_key_id, uint32_t *p_quote_size)
{
if ( l_sgx_get_quote_size_ex == 0 ) {
if ( h_libsgx_uae_service == 0 ) _load_libsgx_uae_service();
*(void **)(&p_sgx_get_quote_size_ex)= _load_symbol(h_libsgx_uae_service, "sgx_get_quote_size_ex", &l_sgx_get_quote_size_ex);
}
if ( l_sgx_get_quote_size_ex == -1 ) _undefined_symbol("sgx_get_quote_size_ex");
return (sgx_status_t) p_sgx_get_quote_size_ex(p_att_key_id, p_quote_size);
}
sgx_status_t sgx_ecall(const sgx_enclave_id_t eid, const int index, const void *ocall_table, void *ms)
{
if ( l_sgx_ecall == 0 ) {
......@@ -398,14 +560,26 @@ sgx_status_t sgx_ecall(const sgx_enclave_id_t eid, const int index, const void *
return (sgx_status_t) p_sgx_ecall(eid, index, ocall_table, ms);
}
sgx_status_t sgx_get_quote_size(const uint8_t *p_sig_rl, uint32_t *p_quote_size)
int sgx_thread_set_multiple_untrusted_events_ocall(const void **waiters, size_t total)
{
if ( l_sgx_get_quote_size == 0 ) {
if ( l_sgx_thread_set_multiple_untrusted_events_ocall == 0 ) {
if ( h_libsgx_urts == 0 ) _load_libsgx_urts();
*(void **)(&p_sgx_thread_set_multiple_untrusted_events_ocall)= _load_symbol(h_libsgx_urts, "sgx_thread_set_multiple_untrusted_events_ocall", &l_sgx_thread_set_multiple_untrusted_events_ocall);
}
if ( l_sgx_thread_set_multiple_untrusted_events_ocall == -1 ) _undefined_symbol("sgx_thread_set_multiple_untrusted_events_ocall");
return (int) p_sgx_thread_set_multiple_untrusted_events_ocall(waiters, total);
}
int exchange_report_ocall(uint32_t sid, uint8_t *dh_msg2, uint32_t dh_msg2_size, uint8_t *dh_msg3, uint32_t dh_msg3_size, uint32_t timeout)
{
if ( l_exchange_report_ocall == 0 ) {
if ( h_libsgx_uae_service == 0 ) _load_libsgx_uae_service();
*(void **)(&p_sgx_get_quote_size)= _load_symbol(h_libsgx_uae_service, "sgx_get_quote_size", &l_sgx_get_quote_size);
*(void **)(&p_exchange_report_ocall)= _load_symbol(h_libsgx_uae_service, "exchange_report_ocall", &l_exchange_report_ocall);
}
if ( l_sgx_get_quote_size == -1 ) _undefined_symbol("sgx_get_quote_size");
if ( l_exchange_report_ocall == -1 ) _undefined_symbol("exchange_report_ocall");
return (sgx_status_t) p_sgx_get_quote_size(p_sig_rl, p_quote_size);
return (int) p_exchange_report_ocall(sid, dh_msg2, dh_msg2_size, dh_msg3, dh_msg3_size, timeout);
}
/*
Copyright 2018 Intel Corporation
Copyright 2017 Intel Corporation
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of the copyright holder nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
......@@ -28,7 +22,6 @@ PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef __SGX_STUB_H
#define __SGX_STUB_H
......@@ -39,6 +32,8 @@ extern "C" {
int have_sgx_psw();
void *get_sgx_ufunction(const char *name); /* Returns func pointer */
#ifdef __cplusplus
};
#endif
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment