Browse Source

Works with python

dettanym 5 years ago
parent
commit
c7c6212d91
2 changed files with 36 additions and 8 deletions
  1. 16 5
      Makefile
  2. 20 3
      systemMain.cpp

+ 16 - 5
Makefile

@@ -1,8 +1,10 @@
 CXX             = g++
 RM              = rm -f
-CXX_FLAGS       = -Wall  -O2 -std=c++11 -fpic -fdata-sections -ffunction-sections
+PYTHON_CFLAGS = -I/usr/include/python2.7 -I/usr/include/x86_64-linux-gnu/python2.7  -fno-strict-aliasing -Wdate-time -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security  -DNDEBUG -g -fwrapv 
+PYTHON_LDFLAGS = -L/usr/lib/python2.7/config-x86_64-linux-gnu -L/usr/lib -lpython2.7 -lpthread -ldl  -lutil -lm  -Xlinker -export-dynamic -Wl,-O1 -Wl,-Bsymbolic-functions
+CXX_FLAGS       = -Wall  -O2 -std=c++11 -fpic -fdata-sections -ffunction-sections ${PYTHON_CFLAGS}
 LD              = ${CXX} -v
-LD_FLAGS        = -Wall -O2
+LD_FLAGS        = -Wall -O2 ${PYTHON_LDFLAGS}
 
 all_non_sgx_obj := $(system_obj) $(protobuf_obj) #$(patsubst %.cpp,%.o,$(all_non_sgx_cpp)}
 
@@ -37,13 +39,22 @@ Protobuf%.o: Protobuf%.cpp
 	${CXX} -I./include ${CXX_FLAGS} -c $^ -o $@
 
 system%.o: system%.cpp
-	gcc -I./include -I/usr/lib/jvm/java-8-openjdk-amd64/include/ -I/usr/lib/jvm/java-8-openjdk-amd64/include/linux/ ${CXX_FLAGS} -c $^ -o $@
+	${CXX} -I./include -I/usr/lib/jvm/java-8-openjdk-amd64/include/ -I/usr/lib/jvm/java-8-openjdk-amd64/include/linux/ ${CXX_FLAGS} -c $^ -o $@
 
 crypto.o: crypto.cpp 
-	gcc -I${Openssl_Path}/include ${CXX_FLAGS} -c $^ -o $@
+	${CXX} -I${Openssl_Path}/include ${CXX_FLAGS} -c $^ -o $@
 
 verifier:  systemMain.o systemSealerWrapper.o SgxSealer.o ProtobufLAInitiator.o SgxProtobufLAInitiator.o SgxProtobufLAInitiator_Transforms.o ProtobufLAMessages.pb.o crypto.o
 #	echo $(system_obj)
-	${CXX} ${CXX_FLAGS} -Wl,--no-undefined  -Wl,-rpath,$(SGX_SDK)/lib64  systemMain.o systemSealerWrapper.o SgxSealer.o ProtobufLAInitiator.o SgxProtobufLAInitiator.o SgxProtobufLAInitiator_Transforms.o ProtobufLAMessages.pb.o crypto.o -L./ -Wl,--whole-archive -l$(Trts_Library_Name) -Wl,--no-whole-archive  -L$(SGX_LIBRARY_PATH) -l$(Service_Library_Name) -l$(Crypto_Library_Name) -lsgx_tstdc  -lprotobuf  -L${Openssl_Path}/lib -lssl -lcrypto -L/usr/lib/jvm/java-8-openjdk-amd64/jre/lib/amd64/server  -ljvm -Wl,--trace -o $@
+	${CXX} -Wl,--no-undefined  systemMain.o crypto.o  -L${Openssl_Path}/lib -lcrypto -lssl  ${LD_FLAGS} -o $@ 
+
+#-Wl,-rpath,$(SGX_SDK)/lib64  systemMain.o  ${LD_FLAGS} -o $@
+#systemSealerWrapper.o SgxSealer.o 
+#ProtobufLAInitiator.o SgxProtobufLAInitiator.o SgxProtobufLAInitiator_Transforms.o ProtobufLAMessages.pb.o crypto.o #
+#${LD_FLAGS} 
+#-L./ -Wl,--whole-archive -l$(Trts_Library_Name) -Wl,--no-whole-archive  -L$(SGX_LIBRARY_PATH) -l$(Service_Library_Name) -l$(Crypto_Library_Name) -lsgx_tstdc 
+# -lprotobuf 
+# -L${Openssl_Path}/lib -lssl -lcrypto 
+# -o $@
 # -L/usr/lib/jvm/java-8-openjdk-amd64/jre/lib/amd64/server -ljvm 
 

+ 20 - 3
systemMain.cpp

@@ -8,7 +8,7 @@
 #include <sys/stat.h>
 #include <stdio.h>
 #include <signal.h>
-
+#include <Python.h>
 #include "crypto.h"
 #include "ProtobufLAInitiator.h"
 #include "SealerWrapper.h"
@@ -32,7 +32,7 @@ void foo() //sigsegv_handler(int signo)
 
 int main(int argc, char** argv)
 {
-
+/*
 //	signal(SIGSEGV, SIG_IGN);  //sigsegv_handler); 
 	
     JavaVM         *vm;
@@ -98,6 +98,20 @@ int main(int argc, char** argv)
       (env)->ExceptionClear();
       printf("Exception occurred\n"); fflush(stdout);
     }
+*/
+
+  printf("HELLOWORLD\n");fflush(stdout); 
+//  Py_SetProgramName("verifier");  /* optional but recommended */
+  printf("HELLOWORLD 2\n"); fflush(stdout); 
+  Py_Initialize();
+  printf("HELLOWORLD 3\n");fflush(stdout); 
+
+  PyRun_SimpleString("from time import time,ctime\n"
+                     "print 'Today is',ctime(time())\n");
+  Py_Finalize();
+//  return 0;
+
+
 
 
 
@@ -125,7 +139,7 @@ int main(int argc, char** argv)
 	printf("Could not generate RSA keypair - error 0x%x\n", return_internal); fflush(stdout); return return_internal; 
   }
   printf("Generated key pair - outside the fun\n"); fflush(stdout); 
-  int sealed_file_fd = open("sealed_msg.txt", O_CREAT | O_RDWR, S_IRUSR | S_IWUSR);
+/*  int sealed_file_fd = open("sealed_msg.txt", O_CREAT | O_RDWR, S_IRUSR | S_IWUSR);
   if(sealed_file_fd == -1)
   {
     perror("\nError in opening or creating the file sealed_msg.txt - ");
@@ -150,6 +164,8 @@ int main(int argc, char** argv)
   printf("\nSuccessfully sealed the plaintext %s to length 0x%x.\n", apache_signature_keypair_private.c_str(), expected_sealed_msg_size);
   fflush(stdout);
 
+
+/*
   return_sgx = local_attestation_initiator(DECRYPTOR_PORT);
   if(return_sgx != 0)
   {
@@ -196,6 +212,7 @@ int main(int argc, char** argv)
   }
   printf("Successfully verified the Apache enclave and signed its manifest.\n");
   fflush(stdout);
+*/
   return 0;