Added files

parent ae6b1a1a
[submodule "libff"]
path = libff
url = https://github.com/skalenetwork/libff.git
EnclaveGmpTest.o: EnclaveGmpTest.c EnclaveGmpTest_t.h \
/opt/intel/sgxsdk/include/tlibc/stdint.h \
/opt/intel/sgxsdk/include/tlibc/sys/stdint.h \
/opt/intel/sgxsdk/include/tlibc/sys/cdefs.h \
/opt/intel/sgxsdk/include/tlibc/sys/_types.h \
/opt/intel/sgxsdk/include/tlibc/wchar.h \
/opt/intel/sgxsdk/include/tlibc/stddef.h \
/opt/intel/sgxsdk/include/sgx_edger8r.h \
/opt/intel/sgxsdk/include/sgx_defs.h \
/opt/intel/sgxsdk/include/sgx_error.h \
/opt/intel/sgxsdk/include/sgx_eid.h /opt/gmp/6.1.2/include/sgx_tgmp.h \
/opt/intel/sgxsdk/include/tlibc/limits.h \
/opt/intel/sgxsdk/include/tlibc/sys/limits.h \
/opt/intel/sgxsdk/include/tlibc/stdlib.h \
/opt/intel/sgxsdk/include/sgx_trts.h \
/opt/intel/sgxsdk/include/tlibc/math.h \
/opt/intel/sgxsdk/include/tlibc/float.h
EnclaveGmpTest_t.h:
/opt/intel/sgxsdk/include/tlibc/stdint.h:
/opt/intel/sgxsdk/include/tlibc/sys/stdint.h:
/opt/intel/sgxsdk/include/tlibc/sys/cdefs.h:
/opt/intel/sgxsdk/include/tlibc/sys/_types.h:
/opt/intel/sgxsdk/include/tlibc/wchar.h:
/opt/intel/sgxsdk/include/tlibc/stddef.h:
/opt/intel/sgxsdk/include/sgx_edger8r.h:
/opt/intel/sgxsdk/include/sgx_defs.h:
/opt/intel/sgxsdk/include/sgx_error.h:
/opt/intel/sgxsdk/include/sgx_eid.h:
/opt/gmp/6.1.2/include/sgx_tgmp.h:
/opt/intel/sgxsdk/include/tlibc/limits.h:
/opt/intel/sgxsdk/include/tlibc/sys/limits.h:
/opt/intel/sgxsdk/include/tlibc/stdlib.h:
/opt/intel/sgxsdk/include/sgx_trts.h:
/opt/intel/sgxsdk/include/tlibc/math.h:
/opt/intel/sgxsdk/include/tlibc/float.h:
EnclaveGmpTest_t.o: EnclaveGmpTest_t.c EnclaveGmpTest_t.h \
/opt/intel/sgxsdk/include/tlibc/stdint.h \
/opt/intel/sgxsdk/include/tlibc/sys/stdint.h \
/opt/intel/sgxsdk/include/tlibc/sys/cdefs.h \
/opt/intel/sgxsdk/include/tlibc/sys/_types.h \
/opt/intel/sgxsdk/include/tlibc/wchar.h \
/opt/intel/sgxsdk/include/tlibc/stddef.h \
/opt/intel/sgxsdk/include/sgx_edger8r.h \
/opt/intel/sgxsdk/include/sgx_defs.h \
/opt/intel/sgxsdk/include/sgx_error.h \
/opt/intel/sgxsdk/include/sgx_eid.h /opt/gmp/6.1.2/include/sgx_tgmp.h \
/opt/intel/sgxsdk/include/tlibc/limits.h \
/opt/intel/sgxsdk/include/tlibc/sys/limits.h \
/opt/intel/sgxsdk/include/tlibc/stdlib.h \
/opt/intel/sgxsdk/include/sgx_trts.h \
/opt/intel/sgxsdk/include/sgx_lfence.h \
/opt/intel/sgxsdk/include/tlibc/errno.h \
/opt/intel/sgxsdk/include/tlibc/mbusafecrt.h \
/opt/intel/sgxsdk/include/tlibc/string.h \
/opt/intel/sgxsdk/include/tlibc/stdarg.h
EnclaveGmpTest_t.h:
/opt/intel/sgxsdk/include/tlibc/stdint.h:
/opt/intel/sgxsdk/include/tlibc/sys/stdint.h:
/opt/intel/sgxsdk/include/tlibc/sys/cdefs.h:
/opt/intel/sgxsdk/include/tlibc/sys/_types.h:
/opt/intel/sgxsdk/include/tlibc/wchar.h:
/opt/intel/sgxsdk/include/tlibc/stddef.h:
/opt/intel/sgxsdk/include/sgx_edger8r.h:
/opt/intel/sgxsdk/include/sgx_defs.h:
/opt/intel/sgxsdk/include/sgx_error.h:
/opt/intel/sgxsdk/include/sgx_eid.h:
/opt/gmp/6.1.2/include/sgx_tgmp.h:
/opt/intel/sgxsdk/include/tlibc/limits.h:
/opt/intel/sgxsdk/include/tlibc/sys/limits.h:
/opt/intel/sgxsdk/include/tlibc/stdlib.h:
/opt/intel/sgxsdk/include/sgx_trts.h:
/opt/intel/sgxsdk/include/sgx_lfence.h:
/opt/intel/sgxsdk/include/tlibc/errno.h:
/opt/intel/sgxsdk/include/tlibc/mbusafecrt.h:
/opt/intel/sgxsdk/include/tlibc/string.h:
/opt/intel/sgxsdk/include/tlibc/stdarg.h:
/*
Copyright 2018 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
PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
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.
*/
#include "EnclaveGmpTest_t.h"
#include <sgx_tgmp.h>
#include <sgx_trts.h>
#include <math.h>
void *(*gmp_realloc_func)(void *, size_t, size_t);
void *(*oc_realloc_func)(void *, size_t, size_t);
void (*gmp_free_func)(void *, size_t);
void (*oc_free_func)(void *, size_t);
void *reallocate_function(void *, size_t, size_t);
void free_function(void *, size_t);
void e_calc_pi (mpf_t *pi, uint64_t digits);
void tgmp_init()
{
oc_realloc_func= &reallocate_function;
oc_free_func= &free_function;
mp_get_memory_functions(NULL, &gmp_realloc_func, &gmp_free_func);
mp_set_memory_functions(NULL, oc_realloc_func, oc_free_func);
}
void free_function (void *ptr, size_t sz)
{
if ( sgx_is_within_enclave(ptr, sz) ) gmp_free_func(ptr, sz);
else {
sgx_status_t status;
status= oc_free(ptr, sz);
if ( status != SGX_SUCCESS ) abort();
}
}
void *reallocate_function (void *ptr, size_t osize, size_t nsize)
{
uint64_t nptr;
sgx_status_t status;
if ( sgx_is_within_enclave(ptr, osize) ) {
return gmp_realloc_func(ptr, osize, nsize);
}
status= oc_realloc(&nptr, ptr, osize, nsize);
if ( status != SGX_SUCCESS ) abort();
/*
* If the entire range of allocated memory is not outside the enclave
* then something truly terrible has happened. In theory, we could
* free() and try again, but would you trust the OS at this point?
*/
if ( ! sgx_is_outside_enclave((void *) ptr, nsize) ) abort();
return (void *) nptr;
}
void e_mpz_add(mpz_t *c_un, mpz_t *a_un, mpz_t *b_un)
{
mpz_t a, b, c;
/*
* Marshal untrusted values into the enclave so we don't accidentally
* leak secrets to untrusted memory.
*
* This is overkill for the trivial example in this function, but
* it's best to develop good coding habits.
*/
mpz_inits(a, b, c, NULL);
mpz_set(a, *a_un);
mpz_set(b, *b_un);
mpz_add(c, a, b);
/* Marshal our result out of the enclave */
mpz_set(*c_un, c);
}
void e_mpz_mul(mpz_t *c_un, mpz_t *a_un, mpz_t *b_un)
{
mpz_t a, b, c;
/* Marshal untrusted values into the enclave. */
mpz_inits(a, b, c, NULL);
mpz_set(a, *a_un);
mpz_set(b, *b_un);
mpz_mul(c, a, b);
/* Marshal our result out of the enclave. */
mpz_set(*c_un, c);
}
void e_mpz_div(mpz_t *c_un, mpz_t *a_un, mpz_t *b_un)
{
mpz_t a, b, c;
/* Marshal untrusted values into the enclave */
mpz_inits(a, b, c, NULL);
mpz_set(a, *a_un);
mpz_set(b, *b_un);
mpz_div(c, a, b);
/* Marshal our result out of the enclave */
mpz_set(*c_un, c);
}
void e_mpf_div(mpf_t *c_un, mpf_t *a_un, mpf_t *b_un)
{
mpf_t a, b, c;
/* Marshal untrusted values into the enclave */
mpf_inits(a, b, c, NULL);
mpf_set(a, *a_un);
mpf_set(b, *b_un);
mpf_div(c, a, b);
/* Marshal our result out of the enclave */
mpf_set(*c_un, c);
}
/* Use the Chudnovsky equation to rapidly estimate pi */
#define DIGITS_PER_ITERATION 14.1816 /* Roughly */
mpz_t c3, c4, c5;
int pi_init= 0;
void e_pi (mpf_t *pi_un, uint64_t digits)
{
mpf_t pi;
/*
* Perform our operations on a variable that's located in the enclave,
* then marshal the final value out of the enclave.
*/
mpf_init(pi);
e_calc_pi(&pi, digits);
/* Marshal our result to untrusted memory */
mpf_set_prec(*pi_un, mpf_get_prec(pi));
mpf_set(*pi_un, pi);
}
void e_calc_pi (mpf_t *pi, uint64_t digits)
{
uint64_t k, n;
mp_bitcnt_t precision;
static double bits= log2(10);
mpz_t kf, kf3, threekf, sixkf, z1, z2, c4k, c5_3k;
mpf_t C, sum, div, f2;
n= (digits/DIGITS_PER_ITERATION)+1;
precision= (digits * bits)+1;
mpf_set_default_prec(precision);
/* Re-initialize the pi variable to use our new precision */
mpf_set_prec(*pi, precision);
/*
426880 sqrt(10005) inf (6k)! (13591409+545140134k)
------------------- = SUM ---------------------------
pi k=0 (3k)!(k!)^3(-640320)^3k
C / pi = SUM (6k)! * (c3 + c4*k) / (3k)!(k!)^3(c5)^3k
C / pi = SUM f1 / f2
pi = C / sum
*/
mpz_inits(sixkf, z1, z2, kf, kf3, threekf, c4k, c5_3k, NULL);
mpf_inits(C, sum, div, f2, NULL);
/* Calculate 'C' */
mpf_sqrt_ui(C, 10005);
mpf_mul_ui(C, C, 426880);
if ( ! pi_init ) {
/* Constants needed in 'sum'. */
mpz_inits(c3, c4, c5, NULL);
mpz_set_ui(c3, 13591409);
mpz_set_ui(c4, 545140134);
mpz_set_si(c5, -640320);
pi_init= 1;
}
mpf_set_ui(sum, 0);
for (k= 0; k< n; ++k) {
/* Numerator */
mpz_fac_ui(sixkf, 6*k);
mpz_mul_ui(c4k, c4, k);
mpz_add(c4k, c4k, c3);
mpz_mul(z1, c4k, sixkf);
mpf_set_z(div, z1);
/* Denominator */
mpz_fac_ui(threekf, 3*k);
mpz_fac_ui(kf, k);
mpz_pow_ui(kf3, kf, 3);
mpz_mul(z2, threekf, kf3);
mpz_pow_ui(c5_3k, c5, 3*k);
mpz_mul(z2, z2, c5_3k);
/* Divison */
mpf_set_z(f2, z2);
mpf_div(div, div, f2);
/* Sum */
mpf_add(sum, sum, div);
}
mpf_div(*pi, C, sum);
mpf_clears(div, sum, f2, NULL);
}
<EnclaveConfiguration>
<ProdID>0</ProdID>
<ISVSVN>0</ISVSVN>
<StackMaxSize>0x100000</StackMaxSize>
<HeapMaxSize>0x1000000</HeapMaxSize>
<TCSNum>1</TCSNum>
<TCSPolicy>1</TCSPolicy>
<!-- Recommend changing 'DisableDebug' to 1 to make the enclave undebuggable for enclave release -->
<DisableDebug>0</DisableDebug>
<MiscSelect>0</MiscSelect>
<MiscMask>0xFFFFFFFF</MiscMask>
</EnclaveConfiguration>
enclave {
trusted {
include "sgx_tgmp.h"
public void tgmp_init();
public void e_mpz_add(
[user_check] mpz_t *c, [user_check] mpz_t *a, [user_check] mpz_t *b
);
public void e_mpz_mul(
[user_check] mpz_t *c, [user_check] mpz_t *a, [user_check] mpz_t *b
);
public void e_mpz_div(
[user_check] mpz_t *c, [user_check] mpz_t *a, [user_check] mpz_t *b
);
public void e_mpf_div(
[user_check] mpf_t *c, [user_check] mpf_t *a, [user_check] mpf_t *b
);
public void e_pi ([user_check] mpf_t *pi, uint64_t digits);
};
untrusted {
include "gmp.h"
uint64_t oc_realloc([user_check] void *optr, size_t osz, size_t nsz);
void oc_free([user_check] void *optr, size_t sz);
};
};
-----BEGIN RSA PRIVATE KEY-----
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
-----END RSA PRIVATE KEY-----
This diff is collapsed.
## This line must come first when building an Intel SGX enclave.
include $(top_srcdir)/build-aux/sgx_enclave.am
## It sets the following Automake variables:
##
## EXEEXT=.so
## AM_CPPFLAGS = -I$(SGXSDK_INCDIR)
## AM_LDFLAGS = -L$(SGXSDK_LIBDIR)
## libexec_PROGRAMS = $(ENCLAVE)
## CLEANFILES = $(ENCLAVE).signed.so
##
## and places required compiler flags in:
##
## AM_CFLAGS
## AM_CXXFLAGS
##
## It adds a pattern rule for building proxy functions from EDL files:
##
## %_u.h %_u.c: %.edl
##
## And creates build targets for a signed enclave, generating a
## temporary private signing key, and a basic enclave config file:
##
## $(ENCLAVE_CONFIG):
## $(ENCLAVE_KEY):
## $(ENCLAVE).signed$(EXEEXT): $(ENCLAVE)$(EXEEXT)
##
## And sets these Makefile variables:
##
## SGXSDK
## SGXSDK_BINDIR
## SGXSDK_INCDIR
## SGXSDK_LIBDIR
## SGXSSL
## SGXSSL_BINDIR
## SGXSSL_INCDIR
## SGXSSL_LIBDIR
## SGX_TRTS_LIB
## SGX_TSERVICE_LIB
## SGX_EDGER8R
## SGX_SIGN
## The name of your enclave, enclave config file, and private key
## file go in these variables. The ENCLAVE variable creates the
## following automake target defn:
##
## libexec_PROGRAMS=$(ENCLAVE)
ENCLAVE=EnclaveGmpTest
ENCLAVE_CONFIG=$(ENCLAVE).config.xml
ENCLAVE_KEY=$(ENCLAVE)_private.pem
## Provide additional flags to sgx_sign when signing the enclave.
## This is almost never necessary. If you don't know if you need
## this, you probably don't.
## SGX_SIGN_FLAGS =
## Additional Automake flags needed to build the enclave.
##
AM_CPPFLAGS += $(TGMP_CPPFLAGS)
AM_CXXFLAGS += -fno-builtin
## Additional files to remove with 'make clean'. This list needs
## to include your edger8r genreated files.
CLEANFILES+= EnclaveGmpTest_t.c EnclaveGmpTest_t.h
## Supply additional flags to edger8r here.
##
## SGX_EDGER8R_FLAGS=
## Put your sources here. Don't forget to list the _t.c and _t.h
## files. You can't use the $(ENCLAVE) variable in the build
## target name (i.e., $(ENCLAVE)_SOURCES will not work).
EnclaveGmpTest_SOURCES = EnclaveGmpTest_t.c EnclaveGmpTest_t.h \
EnclaveGmpTest.c $(ENCLAVE_KEY) $(ENCLAVE_CONFIG)
## Add additional linker flags to AM_LDFLAGS here. Don't put
## libraries flags here (see below).
##
## Be sure to use += to add to, and not replace, the default
## AM_LDFLAGS.
AM_LDFLAGS += $(TGMP_LDFLAGS)
## This line is REQUIRED. It can't be generically defined for
## automake, so you must specify it for your enclave. Note that you
## can't say $(ENCLAVE)_LDADD here: you must spell out the enclave name.
## If you add flags to it, you MUST include @SGX_ENCLAVE_LDADD@ as part
## of the definition to make sure you pick up the right linker flags
## and SGX trusted libraries.
EnclaveGmpTest_LDADD = @SGX_ENCLAVE_LDADD@
## Place any additional trusted libraries that your enclave may need in
## SGX_EXTRA_TLIBS. This will ensure they get place inside the
## --startgroup and --endgroup flags. (This would be where you'd add
## SGXSSL libraries, and your trusted c++ library
SGX_EXTRA_TLIBS=-lsgx_tgmp
## This line is OPTIONAL, and comes with a WARNING.
##
## In general, you shouldn't need to use the program-specific LDFLAGS
## instead of AM_LDFLAGS. But, if you need to, then you'll need to ensure
## @SGX_ENCLAVE_LDFLAGS@ is included in the definition as this will
## override AM_LDFLAGS.
##
## EnclaveGmpTest_LDFLAGS = @SGX_ENCLAVE_LDFLAGS@
##
This diff is collapsed.
Copyright 2018 Intel Corp.
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 PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
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.
This diff is collapsed.
## This must come first when building an application that uses Intel
## SGX enclaves.
include $(top_srcdir)/build-aux/sgx_app.am
## It sets the following automake variables:
##
## AM_CPPFLAGS = -I$(SGXSDK_INCDIR)
## AM_LDFLAGS = -L$(SGXSDK_LIBDIR)
##
## And a pattern rule for building proxy functions from EDL files:
##
## %_u.h %_u.c: %.edl
##
## And sets these Makefile variables:
##
## SGXSDK
## SGXSDK_BINDIR
## SGXSDK_INCDIR
## SGXSDK_LIBDIR
## SGXSSL
## SGXSSL_BINDIR
## SGXSSL_INCDIR
## SGXSSL_LIBDIR
## SGX_URTS_LIB
## SGX_UAE_SERVICE_LIB
## SGX_EDGER8R
SUBDIRS=EnclaveGmpTest
## Supply additional flags to edger8r here.
##
## SGX_EDGER8R_FLAGS=
## Needed to make our pattern rule work.
EnclaveGmpTest.edl: EnclaveGmpTest/EnclaveGmpTest.edl
ln -s $?
## Additional automake variables
##
## AM_CPPFLAGS +=
## AM_CFLAGS =
## AM_CXXFLAGS =
AM_CPPFLAGS += -DSKALE_SGX=1 -IlibBLS -IlibBLS/libff -fno-builtin-memset $(GMP_CPPFLAGS)
## Additional targets to remove with 'make clean'. You must list
## any edger8r generated files here.
CLEANFILES = $(COMMON_ENCLAVE_SRC) EnclaveGmpTest.edl \
EnclaveGmpTest.signed.so
## The build target
bin_PROGRAMS = sgxgmpmath sgxgmppi
## You can't use $(wildcard ...) with automake so all source files
## have to be explicitly listed.
COMMON_SRC = sgx_stub.c sgx_detect_linux.c create_enclave.c oc_alloc.c
COMMON_ENCLAVE_SRC = EnclaveGmpTest_u.c EnclaveGmpTest_u.h \
libBLS/bls/BLSPrivateKey.cpp \
libBLS/bls/BLSSignature.cpp \
libBLS/bls/BLSutils.cpp \
libBLS/libff/libff/algebra/curves/alt_bn128/alt_bn128_init.cpp \
libBLS/libff/libff/algebra/curves/alt_bn128/alt_bn128_g1.cpp \
libBLS/libff/libff/algebra/curves/alt_bn128/alt_bn128_g2.cpp
sgxgmpmath_SOURCES = sgxgmpmath.c $(COMMON_SRC)
nodist_sgxgmpmath_SOURCES = $(COMMON_ENCLAVE_SRC)
EXTRA_sgxgmpmath_DEPENDENCIES = EnclaveGmpTest.signed.so
sgxgmppi_SOURCES = sgxgmppi.c $(COMMON_SRC)
nodist_sgxgmppi_SOURCES = $(COMMON_ENCLAVE_SRC)
EXTRA_sgxgmppi_DEPENDENCIES = EnclaveGmpTest.signed.so
BUILT_SOURCES = $(COMMON_ENCLAVE_SRC)
AM_LDFLAGS += $(GMP_LDFLAGS)
EnclaveGmpTest.signed.so: EnclaveGmpTest/EnclaveGmpTest.signed.so
ln -s $?
## Library flags. At minimum, an Intel SGX application will need:
##
## -l$(SGX_URTS_LIB)
##
## Applications that use platform services or perform attestation
## will also need:
##
## -l$(SGX_UA_SERVICE_LIB)
##
## Use the variables, not the actual library names to ensure these
## targets work on simulation builds.
sgxgmpmath_LDADD=-l$(SGX_URTS_LIB) -lgmp -ldl -l:libsgx_capable.a -lpthread
sgxgmppi_LDADD=-l$(SGX_URTS_LIB) -lgmp -ldl -l:libsgx_capable.a -lpthread
This diff is collapsed.
This diff is collapsed.
#! /bin/sh
aclocal && \
automake --add-missing && \
autoconf
## Intel SGX SDK
SGXSDK=@SGXSDK@
SGXSDK_BINDIR=@SGXSDK_BINDIR@
SGXSDK_INCDIR=@SGXSDK_INCDIR@
SGXSDK_LIBDIR=@SGXSDK_LIBDIR@
SGX_EDGER8R=$(SGXSDK_BINDIR)/sgx_edger8r
## Intel SGX SSL
SGXSSL=@SGXSSL@
SGXSSL_BINDIR=@SGXSSL_BINDIR@
SGXSSL_INCDIR=@SGXSSL_INCDIR@
SGXSSL_LIBDIR=@SGXSSL_LIBDIR@
if SGX_ENABLED
## All Intel SGX applications need at least these flags
AM_CPPFLAGS = -I$(SGXSDK_INCDIR)
AM_LDFLAGS = -L$(SGXSDK_LIBDIR)
else
AM_CPPFLAGS =
AM_LDFLAGS =
endif
## These libraries exist in both hardware and simulation (_sim) form,
## so they need to be listed as Makefile variables.
SGX_URTS_LIB=@SGX_URTS_LIB@
SGX_UAE_SERVICE_LIB=@SGX_UAE_SERVICE_LIB@
## Rule to generate untrusted proxy functions from an EDL file.
if SGX_ENABLED
%_u.h %_u.c: %.edl
$(SGX_EDGER8R) --search-path $(SGXSDK_INCDIR) $(SGX_EDGER8R_FLAGS) --untrusted $<
endif
## Intel SGX SDK
SGXSDK=@SGXSDK@
SGXSDK_BINDIR=@SGXSDK_BINDIR@
SGXSDK_INCDIR=@SGXSDK_INCDIR@
SGXSDK_LIBDIR=@SGXSDK_LIBDIR@
SGX_EDGER8R=$(SGXSDK_BINDIR)/sgx_edger8r
SGX_SIGN=$(SGXSDK_BINDIR)/sgx_sign
## Intel SGX SSL
SGXSSL=@SGXSSL@
SGXSSL_BINDIR=@SGXSSL_BINDIR@
SGXSSL_INCDIR=@SGXSSL_INCDIR@
SGXSSL_LIBDIR=@SGXSSL_LIBDIR@
## Required flags for compiling and linking an Intel SGX enclave.
AM_CFLAGS=@SGX_ENCLAVE_CFLAGS@
AM_CPPFLAGS=@SGX_ENCLAVE_CPPFLAGS@
AM_CXXFLAGS=@SGX_ENCLAVE_CXXFLAGS@ @SGX_ENCLAVE_CFLAGS@
AM_LDFLAGS=@SGX_ENCLAVE_LDFLAGS@
## Trusted libraries. These exist in both hardware and simulation (_sim)
## form, so they need to be Makefile variables.
SGX_TRTS_LIB=@SGX_TRTS_LIB@
SGX_TSERVICE_LIB=@SGX_TSERVICE_LIB@
## Automake doesn't support creating shared libraries directly without
## forcing you to use libtool, and libtool is not an apprpriate tool
## for building an Intel SGX enclave. Automake also recognizes .so as
## shared library extension and complains if you try and use it.
##
## The solution is to use Automake's EXEEXT feature to append the
## .so extension, and build the enclave as if it were a program.
## This template assumes a libexec instead of bin target, which
## probably makes more sense anyway.
EXEEXT=.so
libexec_PROGRAMS = $(ENCLAVE)
## Add the signed enclave ot the list of files to be cleaned.
CLEANFILES = $(ENCLAVE).signed.so
## Rule to make trusted proxy functions from an EDL file.
%_t.h %_t.c: %.edl
$(SGX_EDGER8R) --search-path $(SGXSDK_INCDIR) $(SGX_EDGER8R_FLAGS) --trusted $<
## When building a debug enclave, go ahead and sign directly using the
## supplied private key.
##
## In release mode, don't sign the enclave: instead, print a message
## to aid the developer through the two-step signing process.
if ENCLAVE_RELEASE_SIGN
libexec_PROGRAMS += signed_enclave_rel
## This is a hack.
nodist_signed_enclave_rel_SOURCES= signed_enclave_rel.c
.PHONY: signed_enclave_rel
else
## This is the same hack.
libexec_PROGRAMS += signed_enclave_debug
nodist_signed_enclave_debug_SOURCES= signed_enclave_debug.c
.PHONY: signed_enclave_debug
endif
signed_enclave_debug$(EXEEXT): $(ENCLAVE).signed$(EXEEXT)
$(ENCLAVE).signed$(EXEEXT): $(ENCLAVE)$(EXEEXT) $(ENCLAVE_CONFIG)
$(SGX_SIGN) sign $(SGX_SIGN_FLAGS) -key $(ENCLAVE_KEY) -enclave $(ENCLAVE).so -out $(ENCLAVE).signed.so -config $(ENCLAVE_CONFIG)
signed_enclave_rel$(EXEEXT):
@echo "--------------------------------------------------------------"
@echo "The project has been built in release hardware mode."
@echo "Please sign $(ENCLAVE).so with your signing key "
@echo "before you run the application to launch and access "
@echo "the enclave."
@echo
@echo "To sign the enclave use the command:"
@echo " $(SGX_SIGN) sign $(SGX_SIGN_FLAGS) -key <your_key> -enclave $(ENCLAVE).so -out $(ENCLAVE).signed.so -config $(ENCLAVE_CONFIG)"
@echo "You can also sign the enclave using an external signing tool."
@echo "--------------------------------------------------------------"
## A convenience target for randomly generating a debug signing key.
$(ENCLAVE_KEY):
@echo "Creating random private key file for testing and"
@echo "debugging purposes:"
@echo "$(ENCLAVE_PKEY)"
openssl genrsa -3 -out $@ 3072
## A convenience target for building a basic enclave configuration file.
$(ENCLAVE_CONFIG):
@echo "Creating default enclave configuration file:"
@echo "$(ENCLAVE_CFG)"
@echo "<EnclaveConfiguration>">$(ENCLAVE).config.xml
@echo " <ProdID>0</ProdID>">>$(ENCLAVE).config.xml
@echo " <ISVSVN>0</ISVSVN>">>$(ENCLAVE).config.xml
@echo " <StackMaxSize>0x40000</StackMaxSize>">>$(ENCLAVE).config.xml
@echo " <HeapMaxSize>0x100000</HeapMaxSize>">>$(ENCLAVE).config.xml
@echo " <TCSNum>1</TCSNum>">>$(ENCLAVE).config.xml
@echo " <TCSPolicy>1</TCSPolicy>">>$(ENCLAVE).config.xml
@echo " <!-- Recommend changing 'DisableDebug' to 1 to make the enclave undebuggable for enclave release -->">>$(ENCLAVE).config.xml
@echo " <DisableDebug>0</DisableDebug>">>$(ENCLAVE).config.xml
@echo " <MiscSelect>0</MiscSelect>">>$(ENCLAVE).config.xml
@echo " <MiscMask>0xFFFFFFFF</MiscMask>">>$(ENCLAVE).config.xml
@echo " </EnclaveConfiguration>">>$(ENCLAVE).config.xml
@echo ""
## Intel SGX SDK
SGXSDK=@SGXSDK@
SGXSDK_BINDIR=@SGXSDK_BINDIR@
SGXSDK_INCDIR=@SGXSDK_INCDIR@
SGXSDK_LIBDIR=@SGXSDK_LIBDIR@
SGX_EDGER8R=$(SGXSDK_BINDIR)/sgx_edger8r
## Intel SGX SSL
SGXSSL=@SGXSSL@
SGXSSL_BINDIR=@SGXSSL_BINDIR@
SGXSSL_INCDIR=@SGXSSL_INCDIR@
SGXSSL_LIBDIR=@SGXSSL_LIBDIR@
## Flags required when compiling a trusted library.
AM_CFLAGS=@SGX_TLIB_CFLAGS@
AM_CPPFLAGS=@SGX_TLIB_CPPFLAGS@
AM_CXXFLAGS=@SGX_TLIB_CXXFLAGS@
## Rule to make trusted proxy functions from an EDL file.
%_t.h %_t.c: %.edl
$(SGX_EDGER8R) --search-path $(SGXSDK_INCDIR) $(SGX_EDGER8R_FLAGS) --trusted $<
/usr/share/automake-1.15/compile
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
AC_INIT([SGX GMP Test], 1.0, [john.p.mechalas@intel.com])
AC_CONFIG_MACRO_DIRS([m4])
AM_INIT_AUTOMAKE([foreign])
AC_PROG_CC
AC_PROG_CXX
AC_PROG_CPP
AM_PROG_CC_C_O
SGX_INIT()
gmpdir=
tgmpdir=
AC_ARG_WITH([gmpdir],
AC_HELP_STRING([--with-gmpdir=PATH], [specify the libgmp directory]),
gmpdir=$withval
)
AC_ARG_WITH([trusted-gmpdir],
AC_HELP_STRING([--with-trusted-gmpdir=PATH], [the trusted libgmp directory (default: gmp directory)]),
tgmpdir=$withval,
tgmpdir=$gmpdir
)
AS_IF([test "$gmpdir" != ""], [
AC_SUBST([GMP_CPPFLAGS], [-I$gmpdir/include])
AC_SUBST([GMP_LDFLAGS], [-L$gmpdir/lib])
])
AS_IF([test "$tgmpdir" != ""], [
AC_SUBST([TGMP_CPPFLAGS], [-I$tgmpdir/include])
AC_SUBST([TGMP_LDFLAGS], [-L$tgmpdir/lib])
])
AC_CONFIG_FILES([Makefile EnclaveGmpTest/Makefile])
AC_OUTPUT()
/*
Copyright 2018 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
PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
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.
*/
#include "create_enclave.h"
#include "sgx_stub.h"
#include <limits.h>
#include <stdio.h>
#include <sgx_urts.h>
#include <sys/stat.h>
#include <stdlib.h>
#include <string.h>
#define MAX_LEN 80
#ifdef __x86_64__
#define DEF_LIB_SEARCHPATH "/lib:/lib64:/usr/lib:/usr/lib64"
#else
#define DEF_LIB_SEARCHPATH "/lib:/usr/lib"
#endif
int file_in_searchpath (const char *file, char *search, char *fullpath,
size_t len);
/*
* Search for the enclave file and then try and load it.
*/
sgx_status_t sgx_create_enclave_search (const char *filename, const int debug,
sgx_launch_token_t *token, int *updated, sgx_enclave_id_t *eid,
sgx_misc_attribute_t *attr)
{
struct stat sb;
char epath[PATH_MAX]; /* includes NULL */
/* Is filename an absolute path? */
if ( filename[0] == '/' )
return sgx_create_enclave(filename, debug, token, updated, eid, attr);
/* Is the enclave in the current working directory? */
if ( stat(filename, &sb) == 0 )
return sgx_create_enclave(filename, debug, token, updated, eid, attr);
/* Search the paths in LD_LBRARY_PATH */
if ( file_in_searchpath(filename, getenv("LD_LIBRARY_PATH"), epath, PATH_MAX) )
return sgx_create_enclave(epath, debug, token, updated, eid, attr);
/* Search the paths in DT_RUNPATH */
if ( file_in_searchpath(filename, getenv("DT_RUNPATH"), epath, PATH_MAX) )
return sgx_create_enclave(epath, debug, token, updated, eid, attr);
/* Standard system library paths */
if ( file_in_searchpath(filename, DEF_LIB_SEARCHPATH, epath, PATH_MAX) )
return sgx_create_enclave(epath, debug, token, updated, eid, attr);
/*
* If we've made it this far then we don't know where else to look.
* Just call sgx_create_enclave() which assumes the enclave is in
* the current working directory. This is almost guaranteed to fail,
* but it will insure we are consistent about the error codes that
* get reported to the calling function.
*/
return sgx_create_enclave(filename, debug, token, updated, eid, attr);
}
int file_in_searchpath (const char *file, char *search, char *fullpath,
size_t len)
{
char *p, *str;
size_t rem;
struct stat sb;
if ( search == NULL ) return 0;
if ( strlen(search) == 0 ) return 0;
str= strdup(search);
if ( str == NULL ) return 0;
p= strtok(str, ":");
while ( p != NULL) {
size_t lp= strlen(p);
if ( lp ) {
strncpy(fullpath, p, len);
rem= len-lp-1;
strncat(fullpath, "/", rem);
--rem;
strncat(fullpath, file, rem);
if ( stat(fullpath, &sb) == 0 ) {
free(str);
return 1;
}
}
p= strtok(NULL, ":");
}
free(str);
return 0;
}
/*
Copyright 2018 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
PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
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 __CREATE_ENCLAVE_H
#define __CREATE_ENCLAVE_H
#include <sgx_urts.h>
#ifdef __cplusplus
extern "C" {
#endif
sgx_status_t sgx_create_enclave_search (
const char *filename,
const int debug,
sgx_launch_token_t *token,
int *updated,
sgx_enclave_id_t *eid,
sgx_misc_attribute_t *attr
);
#ifdef __cplusplus
};
#endif
#endif
/usr/share/automake-1.15/depcomp
\ No newline at end of file
/usr/share/automake-1.15/install-sh
\ No newline at end of file
Subproject commit f2067162520f91438b44e71a2cab2362f1c3cab4
# SGX_INIT
# --------
# Initialize automake/autoconf with Intel SGX build options.
# Calling this macro from configure.ac will enforce SGX support
# in the build.
AC_DEFUN([SGX_INIT],[
AS_VAR_IF([ac_cv_sgx_init], [yes], [AC_MSG_ERROR([[already called SGX_INIT or SGX_INIT_OPTIONAL]])])
AC_ARG_WITH([enclave-libdir],
[AS_HELP_STRING([--with-enclave-libdir=path],
[Set the directory where enclave libraries should be installed (default: EPREFIX/libexec)])
], [enclave_libdir=$withval],
[enclave_libdir=\$\{exec_prefix\}/libexec])
AC_ARG_ENABLE([sgx-simulation],
[AS_HELP_STRING([--enable-sgx-simulation],
[Use Intel SGX in simulation mode. Implies --enable-sgx (default: disabled)])
], [sgxsim=${enableval}], [sgxsim=no])
AC_ARG_WITH([sgx-build],
[AS_HELP_STRING([--with-sgx-build=debug|prerelease|release],
[Set Intel SGX build mode (default: debug)])
], [_sgxbuild=$withval], [_sgxbuild=debug])
AC_ARG_WITH([sgxssl],
[AS_HELP_STRING([--with-sgxssl=path],
[Set the path to your Intel SGX SSL directory (defaults to /opt/intel/sgxssl)])
], [SGXSSL=$withval],[SGXSSL=/opt/intel/sgxssl])
AC_ARG_WITH([sgxsdk],
[AS_HELP_STRING([--with-sgxsdk=path],
[Set the path to your Intel SGX SDK directory (defaults to auto-detection)])
], [SGXSDK=$withval],[SGXSDK="detect"])
AS_IF([test "x$sgxsim" = "yes"], [sgxenable=yes])
AS_IF([test "x$sgxenable" != "xno"],
[ac_cv_enable_sgx=yes], [ac_cv_enable_sgx=no])
AM_CONDITIONAL([SGX_ENABLED], [test "$ac_cv_enable_sgx" = "yes"])
AM_COND_IF([SGX_ENABLED], [
AS_IF([test "x$sgxsim" = "xyes"], [
AC_SUBST(SGX_TRTS_LIB, [sgx_trts_sim])
AC_SUBST(SGX_TSERVICE_LIB, [sgx_tservice_sim])
AC_SUBST(SGX_UAE_SERVICE_LIB, [sgx_uae_service_sim])
AC_SUBST(SGX_URTS_LIB, [sgx_urts_sim])
AC_SUBST(LIBS_HW_SIMU, ["-lsgx_urts_sim -lsgx_uae_service_sim"])
AC_DEFINE(SGX_HW_SIM, 1, [Enable hardware simulation mode])
], [
AC_SUBST(SGX_TRTS_LIB, [sgx_trts])
AC_SUBST(SGX_TSERVICE_LIB, [sgx_tservice])
AC_SUBST(SGX_UAE_SERVICE_LIB, [sgx_uae_service])
AC_SUBST(SGX_URTS_LIB, [sgx_urts])
]
)
AS_IF([test "x$_sgxbuild" = "xdebug"], [
AC_DEFINE(DEBUG, 1, [Enable debugging])
AC_SUBST(ENCLAVE_SIGN_TARGET, [signed_enclave_dev])
],
[test "x$_sgxbuild" = "xprerelease"], [
AC_DEFINE(NDEBUG, 1, [Flag set for prerelease and release builds])
AC_DEFINE(EDEBUG, 1, [Flag set for prerelease builds])
AC_SUBST(ENCLAVE_SIGN_TARGET, [signed_enclave_dev])
],
[test "x$_sgxbuild" = "xrelease"], [
AS_IF(test "x$_sgxsim" = "xyes", [
AC_MSG_ERROR([Can't build in both release and simulation mode])
],
[
AC_DEFINE(NDEBUG, 1)
AC_SUBST(ENCLAVE_SIGN_TARGET, [signed_enclave_rel])
])
],
[AC_MSG_ERROR([Unknown build mode $_sgxbuild])]
)
AC_SUBST(SGX_DEBUG_FLAGS, [$_sgxdebug])
AS_IF([test "x$SGX_SDK" = "x"], [SGXSDK=detect], [SGXSDK=env])
AS_IF([test "x$SGXSDK" = "xenv"], [SGXSDK=$SGX_SDK],
[test "x$SGXSDK" != "xdetect"], [],
[test -d /opt/intel/sgxsdk], [SGXSDK=/opt/intel/sgxsdk],
[test -d ~/sgxsdk], [SGXSDK=~/sgxsdk],
[test -d ./sgxsdk], [SGXSDK=./sgxsdk],
[AC_MSG_ERROR([Can't detect your Intel SGX SDK installation directory])])
AC_SUBST(SGXSDK)
AC_SUBST(SGXSDK_INCDIR, $SGXSDK/include)
ac_cv_sgx_sdk=$SGXSDK
ac_cv_sgx_sdk_incdir=$SGXSDK/include
AS_IF([test -d $SGXSDK/lib], [
AC_SUBST(SGXSDK_LIBDIR, $SGXSDK/lib)
ac_cv_sgx_sdk_libdir=$SGXSDK/lib
], [test -d $SGXSDK/lib64], [
AC_SUBST(SGXSDK_LIBDIR, $SGXSDK/lib64)
ac_cv_sgx_sdk_libdir=$SGXSDK/lib64
], [
AC_MSG_ERROR(Can't find Intel SGX SDK lib directory)
])
AS_IF([test -d $SGXSDK/bin/ia32], [
ac_cv_sgx_sdk_bindir=$SGXSDK/bin
AC_SUBST(SGXSDK_BINDIR, $SGXSDK/bin/ia32)
], [test -d $SGXSDK/bin/x64], [
ac_cv_sgx_sdk_bindir=$SGXSDK/bin/x64
AC_SUBST(SGXSDK_BINDIR, $SGXSDK/bin/x64)
], [
AC_MSG_ERROR(Can't find Intel SGX SDK bin directory)
])
AC_MSG_NOTICE([Found your Intel SGX SDK in $SGXSDK])
AC_SUBST(enclave_libdir)
AC_SUBST(SGXSSL)
AC_SUBST(SGXSSL_INCDIR, $SGXSSL/include)
AC_SUBST(SGXSSL_LIBDIR, $SGXSSL/lib64)
dnl These are not quite the same as the Makefile substitution variables.
dnl They are set in a manner to allow autoconf to use them when running
dnl a compiler or linker for things like header and function checks.
ac_cv_sgx_tlib_cflags="-nostdinc -fvisibility=hidden -fpie -fstack-protector"
ac_cv_sgx_tlib_cppflags="-I${ac_cv_sgx_sdk_incdir} -I${ac_cv_sgx_sdk_incdir}/tlibc"
ac_cv_sgx_tlib_cxxflags="-nostdinc++ -fvisibility=hidden -fpie -fstack-protector"
ac_cv_sgx_enclave_ldflags="-nostdlib -nodefaultlibs -nostartfiles -L${ac_cv_sgx_sdk_libdir}"
ac_cv_sgx_enclave_ldadd="-Wl,--no-undefined -Wl,--whole-archive -lsgx_trts -Wl,--no-whole-archive -Wl,--start-group -lsgx_tstdc -lsgx_tcrypto -lsgx_tservice_lib -Wl,--end-group -Wl,-Bstatic -Wl,-Bsymbolic -Wl,-pie,-eenclave_entry -Wl,--export-dynamic -Wl,--defsym,__ImageBase=0"
dnl Substitutions for building a trusted library
AC_SUBST(SGX_TLIB_CFLAGS,
["-nostdinc -fvisibility=hidden -fpie -fstack-protector"])
AC_SUBST(SGX_TLIB_CPPFLAGS,
["-I\$(SGXSDK_INCDIR) -I\$(SGXSDK_INCDIR)/tlibc"])
AC_SUBST(SGX_TLIB_CXXFLAGS,
["-nostdinc++ -fvisibility=hidden -fpie -fstack-protector"])
dnl Substitutions for building an enclave
AC_SUBST(SGX_ENCLAVE_CFLAGS,
["-nostdinc -fvisibility=hidden -fpie -ffunction-sections -fdata-sections -fstack-protector"])
AC_SUBST(SGX_ENCLAVE_CPPFLAGS,
["-I\$(SGXSDK_INCDIR) -I\$(SGXSDK_INCDIR)/tlibc"])
AC_SUBST(SGX_ENCLAVE_CXXFLAGS, ["-nostdinc++ -fvisibility=hidden -fpie -ffunction-sections -fdata-sections -fstack-protector"])
AC_SUBST(SGX_ENCLAVE_LDFLAGS,
["-nostdlib -nodefaultlibs -nostartfiles -L\$(SGXSDK_LIBDIR)"])
AC_SUBST(SGX_ENCLAVE_LDADD,
["-Wl,--no-undefined -Wl,--whole-archive -l\$(SGX_TRTS_LIB) -Wl,--no-whole-archive -Wl,--start-group \$(SGX_EXTRA_TLIBS) -lsgx_tstdc -lsgx_tcrypto -l\$(SGX_TSERVICE_LIB) -Wl,--end-group -Wl,-Bstatic -Wl,-Bsymbolic -Wl,-pie,-eenclave_entry -Wl,--export-dynamic -Wl,--defsym,__ImageBase=0"])
])
AM_CONDITIONAL([ENCLAVE_RELEASE_SIGN], [test "x$_sgxbuild" = "xrelease"])
AM_CONDITIONAL([SGX_HW_SIM], [test "x$sgxsim" = "xyes"])
AC_MSG_NOTICE([enabling SGX... ${ac_cv_enable_sgx}])
ac_cv_sgx_init=yes
])
# SGX_IF_ENABLED(ACTION_IF_TRUE, ACTION_IF_FALSE)
# -----------------------------------------------
# Execute ACTION_IF_TRUE if SGX is enabled for the build
# (SGX_INIT was called in configure.ac, or SGX_INIT_OPTIONAL
# was called and the user supplied --enable-sgx on the
# command line).
AC_DEFUN([SGX_IF_ENABLED],[
AS_IF([test "x${ac_cv_enable_sgx}" = "xyes"], [$1], [$2])
])
# SGX_INIT_OPTIONAL
# -----------------
# Initialize automake/autoconf with Intel SGX build options.
# Calling this macro from configure.ac will make SGX support
# a build configuration option (--enable-sgx)
AC_DEFUN([SGX_INIT_OPTIONAL],[
AS_VAR_IF([ac_cv_sgx_init], [yes], [AC_MSG_ERROR([[already called SGX_INIT]])])
AC_ARG_ENABLE([sgx],
[AS_HELP_STRING([--enable-sgx],
[Build with/without Intel SGX support (default: disabled)])
], [sgxenable=${enableval}], [sgxenable=no])
SGX_INIT
])
This diff is collapsed.
# SGX_TSTDC_CHECK_TYPE_PREFIX([TYPE], [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND], [INCLUDES])
# -----------------------------------------------------------------------------
# Works like SGX_TSTDC_CHECK_TYPE, only assigns a prefix of "tstdc_" to
# the cache variable and "TSTDC_" to the CPP define (HAVE_TSTDC_x).
AC_DEFUN([SGX_TSTDC_CHECK_TYPE_PREFIX], [
type=AS_TR_SH([$1])
AS_VAR_SET_IF([ac_cv_type_$type], [
AS_VAR_COPY([o_ac_cv_type_$type],[ac_cv_type_$type])
AS_UNSET([ac_cv_type_$type])
])
SGX_TSTDC_CHECK_TYPE([$1], [$2], [$3], [$4])
AS_VAR_COPY([ac_cv_tstdc_type_$type],[ac_cv_type_$type])
AS_VAR_SET_IF([o_ac_cv_type_$type], [
AS_VAR_COPY([ac_cv_type_$type],[o_ac_cv_type_$type])
AS_UNSET([o_ac_cv_type_$type])
],[
AS_UNSET([ac_cv_type_$type])
])
AC_DEFINE(AS_TR_CPP([HAVE_TSTDC_$1]), 1)
]) # SGX_TSTDC_CHECK_TYPE_PREFIX
# SGX_TSTDC_CHECK_TYPES_PREFIX([TYPES], [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND], [INCLUDES])
# -----------------------------------------------------------------------------
# Works like SGX_TSTDC_CHECK_TYPES, only assigns a prefix of "tstdc_" to
# the cache variable and "TSTDC_" to the CPP define (HAVE_TSTDC_x).
AC_DEFUN([SGX_TSTDC_CHECK_TYPES_PREFIX], [
m4_foreach_w([SGX_Type], [$1], [
SGX_TSTDC_CHECK_TYPE_PREFIX(m4_defn([SGX_Type]), [$2], [$3])
])
]) # SGX_TSTDC_CHECK_TYPES_PREIFX
# SGX_TSTDC_CHECK_DECL_PREFIX([SYMBOL], [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND], [INCLUDES])
# ------------------------------------------------------------------------
# Works like SGX_TSTDC_CHECK_DECL, only assigns a prefix of "tstdc_" to
# the cache variable and "TSTDC_" to the CPP define (HAVE_TSTDC_x).
AC_DEFUN([SGX_TSTDC_CHECK_DECL_PREFIX], [
decl=AS_TR_SH([$1])
AS_VAR_SET_IF([ac_cv_decl_$decl], [
AS_VAR_COPY([o_ac_cv_decl_$decl],[ac_cv_decl_$decl])
AS_UNSET([ac_cv_decl_$decl])
])
SGX_TSTDC_CHECK_DECL([$1], [$2], [$3], [$4])
AS_VAR_COPY([ac_cv_tstdc_decl_$decl],[ac_cv_decl_$decl])
AS_VAR_SET_IF([o_ac_cv_decl_$decl], [
AS_VAR_COPY([ac_cv_decl_$decl],[o_ac_cv_decl_$decl])
AS_UNSET([o_ac_cv_decl_$decl])
],[
AS_UNSET([ac_cv_decl_$decl])
])
AC_DEFINE(AS_TR_CPP([HAVE_TSTDC_$1]), 1)
]) # SGX_TSTDC_CHECK_DECL_PREFIX
# SGX_TSTDC_CHECK_DECLS_PREFIX([SYMBOLS], [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND], [INCLUDES])
# ------------------------------------------------------------------------
# Works like SGX_TSTDC_CHECK_DECLS, only assigns a prefix of "tstdc_" to
# the cache variable and "TSTDC_" to the CPP define (HAVE_TSTDC_x).
AC_DEFUN([SGX_TSTDC_CHECK_DECLS_PREFIX], [
m4_foreach_w([SGX_Decl], [$1], [
SGX_TSTDC_CHECK_DECL_PREFIX(m4_defn([SGX_Decl]), [$2], [$3])
])
]) # SGX_TSTDC_CHECK_DECLS_PREFIX
# SGX_TSTDC_CHECK_DECLS_ONCE_PREFIX([SYMBOLS])
# -------------------------------------
# Works like SGX_TSTDC_CHECK_DECLS_ONCE, only assigns a prefix of "tstdc_"
# to the cache variable and "TSTDC_" to the CPP define (HAVE_TSTDC_x).
AC_DEFUN([SGX_TSTDC_CHECK_DECLS_ONCE_PREFIX], [
SGX_TSTDC_CHECK_DECLS_PREFIX([$1])
]) # SGX_TSTDC_CHECK_DECLS_PREFIX
# SGX_TSTDC_CHECK_HEADER_PREFIX(HEADER, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
# ------------------------------------------------------------------------
# Works like SGX_TSTDC_CHECK_HEADER, only assigns a prefix of "tstdc_" to
# the cache variable and "TSTDC_" to the CPP define (HAVE_TSTDC_x).
AC_DEFUN([SGX_TSTDC_CHECK_HEADER_PREFIX], [
header=AS_TR_SH([$1])
AS_VAR_SET_IF([ac_cv_header_$header], [
AS_VAR_COPY([o_ac_cv_header_$header],[ac_cv_header_$header])
AS_UNSET([ac_cv_header_$header])
])
SGX_TSTDC_CHECK_HEADER([$1], [$2], [$3])
AS_VAR_COPY([ac_cv_tstdc_header_$header],[ac_cv_header_$header])
AS_VAR_SET_IF([o_ac_cv_header_$header], [
AS_VAR_COPY([ac_cv_header_$header],[o_ac_cv_header_$header])
AS_UNSET([o_ac_cv_header_$header])
],[
AS_UNSET([ac_cv_header_$header])
])
AH_TEMPLATE(AS_TR_CPP([HAVE_TSTDC_$1]),
[Define to 1 if Intel SGX has the <$1> header file.])
AC_DEFINE(AS_TR_CPP([HAVE_TSTDC_$1]), 1)
]) # SGX_TSTDC_CHECK_HEADER_PREFIX
# SGX_TSTDC_CHECK_HEADERS_PREFIX(HEADER, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
# ------------------------------------------------------------------------
# Works like SGX_TSTDC_CHECK_HEADERS, only assigns a prefix of "tstdc_" to
# the cache variable and "TSTDC_" to the CPP define (HAVE_TSTDC_x).
AC_DEFUN([SGX_TSTDC_CHECK_HEADERS_PREFIX], [
m4_foreach_w([SGX_Header], [$1], [
SGX_TSTDC_CHECK_HEADER_PREFIX(m4_defn([SGX_Header]), [$2], [$3])
])
]) # SGX_TSTDC_CHECK_HEADERS_PREFIX
# SGX_TSTDC_CHECK_FUNC_PREFIX(FUNCTION, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
# ------------------------------------------------------------------------
# Works like SGX_TSTDC_CHECK_FUNC, only assigns a prefix of "tstdc_" to
# the cache variable and "TSTDC_" to the CPP define (HAVE_TSTDC_x).
AC_DEFUN([SGX_TSTDC_CHECK_FUNC_PREFIX], [
func=AS_TR_SH([$1])
AS_VAR_SET_IF([ac_cv_func_$func], [
AS_VAR_COPY([o_ac_cv_func_$func],[ac_cv_func_$func])
AS_UNSET([ac_cv_func_$func])
])
SGX_TSTDC_CHECK_FUNC([$1], [$2], [$3])
AS_VAR_COPY([ac_cv_tstdc_func_$func],[ac_cv_func_$func])
AS_VAR_SET_IF([o_ac_cv_func_$func], [
AS_VAR_COPY([ac_cv_func_$func],[o_ac_cv_func_$func])
AS_UNSET([o_ac_cv_func_$func])
],[
AS_UNSET([ac_cv_func_$func])
])
AC_DEFINE(AS_TR_CPP([HAVE_TSTDC_$1]), 1)
]) # SGX_TSTDC_CHECK_FUNC_PREFIX
# SGX_TSTDC_CHECK_FUNCS_PREFIX(FUNCTION..., [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
# ----------------------------------------------------------------------------
# Works like SGX_TSTDC_CHECK_FUNCS, only assigns a prefix of "tstdc_" to
# the cache variable and "TSTDC_" to the CPP define (HAVE_TSTDC_x).
AC_DEFUN([SGX_TSTDC_CHECK_FUNCS_PREFIX], [
m4_foreach_w([SGX_Func], [$1], [
SGX_TSTDC_CHECK_FUNC_PREFIX(m4_defn([SGX_Func]), [$2], [$3])
])
]) # SGX_TSTDC_CHECK_FUNCS_PREFIX
/usr/share/automake-1.15/missing
\ No newline at end of file
This diff is collapsed.
#ifndef OSTREAM_HPP
#define OSTREAM_HPP
namespace std {
class ostream {
;}
;
}
#endif
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
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