Skip to content

Commit 6017b36

Browse files
author
Thomas Knauth
committed
Initial commit.
0 parents  commit 6017b36

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+3987
-0
lines changed

.gitignore

+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# -*- mode: gitignore; -*-
2+
*~
3+
\#*\#
4+
/.emacs.desktop
5+
/.emacs.desktop.lock
6+
*.elc
7+
auto-save-list
8+
tramp
9+
.\#*
10+
11+
# Org-mode
12+
.org-id-locations
13+
*_archive
14+
15+
# flymake-mode
16+
*_flymake.*
17+
18+
# eshell files
19+
/eshell/history
20+
/eshell/lastdir
21+
22+
# elpa packages
23+
/elpa/
24+
25+
# reftex files
26+
*.rel
27+
28+
# AUCTeX auto folder
29+
/auto/
30+
31+
# cask packages
32+
.cask/
33+
dist/
34+
35+
# Flycheck
36+
flycheck_*.el
37+
38+
# server auth directory
39+
/server/
40+
41+
# projectiles files
42+
.projectile
43+
44+
# directory configuration
45+
.dir-locals.el
46+
47+
*.o
48+

LICENSE

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
Copyright 2017, Intel(R) Corporation (http://www.intel.com)
2+
3+
Licensed under the Apache License, Version 2.0 (the "License");
4+
you may not use this file except in compliance with the License.
5+
You may obtain a copy of the License at
6+
7+
http://www.apache.org/licenses/LICENSE-2.0
8+
9+
Unless required by applicable law or agreed to in writing, software
10+
distributed under the License is distributed on an "AS IS" BASIS,
11+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
See the License for the specific language governing permissions and
13+
limitations under the License.

Makefile

+109
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
# Makefile to build non-SGX-SDK-based RA-TLS client and server
2+
# programs.
3+
4+
CFLAGS=-std=gnu99 -I. -I/opt/intel/sgxsdk/include -Ideps/local/include -fPIC
5+
CFLAGSERRORS=-Wall -Wextra -Wwrite-strings -Wlogical-op -Wshadow -Werror
6+
CFLAGS+=$(CFLAGSERRORS) -g -O0 -DWOLFSSL_SGX_ATTESTATION -DWOLFSSL_CERT_EXT # -DDEBUG -DDYNAMIC_RSA
7+
CFLAGS+=-DSGX_GROUP_OUT_OF_DATE
8+
LDFLAGS=-Ldeps/local/lib -Lopenssl -static
9+
LDLIBS=-l:libwolfssl.a -l:libm.a -l:libpthread.a -l:libmbedtls.a -l:libmbedx509.a -l:libmbedcrypto.a -lssl -lcrypto
10+
11+
EXECS=mbedtls-ssl-server \
12+
wolfssl-ssl-server \
13+
mbedtls-client \
14+
wolfssl-client \
15+
openssl-client \
16+
deps/wolfssl-examples/SGX_Linux/App
17+
18+
LIBS=libmbedtls-ra-attester.a \
19+
libwolfssl-ra-attester.a \
20+
libnonsdk-ra-attester.a \
21+
libmbedtls-ra-challenger.a \
22+
libwolfssl-ra-challenger.a
23+
24+
all : $(EXECS) $(LIBS)
25+
26+
wolfssl-client : deps/wolfssl-examples/tls/client-tls.c libwolfssl-ra-challenger.a
27+
$(CC) -o $@ $^ $(CFLAGS) $(LDFLAGS) $(LDLIBS)
28+
29+
mbedtls-client : deps/mbedtls/programs/ssl/ssl_client1.c libwolfssl-ra-challenger.a
30+
$(CC) -o $@ $^ $(CFLAGS) $(LDFLAGS) $(LDLIBS)
31+
32+
openssl-client : openssl-client.c libwolfssl-ra-challenger.a
33+
# Cannot use wolfSSL and OpenSSL in the same application. They export functions with identical names (e.g., i2d_X509() )
34+
$(CC) -o $@ $< $(CFLAGS) -Ldeps/local/lib -L. -l:libwolfssl-ra-challenger.a -l:libwolfssl.a -lssl -lcrypto -lm
35+
36+
libmbedtls-ra-challenger.a : mbedtls-ra-challenger.o ra-challenger.o
37+
$(AR) rcs $@ $^
38+
39+
libwolfssl-ra-challenger.a : wolfssl-ra-challenger.o wolfssl-ra.o ra-challenger.o
40+
$(AR) rcs $@ $^
41+
42+
libmbedtls-ra-attester.a : mbedtls-ra-attester.o ias-ra.o
43+
$(AR) rcs $@ $^
44+
45+
libwolfssl-ra-attester.a : wolfssl-ra-attester.o ias-ra.o
46+
$(AR) rcs $@ $^
47+
48+
SGX_GIT=deps/linux-sgx
49+
EPID_SDK=$(SGX_GIT)/external/epid-sdk-3.0.0
50+
51+
CFLAGS+=-I$(SGX_GIT)/common/inc/internal -I$(EPID_SDK) -I$(SGX_GIT)/common/inc
52+
53+
WOLFSSL_RA_ATTESTER_SRC=wolfssl-ra-attester.c wolfssl-ra.c
54+
MBEDTLS_RA_ATTESTER_SRC=mbedtls-ra-attester.c ra-challenger.c
55+
MBEDTLS_RA_CHALLENGER_SRC=mbedtls-ra-challenger.c
56+
NONSDK_RA_ATTESTER_SRC=ias-ra.c nonsdk-ra-attester.c messages.pb-c.c sgx_report.S
57+
58+
messages.pb-c.c messages.pb-c.h :
59+
( cd deps/linux-sgx/psw/ae/common/proto/ ; protoc-c messages.proto --c_out=. )
60+
cp deps/linux-sgx/psw/ae/common/proto/messages.pb-c.c deps/linux-sgx/psw/ae/common/proto/messages.pb-c.h .
61+
62+
libnonsdk-ra-attester.a : mbedtls-ra-attester.o ias-ra.o nonsdk-ra-attester.o messages.pb-c.o sgx_report.o
63+
$(AR) rcs $@ $^
64+
65+
66+
#### HTTPS server based on mbedtls and wolfSSL. Use with Graphene-SGX.
67+
68+
SSL_SERVER_INCLUDES=-I. -I/opt/intel/sgxsdk/include -Ideps/local/include \
69+
-Ideps/linux-sgx/common/inc/internal \
70+
-Ideps/linux-sgx/external/epid-sdk-3.0.0 \
71+
-I$(SGX_GIT)/common/inc
72+
73+
MBEDTLS_SSL_SERVER_SRC=deps/mbedtls/programs/ssl/ssl_server.c \
74+
ra_tls_options.c \
75+
$(MBEDTLS_RA_ATTESTER_SRC) $(MBEDTLS_RA_CHALLENGER_SRC) \
76+
$(NONSDK_RA_ATTESTER_SRC)
77+
MBEDTLS_SSL_SERVER_LIBS=-l:libcurl.a -lcrypto -lprotobuf-c -lssl -l:libmbedx509.a -l:libmbedtls.a -l:libmbedcrypto.a -lz
78+
79+
mbedtls-ssl-server : $(MBEDTLS_SSL_SERVER_SRC) ssl-server.manifest
80+
$(CC) $(MBEDTLS_SSL_SERVER_SRC) -o $@ $(CFLAGSERRORS) $(SSL_SERVER_INCLUDES) -Ldeps/local/lib/ $(MBEDTLS_SSL_SERVER_LIBS)
81+
deps/graphene/Pal/src/host/Linux-SGX/signer/pal-sgx-sign -libpal deps/graphene/Runtime/libpal-Linux-SGX.so -key deps/graphene/Pal/src/host/Linux-SGX/signer/enclave-key.pem -output $@.manifest.sgx -exec $@ -manifest ssl-server.manifest
82+
deps/graphene/Pal/src/host/Linux-SGX/signer/pal-sgx-get-token -output $@.token -sig $@.sig
83+
84+
WOLFSSL_SSL_SERVER_SRC=deps/wolfssl-examples/tls/server-tls.c \
85+
ra_tls_options.c \
86+
$(WOLFSSL_RA_ATTESTER_SRC) \
87+
$(NONSDK_RA_ATTESTER_SRC)
88+
89+
WOLFSSL_SSL_SERVER_LIBS=-l:libcurl.a -l:libwolfssl.a -lcrypto -lprotobuf-c -lssl -lm -lz
90+
91+
wolfssl-ssl-server : $(WOLFSSL_SSL_SERVER_SRC) ssl-server.manifest
92+
$(CC) -o $@ $(CFLAGSERRORS) $(SSL_SERVER_INCLUDES) -Ldeps/local/lib $(WOLFSSL_SSL_SERVER_SRC) $(WOLFSSL_SSL_SERVER_LIBS)
93+
deps/graphene/Pal/src/host/Linux-SGX/signer/pal-sgx-sign -libpal deps/graphene/Runtime/libpal-Linux-SGX.so -key deps/graphene/Pal/src/host/Linux-SGX/signer/enclave-key.pem -output $@.manifest.sgx -exec $@ -manifest ssl-server.manifest
94+
deps/graphene/Pal/src/host/Linux-SGX/signer/pal-sgx-get-token -output $@.token -sig $@.sig
95+
96+
deps/wolfssl-examples/SGX_Linux/App : deps/wolfssl/IDE/LINUX-SGX/libwolfssl.sgx.static.lib.a libsgx_ra_tls_wolfssl.a sgxsdk-ra-attester_u.c ias-ra.c
97+
cp sgxsdk-ra-attester_u.c ias-ra.c deps/wolfssl-examples/SGX_Linux/untrusted
98+
make -C deps/wolfssl-examples/SGX_Linux SGX_MODE=HW SGX_DEBUG=1 SGX_WOLFSSL_LIB=$(shell readlink -f deps/wolfssl/IDE/LINUX-SGX) SGX_SDK=/opt/intel/sgxsdk WOLFSSL_ROOT=$(shell readlink -f deps/wolfssl) SGX_RA_TLS_LIB=$(shell readlink -f .)
99+
100+
README.html : README.md
101+
pandoc --from markdown_github --to html --standalone $< --output $@
102+
103+
clean :
104+
$(RM) *.o
105+
106+
mrproper : clean
107+
$(RM) $(EXECS) $(LIBS)
108+
109+
.PHONY = all clean mrproper

NOTICE

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
Integrating Intel SGX Remote Attestation with Transport Layer Security
2+
Copyright 2017 Intel(R) Corporation
3+
4+
This software was developed at Intel Labs
5+
(https://www.intel.com/intellabs). This software is a research proof
6+
of concept to demonstrate the integration of Intel SGX Remote
7+
Attestation with the Transport Layer Security protocol.
8+
9+
This software not intended for production use.

README.html

+76
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
2+
<html xmlns="http://www.w3.org/1999/xhtml">
3+
<head>
4+
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
5+
<meta http-equiv="Content-Style-Type" content="text/css" />
6+
<meta name="generator" content="pandoc" />
7+
<title></title>
8+
<style type="text/css">code{white-space: pre;}</style>
9+
</head>
10+
<body>
11+
<h1 id="introduction">Introduction</h1>
12+
<p>This project provides a proof-of-concept implementation on how to integrate Intel SGX remote attestation into the TLS connection setup. Conceptually, we extend the standard X.509 certificate with SGX-related information. The additional information allows the receiver of the certificate to verify that it is indeed communicating with an SGX enclave. The accompanying <a href="https://software.intel.com/en-us/sgx/resource-library">white paper</a> &quot;Integrating Remote Attestation with Transport Layer Security&quot; provides more details.</p>
13+
<h2 id="repository-structure">Repository Structure</h2>
14+
<p>The repository includes code to generate and parse extended X.509 certificates. The build system creates the following executables:</p>
15+
<ul>
16+
<li><p>Sample server (attester)</p>
17+
<ul>
18+
<li>using the SGX SDK based on <a href="deps/wolfssl-examples/SGX_Linux">wolfSSL</a></li>
19+
<li>using Graphene-SGX based on <a href="deps/wolfssl-examples/tls/server-tls.c">wolfSSL</a></li>
20+
<li>using Graphene-SGX based on <a href="deps/mbedtls/programs/ssl/ssl_server.c">mbedtls</a></li>
21+
</ul></li>
22+
<li><p>Non-SGX clients (challengers) based on different TLS libraries</p>
23+
<ul>
24+
<li><a href="mbedtls/programs/ssl/ssl_client1.c">mbedtls</a></li>
25+
<li><a href="deps/wolfssl-examples/tls/client-tls.c">wolfSSL</a></li>
26+
<li><a href="openssl-client.c">OpenSSL</a></li>
27+
</ul></li>
28+
</ul>
29+
<p>The code pertaining to the generation and parsing of extended X.509 certificates is located in the project's root directory.</p>
30+
<h2 id="code-structure">Code Structure</h2>
31+
<p>The code is split into two parts: the attester and the challenger. The challenger parses certificates, computes signatures and hashsums. The attester generates keys, certificates and interfaces with SGX. We have implementations based on two different cryptographic libraries: wolfSSL (<a href="wolfssl-ra-challenger.c">challenger</a>, <a href="wolfssl-ra-attester.c">attester</a>) and mbedtls (<a href="mbedtls-ra-challenger.c">challenger</a>, <a href="mbedtls-ra-attester.c">attester</a>).</p>
32+
<p>The attester's code consists of <a href="sgxsdk-ra-attester_t.c">trusted</a> and <a href="sgxsdk-ra-attester_u.c">untrusted</a> SGX-SDK specific code to produce a quote using the SGX SDK. If the SGX SDK is not used, e.g., when using Graphene-SGX, there is code to <a href="nonsdk-ra-attester.c">obtain the SGX quote</a> by directly communicating with the platform's architectural enclave.</p>
33+
<p>Given a quote, there is <a href="ias-ra.c">code to obtain an attestation verification report</a> from the Intel Attestation Service. This code uses libcurl and OpenSSL.</p>
34+
<p><a href="deps/wolfssl-examples/SGX_Linux">An SGX SDK-based server</a> based on wolfSSL demonstrates how to use the <a href="ra-attester.h">public attester API</a>.</p>
35+
<p>We provide three non-SGX clients (<a href="mbedtls-client.c">mbedtls</a>, <a href="wolfssl-client.c">wolfSSL</a>, <a href="openssl-client.c">OpenSSL</a>) to show how seamless remote attestation works with different TLS libraries. They use the public <a href="ra-challenger.h">challenger's API</a>. In principle, the client may also run in an enclave, but we provide no code for this at the moment.</p>
36+
<h1 id="build">Build</h1>
37+
<h2 id="prerequisites">Prerequisites</h2>
38+
<p>The code is tested with the SGX SDK (v2.0), SGX driver (v2.0) and SGX PSW (v2.0) installed on the host. Results may vary with different versions. Follow the <a href="https://01.org/intel-software-guard-extensions/downloads">official instructions</a> to install the components and ensure they are working as intended. For Graphene-SGX, follow <a href="https://github.com/oscarlab/graphene/wiki/SGX-Quick-Start">their instructions</a> to build and load the graphene-sgx kernel module.</p>
39+
<p><a href="https://software.intel.com/formfill/sgx-onboarding">Register a (self-signed) certificate</a> to be able to connect to Intel's Attestation Service (IAS). The registration process will also assign you a software provider ID (SPID). It is recommended to store the private key and certificate in the file ias-client-key.pem and ias-client-cert.pem in the project's root directory. Otherwise, the paths in ra_tls_options.c and ssl-server.manifest must be updated accordingly.</p>
40+
<p>In any case, you must update the SPID in <a href="ra_tls_options.c" class="uri">ra_tls_options.c</a> after registering with Intel.</p>
41+
<p><a href="build.sh">The tooling supports</a> building in your current environment and in a bare-bones container from scratch. The container install assumes you are executing as root and installs all necessary Ubuntu packages (tested with Ubuntu 16.04), the SGX SDK and SGX PSW, besides compiling the project dependencies and sources.</p>
42+
<p>Invoking build.sh without arguments builds for the current environment; with arguments (any) the script does a &quot;container build&quot;. The <a href="container-build.sh" class="uri">container-build.sh</a> script kicks off a container build based on the current checkout. You may want to change the proxy settings in the script to match your environment.</p>
43+
<h2 id="current-environment">Current Environment</h2>
44+
<p>This assumes you have all the dependencies etc (C/C++ toolchain, cmake, ...) installed. If in doubt, look into the <a href="build.sh">build script</a> which packages the container build installs. Install them manually.</p>
45+
<p>Build with</p>
46+
<pre><code> ./build.sh</code></pre>
47+
<h2 id="in-a-docker-container">In a Docker container</h2>
48+
<p>To run the examples in a container, a working installation of the SGX SDK and Graphene-SGX are required on the host. In particular, the container needs access to</p>
49+
<pre><code>- /dev/isgx (SGX SDK)
50+
- /var/run/aesmd (SGX SDK)
51+
- /dev/gsgx (Graphene-SGX)</code></pre>
52+
<p>We pass these devices/directories through to the container.</p>
53+
<p>Start the container and map the SGX device and AESM socket into the container. We also map the project's source as read-only into the container.</p>
54+
<pre><code> docker run --device=/dev/isgx --device=/dev/gsgx -v /var/run/aesmd:/var/run/aesmd -v[project root]:/root/project-ro:ro -it ubuntu:16.04 bash
55+
</code></pre>
56+
<p>In the container, copy the project sources to a new directory with read/write permissisons and kick off the build process.</p>
57+
<pre><code> cd ; cp -a ~/project-ro/ ~/project-rw ; cd ~/project-rw ; bash ./build.sh container</code></pre>
58+
<h1 id="run">Run</h1>
59+
<h2 id="the-sgx-sdk-server">The SGX SDK server</h2>
60+
<p>To start the wolfSSL-based SGX server run.</p>
61+
<pre><code> ( cd deps/wolfssl-examples/SGX_Linux ; ./App -s )</code></pre>
62+
<p>With the server up and running, execute any of the <a href="#the-clients">clients</a>. If you are running in a container, you can get a 2nd console as follows.</p>
63+
<pre><code> docker ps</code></pre>
64+
<p>Use the container's ID with the following command for a 2nd console.</p>
65+
<pre><code> docker exec -ti --user root [container id] bash</code></pre>
66+
<h2 id="the-graphene-sgx-server">The Graphene-SGX server</h2>
67+
<p>First, start an socat instance to make AESM's named Unix socket accessible over TCP/IP.</p>
68+
<pre><code> socat -t10 TCP-LISTEN:1234,bind=127.0.0.1,reuseaddr,fork,range=127.0.0.0/8 UNIX-CLIENT:/var/run/aesmd/aesm.socket &amp;</code></pre>
69+
<p>Next, start the server application on Graphene-SGX</p>
70+
<pre><code> SGX=1 ./deps/graphene/Runtime/pal_loader ./[binary]</code></pre>
71+
<p>where [binary] can be either mbedtls-ssl-server or wolfssl-ssl-server.</p>
72+
<h2 id="the-clients">The clients</h2>
73+
<p>Execute any one of ./[wolfssl|mbedtls|openssl]-client in the project's root directory.</p>
74+
<p>Each client outputs a bunch of connection-related information, such as the server's SGX identity (MRENCLAVE, MRSIGNER). You can cross-check this with what the server reports in his output.</p>
75+
</body>
76+
</html>

0 commit comments

Comments
 (0)