Unverified Commit b33321c2 authored by kladko's avatar kladko

SKALE-3067-cleanup-sgx

parent 18c63687
...@@ -42,7 +42,6 @@ CSRManagerServer::CSRManagerServer(AbstractServerConnector &connector, ...@@ -42,7 +42,6 @@ CSRManagerServer::CSRManagerServer(AbstractServerConnector &connector,
Json::Value getUnsignedCSRsImpl() { Json::Value getUnsignedCSRsImpl() {
spdlog::info(__FUNCTION__); spdlog::info(__FUNCTION__);
INIT_RESULT(result) INIT_RESULT(result)
try { try {
vector<string> hashes_vect = LevelDB::getCsrDb()->writeKeysToVector1(MAX_CSR_NUM); vector<string> hashes_vect = LevelDB::getCsrDb()->writeKeysToVector1(MAX_CSR_NUM);
for (int i = 0; i < (int) hashes_vect.size(); i++) { for (int i = 0; i < (int) hashes_vect.size(); i++) {
...@@ -50,11 +49,12 @@ Json::Value getUnsignedCSRsImpl() { ...@@ -50,11 +49,12 @@ Json::Value getUnsignedCSRsImpl() {
} }
} HANDLE_SGX_EXCEPTION(result); } HANDLE_SGX_EXCEPTION(result);
return result; RETURN_SUCCESS(result)
} }
Json::Value signByHashImpl(const string &hash, int status) { Json::Value signByHashImpl(const string &hash, int status) {
Json::Value result;
INIT_RESULT(result)
result["errorMessage"] = ""; result["errorMessage"] = "";
try { try {
...@@ -102,7 +102,7 @@ Json::Value signByHashImpl(const string &hash, int status) { ...@@ -102,7 +102,7 @@ Json::Value signByHashImpl(const string &hash, int status) {
} HANDLE_SGX_EXCEPTION(result) } HANDLE_SGX_EXCEPTION(result)
return result; return result;
} }
Json::Value CSRManagerServer::getUnsignedCSRs() { Json::Value CSRManagerServer::getUnsignedCSRs() {
......
...@@ -152,9 +152,9 @@ vector<vector<string>> get_verif_vect(const char *encryptedPolyHex, int t, int n ...@@ -152,9 +152,9 @@ vector<vector<string>> get_verif_vect(const char *encryptedPolyHex, int t, int n
return pubSharesVect; return pubSharesVect;
} }
string trustedGetSecretShares(const string &_polyName, const char *_encryptedPolyHex, const vector<string> &_publicKeys, string getSecretShares(const string &_polyName, const char *_encryptedPolyHex, const vector<string> &_publicKeys,
int _t, int _t,
int _n) { int _n) {
vector<char> hexEncrKey(BUF_LEN, 0); vector<char> hexEncrKey(BUF_LEN, 0);
vector<char> errMsg1(BUF_LEN, 0); vector<char> errMsg1(BUF_LEN, 0);
int errStatus = 0; int errStatus = 0;
......
...@@ -35,7 +35,7 @@ vector <vector<string>> get_verif_vect(const char* encryptedPolyHex, int t, int ...@@ -35,7 +35,7 @@ vector <vector<string>> get_verif_vect(const char* encryptedPolyHex, int t, int
vector<string> splitString(const char* coeffs, const char symbol); vector<string> splitString(const char* coeffs, const char symbol);
string trustedGetSecretShares(const string& _polyName, const char* _encryptedPolyHex, const vector<string>& _publicKeys, int _t, int _n); string getSecretShares(const string& _polyName, const char* _encryptedPolyHex, const vector<string>& _publicKeys, int _t, int _n);
bool verifyShares(const char* publicShares, const char* encr_sshare, const char * encryptedKeyHex, int t, int n, int ind); bool verifyShares(const char* publicShares, const char* encr_sshare, const char * encryptedKeyHex, int t, int n, int ind);
......
...@@ -74,7 +74,7 @@ public: ...@@ -74,7 +74,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"] = UNKNOWN_ERROR; __RESULT__["errorMessage"] = \
"Server error. Please see server log."; "Server error. Please see server log.";
#define HANDLE_SGX_EXCEPTION(__RESULT__) \ #define HANDLE_SGX_EXCEPTION(__RESULT__) \
......
...@@ -112,7 +112,8 @@ Json::Value signCertificateImpl(const string &_csr, bool _autoSign = false) { ...@@ -112,7 +112,8 @@ Json::Value signCertificateImpl(const string &_csr, bool _autoSign = false) {
} HANDLE_SGX_EXCEPTION(result) } HANDLE_SGX_EXCEPTION(result)
return result; RETURN_SUCCESS(result)
} }
Json::Value getCertificateImpl(const string &hash) { Json::Value getCertificateImpl(const string &hash) {
...@@ -147,7 +148,7 @@ Json::Value getCertificateImpl(const string &hash) { ...@@ -147,7 +148,7 @@ Json::Value getCertificateImpl(const string &hash) {
} HANDLE_SGX_EXCEPTION(result) } HANDLE_SGX_EXCEPTION(result)
return result; RETURN_SUCCESS(result)
} }
......
...@@ -221,22 +221,7 @@ SGXWalletServer::blsSignMessageHashImpl(const string &_keyShareName, const strin ...@@ -221,22 +221,7 @@ SGXWalletServer::blsSignMessageHashImpl(const string &_keyShareName, const strin
} }
value = readFromDb(_keyShareName); value = readFromDb(_keyShareName);
} catch (SGXException& _e) {
result["status"] = _e.status;
result["errorMessage"] = _e.errString;
return result;
} catch (exception& _e) {
result["errorMessage"] = _e.what();
return result;
}
catch (...) {
exception_ptr p = current_exception();
printf("Exception %s \n", p.__cxa_exception_type()->name());
result["errorMessage"] = "Exception in dbRead";
return result;
}
try {
if (!bls_sign(value->c_str(), _messageHash.c_str(), t, n, _signerIndex, signature.data())) { if (!bls_sign(value->c_str(), _messageHash.c_str(), t, n, _signerIndex, signature.data())) {
result["status"] = -1; result["status"] = -1;
result["errorMessage"] = "Could not sign"; result["errorMessage"] = "Could not sign";
...@@ -409,8 +394,6 @@ Json::Value SGXWalletServer::getVerificationVectorImpl(const string &_polyName, ...@@ -409,8 +394,6 @@ Json::Value SGXWalletServer::getVerificationVectorImpl(const string &_polyName,
INIT_RESULT(result); INIT_RESULT(result);
result["status"] = 0;
result["errorMessage"] = "";
vector <vector<string>> verifVector; vector <vector<string>> verifVector;
try { try {
...@@ -438,17 +421,14 @@ Json::Value SGXWalletServer::getVerificationVectorImpl(const string &_polyName, ...@@ -438,17 +421,14 @@ Json::Value SGXWalletServer::getVerificationVectorImpl(const string &_polyName,
result["verificationVector"] = ""; result["verificationVector"] = "";
} }
RETURN_SUCCESS(result)
return result;
} }
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) {
INIT_RESULT(result); INIT_RESULT(result);
result["status"] = 0;
result["errorMessage"] = "";
try { try {
if (_pubKeys.size() != (uint64_t) _n) { if (_pubKeys.size() != (uint64_t) _n) {
throw SGXException(INVALID_DKG_PARAMS, "invalid number of public keys"); throw SGXException(INVALID_DKG_PARAMS, "invalid number of public keys");
...@@ -470,11 +450,12 @@ Json::Value SGXWalletServer::getSecretShareImpl(const string &_polyName, const J ...@@ -470,11 +450,12 @@ Json::Value SGXWalletServer::getSecretShareImpl(const string &_polyName, const J
pubKeysStrs.push_back(_pubKeys[i].asString()); pubKeysStrs.push_back(_pubKeys[i].asString());
} }
string s = trustedGetSecretShares(_polyName, encrPoly->c_str(), pubKeysStrs, _t, _n); string s = getSecretShares(_polyName, encrPoly->c_str(), pubKeysStrs, _t, _n);
result["secretShare"] = s; result["secretShare"] = s;
} HANDLE_SGX_EXCEPTION(result) } HANDLE_SGX_EXCEPTION(result)
RETURN_SUCCESS(result) RETURN_SUCCESS(result)
} }
Json::Value SGXWalletServer::dkgVerificationImpl(const string &_publicShares, const string &_ethKeyName, Json::Value SGXWalletServer::dkgVerificationImpl(const string &_publicShares, const string &_ethKeyName,
...@@ -517,8 +498,6 @@ SGXWalletServer::createBLSPrivateKeyImpl(const string &_blsKeyName, const string ...@@ -517,8 +498,6 @@ SGXWalletServer::createBLSPrivateKeyImpl(const string &_blsKeyName, const string
INIT_RESULT(result) INIT_RESULT(result)
result["status"] = 0;
result["errorMessage"] = "";
try { try {
if (_secretShare.length() != (uint64_t) _n * 192) { if (_secretShare.length() != (uint64_t) _n * 192) {
...@@ -615,9 +594,7 @@ Json::Value SGXWalletServer::multG2Impl(const string &_x) { ...@@ -615,9 +594,7 @@ Json::Value SGXWalletServer::multG2Impl(const string &_x) {
} HANDLE_SGX_EXCEPTION(result) } HANDLE_SGX_EXCEPTION(result)
result["status"] = 0; RETURN_SUCCESS(result)
result["errorMessage"] = "";
return result;
} }
Json::Value SGXWalletServer::isPolyExistsImpl(const string &_polyName) { Json::Value SGXWalletServer::isPolyExistsImpl(const string &_polyName) {
...@@ -633,9 +610,7 @@ Json::Value SGXWalletServer::isPolyExistsImpl(const string &_polyName) { ...@@ -633,9 +610,7 @@ Json::Value SGXWalletServer::isPolyExistsImpl(const string &_polyName) {
} }
} HANDLE_SGX_EXCEPTION(result) } HANDLE_SGX_EXCEPTION(result)
result["status"] = 0; RETURN_SUCCESS(result)
result["errorMessage"] = "";
return result;
} }
Json::Value SGXWalletServer::getServerStatusImpl() { Json::Value SGXWalletServer::getServerStatusImpl() {
...@@ -647,9 +622,7 @@ Json::Value SGXWalletServer::getServerVersionImpl() { ...@@ -647,9 +622,7 @@ Json::Value SGXWalletServer::getServerVersionImpl() {
INIT_RESULT(result) INIT_RESULT(result)
result["version"] = TOSTRING(SGXWALLET_VERSION); result["version"] = TOSTRING(SGXWALLET_VERSION);
result["status"] = 0; RETURN_SUCCESS(result)
result["errorMessage"] = "";
return result;
} }
Json::Value SGXWalletServer::deleteBlsKeyImpl(const std::string& name) { Json::Value SGXWalletServer::deleteBlsKeyImpl(const std::string& name) {
......
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