SKALE-3660 remove semaphore

parent 0c65f553
...@@ -184,10 +184,8 @@ bool sign_aes(const char *_encryptedKeyHex, const char *_hashHex, size_t _t, siz ...@@ -184,10 +184,8 @@ bool sign_aes(const char *_encryptedKeyHex, const char *_hashHex, size_t _t, siz
sgx_status_t status = SGX_SUCCESS; sgx_status_t status = SGX_SUCCESS;
SEMAPHORE_BEGIN status = trustedBlsSignMessage(eid, &errStatus, errMsg.data(), encryptedKey,
status = trustedBlsSignMessage(eid, &errStatus, errMsg.data(), encryptedKey, sz, xStrArg, yStrArg, signature);
sz, xStrArg, yStrArg, signature);
SEMAPHORE_END
HANDLE_TRUSTED_FUNCTION_ERROR(status, errStatus, errMsg.data()); HANDLE_TRUSTED_FUNCTION_ERROR(status, errStatus, errMsg.data());
...@@ -226,10 +224,8 @@ string encryptBLSKeyShare2Hex(int *errStatus, char *err_string, const char *_key ...@@ -226,10 +224,8 @@ string encryptBLSKeyShare2Hex(int *errStatus, char *err_string, const char *_key
sgx_status_t status = SGX_SUCCESS; sgx_status_t status = SGX_SUCCESS;
SEMAPHORE_BEGIN status = trustedEncryptKey(eid, errStatus, errMsg.data(), keyArray->data(), encryptedKey->data(),
status = trustedEncryptKey(eid, errStatus, errMsg.data(), keyArray->data(), encryptedKey->data(), &encryptedLen);
&encryptedLen);
SEMAPHORE_END
HANDLE_TRUSTED_FUNCTION_ERROR(status, *errStatus, errMsg.data()); HANDLE_TRUSTED_FUNCTION_ERROR(status, *errStatus, errMsg.data());
......
...@@ -149,10 +149,8 @@ string BLSPrivateKeyShareSGX::signWithHelperSGXstr( ...@@ -149,10 +149,8 @@ string BLSPrivateKeyShareSGX::signWithHelperSGXstr(
sgx_status_t status = SGX_SUCCESS; sgx_status_t status = SGX_SUCCESS;
SEMAPHORE_BEGIN status = trustedBlsSignMessage(eid, &errStatus, errMsg.data(), encryptedKey,
status = trustedBlsSignMessage(eid, &errStatus, errMsg.data(), encryptedKey, encryptedKeyHex->size() / 2, xStrArg, yStrArg, signature);
encryptedKeyHex->size() / 2, xStrArg, yStrArg, signature);
SEMAPHORE_END
HANDLE_TRUSTED_FUNCTION_ERROR(status, errStatus, errMsg.data()); HANDLE_TRUSTED_FUNCTION_ERROR(status, errStatus, errMsg.data());
......
...@@ -136,11 +136,8 @@ string gen_dkg_poly(int _t) { ...@@ -136,11 +136,8 @@ string gen_dkg_poly(int _t) {
sgx_status_t status = SGX_SUCCESS; sgx_status_t status = SGX_SUCCESS;
status = trustedGenDkgSecret(eid, &errStatus, errMsg.data(), encrypted_dkg_secret.data(),
SEMAPHORE_BEGIN &enc_len, _t);
status = trustedGenDkgSecret(
eid, &errStatus, errMsg.data(), encrypted_dkg_secret.data(), &enc_len, _t);
SEMAPHORE_END
HANDLE_TRUSTED_FUNCTION_ERROR(status, errStatus, errMsg.data()); HANDLE_TRUSTED_FUNCTION_ERROR(status, errStatus, errMsg.data());
...@@ -176,11 +173,8 @@ vector <vector<string>> get_verif_vect(const string &encryptedPolyHex, int t, in ...@@ -176,11 +173,8 @@ vector <vector<string>> get_verif_vect(const string &encryptedPolyHex, int t, in
sgx_status_t status = SGX_SUCCESS; sgx_status_t status = SGX_SUCCESS;
status = trustedGetPublicShares(eid, &errStatus, errMsg.data(), encrDKGPoly.data(), encLen,
SEMAPHORE_BEGIN pubShares.data(), t, n);
status = trustedGetPublicShares(eid, &errStatus, errMsg.data(), encrDKGPoly.data(), encLen,
pubShares.data(), t, n);
SEMAPHORE_END
HANDLE_TRUSTED_FUNCTION_ERROR(status, errStatus, errMsg.data()); HANDLE_TRUSTED_FUNCTION_ERROR(status, errStatus, errMsg.data());
...@@ -369,10 +363,8 @@ verifyShares(const char *publicShares, const char *encr_sshare, const char *encr ...@@ -369,10 +363,8 @@ verifyShares(const char *publicShares, const char *encr_sshare, const char *encr
sgx_status_t status = SGX_SUCCESS; sgx_status_t status = SGX_SUCCESS;
SEMAPHORE_BEGIN status = trustedDkgVerify(eid, &errStatus, errMsg.data(), pshares, encr_sshare, encr_key, decKeyLen, t,
status = trustedDkgVerify(eid, &errStatus, errMsg.data(), pshares, encr_sshare, encr_key, decKeyLen, t, ind, &result);
ind, &result);
SEMAPHORE_END
HANDLE_TRUSTED_FUNCTION_ERROR(status, errStatus, errMsg.data()); HANDLE_TRUSTED_FUNCTION_ERROR(status, errStatus, errMsg.data());
...@@ -406,10 +398,8 @@ verifySharesV2(const char *publicShares, const char *encr_sshare, const char *en ...@@ -406,10 +398,8 @@ verifySharesV2(const char *publicShares, const char *encr_sshare, const char *en
sgx_status_t status = SGX_SUCCESS; sgx_status_t status = SGX_SUCCESS;
SEMAPHORE_BEGIN status = trustedDkgVerifyV2(eid, &errStatus, errMsg.data(), pshares, encr_sshare, encr_key, decKeyLen, t,
status = trustedDkgVerifyV2(eid, &errStatus, errMsg.data(), pshares, encr_sshare, encr_key, decKeyLen, t, ind, &result);
ind, &result);
SEMAPHORE_END
HANDLE_TRUSTED_FUNCTION_ERROR(status, errStatus, errMsg.data()); HANDLE_TRUSTED_FUNCTION_ERROR(status, errStatus, errMsg.data());
...@@ -437,10 +427,8 @@ bool createBLSShare(const string &blsKeyName, const char *s_shares, const char * ...@@ -437,10 +427,8 @@ bool createBLSShare(const string &blsKeyName, const char *s_shares, const char *
sgx_status_t status = SGX_SUCCESS; sgx_status_t status = SGX_SUCCESS;
SEMAPHORE_BEGIN status = trustedCreateBlsKey(eid, &errStatus, errMsg.data(), s_shares, encr_key, decKeyLen, encr_bls_key,
status = trustedCreateBlsKey(eid, &errStatus, errMsg.data(), s_shares, encr_key, decKeyLen, encr_bls_key, &enc_bls_len);
&enc_bls_len);
SEMAPHORE_END
HANDLE_TRUSTED_FUNCTION_ERROR(status, errStatus, errMsg.data()); HANDLE_TRUSTED_FUNCTION_ERROR(status, errStatus, errMsg.data());
...@@ -471,9 +459,7 @@ vector <string> getBLSPubKey(const char *encryptedKeyHex) { ...@@ -471,9 +459,7 @@ vector <string> getBLSPubKey(const char *encryptedKeyHex) {
sgx_status_t status = SGX_SUCCESS; sgx_status_t status = SGX_SUCCESS;
SEMAPHORE_BEGIN status = trustedGetBlsPubKey(eid, &errStatus, errMsg1.data(), encrKey, decKeyLen, pubKey);
status = trustedGetBlsPubKey(eid, &errStatus, errMsg1.data(), encrKey, decKeyLen, pubKey);
SEMAPHORE_END
HANDLE_TRUSTED_FUNCTION_ERROR(status, errStatus, errMsg1.data()); HANDLE_TRUSTED_FUNCTION_ERROR(status, errStatus, errMsg1.data());
...@@ -557,9 +543,8 @@ string decryptDHKey(const string &polyName, int ind) { ...@@ -557,9 +543,8 @@ string decryptDHKey(const string &polyName, int ind) {
sgx_status_t status = SGX_SUCCESS; sgx_status_t status = SGX_SUCCESS;
SEMAPHORE_BEGIN status = trustedDecryptKey(eid, &errStatus, errMsg1.data(), encryptedDHKey, dhEncLen, DHKey);
status = trustedDecryptKey(eid, &errStatus, errMsg1.data(), encryptedDHKey, dhEncLen, DHKey);
SEMAPHORE_END
HANDLE_TRUSTED_FUNCTION_ERROR(status, errStatus, errMsg1.data()) HANDLE_TRUSTED_FUNCTION_ERROR(status, errStatus, errMsg1.data())
return DHKey; return DHKey;
......
...@@ -59,11 +59,9 @@ vector <string> genECDSAKey() { ...@@ -59,11 +59,9 @@ vector <string> genECDSAKey() {
sgx_status_t status = SGX_SUCCESS; sgx_status_t status = SGX_SUCCESS;
SEMAPHORE_BEGIN status = trustedGenerateEcdsaKey(eid, &errStatus,
status = trustedGenerateEcdsaKey(eid, &errStatus, errMsg.data(), encr_pr_key.data(), &enc_len,
errMsg.data(), encr_pr_key.data(), &enc_len, pub_key_x.data(), pub_key_y.data());
pub_key_x.data(), pub_key_y.data());
SEMAPHORE_END
HANDLE_TRUSTED_FUNCTION_ERROR(status, errStatus,errMsg.data()); HANDLE_TRUSTED_FUNCTION_ERROR(status, errStatus,errMsg.data());
...@@ -101,10 +99,8 @@ string getECDSAPubKey(const std::string& _encryptedKeyHex) { ...@@ -101,10 +99,8 @@ string getECDSAPubKey(const std::string& _encryptedKeyHex) {
sgx_status_t status = SGX_SUCCESS; sgx_status_t status = SGX_SUCCESS;
SEMAPHORE_BEGIN status = trustedGetPublicEcdsaKey(eid, &errStatus,
status = trustedGetPublicEcdsaKey(eid, &errStatus, errMsg.data(), encrPrKey.data(), enc_len, pubKeyX.data(), pubKeyY.data());
errMsg.data(), encrPrKey.data(), enc_len, pubKeyX.data(), pubKeyY.data());
SEMAPHORE_END
HANDLE_TRUSTED_FUNCTION_ERROR(status, errStatus, errMsg.data()) HANDLE_TRUSTED_FUNCTION_ERROR(status, errStatus, errMsg.data())
...@@ -190,12 +186,10 @@ vector <string> ecdsaSignHash(const std::string& encryptedKeyHex, const char *ha ...@@ -190,12 +186,10 @@ vector <string> ecdsaSignHash(const std::string& encryptedKeyHex, const char *ha
sgx_status_t status = SGX_SUCCESS; sgx_status_t status = SGX_SUCCESS;
SEMAPHORE_BEGIN status = trustedEcdsaSign(eid, &errStatus,
status = trustedEcdsaSign(eid, &errStatus, errMsg.data(), encryptedKey.data(), decLen, hashHex,
errMsg.data(), encryptedKey.data(), decLen, hashHex, signatureR.data(),
signatureR.data(), signatureS.data(), &signatureV, base);
signatureS.data(), &signatureV, base);
SEMAPHORE_END
HANDLE_TRUSTED_FUNCTION_ERROR(status, errStatus, errMsg.data()); HANDLE_TRUSTED_FUNCTION_ERROR(status, errStatus, errMsg.data());
...@@ -242,10 +236,9 @@ string encryptECDSAKey(const string& _key) { ...@@ -242,10 +236,9 @@ string encryptECDSAKey(const string& _key) {
uint64_t enc_len = 0; uint64_t enc_len = 0;
sgx_status_t status = SGX_SUCCESS; sgx_status_t status = SGX_SUCCESS;
SEMAPHORE_BEGIN
status = trustedEncryptKey(eid, &errStatus, errString.data(), key.data(), status = trustedEncryptKey(eid, &errStatus, errString.data(), key.data(),
encryptedKey.data(), &enc_len); encryptedKey.data(), &enc_len);
SEMAPHORE_END
if (status != 0) { if (status != 0) {
throw SGXException(status, string("Could not encrypt ECDSA key: " + string(errString.begin(), errString.end())).c_str()); throw SGXException(status, string("Could not encrypt ECDSA key: " + string(errString.begin(), errString.end())).c_str());
......
...@@ -57,10 +57,6 @@ using namespace std; ...@@ -57,10 +57,6 @@ using namespace std;
std::shared_timed_mutex sgxInitMutex; std::shared_timed_mutex sgxInitMutex;
// MAX 200 threads can call enclave
boost::interprocess::interprocess_semaphore enclaveSemaphore(200);
uint64_t initTime; uint64_t initTime;
void setFullOptions(uint64_t _logLevel, int _useHTTPS, int _autoconfirm, int _enterBackupKey) { void setFullOptions(uint64_t _logLevel, int _useHTTPS, int _autoconfirm, int _enterBackupKey) {
...@@ -123,7 +119,7 @@ void SGXWalletServer::printDB() { ...@@ -123,7 +119,7 @@ void SGXWalletServer::printDB() {
#ifdef SGX_HW_SIM #ifdef SGX_HW_SIM
#define NUM_THREADS 16 #define NUM_THREADS 16
#else #else
#define NUM_THREADS 1024 #define NUM_THREADS 200
#endif #endif
......
...@@ -113,7 +113,7 @@ extern bool autoconfirm; ...@@ -113,7 +113,7 @@ extern bool autoconfirm;
#define FILE_NOT_FOUND -44 #define FILE_NOT_FOUND -44
#define INVALID_DKG_GETSS_PARAMS -45 #define INVALID_DKG_GETSS_PARAMS -45
#define INVALID_DKG_GETSS_PUB_KEY_COUNT -46 #define INVALID_DKG_GETSS_PUB_KEY_COUNT -46
#define INVALID_DKG_GETSS_KEY_HEX -47 #define INVALID_DKG_GETSS_KEY_HEX -47
#define INVALID_DKG_VERIFY_ECDSA_KEY_NAME -48 #define INVALID_DKG_VERIFY_ECDSA_KEY_NAME -48
#define INVALID_DKG_VERIFY_PARAMS -49 #define INVALID_DKG_VERIFY_PARAMS -49
#define INVALID_DKG_VERIFY_SS_HEX -50 #define INVALID_DKG_VERIFY_SS_HEX -50
...@@ -125,14 +125,14 @@ extern bool autoconfirm; ...@@ -125,14 +125,14 @@ extern bool autoconfirm;
#define INVALID_CREATE_BLS_KEY_NAME -56 #define INVALID_CREATE_BLS_KEY_NAME -56
#define INVALID_CREATE_BLS_DKG_PARAMS -57 #define INVALID_CREATE_BLS_DKG_PARAMS -57
#define INVALID_CREATE_BLS_SHARE -58 #define INVALID_CREATE_BLS_SHARE -58
#define INVALID_GET_BLS_PUBKEY_NAME -59 #define INVALID_GET_BLS_PUBKEY_NAME -59
#define INVALID_DKG_CALCULATE_ALL_PARAMS -60 #define INVALID_DKG_CALCULATE_ALL_PARAMS -60
#define INVALID_DKG_CALCULATE_ALL_PUBSHARES -61 #define INVALID_DKG_CALCULATE_ALL_PUBSHARES -61
#define INVALID_DKG_CALCULATE_ALL_PUBSHARES_SIZE -62 #define INVALID_DKG_CALCULATE_ALL_PUBSHARES_SIZE -62
#define INVALID_DKG_CALCULATE_ALL_PUBSHARES_STRING -63 #define INVALID_DKG_CALCULATE_ALL_PUBSHARES_STRING -63
#define INVALID_DKG_CALCULATE_ALL_STRING_PUBSHARES_SLENGTH -64 #define INVALID_DKG_CALCULATE_ALL_STRING_PUBSHARES_SLENGTH -64
#define INVALID_DKG_CALCULATE_ALL_STRING_PUBKEYS_SIZE -65 #define INVALID_DKG_CALCULATE_ALL_STRING_PUBKEYS_SIZE -65
#define INVALID_COMPLAINT_RESPONSE_POLY_NAME -66 #define INVALID_COMPLAINT_RESPONSE_POLY_NAME -66
#define INVALID_DKG_GETSS_V2_PARAMS -63 #define INVALID_DKG_GETSS_V2_PARAMS -63
#define INVALID_DKG_GETSS_V2_POLY_NAME -64 #define INVALID_DKG_GETSS_V2_POLY_NAME -64
#define INVALID_DKG_GETSS_V2_PUBKEY_COUNT -65 #define INVALID_DKG_GETSS_V2_PUBKEY_COUNT -65
...@@ -147,7 +147,7 @@ extern bool autoconfirm; ...@@ -147,7 +147,7 @@ extern bool autoconfirm;
#define CONVERT_G2_INCORRECT_STRING_CONVERSION -74 #define CONVERT_G2_INCORRECT_STRING_CONVERSION -74
#define DELETE_BLS_KEY_INVALID_KEYNAME -75 #define DELETE_BLS_KEY_INVALID_KEYNAME -75
#define DELETE_BLS_KEY_NOT_FOUND -76 #define DELETE_BLS_KEY_NOT_FOUND -76
#define VERIFY_SHARES_INVALID_PUBLIC_SHARES -77 #define VERIFY_SHARES_INVALID_PUBLIC_SHARES -77
#define VERIFY_SHARES_V2_INVALID_POLY_HEX -78 #define VERIFY_SHARES_V2_INVALID_POLY_HEX -78
#define VERIFY_SHARES_V2_INVALID_PUBLIC_SHARES -79 #define VERIFY_SHARES_V2_INVALID_PUBLIC_SHARES -79
#define CREATE_BLS_SHARE_INVALID_KEY_HEX -80 #define CREATE_BLS_SHARE_INVALID_KEY_HEX -80
...@@ -158,7 +158,7 @@ extern bool autoconfirm; ...@@ -158,7 +158,7 @@ extern bool autoconfirm;
#define GET_ECDSA_PUB_KEY_INVALID_KEY_HEX -85 #define GET_ECDSA_PUB_KEY_INVALID_KEY_HEX -85
#define ECDSA_SIGN_INVALID_KEY_HEX -86 #define ECDSA_SIGN_INVALID_KEY_HEX -86
#define SET_SEK_INVALID_SEK_HEX -87 #define SET_SEK_INVALID_SEK_HEX -87
#define TEST_INVALID_HEX -88 #define TEST_INVALID_HEX -88
#define SGX_ENCLAVE_ERROR -666 #define SGX_ENCLAVE_ERROR -666
...@@ -173,10 +173,5 @@ extern bool autoconfirm; ...@@ -173,10 +173,5 @@ extern bool autoconfirm;
#define TEST_VALUE "1234567890" #define TEST_VALUE "1234567890"
#define SEMAPHORE_BEGIN { semaphore_guard __ENCLAVE__GUARD__(enclaveSemaphore) ;
#define SEMAPHORE_END }
#endif //SGXWALLET_SGXWALLET_COMMON_H #endif //SGXWALLET_SGXWALLET_COMMON_H
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