浏览代码

Fixed ProtobufMessageRW.* refs to the right repo.

Changed the linking order of sgx libs to make it identical to verifiers (yet untested) and added necessary code to expose symbols in main file.
dettanym 5 年之前
父节点
当前提交
e1db93643e
共有 4 个文件被更改,包括 35 次插入2 次删除
  1. 3 0
      Makefile
  2. 1 1
      ProtobufMessageRW.cpp
  3. 1 1
      include/ProtobufMessageRW.h
  4. 30 0
      systemMain.cpp

+ 3 - 0
Makefile

@@ -12,6 +12,7 @@ SGX_LIBRARY_PATH := $(SGX_SDK)/lib64
 Trts_Library_Name := sgx_trts
 Service_Library_Name := sgx_tservice
 Crypto_Library_Name := sgx_tcrypto
+SgxC_Library_Name := sgx_tstdc
 SGX_INCLUDE_PATHS := -I$(SGX_SDK)/include -I$(SGX_SDK)/include/tlibc -I$(SGX_SDK)/include/libcxx
 
 Uae_Library_Name := sgx_uae_service
@@ -47,4 +48,6 @@ crypto.o: crypto.cpp
 
 localattestation_decryption.so: systemMain.o MainLogic.o LAInitiator/LA.o LAInitiator/Tramsforms.o  ProtobufLAMessages.pb.o PostLA/PostLAMessaging.o PostLA/PostLAMessages.pb.o ProtobufMessageRW.o crypto.o
 	${CXX} ${LD_FLAGS} -Wl,--verbose systemMain.o MainLogic.o LAInitiator/LA.o LAInitiator/Tramsforms.o  ProtobufLAMessages.pb.o PostLA/PostLAMessaging.o PostLA/PostLAMessages.pb.o ProtobufMessageRW.o crypto.o  -lphpcpp -L./ -Wl,--whole-archive -l$(Trts_Library_Name) -Wl,--no-whole-archive  -l$(Service_Library_Name) -l$(Crypto_Library_Name) -lsgx_tstdc -lprotobuf -lssl -lcrypto   -Wl,-Bsymbolic -Wl,-pie,-eenclave_entry -Wl,--export-dynamic  -o $@
+# -lphpcpp -L./ -Wl,--whole-archive -l$(Trts_Library_Name) -Wl,--no-whole-archive  -l$(Service_Library_Name) -l$(Crypto_Library_Name) -lsgx_tstdc -lprotobuf -lssl -lcrypto
+#-lcrypto -lssl -L$(SGX_LIBRARY_PATH) -l$(Service_Library_Name) -l$(Crypto_Library_Name) -l$(Trts_Library_Name) -l$(SgxC_Library_Name) -lprotobuf
 # -Wl,-Bsymbolic -Wl,-pie,-eenclave_entry -Wl,--export-dynamic  -Wl,--verbose -o $@

+ 1 - 1
ProtobufMessageRW.cpp

@@ -1 +1 @@
-../commonVerifierPHPfiles/ProtobufMessageRW.cpp
+../dhmsgs_proto_defs/ProtobufMessageRW.cpp

+ 1 - 1
include/ProtobufMessageRW.h

@@ -1 +1 @@
-../../commonVerifierPHPfiles/header_files/ProtobufMessageRW.h
+../../dhmsgs_proto_defs/ProtobufMessageRW.h

+ 30 - 0
systemMain.cpp

@@ -13,6 +13,36 @@ using namespace std;
 
 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;
+}
+
 // Mitigator-Public-Key:
 
 MainLogic *mainLogic = NULL;