Unverified Commit 18c63687 authored by kladko's avatar kladko

SKALE-3067-cleanup-sgx

parent 1ccc35ce
...@@ -76,7 +76,7 @@ public: ...@@ -76,7 +76,7 @@ public:
#define INIT_RESULT(__RESULT__) Json::Value __RESULT__; \ #define INIT_RESULT(__RESULT__) Json::Value __RESULT__; \
int errStatus = UNKNOWN_ERROR; string errMsg(BUF_LEN, '\0');__RESULT__["status"] = 0; __RESULT__["errorMessage"] = \ 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 HANDLE_SGX_EXCEPTION(__RESULT__) \ #define HANDLE_SGX_EXCEPTION(__RESULT__) \
catch (SGXException& _e) { \ catch (SGXException& _e) { \
__RESULT__["status"] = _e.status; \ __RESULT__["status"] = _e.status; \
...@@ -92,5 +92,11 @@ public: ...@@ -92,5 +92,11 @@ public:
__RESULT__["errorMessage"] = "Unknown exception"; \ __RESULT__["errorMessage"] = "Unknown exception"; \
return __RESULT__; \ return __RESULT__; \
} }
#define RETURN_SUCCESS(__RESULT__) \
__RESULT__["status"] = 0; \
__RESULT__["errorMessage"] = ""; \
return __RESULT__;
#endif #endif
...@@ -189,10 +189,7 @@ SGXWalletServer::importBLSKeyShareImpl(const string &_keyShare, const string &_k ...@@ -189,10 +189,7 @@ SGXWalletServer::importBLSKeyShareImpl(const string &_keyShare, const string &_k
} HANDLE_SGX_EXCEPTION(result) } HANDLE_SGX_EXCEPTION(result)
result["status"] = 0; RETURN_SUCCESS(result)
result["errorMessage"] = "";
return result;
} }
Json::Value Json::Value
...@@ -250,20 +247,16 @@ SGXWalletServer::blsSignMessageHashImpl(const string &_keyShareName, const strin ...@@ -250,20 +247,16 @@ SGXWalletServer::blsSignMessageHashImpl(const string &_keyShareName, const strin
result["signatureShare"] = string(signature.data()); result["signatureShare"] = string(signature.data());
result["status"] = 0; RETURN_SUCCESS(result)
result["errorMessage"] = "";
return result;
} }
Json::Value SGXWalletServer::importECDSAKeyImpl(const string &_key, const string &_keyName) { Json::Value SGXWalletServer::importECDSAKeyImpl(const string &_key, const string &_keyName) {
INIT_RESULT(result); INIT_RESULT(result);
result["status"] = 0;
result["errorMessage"] = "";
result["encryptedKey"] = ""; result["encryptedKey"] = "";
return result; RETURN_SUCCESS(result)
} }
Json::Value SGXWalletServer::generateECDSAKeyImpl() { Json::Value SGXWalletServer::generateECDSAKeyImpl() {
...@@ -295,10 +288,7 @@ Json::Value SGXWalletServer::generateECDSAKeyImpl() { ...@@ -295,10 +288,7 @@ Json::Value SGXWalletServer::generateECDSAKeyImpl() {
result["keyName"] = keyName; result["keyName"] = keyName;
} HANDLE_SGX_EXCEPTION(result) } HANDLE_SGX_EXCEPTION(result)
result["status"] = 0; RETURN_SUCCESS(result)
result["errorMessage"] = "";
return result;
} }
Json::Value SGXWalletServer::renameECDSAKeyImpl(const string &_keyName, const string &_tempKeyName) { Json::Value SGXWalletServer::renameECDSAKeyImpl(const string &_keyName, const string &_tempKeyName) {
...@@ -326,9 +316,7 @@ Json::Value SGXWalletServer::renameECDSAKeyImpl(const string &_keyName, const st ...@@ -326,9 +316,7 @@ Json::Value SGXWalletServer::renameECDSAKeyImpl(const string &_keyName, const st
LevelDB::getLevelDb()->deleteTempNEK(_tempKeyName); LevelDB::getLevelDb()->deleteTempNEK(_tempKeyName);
} HANDLE_SGX_EXCEPTION(result) } HANDLE_SGX_EXCEPTION(result)
result["status"] = 0; RETURN_SUCCESS(result)
result["errorMessage"] = "";
return result;
} }
Json::Value SGXWalletServer::ecdsaSignMessageHashImpl(int _base, const string &_keyName, const string &_messageHash) { Json::Value SGXWalletServer::ecdsaSignMessageHashImpl(int _base, const string &_keyName, const string &_messageHash) {
...@@ -370,10 +358,7 @@ Json::Value SGXWalletServer::ecdsaSignMessageHashImpl(int _base, const string &_ ...@@ -370,10 +358,7 @@ Json::Value SGXWalletServer::ecdsaSignMessageHashImpl(int _base, const string &_
result["signature_s"] = signatureVector.at(2); result["signature_s"] = signatureVector.at(2);
} HANDLE_SGX_EXCEPTION(result) } HANDLE_SGX_EXCEPTION(result)
result["status"] = 0; RETURN_SUCCESS(result)
result["errorMessage"] = "";
return result;
} }
Json::Value SGXWalletServer::getPublicECDSAKeyImpl(const string &_keyName) { Json::Value SGXWalletServer::getPublicECDSAKeyImpl(const string &_keyName) {
...@@ -397,10 +382,7 @@ Json::Value SGXWalletServer::getPublicECDSAKeyImpl(const string &_keyName) { ...@@ -397,10 +382,7 @@ Json::Value SGXWalletServer::getPublicECDSAKeyImpl(const string &_keyName) {
result["publicKey"] = publicKey; result["publicKey"] = publicKey;
} HANDLE_SGX_EXCEPTION(result) } HANDLE_SGX_EXCEPTION(result)
result["status"] = 0; RETURN_SUCCESS(result)
result["errorMessage"] = "";
return result;
} }
Json::Value SGXWalletServer::generateDKGPolyImpl(const string &_polyName, int _t) { Json::Value SGXWalletServer::generateDKGPolyImpl(const string &_polyName, int _t) {
...@@ -420,10 +402,7 @@ Json::Value SGXWalletServer::generateDKGPolyImpl(const string &_polyName, int _t ...@@ -420,10 +402,7 @@ Json::Value SGXWalletServer::generateDKGPolyImpl(const string &_polyName, int _t
writeDataToDB(_polyName, encrPolyHex); writeDataToDB(_polyName, encrPolyHex);
} HANDLE_SGX_EXCEPTION(result) } HANDLE_SGX_EXCEPTION(result)
result["status"] = 0; RETURN_SUCCESS(result)
result["errorMessage"] = "";
return result;
} }
Json::Value SGXWalletServer::getVerificationVectorImpl(const string &_polyName, int _t, int _n) { Json::Value SGXWalletServer::getVerificationVectorImpl(const string &_polyName, int _t, int _n) {
...@@ -459,8 +438,6 @@ Json::Value SGXWalletServer::getVerificationVectorImpl(const string &_polyName, ...@@ -459,8 +438,6 @@ Json::Value SGXWalletServer::getVerificationVectorImpl(const string &_polyName,
result["verificationVector"] = ""; result["verificationVector"] = "";
} }
result["status"] = 0;
result["errorMessage"] = "";
return result; return result;
} }
...@@ -497,10 +474,7 @@ Json::Value SGXWalletServer::getSecretShareImpl(const string &_polyName, const J ...@@ -497,10 +474,7 @@ Json::Value SGXWalletServer::getSecretShareImpl(const string &_polyName, const J
result["secretShare"] = s; result["secretShare"] = s;
} HANDLE_SGX_EXCEPTION(result) } HANDLE_SGX_EXCEPTION(result)
result["status"] = 0; RETURN_SUCCESS(result)
result["errorMessage"] = "";
return result;
} }
Json::Value SGXWalletServer::dkgVerificationImpl(const string &_publicShares, const string &_ethKeyName, Json::Value SGXWalletServer::dkgVerificationImpl(const string &_publicShares, const string &_ethKeyName,
...@@ -534,9 +508,7 @@ Json::Value SGXWalletServer::dkgVerificationImpl(const string &_publicShares, co ...@@ -534,9 +508,7 @@ Json::Value SGXWalletServer::dkgVerificationImpl(const string &_publicShares, co
result["result"] = true; result["result"] = true;
result["errorMessage"] = ""; RETURN_SUCCESS(result)
result["status"] = 0;
return result;
} }
Json::Value Json::Value
...@@ -589,9 +561,7 @@ SGXWalletServer::createBLSPrivateKeyImpl(const string &_blsKeyName, const string ...@@ -589,9 +561,7 @@ SGXWalletServer::createBLSPrivateKeyImpl(const string &_blsKeyName, const string
} HANDLE_SGX_EXCEPTION(result) } HANDLE_SGX_EXCEPTION(result)
result["status"] = 0; RETURN_SUCCESS(result)
result["errorMessage"] = "";
return result;
} }
Json::Value SGXWalletServer::getBLSPublicKeyShareImpl(const string &_blsKeyName) { Json::Value SGXWalletServer::getBLSPublicKeyShareImpl(const string &_blsKeyName) {
...@@ -611,9 +581,7 @@ Json::Value SGXWalletServer::getBLSPublicKeyShareImpl(const string &_blsKeyName) ...@@ -611,9 +581,7 @@ Json::Value SGXWalletServer::getBLSPublicKeyShareImpl(const string &_blsKeyName)
} }
} HANDLE_SGX_EXCEPTION(result) } HANDLE_SGX_EXCEPTION(result)
result["errorMessage"] = ""; RETURN_SUCCESS(result)
result["status"] = 0;
return result;
} }
...@@ -633,10 +601,7 @@ Json::Value SGXWalletServer::complaintResponseImpl(const string &_polyName, int ...@@ -633,10 +601,7 @@ Json::Value SGXWalletServer::complaintResponseImpl(const string &_polyName, int
result["dhKey"] = DHKey; result["dhKey"] = DHKey;
} HANDLE_SGX_EXCEPTION(result) } HANDLE_SGX_EXCEPTION(result)
result["errorMessage"] = ""; RETURN_SUCCESS(result)
result["status"] = 0;
return result;
} }
Json::Value SGXWalletServer::multG2Impl(const string &_x) { Json::Value SGXWalletServer::multG2Impl(const string &_x) {
...@@ -675,10 +640,7 @@ Json::Value SGXWalletServer::isPolyExistsImpl(const string &_polyName) { ...@@ -675,10 +640,7 @@ Json::Value SGXWalletServer::isPolyExistsImpl(const string &_polyName) {
Json::Value SGXWalletServer::getServerStatusImpl() { Json::Value SGXWalletServer::getServerStatusImpl() {
INIT_RESULT(result) INIT_RESULT(result)
result["status"] = 0; RETURN_SUCCESS(result)
result["errorMessage"] = "";
return result;
} }
Json::Value SGXWalletServer::getServerVersionImpl() { Json::Value SGXWalletServer::getServerVersionImpl() {
...@@ -709,9 +671,8 @@ Json::Value SGXWalletServer::deleteBlsKeyImpl(const std::string& name) { ...@@ -709,9 +671,8 @@ Json::Value SGXWalletServer::deleteBlsKeyImpl(const std::string& name) {
throw SGXException(INVALID_BLS_NAME, error_msg.c_str()); throw SGXException(INVALID_BLS_NAME, error_msg.c_str());
} }
} HANDLE_SGX_EXCEPTION(result) } HANDLE_SGX_EXCEPTION(result)
result["status"] = 0;
result["errorMessage"] = ""; RETURN_SUCCESS(result)
return result;
} }
Json::Value SGXWalletServer::generateDKGPoly(const string &_polyName, int _t) { Json::Value SGXWalletServer::generateDKGPoly(const string &_polyName, int _t) {
......
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