Unverified Commit 55e6ef9f authored by kladko's avatar kladko

SKALE-3067-cleanup-sgx

parent 20362fb3
...@@ -73,7 +73,8 @@ public: ...@@ -73,7 +73,8 @@ public:
static void handleSGXException(Json::Value &_result, SGXException &_e); static void handleSGXException(Json::Value &_result, SGXException &_e);
}; };
#define INIT_RESULT(__RESULT__) Json::Value __RESULT__; __RESULT__["status"] = 0; __RESULT__["errorMessage"] = \ #define INIT_RESULT(__RESULT__) Json::Value __RESULT__; \
int errStatus = UNKNOWN_ERROR; string errMsg(BUF_LEN, '\0');__RESULT__["status"] = 0; __RESULT__["errorMessage"] = \
"Server error. Please see server log."; "Server error. Please see server log.";
#define RESULT_SUCCESS(__RESULT__) ; __RESULT__["status"] = 0; __RESULT__["errorMessage"] = ""; #define RESULT_SUCCESS(__RESULT__) ; __RESULT__["status"] = 0; __RESULT__["errorMessage"] = "";
#define HANDLE_SGX_EXCEPTION(_RESULT_) catch (SGXException &__e) { Log::handleSGXException(_RESULT_, __e);} \ #define HANDLE_SGX_EXCEPTION(_RESULT_) catch (SGXException &__e) { Log::handleSGXException(_RESULT_, __e);} \
......
...@@ -166,10 +166,8 @@ int SGXWalletServer::initHttpServer() { //without ssl ...@@ -166,10 +166,8 @@ int SGXWalletServer::initHttpServer() { //without ssl
Json::Value Json::Value
SGXWalletServer::importBLSKeyShareImpl(const string &_keyShare, const string &_keyShareName, int t, int n, int _index) { SGXWalletServer::importBLSKeyShareImpl(const string &_keyShare, const string &_keyShareName, int t, int n, int _index) {
Json::Value result; INIT_RESULT(result);
int errStatus = UNKNOWN_ERROR;
string errMsg(BUF_LEN, '\0');
result["status"] = 0; result["status"] = 0;
result["errorMessage"] = ""; result["errorMessage"] = "";
...@@ -196,15 +194,20 @@ SGXWalletServer::importBLSKeyShareImpl(const string &_keyShare, const string &_k ...@@ -196,15 +194,20 @@ SGXWalletServer::importBLSKeyShareImpl(const string &_keyShare, const string &_k
result["errorMessage"] = _e.errString; result["errorMessage"] = _e.errString;
} }
result["status"] = errStatus;
result["errorMessage"] = errMsg;
return result; return result;
} }
Json::Value Json::Value
SGXWalletServer::blsSignMessageHashImpl(const string &_keyShareName, const string &_messageHash, int t, int n, SGXWalletServer::blsSignMessageHashImpl(const string &_keyShareName, const string &_messageHash, int t, int n,
int _signerIndex) { int _signerIndex) {
Json::Value result;
result["status"] = -1; INIT_RESULT(result);
result["errorMessage"] = "Unknown server error";
result["signatureShare"] = ""; result["signatureShare"] = "";
string signature(BUF_LEN, '\0'); string signature(BUF_LEN, '\0');
...@@ -260,7 +263,9 @@ SGXWalletServer::blsSignMessageHashImpl(const string &_keyShareName, const strin ...@@ -260,7 +263,9 @@ SGXWalletServer::blsSignMessageHashImpl(const string &_keyShareName, const strin
} }
Json::Value SGXWalletServer::importECDSAKeyImpl(const string &_key, const string &_keyName) { Json::Value SGXWalletServer::importECDSAKeyImpl(const string &_key, const string &_keyName) {
Json::Value result;
INIT_RESULT(result);
result["status"] = 0; result["status"] = 0;
result["errorMessage"] = ""; result["errorMessage"] = "";
result["encryptedKey"] = ""; result["encryptedKey"] = "";
...@@ -268,7 +273,9 @@ Json::Value SGXWalletServer::importECDSAKeyImpl(const string &_key, const string ...@@ -268,7 +273,9 @@ Json::Value SGXWalletServer::importECDSAKeyImpl(const string &_key, const string
} }
Json::Value SGXWalletServer::generateECDSAKeyImpl() { Json::Value SGXWalletServer::generateECDSAKeyImpl() {
Json::Value result;
INIT_RESULT(result);
result["status"] = 0; result["status"] = 0;
result["errorMessage"] = ""; result["errorMessage"] = "";
result["encryptedKey"] = ""; result["encryptedKey"] = "";
...@@ -300,6 +307,7 @@ Json::Value SGXWalletServer::generateECDSAKeyImpl() { ...@@ -300,6 +307,7 @@ Json::Value SGXWalletServer::generateECDSAKeyImpl() {
Json::Value SGXWalletServer::renameECDSAKeyImpl(const string &_keyName, const string &_tempKeyName) { Json::Value SGXWalletServer::renameECDSAKeyImpl(const string &_keyName, const string &_tempKeyName) {
INIT_RESULT(result) INIT_RESULT(result)
result["encryptedKey"] = ""; result["encryptedKey"] = "";
try { try {
...@@ -415,7 +423,9 @@ Json::Value SGXWalletServer::generateDKGPolyImpl(const string &_polyName, int _t ...@@ -415,7 +423,9 @@ Json::Value SGXWalletServer::generateDKGPolyImpl(const string &_polyName, int _t
} }
Json::Value SGXWalletServer::getVerificationVectorImpl(const string &_polyName, int _t, int _n) { Json::Value SGXWalletServer::getVerificationVectorImpl(const string &_polyName, int _t, int _n) {
Json::Value result;
INIT_RESULT(result);
result["status"] = 0; result["status"] = 0;
result["errorMessage"] = ""; result["errorMessage"] = "";
...@@ -449,7 +459,9 @@ Json::Value SGXWalletServer::getVerificationVectorImpl(const string &_polyName, ...@@ -449,7 +459,9 @@ Json::Value SGXWalletServer::getVerificationVectorImpl(const string &_polyName,
} }
Json::Value SGXWalletServer::getSecretShareImpl(const string &_polyName, const Json::Value &_pubKeys, int _t, int _n) { Json::Value SGXWalletServer::getSecretShareImpl(const string &_polyName, const Json::Value &_pubKeys, int _t, int _n) {
Json::Value result;
INIT_RESULT(result);
result["status"] = 0; result["status"] = 0;
result["errorMessage"] = ""; result["errorMessage"] = "";
...@@ -488,7 +500,8 @@ Json::Value SGXWalletServer::getSecretShareImpl(const string &_polyName, const J ...@@ -488,7 +500,8 @@ Json::Value SGXWalletServer::getSecretShareImpl(const string &_polyName, const J
Json::Value SGXWalletServer::dkgVerificationImpl(const string &_publicShares, const string &_ethKeyName, Json::Value SGXWalletServer::dkgVerificationImpl(const string &_publicShares, const string &_ethKeyName,
const string &_secretShare, int _t, int _n, int _index) { const string &_secretShare, int _t, int _n, int _index) {
Json::Value result; INIT_RESULT(result)
result["status"] = 0; result["status"] = 0;
result["errorMessage"] = ""; result["errorMessage"] = "";
result["result"] = true; result["result"] = true;
...@@ -524,7 +537,9 @@ Json::Value SGXWalletServer::dkgVerificationImpl(const string &_publicShares, co ...@@ -524,7 +537,9 @@ Json::Value SGXWalletServer::dkgVerificationImpl(const string &_publicShares, co
Json::Value Json::Value
SGXWalletServer::createBLSPrivateKeyImpl(const string &_blsKeyName, const string &_ethKeyName, const string &_polyName, SGXWalletServer::createBLSPrivateKeyImpl(const string &_blsKeyName, const string &_ethKeyName, const string &_polyName,
const string &_secretShare, int _t, int _n) { const string &_secretShare, int _t, int _n) {
Json::Value result;
INIT_RESULT(result)
result["status"] = 0; result["status"] = 0;
result["errorMessage"] = ""; result["errorMessage"] = "";
......
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