Unverified Commit 90d7eaba authored by kladko's avatar kladko

SKALE-2454-add-logs-to-enclave

parent 3baf6d2e
...@@ -49,7 +49,7 @@ ...@@ -49,7 +49,7 @@
#include "BLSCrypto.h" #include "BLSCrypto.h"
#include "ServerInit.h" #include "ServerInit.h"
#include "RPCException.h" #include "SGXException.h"
#include "spdlog/spdlog.h" #include "spdlog/spdlog.h"
#include "common.h" #include "common.h"
...@@ -160,7 +160,7 @@ bool sign(const char *_encryptedKeyHex, const char *_hashHex, size_t _t, size_t ...@@ -160,7 +160,7 @@ bool sign(const char *_encryptedKeyHex, const char *_hashHex, size_t _t, size_t
uint64_t binLen; uint64_t binLen;
if (!hex2carray(_hashHex, &binLen, hash->data())) { if (!hex2carray(_hashHex, &binLen, hash->data())) {
throw RPCException(INVALID_HEX, "Invalid hash"); throw SGXException(INVALID_HEX, "Invalid hash");
} }
// assert(binLen == hash->size()); // assert(binLen == hash->size());
...@@ -201,7 +201,7 @@ bool sign_aes(const char *_encryptedKeyHex, const char *_hashHex, size_t _t, siz ...@@ -201,7 +201,7 @@ bool sign_aes(const char *_encryptedKeyHex, const char *_hashHex, size_t _t, siz
uint64_t binLen; uint64_t binLen;
if (!hex2carray(_hashHex, &binLen, hash->data())) { if (!hex2carray(_hashHex, &binLen, hash->data())) {
throw RPCException(INVALID_HEX, "Invalid hash"); throw SGXException(INVALID_HEX, "Invalid hash");
} }
// assert(binLen == hash->size()); // assert(binLen == hash->size());
...@@ -335,7 +335,7 @@ char *encryptBLSKeyShare2Hex(int *errStatus, char *err_string, const char *_key) ...@@ -335,7 +335,7 @@ char *encryptBLSKeyShare2Hex(int *errStatus, char *err_string, const char *_key)
} }
if (*errStatus != 0) { if (*errStatus != 0) {
throw RPCException(-666, errMsg->data()); throw SGXException(-666, errMsg->data());
} }
......
...@@ -58,7 +58,7 @@ add_executable(sgxwallet ...@@ -58,7 +58,7 @@ add_executable(sgxwallet
LevelDB.h LevelDB.h
oc_alloc.c oc_alloc.c
RPCException.cpp RPCException.cpp
RPCException.h SGXException.h
secure_enclave_u.c secure_enclave_u.c
secure_enclave_u.h secure_enclave_u.h
SEKManager.cpp SEKManager.cpp
......
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
#include "CSRManagerServer.h" #include "CSRManagerServer.h"
#include "RPCException.h" #include "SGXException.h"
#include "sgxwallet_common.h" #include "sgxwallet_common.h"
#include <iostream> #include <iostream>
...@@ -40,108 +40,107 @@ jsonrpc::HttpServer *hs3 = nullptr; ...@@ -40,108 +40,107 @@ jsonrpc::HttpServer *hs3 = nullptr;
CSRManagerServer::CSRManagerServer(AbstractServerConnector &connector, CSRManagerServer::CSRManagerServer(AbstractServerConnector &connector,
serverVersion_t type):abstractCSRManagerServer(connector, type){} serverVersion_t type) : abstractCSRManagerServer(connector, type) {}
Json::Value getUnsignedCSRsImpl(){ Json::Value getUnsignedCSRsImpl() {
spdlog::info("Enter getUnsignedCSRsImpl"); spdlog::info("Enter getUnsignedCSRsImpl");
Json::Value result; Json::Value result;
result["status"] = 0; result["status"] = 0;
result["errorMessage"] = ""; result["errorMessage"] = "";
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++) {
result["hashes"][i] = hashes_vect.at(i); result["hashes"][i] = hashes_vect.at(i);
} }
} catch (RPCException &_e) { } catch (SGXException &_e) {
cerr << " err str " << _e.errString << endl; cerr << " err str " << _e.errString << endl;
result["status"] = _e.status; result["status"] = _e.status;
result["errorMessage"] = _e.errString; result["errorMessage"] = _e.errString;
}
return result;
}
Json::Value signByHashImpl(const string& hash, int status){
Json::Value result;
result["errorMessage"] = "";
try{
if ( !(status == 0 || status == 2)){
throw RPCException(-111, "Invalid csr status");
}
string csr_db_key = "CSR:HASH:" + hash;
shared_ptr<string> csr_ptr = LevelDB::getCsrDb()->readString(csr_db_key);
if (csr_ptr == nullptr){
throw RPCException(KEY_SHARE_DOES_NOT_EXIST, "HASH DOES NOT EXIST IN DB");
} }
if (status == 0) { return result;
string csr_name = "sgx_data/cert/" + hash + ".csr"; }
ofstream outfile(csr_name);
outfile << *csr_ptr << endl;
outfile.close();
if (access(csr_name.c_str(), F_OK) != 0) {
LevelDB::getCsrDb()->deleteKey(csr_db_key);
throw RPCException(FILE_NOT_FOUND, "Csr does not exist");
}
string signClientCert = "cd sgx_data/cert && ./create_client_cert " + hash; Json::Value signByHashImpl(const string &hash, int status) {
Json::Value result;
result["errorMessage"] = "";
try {
if (!(status == 0 || status == 2)) {
throw SGXException(-111, "Invalid csr status");
}
string csr_db_key = "CSR:HASH:" + hash;
shared_ptr<string> csr_ptr = LevelDB::getCsrDb()->readString(csr_db_key);
if (csr_ptr == nullptr) {
throw SGXException(KEY_SHARE_DOES_NOT_EXIST, "HASH DOES NOT EXIST IN DB");
}
if (status == 0) {
string csr_name = "sgx_data/cert/" + hash + ".csr";
ofstream outfile(csr_name);
outfile << *csr_ptr << endl;
outfile.close();
if (access(csr_name.c_str(), F_OK) != 0) {
LevelDB::getCsrDb()->deleteKey(csr_db_key);
throw SGXException(FILE_NOT_FOUND, "Csr does not exist");
}
string signClientCert = "cd sgx_data/cert && ./create_client_cert " + hash;
if (system(signClientCert.c_str()) == 0) {
spdlog::info("CLIENT CERTIFICATE IS SUCCESSFULLY GENERATED");
} else {
spdlog::info("CLIENT CERTIFICATE GENERATION FAILED");
LevelDB::getCsrDb()->deleteKey(csr_db_key);
string status_db_key = "CSR:HASH:" + hash + "STATUS:";
LevelDB::getCsrStatusDb()->deleteKey(status_db_key);
LevelDB::getCsrStatusDb()->writeDataUnique(status_db_key, "-1");
throw SGXException(FAIL_TO_CREATE_CERTIFICATE, "CLIENT CERTIFICATE GENERATION FAILED");
//exit(-1);
}
}
if (system(signClientCert.c_str()) == 0) {
spdlog::info("CLIENT CERTIFICATE IS SUCCESSFULLY GENERATED");
} else {
spdlog::info("CLIENT CERTIFICATE GENERATION FAILED");
LevelDB::getCsrDb()->deleteKey(csr_db_key); LevelDB::getCsrDb()->deleteKey(csr_db_key);
string status_db_key = "CSR:HASH:" + hash + "STATUS:"; string status_db_key = "CSR:HASH:" + hash + "STATUS:";
LevelDB::getCsrStatusDb()->deleteKey(status_db_key); LevelDB::getCsrStatusDb()->deleteKey(status_db_key);
LevelDB::getCsrStatusDb()->writeDataUnique(status_db_key, "-1"); LevelDB::getCsrStatusDb()->writeDataUnique(status_db_key, to_string(status));
throw RPCException(FAIL_TO_CREATE_CERTIFICATE, "CLIENT CERTIFICATE GENERATION FAILED");
//exit(-1);
}
}
LevelDB::getCsrDb()->deleteKey(csr_db_key);
string status_db_key = "CSR:HASH:" + hash + "STATUS:";
LevelDB::getCsrStatusDb()->deleteKey(status_db_key);
LevelDB::getCsrStatusDb()->writeDataUnique(status_db_key, to_string(status));
result["status"] = status; result["status"] = status;
} catch (RPCException &_e) { } catch (SGXException &_e) {
cerr << " err str " << _e.errString << endl; cerr << " err str " << _e.errString << endl;
result["status"] = _e.status; result["status"] = _e.status;
result["errorMessage"] = _e.errString; result["errorMessage"] = _e.errString;
} }
return result; return result;
} }
Json::Value CSRManagerServer::getUnsignedCSRs(){ Json::Value CSRManagerServer::getUnsignedCSRs() {
lock_guard<recursive_mutex> lock(m); lock_guard<recursive_mutex> lock(m);
return getUnsignedCSRsImpl(); return getUnsignedCSRsImpl();
} }
Json::Value CSRManagerServer::signByHash(const string& hash, int status){ Json::Value CSRManagerServer::signByHash(const string &hash, int status) {
lock_guard<recursive_mutex> lock(m); lock_guard<recursive_mutex> lock(m);
return signByHashImpl(hash, status); return signByHashImpl(hash, status);
} }
int init_csrmanager_server(){ int init_csrmanager_server() {
hs3 = new jsonrpc::HttpServer(BASE_PORT + 2); hs3 = new jsonrpc::HttpServer(BASE_PORT + 2);
hs3 -> BindLocalhost(); hs3->BindLocalhost();
cs = new CSRManagerServer(*hs3, JSONRPC_SERVER_V2); // server (json-rpc 2.0) cs = new CSRManagerServer(*hs3, JSONRPC_SERVER_V2); // server (json-rpc 2.0)
if (!cs->StartListening()) { if (!cs->StartListening()) {
spdlog::info("CSR manager server could not start listening"); spdlog::info("CSR manager server could not start listening");
exit(-1); exit(-1);
} } else {
else { spdlog::info("CSR manager server started on port {}", BASE_PORT + 2);
spdlog::info("CSR manager server started on port {}", BASE_PORT + 2); }
} return 0;
return 0;
}; };
\ No newline at end of file
...@@ -28,7 +28,7 @@ ...@@ -28,7 +28,7 @@
#include <memory> #include <memory>
#include "SGXWalletServer.hpp" #include "SGXWalletServer.hpp"
#include "RPCException.h" #include "SGXException.h"
//#include <libBLS/libff/libff/algebra/curves/alt_bn128/alt_bn128_pp.hpp> //#include <libBLS/libff/libff/algebra/curves/alt_bn128/alt_bn128_pp.hpp>
#include <libff/algebra/curves/alt_bn128/alt_bn128_pp.hpp> #include <libff/algebra/curves/alt_bn128/alt_bn128_pp.hpp>
...@@ -88,7 +88,7 @@ string gen_dkg_poly(int _t) { ...@@ -88,7 +88,7 @@ string gen_dkg_poly(int _t) {
else else
status = gen_dkg_secret_aes(eid, &err_status, errMsg.data(), encrypted_dkg_secret.data(), &enc_len, _t); status = gen_dkg_secret_aes(eid, &err_status, errMsg.data(), encrypted_dkg_secret.data(), &enc_len, _t);
if (err_status != 0) { if (err_status != 0) {
throw RPCException(-666, errMsg.data()); throw SGXException(-666, errMsg.data());
} }
spdlog::debug("gen_dkg_secret, status {}", err_status, " err msg ", errMsg.data()); spdlog::debug("gen_dkg_secret, status {}", err_status, " err msg ", errMsg.data());
...@@ -127,7 +127,7 @@ vector<vector<string>> get_verif_vect(const char *encryptedPolyHex, int t, int n ...@@ -127,7 +127,7 @@ vector<vector<string>> get_verif_vect(const char *encryptedPolyHex, int t, int n
vector<uint8_t> encrDKGPoly(2 * BUF_LEN, 0); vector<uint8_t> encrDKGPoly(2 * BUF_LEN, 0);
if (!hex2carray2(encryptedPolyHex, &encLen, encrDKGPoly.data(), 6100)) { if (!hex2carray2(encryptedPolyHex, &encLen, encrDKGPoly.data(), 6100)) {
throw RPCException(INVALID_HEX, "Invalid encryptedPolyHex"); throw SGXException(INVALID_HEX, "Invalid encryptedPolyHex");
} }
...@@ -144,7 +144,7 @@ vector<vector<string>> get_verif_vect(const char *encryptedPolyHex, int t, int n ...@@ -144,7 +144,7 @@ vector<vector<string>> get_verif_vect(const char *encryptedPolyHex, int t, int n
status = get_public_shares_aes(eid, &errStatus, errMsg1.data(), encrDKGPoly.data(), encLen, pubShares.data(), t, n); status = get_public_shares_aes(eid, &errStatus, errMsg1.data(), encrDKGPoly.data(), encLen, pubShares.data(), t, n);
} }
if (errStatus != 0) { if (errStatus != 0) {
throw RPCException(-666, errMsg1.data()); throw SGXException(-666, errMsg1.data());
} }
...@@ -176,7 +176,7 @@ string get_secret_shares(const string &_polyName, const char *_encryptedPolyHex, ...@@ -176,7 +176,7 @@ string get_secret_shares(const string &_polyName, const char *_encryptedPolyHex,
vector<uint8_t > encrDKGPoly(BUF_LEN, 0); vector<uint8_t > encrDKGPoly(BUF_LEN, 0);
if (!hex2carray2(_encryptedPolyHex, &encLen, encrDKGPoly.data(), 6100)) { if (!hex2carray2(_encryptedPolyHex, &encLen, encrDKGPoly.data(), 6100)) {
throw RPCException(INVALID_HEX, "Invalid encryptedPolyHex"); throw SGXException(INVALID_HEX, "Invalid encryptedPolyHex");
} }
...@@ -187,7 +187,7 @@ string get_secret_shares(const string &_polyName, const char *_encryptedPolyHex, ...@@ -187,7 +187,7 @@ string get_secret_shares(const string &_polyName, const char *_encryptedPolyHex,
status = set_encrypted_dkg_poly_aes(eid, &errStatus, errMsg1.data(), encrDKGPoly.data(), &encLen); status = set_encrypted_dkg_poly_aes(eid, &errStatus, errMsg1.data(), encrDKGPoly.data(), &encLen);
if (status != SGX_SUCCESS || errStatus != 0) { if (status != SGX_SUCCESS || errStatus != 0) {
throw RPCException(-666, errMsg1.data()); throw SGXException(-666, errMsg1.data());
} }
string result; string result;
...@@ -215,7 +215,7 @@ string get_secret_shares(const string &_polyName, const char *_encryptedPolyHex, ...@@ -215,7 +215,7 @@ string get_secret_shares(const string &_polyName, const char *_encryptedPolyHex,
get_encr_sshare_aes(eid, &errStatus, errMsg1.data(), encryptedSkey.data(), &decLen, get_encr_sshare_aes(eid, &errStatus, errMsg1.data(), encryptedSkey.data(), &decLen,
currentShare.data(), sShareG2.data(), pubKeyB.data(), _t, _n, i + 1); currentShare.data(), sShareG2.data(), pubKeyB.data(), _t, _n, i + 1);
if (errStatus != 0) { if (errStatus != 0) {
throw RPCException(-666, errMsg1.data()); throw SGXException(-666, errMsg1.data());
} }
spdlog::debug("cur_share is {}", currentShare.data()); spdlog::debug("cur_share is {}", currentShare.data());
...@@ -253,7 +253,7 @@ verifyShares(const char *publicShares, const char *encr_sshare, const char *encr ...@@ -253,7 +253,7 @@ verifyShares(const char *publicShares, const char *encr_sshare, const char *encr
uint8_t encr_key[BUF_LEN]; uint8_t encr_key[BUF_LEN];
memset(encr_key, 0, BUF_LEN); memset(encr_key, 0, BUF_LEN);
if (!hex2carray(encryptedKeyHex, &dec_key_len, encr_key)) { if (!hex2carray(encryptedKeyHex, &dec_key_len, encr_key)) {
throw RPCException(INVALID_HEX, "Invalid encryptedPolyHex"); throw SGXException(INVALID_HEX, "Invalid encryptedPolyHex");
} }
int result; int result;
...@@ -270,7 +270,7 @@ verifyShares(const char *publicShares, const char *encr_sshare, const char *encr ...@@ -270,7 +270,7 @@ verifyShares(const char *publicShares, const char *encr_sshare, const char *encr
dkg_verification_aes(eid, &err_status, errMsg1, pshares, encr_sshare, encr_key, dec_key_len, t, ind, &result); dkg_verification_aes(eid, &err_status, errMsg1, pshares, encr_sshare, encr_key, dec_key_len, t, ind, &result);
if (result == 2) { if (result == 2) {
throw RPCException(INVALID_HEX, "Invalid public shares"); throw SGXException(INVALID_HEX, "Invalid public shares");
} }
spdlog::debug("errMsg1: {}", errMsg1); spdlog::debug("errMsg1: {}", errMsg1);
...@@ -295,7 +295,7 @@ bool CreateBLSShare(const string &blsKeyName, const char *s_shares, const char * ...@@ -295,7 +295,7 @@ bool CreateBLSShare(const string &blsKeyName, const char *s_shares, const char *
uint8_t encr_key[BUF_LEN]; uint8_t encr_key[BUF_LEN];
memset(encr_key, 0, BUF_LEN); memset(encr_key, 0, BUF_LEN);
if (!hex2carray(encryptedKeyHex, &dec_key_len, encr_key)) { if (!hex2carray(encryptedKeyHex, &dec_key_len, encr_key)) {
throw RPCException(INVALID_HEX, "Invalid encryptedKeyHex"); throw SGXException(INVALID_HEX, "Invalid encryptedKeyHex");
} }
uint32_t enc_bls_len = 0; uint32_t enc_bls_len = 0;
...@@ -310,7 +310,7 @@ bool CreateBLSShare(const string &blsKeyName, const char *s_shares, const char * ...@@ -310,7 +310,7 @@ bool CreateBLSShare(const string &blsKeyName, const char *s_shares, const char *
spdlog::error(errMsg1); spdlog::error(errMsg1);
spdlog::error("status {}", err_status); spdlog::error("status {}", err_status);
throw RPCException(ERROR_IN_ENCLAVE, "Create BLS private key failed in enclave"); throw SGXException(ERROR_IN_ENCLAVE, "Create BLS private key failed in enclave");
} else { } else {
char hexBLSKey[2 * BUF_LEN]; char hexBLSKey[2 * BUF_LEN];
...@@ -334,7 +334,7 @@ vector<string> GetBLSPubKey(const char *encryptedKeyHex) { ...@@ -334,7 +334,7 @@ vector<string> GetBLSPubKey(const char *encryptedKeyHex) {
uint64_t dec_key_len; uint64_t dec_key_len;
uint8_t encr_key[BUF_LEN]; uint8_t encr_key[BUF_LEN];
if (!hex2carray(encryptedKeyHex, &dec_key_len, encr_key)) { if (!hex2carray(encryptedKeyHex, &dec_key_len, encr_key)) {
throw RPCException(INVALID_HEX, "Invalid encryptedKeyHex"); throw SGXException(INVALID_HEX, "Invalid encryptedKeyHex");
} }
char pub_key[320]; char pub_key[320];
...@@ -346,7 +346,7 @@ vector<string> GetBLSPubKey(const char *encryptedKeyHex) { ...@@ -346,7 +346,7 @@ vector<string> GetBLSPubKey(const char *encryptedKeyHex) {
get_bls_pub_key_aes(eid, &err_status, errMsg1, encr_key, dec_key_len, pub_key); get_bls_pub_key_aes(eid, &err_status, errMsg1, encr_key, dec_key_len, pub_key);
if (err_status != 0) { if (err_status != 0) {
spdlog::error(string(errMsg1) + " . Status is {}", err_status); spdlog::error(string(errMsg1) + " . Status is {}", err_status);
throw RPCException(ERROR_IN_ENCLAVE, "Failed to get BLS public key in enclave"); throw SGXException(ERROR_IN_ENCLAVE, "Failed to get BLS public key in enclave");
} }
vector<string> pub_key_vect = splitString(pub_key, ':'); vector<string> pub_key_vect = splitString(pub_key, ':');
...@@ -373,7 +373,7 @@ string decrypt_DHKey(const string &polyName, int ind) { ...@@ -373,7 +373,7 @@ string decrypt_DHKey(const string &polyName, int ind) {
uint64_t DH_enc_len = 0; uint64_t DH_enc_len = 0;
uint8_t encrypted_DHkey[BUF_LEN]; uint8_t encrypted_DHkey[BUF_LEN];
if (!hex2carray(hexEncrKey_ptr->c_str(), &DH_enc_len, encrypted_DHkey)) { if (!hex2carray(hexEncrKey_ptr->c_str(), &DH_enc_len, encrypted_DHkey)) {
throw RPCException(INVALID_HEX, "Invalid hexEncrKey"); throw SGXException(INVALID_HEX, "Invalid hexEncrKey");
} }
spdlog::debug("encr DH key length is {}", DH_enc_len); spdlog::debug("encr DH key length is {}", DH_enc_len);
spdlog::debug("hex encr DH key length is {}", hexEncrKey_ptr->length()); spdlog::debug("hex encr DH key length is {}", hexEncrKey_ptr->length());
...@@ -386,7 +386,7 @@ string decrypt_DHKey(const string &polyName, int ind) { ...@@ -386,7 +386,7 @@ string decrypt_DHKey(const string &polyName, int ind) {
else else
decrypt_key_aes(eid, &err_status, errMsg1.data(), encrypted_DHkey, DH_enc_len, DHKey); decrypt_key_aes(eid, &err_status, errMsg1.data(), encrypted_DHkey, DH_enc_len, DHKey);
if (err_status != 0) { if (err_status != 0) {
throw RPCException(/*ERROR_IN_ENCLAVE*/ err_status, "decrypt key failed in enclave"); throw SGXException(/*ERROR_IN_ENCLAVE*/ err_status, "decrypt key failed in enclave");
} }
return DHKey; return DHKey;
......
...@@ -25,7 +25,7 @@ ...@@ -25,7 +25,7 @@
#include "BLSCrypto.h" #include "BLSCrypto.h"
#include "sgxwallet.h" #include "sgxwallet.h"
#include "RPCException.h" #include "SGXException.h"
#include <iostream> #include <iostream>
#include <gmp.h> #include <gmp.h>
...@@ -58,7 +58,7 @@ std::vector<std::string> genECDSAKey() { ...@@ -58,7 +58,7 @@ std::vector<std::string> genECDSAKey() {
if (status != SGX_SUCCESS || err_status != 0) { if (status != SGX_SUCCESS || err_status != 0) {
spdlog::error("RPCException thrown with status {}", status); spdlog::error("RPCException thrown with status {}", status);
throw RPCException(status, errMsg); throw SGXException(status, errMsg);
} }
std::vector<std::string> keys(3); std::vector<std::string> keys(3);
...@@ -110,7 +110,7 @@ std::string getECDSAPubKey(const char *_encryptedKeyHex) { ...@@ -110,7 +110,7 @@ std::string getECDSAPubKey(const char *_encryptedKeyHex) {
uint64_t enc_len = 0; uint64_t enc_len = 0;
if (!hex2carray(_encryptedKeyHex, &enc_len, encrPrKey.data())) { if (!hex2carray(_encryptedKeyHex, &enc_len, encrPrKey.data())) {
throw RPCException(INVALID_HEX, "Invalid encryptedKeyHex"); throw SGXException(INVALID_HEX, "Invalid encryptedKeyHex");
} }
if (!encryptKeys) if (!encryptKeys)
...@@ -119,7 +119,7 @@ std::string getECDSAPubKey(const char *_encryptedKeyHex) { ...@@ -119,7 +119,7 @@ std::string getECDSAPubKey(const char *_encryptedKeyHex) {
else status = get_public_ecdsa_key_aes(eid, &err_status, else status = get_public_ecdsa_key_aes(eid, &err_status,
errMsg.data(), encrPrKey.data(), enc_len, pubKeyX.data(), pubKeyY.data()); errMsg.data(), encrPrKey.data(), enc_len, pubKeyX.data(), pubKeyY.data());
if (err_status != 0) { if (err_status != 0) {
throw RPCException(-666, errMsg.data()); throw SGXException(-666, errMsg.data());
} }
string pubKey = string(pubKeyX.data()) + string(pubKeyY.data());//concatPubKeyWith0x(pub_key_x, pub_key_y);// string pubKey = string(pubKeyX.data()) + string(pubKeyY.data());//concatPubKeyWith0x(pub_key_x, pub_key_y);//
...@@ -146,7 +146,7 @@ vector<string> ecdsaSignHash(const char *encryptedKeyHex, const char *hashHex, i ...@@ -146,7 +146,7 @@ vector<string> ecdsaSignHash(const char *encryptedKeyHex, const char *hashHex, i
//uint8_t encr_key[BUF_LEN]; //uint8_t encr_key[BUF_LEN];
uint8_t *encr_key = (uint8_t *) calloc(1024, 1); uint8_t *encr_key = (uint8_t *) calloc(1024, 1);
if (!hex2carray(encryptedKeyHex, &dec_len, encr_key)) { if (!hex2carray(encryptedKeyHex, &dec_len, encr_key)) {
throw RPCException(INVALID_HEX, "Invalid encryptedKeyHex"); throw SGXException(INVALID_HEX, "Invalid encryptedKeyHex");
} }
...@@ -162,7 +162,7 @@ vector<string> ecdsaSignHash(const char *encryptedKeyHex, const char *hashHex, i ...@@ -162,7 +162,7 @@ vector<string> ecdsaSignHash(const char *encryptedKeyHex, const char *hashHex, i
status = ecdsa_sign_aes(eid, &err_status, errMsg, encr_key, dec_len, (unsigned char *) hashHex, signature_r, status = ecdsa_sign_aes(eid, &err_status, errMsg, encr_key, dec_len, (unsigned char *) hashHex, signature_r,
signature_s, &signature_v, base); signature_s, &signature_v, base);
if (err_status != 0) { if (err_status != 0) {
throw RPCException(-666, errMsg); throw SGXException(-666, errMsg);
} }
......
...@@ -31,7 +31,7 @@ ...@@ -31,7 +31,7 @@
#include "leveldb/db.h" #include "leveldb/db.h"
#include "sgxwallet_common.h" #include "sgxwallet_common.h"
#include "RPCException.h" #include "SGXException.h"
#include "LevelDB.h" #include "LevelDB.h"
#include "ServerInit.h" #include "ServerInit.h"
...@@ -57,7 +57,7 @@ std::shared_ptr<string> LevelDB::readString(const string &_key) { ...@@ -57,7 +57,7 @@ std::shared_ptr<string> LevelDB::readString(const string &_key) {
auto result = std::make_shared<string>(); auto result = std::make_shared<string>();
if (db == nullptr) { if (db == nullptr) {
throw RPCException(NULL_DATABASE, "Null db"); throw SGXException(NULL_DATABASE, "Null db");
} }
auto status = db->Get(readOptions, _key, &*result); auto status = db->Get(readOptions, _key, &*result);
...@@ -163,7 +163,7 @@ void LevelDB::throwExceptionOnError(Status _status) { ...@@ -163,7 +163,7 @@ void LevelDB::throwExceptionOnError(Status _status) {
return; return;
if (!_status.ok()) { if (!_status.ok()) {
throw RPCException(COULD_NOT_ACCESS_DATABASE, ("Could not access database database:" + _status.ToString()).c_str()); throw SGXException(COULD_NOT_ACCESS_DATABASE, ("Could not access database database:" + _status.ToString()).c_str());
} }
} }
...@@ -213,7 +213,7 @@ void LevelDB::writeDataUnique(const string & Name, const string &value) { ...@@ -213,7 +213,7 @@ void LevelDB::writeDataUnique(const string & Name, const string &value) {
if (readString(Name) != nullptr) { if (readString(Name) != nullptr) {
spdlog::debug("name {}",Name, " already exists"); spdlog::debug("name {}",Name, " already exists");
// std::cerr << "name " << Name << " already exists" << std::endl; // std::cerr << "name " << Name << " already exists" << std::endl;
throw RPCException(KEY_SHARE_ALREADY_EXISTS, "Data with this name already exists"); throw SGXException(KEY_SHARE_ALREADY_EXISTS, "Data with this name already exists");
} }
writeString(key, value); writeString(key, value);
......
...@@ -21,4 +21,4 @@ ...@@ -21,4 +21,4 @@
@date 2019 @date 2019
*/ */
#include "RPCException.h" #include "SGXException.h"
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
*/ */
#include "SEKManager.h" #include "SEKManager.h"
#include "RPCException.h" #include "SGXException.h"
#include "BLSCrypto.h" #include "BLSCrypto.h"
#include "LevelDB.h" #include "LevelDB.h"
...@@ -56,7 +56,7 @@ void create_test_key(){ ...@@ -56,7 +56,7 @@ void create_test_key(){
status = encrypt_key_aes(eid, &errStatus, errMsg.data(), key.c_str(), encrypted_key, &enc_len); status = encrypt_key_aes(eid, &errStatus, errMsg.data(), key.c_str(), encrypted_key, &enc_len);
if ( status != 0){ if ( status != 0){
std::cerr << "encrypt test key failed with status " << status << std::endl; std::cerr << "encrypt test key failed with status " << status << std::endl;
throw RPCException(status, errMsg.data()) ; throw SGXException(status, errMsg.data()) ;
} }
//std::cerr << "enc len is " << enc_len << std::endl; //std::cerr << "enc len is " << enc_len << std::endl;
...@@ -101,7 +101,7 @@ bool check_SEK(std::string SEK){ ...@@ -101,7 +101,7 @@ bool check_SEK(std::string SEK){
status = set_SEK_backup(eid, &err_status, errMsg.data(), encr_SEK.data(), &l, SEK.c_str() ); status = set_SEK_backup(eid, &err_status, errMsg.data(), encr_SEK.data(), &l, SEK.c_str() );
if (status != SGX_SUCCESS){ if (status != SGX_SUCCESS){
cerr << "RPCException thrown with status " << status << endl; cerr << "RPCException thrown with status " << status << endl;
throw RPCException(status, errMsg.data()); throw SGXException(status, errMsg.data());
} }
status = decrypt_key_aes(eid, &err_status, errMsg.data(), encr_test_key.data(), len, decr_key.data()); status = decrypt_key_aes(eid, &err_status, errMsg.data(), encr_test_key.data(), len, decr_key.data());
...@@ -135,7 +135,7 @@ void gen_SEK(){ ...@@ -135,7 +135,7 @@ void gen_SEK(){
status = generate_SEK(eid, &err_status, errMsg.data(), encr_SEK.data(), &enc_len, SEK); status = generate_SEK(eid, &err_status, errMsg.data(), encr_SEK.data(), &enc_len, SEK);
if (status != SGX_SUCCESS || err_status != 0 ){ if (status != SGX_SUCCESS || err_status != 0 ){
throw RPCException(status, errMsg.data()) ; throw SGXException(status, errMsg.data()) ;
} }
vector<char> hexEncrKey(2 * enc_len + 1, 0); vector<char> hexEncrKey(2 * enc_len + 1, 0);
...@@ -175,13 +175,13 @@ void set_SEK(std::shared_ptr<std::string> hex_encr_SEK){ ...@@ -175,13 +175,13 @@ void set_SEK(std::shared_ptr<std::string> hex_encr_SEK){
uint64_t len; uint64_t len;
if (!hex2carray(hex_encr_SEK->c_str(), &len, encr_SEK)){ if (!hex2carray(hex_encr_SEK->c_str(), &len, encr_SEK)){
throw RPCException(INVALID_HEX, "Invalid encrypted SEK Hex"); throw SGXException(INVALID_HEX, "Invalid encrypted SEK Hex");
} }
status = set_SEK(eid, &err_status, errMsg.data(), encr_SEK, len ); status = set_SEK(eid, &err_status, errMsg.data(), encr_SEK, len );
if ( status != SGX_SUCCESS || err_status != 0 ){ if ( status != SGX_SUCCESS || err_status != 0 ){
cerr << "RPCException thrown" << endl; cerr << "RPCException thrown" << endl;
throw RPCException(status, errMsg.data()) ; throw SGXException(status, errMsg.data()) ;
} }
} }
...@@ -213,7 +213,7 @@ void enter_SEK(){ ...@@ -213,7 +213,7 @@ void enter_SEK(){
status = set_SEK_backup(eid, &err_status, errMsg.data(), encr_SEK.data(), &enc_len, SEK.c_str() ); status = set_SEK_backup(eid, &err_status, errMsg.data(), encr_SEK.data(), &enc_len, SEK.c_str() );
if (status != SGX_SUCCESS){ if (status != SGX_SUCCESS){
cerr << "RPCException thrown with status " << status << endl; cerr << "RPCException thrown with status " << status << endl;
throw RPCException(status, errMsg.data()); throw SGXException(status, errMsg.data());
} }
vector<char> hexEncrKey(2 * enc_len + 1, 0); vector<char> hexEncrKey(2 * enc_len + 1, 0);
......
...@@ -28,14 +28,14 @@ ...@@ -28,14 +28,14 @@
#include <string> #include <string>
#include <exception> #include <exception>
class RPCException : public std::exception { class SGXException : public std::exception {
public: public:
int32_t status; int32_t status;
std::string errString; std::string errString;
RPCException(int32_t _status, const char* _errString) : status(_status), errString(_errString) {} SGXException(int32_t _status, const char* _errString) : status(_status), errString(_errString) {}
}; };
......
...@@ -32,7 +32,7 @@ ...@@ -32,7 +32,7 @@
#include "sgxwallet_common.h" #include "sgxwallet_common.h"
#include "RPCException.h" #include "SGXException.h"
#include "LevelDB.h" #include "LevelDB.h"
#include <thread> #include <thread>
...@@ -79,7 +79,7 @@ Json::Value signCertificateImpl(const string &_csr, bool _autoSign = false) { ...@@ -79,7 +79,7 @@ Json::Value signCertificateImpl(const string &_csr, bool _autoSign = false) {
outfile << _csr << endl; outfile << _csr << endl;
outfile.close(); outfile.close();
if (access(csr_name.c_str(), F_OK) != 0) { if (access(csr_name.c_str(), F_OK) != 0) {
throw RPCException(FILE_NOT_FOUND, "Csr does not exist"); throw SGXException(FILE_NOT_FOUND, "Csr does not exist");
} }
string genCert = "cd cert && ./create_client_cert " + hash; string genCert = "cd cert && ./create_client_cert " + hash;
...@@ -91,7 +91,7 @@ Json::Value signCertificateImpl(const string &_csr, bool _autoSign = false) { ...@@ -91,7 +91,7 @@ Json::Value signCertificateImpl(const string &_csr, bool _autoSign = false) {
spdlog::info("CLIENT CERTIFICATE GENERATION FAILED"); spdlog::info("CLIENT CERTIFICATE GENERATION FAILED");
string status_db_key = "CSR:HASH:" + hash + "STATUS:"; string status_db_key = "CSR:HASH:" + hash + "STATUS:";
LevelDB::getCsrStatusDb()->writeDataUnique(status_db_key, to_string(FAIL_TO_CREATE_CERTIFICATE)); LevelDB::getCsrStatusDb()->writeDataUnique(status_db_key, to_string(FAIL_TO_CREATE_CERTIFICATE));
throw RPCException(FAIL_TO_CREATE_CERTIFICATE, "CLIENT CERTIFICATE GENERATION FAILED"); throw SGXException(FAIL_TO_CREATE_CERTIFICATE, "CLIENT CERTIFICATE GENERATION FAILED");
//exit(-1); //exit(-1);
} }
} }
...@@ -102,7 +102,7 @@ Json::Value signCertificateImpl(const string &_csr, bool _autoSign = false) { ...@@ -102,7 +102,7 @@ Json::Value signCertificateImpl(const string &_csr, bool _autoSign = false) {
string db_key = "CSR:HASH:" + hash + "STATUS:"; string db_key = "CSR:HASH:" + hash + "STATUS:";
LevelDB::getCsrStatusDb()->writeDataUnique(db_key, status); LevelDB::getCsrStatusDb()->writeDataUnique(db_key, status);
} catch (RPCException &_e) { } catch (SGXException &_e) {
cerr << " err str " << _e.errString << endl; cerr << " err str " << _e.errString << endl;
result["status"] = _e.status; result["status"] = _e.status;
result["errorMessage"] = _e.errString; result["errorMessage"] = _e.errString;
...@@ -120,7 +120,7 @@ Json::Value GetSertificateImpl(const string &hash) { ...@@ -120,7 +120,7 @@ Json::Value GetSertificateImpl(const string &hash) {
string db_key = "CSR:HASH:" + hash + "STATUS:"; string db_key = "CSR:HASH:" + hash + "STATUS:";
shared_ptr<string> status_str_ptr = LevelDB::getCsrStatusDb()->readString(db_key); shared_ptr<string> status_str_ptr = LevelDB::getCsrStatusDb()->readString(db_key);
if (status_str_ptr == nullptr) { if (status_str_ptr == nullptr) {
throw RPCException(KEY_SHARE_DOES_NOT_EXIST, "Data with this name does not exist in csr db"); throw SGXException(KEY_SHARE_DOES_NOT_EXIST, "Data with this name does not exist in csr db");
} }
int status = atoi(status_str_ptr->c_str()); int status = atoi(status_str_ptr->c_str());
...@@ -132,7 +132,7 @@ Json::Value GetSertificateImpl(const string &hash) { ...@@ -132,7 +132,7 @@ Json::Value GetSertificateImpl(const string &hash) {
string status_db_key = "CSR:HASH:" + hash + "STATUS:"; string status_db_key = "CSR:HASH:" + hash + "STATUS:";
LevelDB::getCsrStatusDb()->deleteKey(status_db_key); LevelDB::getCsrStatusDb()->deleteKey(status_db_key);
LevelDB::getCsrStatusDb()->writeDataUnique(status_db_key, to_string(FILE_NOT_FOUND)); LevelDB::getCsrStatusDb()->writeDataUnique(status_db_key, to_string(FILE_NOT_FOUND));
throw RPCException(FILE_NOT_FOUND, "Certificate does not exist"); throw SGXException(FILE_NOT_FOUND, "Certificate does not exist");
} else { } else {
ostringstream ss; ostringstream ss;
ss << infile.rdbuf(); ss << infile.rdbuf();
...@@ -154,7 +154,7 @@ Json::Value GetSertificateImpl(const string &hash) { ...@@ -154,7 +154,7 @@ Json::Value GetSertificateImpl(const string &hash) {
result["status"] = status; result["status"] = status;
result["cert"] = cert; result["cert"] = cert;
} catch (RPCException &_e) { } catch (SGXException &_e) {
cerr << " err str " << _e.errString << endl; cerr << " err str " << _e.errString << endl;
result["status"] = _e.status; result["status"] = _e.status;
result["errorMessage"] = _e.errString; result["errorMessage"] = _e.errString;
......
This diff is collapsed.
...@@ -31,8 +31,10 @@ ...@@ -31,8 +31,10 @@
#endif #endif
EXTERNC void setFullOptions(int _printDebugInfo, int _useHTTPS, int _autoconfirm, int _encryptKeys); EXTERNC void setFullOptions(int _printDebugInfo,
EXTERNC void setOptions(int _printDebugInfo, int _useHTTPS, int _autoconfirm); int _printTraceInfo, int _useHTTPS, int _autoconfirm, int _encryptKeys);
EXTERNC void setOptions(int _printDebugInfo,
int _printTraceInfo, int _useHTTPS, int _autoconfirm);
......
...@@ -59,6 +59,8 @@ void printUsage() { ...@@ -59,6 +59,8 @@ void printUsage() {
fprintf(stderr, "-c do not verify client certificate\n"); fprintf(stderr, "-c do not verify client certificate\n");
fprintf(stderr, "-s sign client certificate without human confirmation \n"); fprintf(stderr, "-s sign client certificate without human confirmation \n");
fprintf(stderr, "-d turn on debug output\n"); fprintf(stderr, "-d turn on debug output\n");
fprintf(stderr, "-v verbose mode: turn on debug output\n");
fprintf(stderr, "-vv detailed verbose mode: turn on debug and trace outputs\n");
fprintf(stderr, "-0 launch SGXWalletServer using http (not https)\n"); fprintf(stderr, "-0 launch SGXWalletServer using http (not https)\n");
fprintf(stderr, "-b Restore from back up (you will need to enter backup key) \n"); fprintf(stderr, "-b Restore from back up (you will need to enter backup key) \n");
fprintf(stderr, "-y Do not ask user to acknoledge receipt of backup key \n"); fprintf(stderr, "-y Do not ask user to acknoledge receipt of backup key \n");
...@@ -69,6 +71,7 @@ int main(int argc, char *argv[]) { ...@@ -69,6 +71,7 @@ int main(int argc, char *argv[]) {
bool encryptKeysOption = false; bool encryptKeysOption = false;
bool useHTTPSOption = true; bool useHTTPSOption = true;
bool printDebugInfoOption = false; bool printDebugInfoOption = false;
bool printTraceInfoOption = false;
bool autoconfirmOption = false; bool autoconfirmOption = false;
bool checkClientCertOption = true; bool checkClientCertOption = true;
bool autoSignClientCertOption = false; bool autoSignClientCertOption = false;
...@@ -83,17 +86,11 @@ int main(int argc, char *argv[]) { ...@@ -83,17 +86,11 @@ int main(int argc, char *argv[]) {
while ((opt = getopt(argc, argv, "cshd0aby")) != -1) { while ((opt = getopt(argc, argv, "cshd0abyvV")) != -1) {
switch (opt) { switch (opt) {
case 'h': case 'h':
if (strlen(argv[1]) == 2) { printUsage();
printUsage(); exit(0);
exit(0);
} else {
fprintf(stderr, "unknown flag %s\n", argv[1]);
printUsage();
exit(1);
}
case 'c': case 'c':
checkClientCertOption = false; checkClientCertOption = false;
break; break;
...@@ -103,6 +100,13 @@ int main(int argc, char *argv[]) { ...@@ -103,6 +100,13 @@ int main(int argc, char *argv[]) {
case 'd': case 'd':
printDebugInfoOption = true; printDebugInfoOption = true;
break; break;
case 'v':
printDebugInfoOption = true;
break;
case 'V':
printDebugInfoOption = true;
printTraceInfoOption = true;
break;
case '0': case '0':
useHTTPSOption = false; useHTTPSOption = false;
break; break;
...@@ -115,15 +119,14 @@ int main(int argc, char *argv[]) { ...@@ -115,15 +119,14 @@ int main(int argc, char *argv[]) {
case 'y': case 'y':
autoconfirmOption = true; autoconfirmOption = true;
break; break;
case '?': default:
printUsage(); printUsage();
exit(1); exit(1);
default:
break; break;
} }
} }
setFullOptions(printDebugInfoOption, useHTTPSOption, autoconfirmOption, encryptKeysOption); setFullOptions(printDebugInfoOption, printTraceInfoOption, useHTTPSOption, autoconfirmOption, encryptKeysOption);
initAll(checkClientCertOption, autoSignClientCertOption); initAll(checkClientCertOption, autoSignClientCertOption);
......
...@@ -35,7 +35,7 @@ ...@@ -35,7 +35,7 @@
extern int printDebugInfo;
extern int useHTTPS; extern int useHTTPS;
extern int encryptKeys; extern int encryptKeys;
extern int autoconfirm; extern int autoconfirm;
......
...@@ -52,7 +52,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ...@@ -52,7 +52,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "BLSCrypto.h" #include "BLSCrypto.h"
#include "ServerInit.h" #include "ServerInit.h"
#include "DKGCrypto.h" #include "DKGCrypto.h"
#include "RPCException.h" #include "SGXException.h"
#include "LevelDB.h" #include "LevelDB.h"
#include "SGXWalletServer.hpp" #include "SGXWalletServer.hpp"
...@@ -134,7 +134,7 @@ void destroyEnclave() { ...@@ -134,7 +134,7 @@ void destroyEnclave() {
TEST_CASE("BLS key encrypt", "[bls-key-encrypt]") { TEST_CASE("BLS key encrypt", "[bls-key-encrypt]") {
resetDB(); resetDB();
setOptions(false, false, true); setOptions(false, false, false, true);
initAll(false, true); initAll(false, true);
auto key = encryptTestKey(); auto key = encryptTestKey();
REQUIRE(key != nullptr); REQUIRE(key != nullptr);
...@@ -143,7 +143,7 @@ TEST_CASE("BLS key encrypt", "[bls-key-encrypt]") { ...@@ -143,7 +143,7 @@ TEST_CASE("BLS key encrypt", "[bls-key-encrypt]") {
/* Do later /* Do later
TEST_CASE("BLS key encrypt/decrypt", "[bls-key-encrypt-decrypt]") { TEST_CASE("BLS key encrypt/decrypt", "[bls-key-encrypt-decrypt]") {
resetDB(); resetDB();
setOptions(false, false, true); setOptions(false, false, false, true);
initAll(false, true); initAll(false, true);
//init_enclave(); //init_enclave();
...@@ -175,7 +175,7 @@ TEST_CASE("BLS key encrypt/decrypt", "[bls-key-encrypt-decrypt]") { ...@@ -175,7 +175,7 @@ TEST_CASE("BLS key encrypt/decrypt", "[bls-key-encrypt-decrypt]") {
TEST_CASE("DKG gen test", "[dkg-gen]") { TEST_CASE("DKG gen test", "[dkg-gen]") {
resetDB(); resetDB();
setOptions(false, false, true); setOptions(false, false, false, true);
initAll(false, true); initAll(false, true);
...@@ -263,7 +263,7 @@ libff::alt_bn128_G2 VectStringToG2(const vector<string> &G2_str_vect) { ...@@ -263,7 +263,7 @@ libff::alt_bn128_G2 VectStringToG2(const vector<string> &G2_str_vect) {
TEST_CASE("DKG public shares test", "[dkg-pub-shares]") { TEST_CASE("DKG public shares test", "[dkg-pub-shares]") {
resetDB(); resetDB();
setOptions(false, false, true); setOptions(false, false, false, true);
initAll(false, true); initAll(false, true);
...@@ -338,7 +338,7 @@ TEST_CASE("DKG public shares test", "[dkg-pub-shares]") { ...@@ -338,7 +338,7 @@ TEST_CASE("DKG public shares test", "[dkg-pub-shares]") {
TEST_CASE("DKG encrypted secret shares test", "[dkg-encr-sshares]") { TEST_CASE("DKG encrypted secret shares test", "[dkg-encr-sshares]") {
resetDB(); resetDB();
setOptions(false, false, true); setOptions(false, false, false, true);
initAll(false, true); initAll(false, true);
...@@ -375,7 +375,7 @@ TEST_CASE("DKG encrypted secret shares test", "[dkg-encr-sshares]") { ...@@ -375,7 +375,7 @@ TEST_CASE("DKG encrypted secret shares test", "[dkg-encr-sshares]") {
TEST_CASE("DKG verification test", "[dkg-verify]") { TEST_CASE("DKG verification test", "[dkg-verify]") {
resetDB(); resetDB();
setOptions(false, false, true); setOptions(false, false, false, true);
initAll(false, true); initAll(false, true);
...@@ -416,7 +416,7 @@ TEST_CASE("DKG verification test", "[dkg-verify]") { ...@@ -416,7 +416,7 @@ TEST_CASE("DKG verification test", "[dkg-verify]") {
TEST_CASE("ECDSA keygen and signature test", "[ecdsa]") { TEST_CASE("ECDSA keygen and signature test", "[ecdsa]") {
resetDB(); resetDB();
setOptions(false, false, true); setOptions(false, false, false, true);
initAll(false, true); initAll(false, true);
...@@ -460,7 +460,7 @@ TEST_CASE("ECDSA keygen and signature test", "[ecdsa]") { ...@@ -460,7 +460,7 @@ TEST_CASE("ECDSA keygen and signature test", "[ecdsa]") {
TEST_CASE("Test test", "[test]") { TEST_CASE("Test test", "[test]") {
resetDB(); resetDB();
setOptions(false, false, true); setOptions(false, false, false, true);
initAll(false, true); initAll(false, true);
vector<char> errMsg(BUF_LEN, 0); vector<char> errMsg(BUF_LEN, 0);
...@@ -482,7 +482,7 @@ TEST_CASE("Test test", "[test]") { ...@@ -482,7 +482,7 @@ TEST_CASE("Test test", "[test]") {
TEST_CASE("get public ECDSA key", "[get-pub-ecdsa-key]") { TEST_CASE("get public ECDSA key", "[get-pub-ecdsa-key]") {
resetDB(); resetDB();
setOptions(false, false, true); setOptions(false, false, false, true);
initAll(false, true); initAll(false, true);
int errStatus = 0; int errStatus = 0;
...@@ -550,7 +550,7 @@ string ConvertDecToHex(string dec, int numBytes = 32) { ...@@ -550,7 +550,7 @@ string ConvertDecToHex(string dec, int numBytes = 32) {
TEST_CASE("BLS_DKG test", "[bls-dkg]") { TEST_CASE("BLS_DKG test", "[bls-dkg]") {
resetDB(); resetDB();
setOptions(false, false, true); setOptions(false, false, false, true);
initAll(false, true); initAll(false, true);
HttpClient client("http://localhost:1029"); HttpClient client("http://localhost:1029");
...@@ -636,7 +636,7 @@ TEST_CASE("BLS_DKG test", "[bls-dkg]") { ...@@ -636,7 +636,7 @@ TEST_CASE("BLS_DKG test", "[bls-dkg]") {
auto hash_arr = make_shared<array<uint8_t, 32>>(); auto hash_arr = make_shared<array<uint8_t, 32>>();
uint64_t binLen; uint64_t binLen;
if (!hex2carray(hash.c_str(), &binLen, hash_arr->data())) { if (!hex2carray(hash.c_str(), &binLen, hash_arr->data())) {
throw RPCException(INVALID_HEX, "Invalid hash"); throw SGXException(INVALID_HEX, "Invalid hash");
} }
...@@ -678,7 +678,7 @@ TEST_CASE("BLS_DKG test", "[bls-dkg]") { ...@@ -678,7 +678,7 @@ TEST_CASE("BLS_DKG test", "[bls-dkg]") {
} }
TEST_CASE("API test", "[api]") { TEST_CASE("API test", "[api]") {
setOptions(false, false, true); setOptions(false, false, false, true);
initAll(false, true); initAll(false, true);
//HttpServer httpserver(1025); //HttpServer httpserver(1025);
...@@ -733,7 +733,7 @@ TEST_CASE("API test", "[api]") { ...@@ -733,7 +733,7 @@ TEST_CASE("API test", "[api]") {
TEST_CASE("getServerStatus test", "[get-server-status]") { TEST_CASE("getServerStatus test", "[get-server-status]") {
resetDB(); resetDB();
setOptions(false, false, true); setOptions(false, false, false, true);
initAll(false, true); initAll(false, true);
HttpClient client("http://localhost:1029"); HttpClient client("http://localhost:1029");
StubClient c(client, JSONRPC_CLIENT_V2); StubClient c(client, JSONRPC_CLIENT_V2);
...@@ -806,7 +806,7 @@ void SendRPCRequest() { ...@@ -806,7 +806,7 @@ void SendRPCRequest() {
auto hash_arr = make_shared<array<uint8_t, 32>>(); auto hash_arr = make_shared<array<uint8_t, 32>>();
uint64_t binLen; uint64_t binLen;
if (!hex2carray(hash.c_str(), &binLen, hash_arr->data())) { if (!hex2carray(hash.c_str(), &binLen, hash_arr->data())) {
throw RPCException(INVALID_HEX, "Invalid hash"); throw SGXException(INVALID_HEX, "Invalid hash");
} }
map<size_t, shared_ptr<BLSPublicKeyShare>> koefs_pkeys_map; map<size_t, shared_ptr<BLSPublicKeyShare>> koefs_pkeys_map;
...@@ -839,7 +839,7 @@ void SendRPCRequest() { ...@@ -839,7 +839,7 @@ void SendRPCRequest() {
TEST_CASE("ManySimultaneousThreads", "[many-threads-test]") { TEST_CASE("ManySimultaneousThreads", "[many-threads-test]") {
resetDB(); resetDB();
setOptions(false, false, true); setOptions(false, false, false, true);
initAll(false, true); initAll(false, true);
...@@ -858,7 +858,7 @@ TEST_CASE("ManySimultaneousThreads", "[many-threads-test]") { ...@@ -858,7 +858,7 @@ TEST_CASE("ManySimultaneousThreads", "[many-threads-test]") {
TEST_CASE("ecdsa API test", "[ecdsa-api]") { TEST_CASE("ecdsa API test", "[ecdsa-api]") {
resetDB(); resetDB();
setOptions(false, false, true); setOptions(false, false, false, true);
initAll(false, true); initAll(false, true);
...@@ -906,7 +906,7 @@ TEST_CASE("ecdsa API test", "[ecdsa-api]") { ...@@ -906,7 +906,7 @@ TEST_CASE("ecdsa API test", "[ecdsa-api]") {
TEST_CASE("dkg API test", "[dkg-api]") { TEST_CASE("dkg API test", "[dkg-api]") {
resetDB(); resetDB();
setOptions(false, false, true); setOptions(false, false, false, true);
initAll(false, true); initAll(false, true);
...@@ -979,7 +979,7 @@ TEST_CASE("dkg API test", "[dkg-api]") { ...@@ -979,7 +979,7 @@ TEST_CASE("dkg API test", "[dkg-api]") {
TEST_CASE("isPolyExists test", "[is-poly]") { TEST_CASE("isPolyExists test", "[is-poly]") {
resetDB(); resetDB();
setOptions(false, false, true); setOptions(false, false, false, true);
initAll(false, true); initAll(false, true);
...@@ -1005,7 +1005,7 @@ TEST_CASE("isPolyExists test", "[is-poly]") { ...@@ -1005,7 +1005,7 @@ TEST_CASE("isPolyExists test", "[is-poly]") {
TEST_CASE("AES_DKG test", "[aes-dkg]") { TEST_CASE("AES_DKG test", "[aes-dkg]") {
resetDB(); resetDB();
setOptions(false, false, true); setOptions(false, false, false, true);
initAll(false, true); initAll(false, true);
...@@ -1078,7 +1078,7 @@ TEST_CASE("AES_DKG test", "[aes-dkg]") { ...@@ -1078,7 +1078,7 @@ TEST_CASE("AES_DKG test", "[aes-dkg]") {
auto hash_arr = make_shared<array<uint8_t, 32>>(); auto hash_arr = make_shared<array<uint8_t, 32>>();
uint64_t binLen; uint64_t binLen;
if (!hex2carray(hash.c_str(), &binLen, hash_arr->data())) { if (!hex2carray(hash.c_str(), &binLen, hash_arr->data())) {
throw RPCException(INVALID_HEX, "Invalid hash"); throw SGXException(INVALID_HEX, "Invalid hash");
} }
...@@ -1121,7 +1121,7 @@ TEST_CASE("AES_DKG test", "[aes-dkg]") { ...@@ -1121,7 +1121,7 @@ TEST_CASE("AES_DKG test", "[aes-dkg]") {
TEST_CASE("bls_sign_api test", "[bls-sign]") { TEST_CASE("bls_sign_api test", "[bls-sign]") {
resetDB(); resetDB();
setOptions(false, false, true); setOptions(false, false, false, true);
initAll(false, true); initAll(false, true);
HttpClient client("http://localhost:1029"); HttpClient client("http://localhost:1029");
...@@ -1143,7 +1143,7 @@ TEST_CASE("bls_sign_api test", "[bls-sign]") { ...@@ -1143,7 +1143,7 @@ TEST_CASE("bls_sign_api test", "[bls-sign]") {
TEST_CASE("AES encrypt/decrypt", "[AES-encrypt-decrypt]") { TEST_CASE("AES encrypt/decrypt", "[AES-encrypt-decrypt]") {
resetDB(); resetDB();
setOptions(false, false, true); setOptions(false, false, false, true);
initAll(false, true); initAll(false, true);
......
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