SKALE-2977 clean up

parent c53e67de
...@@ -198,6 +198,9 @@ bool sign_aes(const char *_encryptedKeyHex, const char *_hashHex, size_t _t, siz ...@@ -198,6 +198,9 @@ bool sign_aes(const char *_encryptedKeyHex, const char *_hashHex, size_t _t, siz
strncpy(xStrArg, xStr->c_str(), BUF_LEN); strncpy(xStrArg, xStr->c_str(), BUF_LEN);
strncpy(yStrArg, yStr->c_str(), BUF_LEN); strncpy(yStrArg, yStr->c_str(), BUF_LEN);
delete xStr;
delete yStr;
size_t sz = 0; size_t sz = 0;
uint8_t encryptedKey[BUF_LEN]; uint8_t encryptedKey[BUF_LEN];
...@@ -206,8 +209,6 @@ bool sign_aes(const char *_encryptedKeyHex, const char *_hashHex, size_t _t, siz ...@@ -206,8 +209,6 @@ bool sign_aes(const char *_encryptedKeyHex, const char *_hashHex, size_t _t, siz
if (!result) { if (!result) {
cerr << "Invalid hex encrypted key" << endl; cerr << "Invalid hex encrypted key" << endl;
delete xStr;
delete yStr;
BOOST_THROW_EXCEPTION(std::invalid_argument("Invalid hex encrypted key")); BOOST_THROW_EXCEPTION(std::invalid_argument("Invalid hex encrypted key"));
} }
...@@ -219,15 +220,11 @@ bool sign_aes(const char *_encryptedKeyHex, const char *_hashHex, size_t _t, siz ...@@ -219,15 +220,11 @@ bool sign_aes(const char *_encryptedKeyHex, const char *_hashHex, size_t _t, siz
if (status != SGX_SUCCESS) { if (status != SGX_SUCCESS) {
cerr << "SGX enclave call to trustedBlsSignMessage failed with status:" << status << std::endl; cerr << "SGX enclave call to trustedBlsSignMessage failed with status:" << status << std::endl;
delete xStr;
delete yStr;
BOOST_THROW_EXCEPTION(runtime_error("SGX enclave call to trustedBlsSignMessage failed")); BOOST_THROW_EXCEPTION(runtime_error("SGX enclave call to trustedBlsSignMessage failed"));
} }
if (errStatus != 0) { if (errStatus != 0) {
cerr << "SGX enclave call to trustedBlsSignMessage failed with errStatus:" << errStatus << std::endl; cerr << "SGX enclave call to trustedBlsSignMessage failed with errStatus:" << errStatus << std::endl;
delete xStr;
delete yStr;
BOOST_THROW_EXCEPTION(runtime_error("SGX enclave call to trustedBlsSignMessage failed")); BOOST_THROW_EXCEPTION(runtime_error("SGX enclave call to trustedBlsSignMessage failed"));
} }
...@@ -240,9 +237,6 @@ bool sign_aes(const char *_encryptedKeyHex, const char *_hashHex, size_t _t, siz ...@@ -240,9 +237,6 @@ bool sign_aes(const char *_encryptedKeyHex, const char *_hashHex, size_t _t, siz
strncpy(_sig, sig.c_str(), BUF_LEN); strncpy(_sig, sig.c_str(), BUF_LEN);
delete xStr;
delete yStr;
return true; return true;
} }
......
...@@ -236,13 +236,11 @@ SGXWalletServer::blsSignMessageHashImpl(const string &_keyShareName, const strin ...@@ -236,13 +236,11 @@ SGXWalletServer::blsSignMessageHashImpl(const string &_keyShareName, const strin
exception_ptr p = current_exception(); exception_ptr p = current_exception();
printf("Exception %s \n", p.__cxa_exception_type()->name()); printf("Exception %s \n", p.__cxa_exception_type()->name());
result["status"] = -1; result["status"] = -1;
result["errorMessage"] = "Read key share has thrown exception:"; result["errorMessage"] = "Read key share has thrown exception";
return result; return result;
} }
try { try {
static std::mutex g_mtx;
std::lock_guard<std::mutex> lock(g_mtx);
if (!bls_sign(value->c_str(), _messageHash.c_str(), t, n, _signerIndex, &signature.front())) { if (!bls_sign(value->c_str(), _messageHash.c_str(), t, n, _signerIndex, &signature.front())) {
result["status"] = -1; result["status"] = -1;
result["errorMessage"] = "Could not sign"; result["errorMessage"] = "Could not sign";
......
...@@ -130,7 +130,7 @@ bool enclave_sign(const char *_keyString, const char *_hashXString, const char * ...@@ -130,7 +130,7 @@ bool enclave_sign(const char *_keyString, const char *_hashXString, const char *
return true; return true;
} }
void carray2Hex(const unsigned char *d, int _len, char* _hexArray) { void carray2Hex(const unsigned char *d, int _len, char* _hexArray) {
char hexval[16] = {'0', '1', '2', '3', '4', '5', '6', '7', char hexval[16] = {'0', '1', '2', '3', '4', '5', '6', '7',
'8', '9', 'a', 'b', 'c', 'd', 'e', 'f'}; '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'};
......
...@@ -43,8 +43,6 @@ EXTERNC bool hex2carray2(const char * _hex, uint64_t *_bin_len, ...@@ -43,8 +43,6 @@ EXTERNC bool hex2carray2(const char * _hex, uint64_t *_bin_len,
uint8_t* _bin, const int _max_length ); uint8_t* _bin, const int _max_length );
EXTERNC void enclave_init(); EXTERNC void enclave_init();
void get_global_random(unsigned char* _randBuff, uint64_t size); void get_global_random(unsigned char* _randBuff, uint64_t size);
EXTERNC void LOG_INFO(const char* msg); EXTERNC void LOG_INFO(const char* msg);
......
...@@ -1262,7 +1262,7 @@ void trustedDecryptKeyAES(int *errStatus, char *errString, uint8_t *encryptedPri ...@@ -1262,7 +1262,7 @@ void trustedDecryptKeyAES(int *errStatus, char *errString, uint8_t *encryptedPri
} }
*errStatus = 0; *errStatus = 0;
memcpy(errString, AES_key, 1024); memcpy(errString, AES_key, BUF_LEN);
} }
void trustedBlsSignMessageAES(int *errStatus, char *errString, uint8_t *encryptedPrivateKey, void trustedBlsSignMessageAES(int *errStatus, char *errString, uint8_t *encryptedPrivateKey,
......
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