Browse Source

Removed the dependency of the LA-related calls to a patched version of the SGX library - added in some dummy functions and variables that would otherwise be generated by the edger8r script (other than sgx_init_crypto_lib).
Removed the dependency of the crypto file on a given version of openssl - instead just using the inbuilt openssl header files and libraries.

dettanym 4 years ago
parent
commit
8909dcdf58
2 changed files with 35 additions and 5 deletions
  1. 4 5
      Makefile
  2. 31 0
      systemMain.cpp

+ 4 - 5
Makefile

@@ -5,7 +5,7 @@ PYTHON_LDFLAGS = -L/usr/lib/python2.7/config-x86_64-linux-gnu  -lpython2.7   -lu
 CXX_FLAGS       = -Wall  -O2 -std=c++11 -fpic -fdata-sections -ffunction-sections
 
 LD              = ${CXX} -v
-LD_FLAGS        = -Wall ${PYTHON_LDFLAGS}
+LD_FLAGS        = -Wall #${PYTHON_LDFLAGS}
 
 all_non_sgx_obj := $(system_obj) $(protobuf_obj) #$(patsubst %.cpp,%.o,$(all_non_sgx_cpp)}
 
@@ -17,14 +17,13 @@ protobuf_obj := $(patsubst %.cpp,%.o,$(wildcard Protobuf*))
 system_obj := $(patsubst %.cpp,%.o,$(wildcard system*))
 OBJECTS := systemMain.o systemSealerWrapper.o SgxSealer.o ProtobufLAInitiator.o SgxProtobufLAInitiator.o SgxProtobufLAInitiator_Transforms.o ProtobufLAMessages.pb.o crypto.o 
 
-SGX_SDK := /opt/intel/sgxsdk
 SGX_COMMON_CFLAGS := -m64
 SGX_LIBRARY_PATH := $(SGX_SDK)/lib64
+SgxC_Library_Name := sgx_tstdc
 Trts_Library_Name := sgx_trts
 Service_Library_Name := sgx_tservice
 Crypto_Library_Name := sgx_tcrypto
 SGX_INCLUDE_PATHS := -I$(SGX_SDK)/include -I$(SGX_SDK)/include/tlibc -I$(SGX_SDK)/include/libcxx
-Openssl_Path := /home/m2mazmud/plain-openssl
 
 Uae_Library_Name := sgx_uae_service
 
@@ -47,10 +46,10 @@ ProtobufAutogenerated/%.o: ProtobufAutogenerated/%.cpp
 	#-I/usr/lib/jvm/java-8-openjdk-amd64/include/ -I/usr/lib/jvm/java-8-openjdk-amd64/include/linux/
 
 crypto.o: crypto.cpp 
-	${CXX} -I${Openssl_Path}/include ${CXX_FLAGS} -c $^ -o $@
+	${CXX} ${CXX_FLAGS} -c $^ -o $@
 
 verifier:  systemMain.o DeploymentStageLogic.o LAInitiator/LA.o LAInitiator/Transforms.o PostLA/PostLAMessaging.o ProtobufAutogenerated/ProtobufLAMessages.pb.o ProtobufMessageRW.o crypto.o
-	${CXX} -Wl,--no-undefined  systemMain.o DeploymentStageLogic.o LAInitiator/LA.o LAInitiator/Transforms.o PostLA/PostLAMessaging.o ProtobufAutogenerated/ProtobufLAMessages.pb.o ProtobufMessageRW.o crypto.o  -L${Openssl_Path}/lib -lcrypto -lssl -L./ -l$(Service_Library_Name) -l$(Crypto_Library_Name) -L/home/m2mazmud/linux-sgx-trts-modified/build/linux -lsgx_tstdc -lsgx_trts ${LD_FLAGS} -lprotobuf  -o $@
+	${CXX} systemMain.o DeploymentStageLogic.o LAInitiator/LA.o LAInitiator/Transforms.o PostLA/PostLAMessaging.o ProtobufAutogenerated/ProtobufLAMessages.pb.o ProtobufMessageRW.o crypto.o -Wl,--no-undefined ${LD_FLAGS} -lcrypto -lssl -L$(SGX_LIBRARY_PATH) -l$(Service_Library_Name) -l$(Crypto_Library_Name) -l$(Trts_Library_Name) -l$(SgxC_Library_Name) -lprotobuf  -o $@
 #-L/usr/lib/jvm/java-8-openjdk-amd64/jre/lib/amd64/server -ljvm  
 #-L~/linux-sgx-trts-modified/build/linux -lsgx_tstdc -lsgx_trts ${LD_FLAGS} -o $@
 

+ 31 - 0
systemMain.cpp

@@ -15,6 +15,37 @@ using namespace std;
 #define DECRYPTOR_PORT 3824
 #define SGX_HASH_SIZE 32
 int __ImageBase=0;
+
+void sgx_foo(){};
+void sgx_bar(){};
+
+extern "C" const struct {
+    size_t nr_ecall;    // number of ECALLs
+    struct {
+        void   *ecall_addr;
+        uint8_t is_priv;
+    } ecall_table [2];
+} g_ecall_table = {2, { { (void*)sgx_foo, 1}, { (void*)sgx_bar, 0} }};
+
+extern "C" const struct {
+    // number of OCALLs (number of ECALLs can be found in ECALL table)
+    size_t nr_ocall;
+    // entry_table[m][n] = 1 iff. ECALL n is allowed in the OCALL m.
+    uint8_t entry_table[3][2];
+} g_dyn_entry_table =  {
+        3, {{0, 0}, {0, 1}, {1, 0}}
+};
+
+extern "C" uint32_t sgx_init_crypto_lib(uint64_t cpu_feature_indicator, uint32_t *cpuid_table)
+{
+    return 0;
+}
+
+int sgx_is_within_enclave(const void *addr, size_t size)
+{
+    return 1;
+}
+
 int verify_apache(std::string& path, std::string& keypair) {return 0; }
 
 void foo() //sigsegv_handler(int signo)