123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475 |
- #include <phpcpp.h>
- #include <string.h>
- #include <string>
- #include <unistd.h>
- #include <errno.h>
- #include <fcntl.h>
- #include <sys/types.h>
- #include <sys/stat.h>
- #include <stdio.h>
- #include "crypto.h"
- #include "ProtobufLAInitiator.h"
- using namespace std;
- // #include <unistd.h>
- // based off the example functionreturnvalue.cpp in PHP-CPP
- /**
- * Namespace to use
- */
- using namespace std;
- #define DECRYPTOR_PORT 3825
- int local_attestation_successful=0;
- int __ImageBase=0;
- // Symbols are exported according to the "C" language
- extern "C"
- {
- void local_attestation_initiator_wrapper()
- {
- setbuf(stdout,NULL);
- uint32_t return_sgx;
- return_sgx = local_attestation_initiator(DECRYPTOR_PORT);
- if(return_sgx != 0)
- {
- if(return_sgx== 0xFFFFFFFF)
- {
- perror("\nCould not set up the socket: had the following error: ");
- fflush(stderr);
- }
- else
- {
- printf("\nHad the following error in SGX local attestation: 0x%x", return_sgx);
- fflush(stdout);
- }
- // return return_sgx;
- }
- printf("\nSuccessful LA with port %d.\n", DECRYPTOR_PORT);
- fflush(stdout);
- local_attestation_successful=1;
- // return 0;
- }
- // export the "get_module" function that will be called by the Zend engine
- PHPCPP_EXPORT void *get_module()
- {
- // create extension
- static Php::Extension extension("decryptor_la_setup_and_decryption","1.0");
-
- // add function to extension - make this the decryption function
- // extension.add<my_return_value_function>("my_return_value_function");
- extension.onStartup(&local_attestation_initiator_wrapper);
-
- // return the extension module
- return extension.module();
- }
- }
|