Unverified Commit 3f8f0434 authored by svetaro's avatar svetaro

Fixed server

parent 5c250261
......@@ -89,11 +89,14 @@ secure_enclave.signed.so: secure_enclave/secure_enclave.signed.so
## Use the variables, not the actual library names to ensure these
## targets work on simulation builds.
sgxwallet_LDADD=-l$(SGX_URTS_LIB) -Lleveldb/build -LlibBLS/build -LlibBLS/build/libff/libff -l:libbls.a -l:libleveldb.a -l:libff.a -lgmp -ldl -l:libsgx_capable.a -l:libsgx_tprotected_fs.a -ljsonrpccpp-stub -lpthread -ljsonrpccpp-common -ljsonrpccpp-server -ljsonrpccpp-client -ljsoncpp -lprocps intel-sgx-ssl/Linu./x/package/lib64/libsgx_usgxssl.a
sgxwallet_LDADD=-l$(SGX_URTS_LIB) -Lleveldb/build -LlibBLS/build -LlibBLS/build/libff/libff -l:libbls.a -l:libleveldb.a \
-l:libff.a -lgmp -ldl -l:libsgx_capable.a -l:libsgx_tprotected_fs.a -ljsonrpccpp-stub -lpthread -ljsonrpccpp-common \
-ljsonrpccpp-server -ljsonrpccpp-client -ljsoncpp -lcurl -lprocps intel-sgx-ssl/Linux/package/lib64/libsgx_usgxssl.a
testw_SOURCES=testw.cpp stubclient.cpp SGXWalletServer.cpp RPCException.cpp BLSCrypto.cpp ServerInit.cpp LevelDB.cpp BLSPrivateKeyShareSGX.cpp ECDSACrypto.cpp $(COMMON_SRC)
testw_SOURCES=testw.cpp stubclient.cpp SGXWalletServer.cpp RPCException.cpp BLSCrypto.cpp ServerInit.cpp LevelDB.cpp \
BLSPrivateKeyShareSGX.cpp ECDSACrypto.cpp $(COMMON_SRC)
nodist_testw_SOURCES=${nodist_sgxwallet_SOURCES}
EXTRA_testw_DEPENDENCIES=${EXTRA_sgxwallet_DEPENDENCIES}
testw_LDADD= ${sgxwallet_LDADD}
......
......@@ -31,11 +31,19 @@ SGXWalletServer::SGXWalletServer(AbstractServerConnector &connector,
serverVersion_t type)
: AbstractStubServer(connector, type) {}
SGXWalletServer* s = nullptr;
int init_server() {
HttpServer httpserver(1025);
SGXWalletServer s(httpserver,
s = new SGXWalletServer(httpserver,
JSONRPC_SERVER_V1V2); // hybrid server (json-rpc 1.0 & 2.0)
s.StartListening();
if (!s->StartListening()) {
cerr << "Server could not start listening" << endl;
exit(-1);
}
return 0;
}
......@@ -142,13 +150,16 @@ Json::Value generateECDSAKeyImpl(const std::string &_keyName) {
result["errorMessage"] = "";
result["encryptedKey"] = "";
cerr << "Calling method" << endl;
char* encryptedKey = nullptr;
try {
/* char* encryptedKey = gen_ecdsa_key();
encryptedKey = gen_ecdsa_key();
if (encryptedKey == nullptr) {
throw RPCException(UNKNOWN_ERROR, "");
}*/
}
writeECDSAKey(_keyName, encryptedKey);
} catch (RPCException &_e) {
......
......@@ -12,6 +12,8 @@ using namespace std;
class SGXWalletServer : public AbstractStubServer {
SGXWalletServer* server = nullptr;
public:
SGXWalletServer(AbstractServerConnector &connector, serverVersion_t type);
......
......@@ -33,6 +33,7 @@ class AbstractStubServer : public jsonrpc::AbstractServer<AbstractStubServer>
}
inline virtual void generateECDSAKeyI(const Json::Value &request, Json::Value &response)
{
std::cerr <<"Got request" << std::endl;
response = this->generateECDSAKey(request["keyName"].asString());
}
inline virtual void ecdsaSignMessageHashI(const Json::Value &request, Json::Value &response)
......
......@@ -68,6 +68,8 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "catch.hpp"
#include "stubclient.h"
std::string stringFromFr(libff::alt_bn128_Fr& el) {
mpz_t t;
......@@ -401,6 +403,39 @@ TEST_CASE("ECDSA keygen and signature test", "[ecdsa_test]") {
printf("\nsignature v: %s ", signature_v);
printf("\n %s \n", errMsg);
}
#include "stubclient.h"
#include <jsonrpccpp/client/connectors/httpclient.h>
using namespace jsonrpc;
using namespace std;
TEST_CASE("API test", "[api_test]") {
cerr << "API test started" << endl;
// init_all();
//HttpServer httpserver(1025);
//SGXWalletServer s(httpserver,
// JSONRPC_SERVER_V1); // hybrid server (json-rpc 1.0 & 2.0)
// s.StartListening();
cerr << "Server inited" << endl;
HttpClient client("http://localhost:1025");
StubClient c(client, JSONRPC_CLIENT_V1);
cerr << "Client inited" << endl;
try {
cout << c.generateECDSAKey("test_key") << endl;
} catch (JsonRpcException &e) {
cerr << e.what() << endl;
}
/* shared_ptr <std::string> key_ptr = readECDSAKey("test_key");
if (key_ptr == nullptr) cerr<< " key is null" << endl;
else cerr << "key is " << *key_ptr << endl;*/
}
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