Unverified Commit 90d7eaba authored by kladko's avatar kladko

SKALE-2454-add-logs-to-enclave

parent 3baf6d2e
......@@ -49,7 +49,7 @@
#include "BLSCrypto.h"
#include "ServerInit.h"
#include "RPCException.h"
#include "SGXException.h"
#include "spdlog/spdlog.h"
#include "common.h"
......@@ -160,7 +160,7 @@ bool sign(const char *_encryptedKeyHex, const char *_hashHex, size_t _t, size_t
uint64_t binLen;
if (!hex2carray(_hashHex, &binLen, hash->data())) {
throw RPCException(INVALID_HEX, "Invalid hash");
throw SGXException(INVALID_HEX, "Invalid hash");
}
// assert(binLen == hash->size());
......@@ -201,7 +201,7 @@ bool sign_aes(const char *_encryptedKeyHex, const char *_hashHex, size_t _t, siz
uint64_t binLen;
if (!hex2carray(_hashHex, &binLen, hash->data())) {
throw RPCException(INVALID_HEX, "Invalid hash");
throw SGXException(INVALID_HEX, "Invalid hash");
}
// assert(binLen == hash->size());
......@@ -335,7 +335,7 @@ char *encryptBLSKeyShare2Hex(int *errStatus, char *err_string, const char *_key)
}
if (*errStatus != 0) {
throw RPCException(-666, errMsg->data());
throw SGXException(-666, errMsg->data());
}
......
......@@ -58,7 +58,7 @@ add_executable(sgxwallet
LevelDB.h
oc_alloc.c
RPCException.cpp
RPCException.h
SGXException.h
secure_enclave_u.c
secure_enclave_u.h
SEKManager.cpp
......
......@@ -23,7 +23,7 @@
#include "CSRManagerServer.h"
#include "RPCException.h"
#include "SGXException.h"
#include "sgxwallet_common.h"
#include <iostream>
......@@ -40,21 +40,21 @@ jsonrpc::HttpServer *hs3 = nullptr;
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");
Json::Value result;
result["status"] = 0;
result["errorMessage"] = "";
try{
try {
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);
}
} catch (RPCException &_e) {
} catch (SGXException &_e) {
cerr << " err str " << _e.errString << endl;
result["status"] = _e.status;
result["errorMessage"] = _e.errString;
......@@ -64,19 +64,19 @@ Json::Value getUnsignedCSRsImpl(){
return result;
}
Json::Value signByHashImpl(const string& hash, int status){
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");
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 RPCException(KEY_SHARE_DOES_NOT_EXIST, "HASH DOES NOT EXIST IN DB");
if (csr_ptr == nullptr) {
throw SGXException(KEY_SHARE_DOES_NOT_EXIST, "HASH DOES NOT EXIST IN DB");
}
if (status == 0) {
......@@ -86,7 +86,7 @@ Json::Value signByHashImpl(const string& hash, int status){
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");
throw SGXException(FILE_NOT_FOUND, "Csr does not exist");
}
string signClientCert = "cd sgx_data/cert && ./create_client_cert " + hash;
......@@ -99,7 +99,7 @@ Json::Value signByHashImpl(const string& hash, int status){
string status_db_key = "CSR:HASH:" + hash + "STATUS:";
LevelDB::getCsrStatusDb()->deleteKey(status_db_key);
LevelDB::getCsrStatusDb()->writeDataUnique(status_db_key, "-1");
throw RPCException(FAIL_TO_CREATE_CERTIFICATE, "CLIENT CERTIFICATE GENERATION FAILED");
throw SGXException(FAIL_TO_CREATE_CERTIFICATE, "CLIENT CERTIFICATE GENERATION FAILED");
//exit(-1);
}
}
......@@ -111,7 +111,7 @@ Json::Value signByHashImpl(const string& hash, int status){
result["status"] = status;
} catch (RPCException &_e) {
} catch (SGXException &_e) {
cerr << " err str " << _e.errString << endl;
result["status"] = _e.status;
result["errorMessage"] = _e.errString;
......@@ -121,26 +121,25 @@ Json::Value signByHashImpl(const string& hash, int status){
}
Json::Value CSRManagerServer::getUnsignedCSRs(){
Json::Value CSRManagerServer::getUnsignedCSRs() {
lock_guard<recursive_mutex> lock(m);
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);
return signByHashImpl(hash, status);
}
int init_csrmanager_server(){
int init_csrmanager_server() {
hs3 = new jsonrpc::HttpServer(BASE_PORT + 2);
hs3 -> BindLocalhost();
hs3->BindLocalhost();
cs = new CSRManagerServer(*hs3, JSONRPC_SERVER_V2); // server (json-rpc 2.0)
if (!cs->StartListening()) {
spdlog::info("CSR manager server could not start listening");
exit(-1);
}
else {
} else {
spdlog::info("CSR manager server started on port {}", BASE_PORT + 2);
}
return 0;
......
......@@ -28,7 +28,7 @@
#include <memory>
#include "SGXWalletServer.hpp"
#include "RPCException.h"
#include "SGXException.h"
//#include <libBLS/libff/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) {
else
status = gen_dkg_secret_aes(eid, &err_status, errMsg.data(), encrypted_dkg_secret.data(), &enc_len, _t);
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());
......@@ -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);
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
status = get_public_shares_aes(eid, &errStatus, errMsg1.data(), encrDKGPoly.data(), encLen, pubShares.data(), t, n);
}
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,
vector<uint8_t > encrDKGPoly(BUF_LEN, 0);
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,
status = set_encrypted_dkg_poly_aes(eid, &errStatus, errMsg1.data(), encrDKGPoly.data(), &encLen);
if (status != SGX_SUCCESS || errStatus != 0) {
throw RPCException(-666, errMsg1.data());
throw SGXException(-666, errMsg1.data());
}
string result;
......@@ -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,
currentShare.data(), sShareG2.data(), pubKeyB.data(), _t, _n, i + 1);
if (errStatus != 0) {
throw RPCException(-666, errMsg1.data());
throw SGXException(-666, errMsg1.data());
}
spdlog::debug("cur_share is {}", currentShare.data());
......@@ -253,7 +253,7 @@ verifyShares(const char *publicShares, const char *encr_sshare, const char *encr
uint8_t encr_key[BUF_LEN];
memset(encr_key, 0, BUF_LEN);
if (!hex2carray(encryptedKeyHex, &dec_key_len, encr_key)) {
throw RPCException(INVALID_HEX, "Invalid encryptedPolyHex");
throw SGXException(INVALID_HEX, "Invalid encryptedPolyHex");
}
int result;
......@@ -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);
if (result == 2) {
throw RPCException(INVALID_HEX, "Invalid public shares");
throw SGXException(INVALID_HEX, "Invalid public shares");
}
spdlog::debug("errMsg1: {}", errMsg1);
......@@ -295,7 +295,7 @@ bool CreateBLSShare(const string &blsKeyName, const char *s_shares, const char *
uint8_t encr_key[BUF_LEN];
memset(encr_key, 0, BUF_LEN);
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;
......@@ -310,7 +310,7 @@ bool CreateBLSShare(const string &blsKeyName, const char *s_shares, const char *
spdlog::error(errMsg1);
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 {
char hexBLSKey[2 * BUF_LEN];
......@@ -334,7 +334,7 @@ vector<string> GetBLSPubKey(const char *encryptedKeyHex) {
uint64_t dec_key_len;
uint8_t encr_key[BUF_LEN];
if (!hex2carray(encryptedKeyHex, &dec_key_len, encr_key)) {
throw RPCException(INVALID_HEX, "Invalid encryptedKeyHex");
throw SGXException(INVALID_HEX, "Invalid encryptedKeyHex");
}
char pub_key[320];
......@@ -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);
if (err_status != 0) {
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, ':');
......@@ -373,7 +373,7 @@ string decrypt_DHKey(const string &polyName, int ind) {
uint64_t DH_enc_len = 0;
uint8_t encrypted_DHkey[BUF_LEN];
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("hex encr DH key length is {}", hexEncrKey_ptr->length());
......@@ -386,7 +386,7 @@ string decrypt_DHKey(const string &polyName, int ind) {
else
decrypt_key_aes(eid, &err_status, errMsg1.data(), encrypted_DHkey, DH_enc_len, DHKey);
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;
......
......@@ -25,7 +25,7 @@
#include "BLSCrypto.h"
#include "sgxwallet.h"
#include "RPCException.h"
#include "SGXException.h"
#include <iostream>
#include <gmp.h>
......@@ -58,7 +58,7 @@ std::vector<std::string> genECDSAKey() {
if (status != SGX_SUCCESS || err_status != 0) {
spdlog::error("RPCException thrown with status {}", status);
throw RPCException(status, errMsg);
throw SGXException(status, errMsg);
}
std::vector<std::string> keys(3);
......@@ -110,7 +110,7 @@ std::string getECDSAPubKey(const char *_encryptedKeyHex) {
uint64_t enc_len = 0;
if (!hex2carray(_encryptedKeyHex, &enc_len, encrPrKey.data())) {
throw RPCException(INVALID_HEX, "Invalid encryptedKeyHex");
throw SGXException(INVALID_HEX, "Invalid encryptedKeyHex");
}
if (!encryptKeys)
......@@ -119,7 +119,7 @@ std::string getECDSAPubKey(const char *_encryptedKeyHex) {
else status = get_public_ecdsa_key_aes(eid, &err_status,
errMsg.data(), encrPrKey.data(), enc_len, pubKeyX.data(), pubKeyY.data());
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);//
......@@ -146,7 +146,7 @@ vector<string> ecdsaSignHash(const char *encryptedKeyHex, const char *hashHex, i
//uint8_t encr_key[BUF_LEN];
uint8_t *encr_key = (uint8_t *) calloc(1024, 1);
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
status = ecdsa_sign_aes(eid, &err_status, errMsg, encr_key, dec_len, (unsigned char *) hashHex, signature_r,
signature_s, &signature_v, base);
if (err_status != 0) {
throw RPCException(-666, errMsg);
throw SGXException(-666, errMsg);
}
......
......@@ -31,7 +31,7 @@
#include "leveldb/db.h"
#include "sgxwallet_common.h"
#include "RPCException.h"
#include "SGXException.h"
#include "LevelDB.h"
#include "ServerInit.h"
......@@ -57,7 +57,7 @@ std::shared_ptr<string> LevelDB::readString(const string &_key) {
auto result = std::make_shared<string>();
if (db == nullptr) {
throw RPCException(NULL_DATABASE, "Null db");
throw SGXException(NULL_DATABASE, "Null db");
}
auto status = db->Get(readOptions, _key, &*result);
......@@ -163,7 +163,7 @@ void LevelDB::throwExceptionOnError(Status _status) {
return;
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) {
if (readString(Name) != nullptr) {
spdlog::debug("name {}",Name, " already exists");
// 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);
......
......@@ -21,4 +21,4 @@
@date 2019
*/
#include "RPCException.h"
#include "SGXException.h"
......@@ -22,7 +22,7 @@
*/
#include "SEKManager.h"
#include "RPCException.h"
#include "SGXException.h"
#include "BLSCrypto.h"
#include "LevelDB.h"
......@@ -56,7 +56,7 @@ void create_test_key(){
status = encrypt_key_aes(eid, &errStatus, errMsg.data(), key.c_str(), encrypted_key, &enc_len);
if ( status != 0){
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;
......@@ -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() );
if (status != SGX_SUCCESS){
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());
......@@ -135,7 +135,7 @@ void gen_SEK(){
status = generate_SEK(eid, &err_status, errMsg.data(), encr_SEK.data(), &enc_len, SEK);
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);
......@@ -175,13 +175,13 @@ void set_SEK(std::shared_ptr<std::string> hex_encr_SEK){
uint64_t len;
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 );
if ( status != SGX_SUCCESS || err_status != 0 ){
cerr << "RPCException thrown" << endl;
throw RPCException(status, errMsg.data()) ;
throw SGXException(status, errMsg.data()) ;
}
}
......@@ -213,7 +213,7 @@ void enter_SEK(){
status = set_SEK_backup(eid, &err_status, errMsg.data(), encr_SEK.data(), &enc_len, SEK.c_str() );
if (status != SGX_SUCCESS){
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);
......
......@@ -28,14 +28,14 @@
#include <string>
#include <exception>
class RPCException : public std::exception {
class SGXException : public std::exception {
public:
int32_t status;
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 @@
#include "sgxwallet_common.h"
#include "RPCException.h"
#include "SGXException.h"
#include "LevelDB.h"
#include <thread>
......@@ -79,7 +79,7 @@ Json::Value signCertificateImpl(const string &_csr, bool _autoSign = false) {
outfile << _csr << endl;
outfile.close();
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;
......@@ -91,7 +91,7 @@ Json::Value signCertificateImpl(const string &_csr, bool _autoSign = false) {
spdlog::info("CLIENT CERTIFICATE GENERATION FAILED");
string status_db_key = "CSR:HASH:" + hash + "STATUS:";
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);
}
}
......@@ -102,7 +102,7 @@ Json::Value signCertificateImpl(const string &_csr, bool _autoSign = false) {
string db_key = "CSR:HASH:" + hash + "STATUS:";
LevelDB::getCsrStatusDb()->writeDataUnique(db_key, status);
} catch (RPCException &_e) {
} catch (SGXException &_e) {
cerr << " err str " << _e.errString << endl;
result["status"] = _e.status;
result["errorMessage"] = _e.errString;
......@@ -120,7 +120,7 @@ Json::Value GetSertificateImpl(const string &hash) {
string db_key = "CSR:HASH:" + hash + "STATUS:";
shared_ptr<string> status_str_ptr = LevelDB::getCsrStatusDb()->readString(db_key);
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());
......@@ -132,7 +132,7 @@ Json::Value GetSertificateImpl(const string &hash) {
string status_db_key = "CSR:HASH:" + hash + "STATUS:";
LevelDB::getCsrStatusDb()->deleteKey(status_db_key);
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 {
ostringstream ss;
ss << infile.rdbuf();
......@@ -154,7 +154,7 @@ Json::Value GetSertificateImpl(const string &hash) {
result["status"] = status;
result["cert"] = cert;
} catch (RPCException &_e) {
} catch (SGXException &_e) {
cerr << " err str " << _e.errString << endl;
result["status"] = _e.status;
result["errorMessage"] = _e.errString;
......
......@@ -23,7 +23,7 @@
#include "sgxwallet_common.h"
#include "RPCException.h"
#include "SGXException.h"
#include "LevelDB.h"
#include "BLSCrypto.h"
#include "ECDSACrypto.h"
......@@ -45,21 +45,25 @@
#include "common.h"
void setFullOptions(int _printDebugInfo, int _useHTTPS, int _autoconfirm, int _encryptKeys) {
void setFullOptions(int _printDebugInfo,
int _printTraceInfo, int _useHTTPS, int _autoconfirm, int _encryptKeys) {
if (_printDebugInfo)
spdlog::set_level(spdlog::level::debug);
else {
else if (_printTraceInfo) {
spdlog::set_level(spdlog::level::trace);
} else if (_printTraceInfo) {
spdlog::set_level(spdlog::level::info);
}
printDebugInfo = _printDebugInfo;
useHTTPS = _useHTTPS;
autoconfirm = _autoconfirm;
encryptKeys = _encryptKeys;
}
void setOptions(int _printDebugInfo, int _useHTTPS, int _autoconfirm) {
setFullOptions(_printDebugInfo, _useHTTPS, _autoconfirm, false);
void setOptions(int _printDebugInfo,
int _printTraceInfo, int _useHTTPS, int _autoconfirm) {
setFullOptions(_printDebugInfo,
_printTraceInfo, _useHTTPS, _autoconfirm, false);
}
......@@ -171,18 +175,18 @@ SGXWalletServer::importBLSKeyShareImpl(const string &_keyShare, const string &_k
encryptedKeyShareHex = encryptBLSKeyShare2Hex(&errStatus, errMsg, _keyShare.c_str());
if (encryptedKeyShareHex == nullptr) {
throw RPCException(UNKNOWN_ERROR, "");
throw SGXException(UNKNOWN_ERROR, "");
}
if (errStatus != 0) {
throw RPCException(errStatus, errMsg);
throw SGXException(errStatus, errMsg);
}
result["encryptedKeyShare"] = string(encryptedKeyShareHex);
writeKeyShare(_keyShareName, encryptedKeyShareHex, _index, n, t);
} catch (RPCException &_e) {
} catch (SGXException &_e) {
result["status"] = _e.status;
result["errorMessage"] = _e.errString;
}
......@@ -195,7 +199,8 @@ SGXWalletServer::importBLSKeyShareImpl(const string &_keyShare, const string &_k
}
Json::Value
SGXWalletServer::blsSignMessageHashImpl(const string &_keyShareName, const string &_messageHash, int t, int n, int _signerIndex) {
SGXWalletServer::blsSignMessageHashImpl(const string &_keyShareName, const string &_messageHash, int t, int n,
int _signerIndex) {
Json::Value result;
result["status"] = -1;
result["errorMessage"] = "Unknown server error";
......@@ -207,7 +212,7 @@ SGXWalletServer::blsSignMessageHashImpl(const string &_keyShareName, const strin
try {
if (!checkName(_keyShareName, "BLS_KEY")) {
throw RPCException(INVALID_POLY_NAME, "Invalid BLSKey name");
throw SGXException(INVALID_POLY_NAME, "Invalid BLSKey name");
}
string cutHash = _messageHash;
if (cutHash[0] == '0' && (cutHash[1] == 'x' || cutHash[1] == 'X')) {
......@@ -218,11 +223,11 @@ SGXWalletServer::blsSignMessageHashImpl(const string &_keyShareName, const strin
}
if (!checkHex(cutHash)) {
throw RPCException(INVALID_HEX, "Invalid hash");
throw SGXException(INVALID_HEX, "Invalid hash");
}
value = readFromDb(_keyShareName);
} catch (RPCException _e) {
} catch (SGXException _e) {
result["status"] = _e.status;
result["errorMessage"] = _e.errString;
return result;
......@@ -276,7 +281,7 @@ Json::Value SGXWalletServer::generateECDSAKeyImpl() {
keys = genECDSAKey();
if (keys.size() == 0) {
throw RPCException(UNKNOWN_ERROR, "key was not generated");
throw SGXException(UNKNOWN_ERROR, "key was not generated");
}
string keyName = "NEK:" + keys.at(2);
......@@ -291,7 +296,7 @@ Json::Value SGXWalletServer::generateECDSAKeyImpl() {
result["PublicKey"] = keys.at(1);
result["keyName"] = keyName;
} catch (RPCException &_e) {
} catch (SGXException &_e) {
cerr << " err str " << _e.errString << endl;
result["status"] = _e.status;
result["errorMessage"] = _e.errString;
......@@ -310,15 +315,15 @@ Json::Value SGXWalletServer::renameECDSAKeyImpl(const string &_keyName, const st
string prefix = _tempKeyName.substr(0, 8);
if (prefix != "tmp_NEK:") {
throw RPCException(UNKNOWN_ERROR, "invalid temp key name");
throw SGXException(UNKNOWN_ERROR, "invalid temp key name");
}
prefix = _keyName.substr(0, 12);
if (prefix != "NEK_NODE_ID:") {
throw RPCException(UNKNOWN_ERROR, "invalid key name");
throw SGXException(UNKNOWN_ERROR, "invalid key name");
}
string postfix = _keyName.substr(12, _keyName.length());
if (!isStringDec(postfix)) {
throw RPCException(UNKNOWN_ERROR, "invalid key name");
throw SGXException(UNKNOWN_ERROR, "invalid key name");
}
shared_ptr<string> key_ptr = readFromDb(_tempKeyName);
......@@ -326,7 +331,7 @@ Json::Value SGXWalletServer::renameECDSAKeyImpl(const string &_keyName, const st
writeDataToDB(_keyName, *key_ptr);
LevelDB::getLevelDb()->deleteTempNEK(_tempKeyName);
} catch (RPCException &_e) {
} catch (SGXException &_e) {
cerr << " err str " << _e.errString << endl;
result["status"] = _e.status;
result["errorMessage"] = _e.errString;
......@@ -357,20 +362,20 @@ Json::Value SGXWalletServer::ecdsaSignMessageHashImpl(int _base, const string &_
}
if (!checkECDSAKeyName(_keyName)) {
throw RPCException(INVALID_ECDSA_KEY_NAME, "Invalid ECDSA key name");
throw SGXException(INVALID_ECDSA_KEY_NAME, "Invalid ECDSA key name");
}
if (!checkHex(cutHash)) {
throw RPCException(INVALID_HEX, "Invalid hash");
throw SGXException(INVALID_HEX, "Invalid hash");
}
if (_base <= 0 || _base > 32) {
throw RPCException(-22, "Invalid base");
throw SGXException(-22, "Invalid base");
}
shared_ptr<string> key_ptr = readFromDb(_keyName, "");
sign_vect = ecdsaSignHash(key_ptr->c_str(), cutHash.c_str(), _base);
if (sign_vect.size() != 3) {
throw RPCException(INVALID_ECSDA_SIGNATURE, "Invalid ecdsa signature");
throw SGXException(INVALID_ECSDA_SIGNATURE, "Invalid ecdsa signature");
}
spdlog::debug("got signature_s {}", sign_vect.at(2));
......@@ -379,7 +384,7 @@ Json::Value SGXWalletServer::ecdsaSignMessageHashImpl(int _base, const string &_
result["signature_r"] = sign_vect.at(1);
result["signature_s"] = sign_vect.at(2);
} catch (RPCException &_e) {
} catch (SGXException &_e) {
cerr << "err str " << _e.errString << endl;
result["status"] = _e.status;
result["errorMessage"] = _e.errString;
......@@ -399,7 +404,7 @@ Json::Value SGXWalletServer::getPublicECDSAKeyImpl(const string &_keyName) {
try {
if (!checkECDSAKeyName(_keyName)) {
throw RPCException(INVALID_ECDSA_KEY_NAME, "Invalid ECDSA key name");
throw SGXException(INVALID_ECDSA_KEY_NAME, "Invalid ECDSA key name");
}
shared_ptr<string> keyStr = readFromDb(_keyName);
publicKey = getECDSAPubKey(keyStr->c_str());
......@@ -409,7 +414,7 @@ Json::Value SGXWalletServer::getPublicECDSAKeyImpl(const string &_keyName) {
result["PublicKey"] = publicKey;
result["publicKey"] = publicKey;
} catch (RPCException &_e) {
} catch (SGXException &_e) {
result["status"] = _e.status;
result["errorMessage"] = _e.errString;
}
......@@ -428,17 +433,17 @@ Json::Value SGXWalletServer::generateDKGPolyImpl(const string &_polyName, int _t
try {
if (!checkName(_polyName, "POLY")) {
throw RPCException(INVALID_POLY_NAME,
throw SGXException(INVALID_POLY_NAME,
"Invalid polynomial name, it should be like POLY:SCHAIN_ID:1:NODE_ID:1:DKG_ID:1");
}
if (_t <= 0 || _t > 32) {
throw RPCException(INVALID_DKG_PARAMS, "Invalid parameter t ");
throw SGXException(INVALID_DKG_PARAMS, "Invalid parameter t ");
}
encrPolyHex = gen_dkg_poly(_t);
writeDataToDB(_polyName, encrPolyHex);
//result["encryptedPoly"] = encrPolyHex;
} catch (RPCException &_e) {
} catch (SGXException &_e) {
cerr << " err str " << _e.errString << endl;
result["status"] = _e.status;
result["errorMessage"] = _e.errString;
......@@ -456,10 +461,10 @@ Json::Value SGXWalletServer::getVerificationVectorImpl(const string &_polyName,
vector<vector<string>> verifVector;
try {
if (!checkName(_polyName, "POLY")) {
throw RPCException(INVALID_POLY_NAME, "Invalid polynomial name");
throw SGXException(INVALID_POLY_NAME, "Invalid polynomial name");
}
if (!check_n_t(_t, _n)) {
throw RPCException(INVALID_DKG_PARAMS, "Invalid parameters: n or t ");
throw SGXException(INVALID_DKG_PARAMS, "Invalid parameters: n or t ");
}
shared_ptr<string> encr_poly_ptr = readFromDb(_polyName);
......@@ -475,7 +480,7 @@ Json::Value SGXWalletServer::getVerificationVectorImpl(const string &_polyName,
}
}
} catch (RPCException &_e) {
} catch (SGXException &_e) {
cerr << " err str " << _e.errString << endl;
result["status"] = _e.status;
result["errorMessage"] = _e.errString;
......@@ -493,13 +498,13 @@ Json::Value SGXWalletServer::getSecretShareImpl(const string &_polyName, const J
try {
if (_pubKeys.size() != (uint64_t) _n) {
throw RPCException(INVALID_DKG_PARAMS, "invalid number of public keys");
throw SGXException(INVALID_DKG_PARAMS, "invalid number of public keys");
}
if (!checkName(_polyName, "POLY")) {
throw RPCException(INVALID_POLY_NAME, "Invalid polynomial name");
throw SGXException(INVALID_POLY_NAME, "Invalid polynomial name");
}
if (!check_n_t(_t, _n)) {
throw RPCException(INVALID_DKG_PARAMS, "Invalid DKG parameters: n or t ");
throw SGXException(INVALID_DKG_PARAMS, "Invalid DKG parameters: n or t ");
}
shared_ptr<string> encr_poly_ptr = readFromDb(_polyName);
......@@ -507,7 +512,7 @@ Json::Value SGXWalletServer::getSecretShareImpl(const string &_polyName, const J
vector<string> pubKeysStrs;
for (int i = 0; i < _n; i++) {
if (!checkHex(_pubKeys[i].asString(), 64)) {
throw RPCException(INVALID_HEX, "Invalid public key");
throw SGXException(INVALID_HEX, "Invalid public key");
}
pubKeysStrs.push_back(_pubKeys[i].asString());
}
......@@ -516,7 +521,7 @@ Json::Value SGXWalletServer::getSecretShareImpl(const string &_polyName, const J
//cerr << "result is " << s << endl;
result["secretShare"] = s;
} catch (RPCException &_e) {
} catch (SGXException &_e) {
//cerr << " err str " << _e.errString << endl;
result["status"] = _e.status;
result["errorMessage"] = _e.errString;
......@@ -538,16 +543,16 @@ Json::Value SGXWalletServer::dkgVerificationImpl(const string &_publicShares, co
try {
if (!checkECDSAKeyName(_ethKeyName)) {
throw RPCException(INVALID_ECDSA_KEY_NAME, "Invalid ECDSA key name");
throw SGXException(INVALID_ECDSA_KEY_NAME, "Invalid ECDSA key name");
}
if (!check_n_t(_t, _n) || _index > _n || _index < 0) {
throw RPCException(INVALID_DKG_PARAMS, "Invalid DKG parameters: n or t ");
throw SGXException(INVALID_DKG_PARAMS, "Invalid DKG parameters: n or t ");
}
if (!checkHex(_secretShare, SECRET_SHARE_NUM_BYTES)) {
throw RPCException(INVALID_HEX, "Invalid Secret share");
throw SGXException(INVALID_HEX, "Invalid Secret share");
}
if (_publicShares.length() != (uint64_t) 256 * _t) {
throw RPCException(INVALID_DKG_PARAMS, "Invalid length of public shares");
throw SGXException(INVALID_DKG_PARAMS, "Invalid length of public shares");
}
shared_ptr<string> encryptedKeyHex_ptr = readFromDb(_ethKeyName);
......@@ -556,7 +561,7 @@ Json::Value SGXWalletServer::dkgVerificationImpl(const string &_publicShares, co
result["result"] = false;
}
} catch (RPCException &_e) {
} catch (SGXException &_e) {
//cerr << " err str " << _e.errString << endl;
result["status"] = _e.status;
result["errorMessage"] = _e.errString;
......@@ -566,7 +571,8 @@ Json::Value SGXWalletServer::dkgVerificationImpl(const string &_publicShares, co
return result;
}
Json::Value SGXWalletServer::createBLSPrivateKeyImpl(const string &_blsKeyName, const string &_ethKeyName, const string &_polyName,
Json::Value
SGXWalletServer::createBLSPrivateKeyImpl(const string &_blsKeyName, const string &_ethKeyName, const string &_polyName,
const string &_secretShare, int _t, int _n) {
......@@ -579,19 +585,19 @@ Json::Value SGXWalletServer::createBLSPrivateKeyImpl(const string &_blsKeyName,
if (_secretShare.length() != (uint64_t) _n * 192) {
spdlog::error("Invalid secret share length - {}", _secretShare.length());
spdlog::error("Secret share - {}", _secretShare);
throw RPCException(INVALID_SECRET_SHARES_LENGTH, "Invalid secret share length");
throw SGXException(INVALID_SECRET_SHARES_LENGTH, "Invalid secret share length");
}
if (!checkECDSAKeyName(_ethKeyName)) {
throw RPCException(INVALID_ECDSA_KEY_NAME, "Invalid ECDSA key name");
throw SGXException(INVALID_ECDSA_KEY_NAME, "Invalid ECDSA key name");
}
if (!checkName(_polyName, "POLY")) {
throw RPCException(INVALID_POLY_NAME, "Invalid polynomial name");
throw SGXException(INVALID_POLY_NAME, "Invalid polynomial name");
}
if (!checkName(_blsKeyName, "BLS_KEY")) {
throw RPCException(INVALID_POLY_NAME, "Invalid BLS key name");
throw SGXException(INVALID_POLY_NAME, "Invalid BLS key name");
}
if (!check_n_t(_t, _n)) {
throw RPCException(INVALID_DKG_PARAMS, "Invalid DKG parameters: n or t ");
throw SGXException(INVALID_DKG_PARAMS, "Invalid DKG parameters: n or t ");
}
vector<string> sshares_vect;
......@@ -603,7 +609,7 @@ Json::Value SGXWalletServer::createBLSPrivateKeyImpl(const string &_blsKeyName,
if (res) {
spdlog::info("BLS KEY SHARE CREATED ");
} else {
throw RPCException(-122, "Error while creating BLS key share");
throw SGXException(-122, "Error while creating BLS key share");
}
for (int i = 0; i < _n; i++) {
......@@ -613,7 +619,7 @@ Json::Value SGXWalletServer::createBLSPrivateKeyImpl(const string &_blsKeyName,
LevelDB::getLevelDb()->deleteKey(shareG2_name);
}
} catch (RPCException &_e) {
} catch (SGXException &_e) {
//cerr << " err str " << _e.errString << endl;
result["status"] = _e.status;
result["errorMessage"] = _e.errString;
......@@ -631,7 +637,7 @@ Json::Value SGXWalletServer::getBLSPublicKeyShareImpl(const string &_blsKeyName)
try {
if (!checkName(_blsKeyName, "BLS_KEY")) {
throw RPCException(INVALID_POLY_NAME, "Invalid BLSKey name");
throw SGXException(INVALID_POLY_NAME, "Invalid BLSKey name");
}
shared_ptr<string> encryptedKeyHex_ptr = readFromDb(_blsKeyName);
spdlog::debug("encr_bls_key_share is {}", *encryptedKeyHex_ptr);
......@@ -643,7 +649,7 @@ Json::Value SGXWalletServer::getBLSPublicKeyShareImpl(const string &_blsKeyName)
result["BlsPublicKeyShare"][i] = public_key_vect.at(i);
}
} catch (RPCException &_e) {
} catch (SGXException &_e) {
cerr << " err str " << _e.errString << endl;
result["status"] = _e.status;
result["errorMessage"] = _e.errString;
......@@ -660,7 +666,7 @@ Json::Value SGXWalletServer::complaintResponseImpl(const string &_polyName, int
result["errorMessage"] = "";
try {
if (!checkName(_polyName, "POLY")) {
throw RPCException(INVALID_POLY_NAME, "Invalid polynomial name");
throw SGXException(INVALID_POLY_NAME, "Invalid polynomial name");
}
string shareG2_name = "shareG2_" + _polyName + "_" + to_string(_ind) + ":";
shared_ptr<string> shareG2_ptr = readFromDb(shareG2_name);
......@@ -671,7 +677,7 @@ Json::Value SGXWalletServer::complaintResponseImpl(const string &_polyName, int
result["dhKey"] = DHKey;
result["DHKey"] = DHKey;
} catch (RPCException &_e) {
} catch (SGXException &_e) {
cerr << " err str " << _e.errString << endl;
result["status"] = _e.status;
result["errorMessage"] = _e.errString;
......@@ -691,7 +697,7 @@ Json::Value SGXWalletServer::multG2Impl(const string &_x) {
result["x*G2"][i] = xG2_vect.at(i);
}
} catch (RPCException &_e) {
} catch (SGXException &_e) {
cerr << " err str " << _e.errString << endl;
result["status"] = _e.status;
result["errorMessage"] = _e.errString;
......@@ -714,7 +720,7 @@ Json::Value SGXWalletServer::isPolyExistsImpl(const string &_polyName) {
result["status"] = 0;
result["errorMessage"] = "";
}
} catch (RPCException &_e) {
} catch (SGXException &_e) {
std::cerr << " err str " << _e.errString << std::endl;
result["status"] = _e.status;
result["errorMessage"] = _e.errString;
......@@ -751,7 +757,8 @@ Json::Value SGXWalletServer::getSecretShare(const string &_polyName, const Json:
}
Json::Value
SGXWalletServer::dkgVerification(const string &_publicShares, const string &ethKeyName, const string &SecretShare, int t,
SGXWalletServer::dkgVerification(const string &_publicShares, const string &ethKeyName, const string &SecretShare,
int t,
int n, int index) {
lock_guard<recursive_mutex> lock(m);
return dkgVerificationImpl(_publicShares, ethKeyName, SecretShare, t, n, index);
......@@ -836,7 +843,7 @@ shared_ptr<string> SGXWalletServer::readFromDb(const string &name, const string
auto dataStr = LevelDB::getLevelDb()->readString(prefix + name);
if (dataStr == nullptr) {
throw RPCException(KEY_SHARE_DOES_NOT_EXIST, "Data with this name does not exist");
throw SGXException(KEY_SHARE_DOES_NOT_EXIST, "Data with this name does not exist");
}
return dataStr;
......@@ -847,7 +854,7 @@ shared_ptr<string> SGXWalletServer::readKeyShare(const string &_keyShareName) {
auto keyShareStr = LevelDB::getLevelDb()->readString("BLSKEYSHARE:" + _keyShareName);
if (keyShareStr == nullptr) {
throw RPCException(KEY_SHARE_DOES_NOT_EXIST, "Key share with this name does not exist");
throw SGXException(KEY_SHARE_DOES_NOT_EXIST, "Key share with this name does not exist");
}
return keyShareStr;
......@@ -869,7 +876,7 @@ void SGXWalletServer::writeKeyShare(const string &_keyShareName, const string &_
auto key = "BLSKEYSHARE:" + _keyShareName;
if (LevelDB::getLevelDb()->readString(_keyShareName) != nullptr) {
throw RPCException(KEY_SHARE_ALREADY_EXISTS, "Key share with this name already exists");
throw SGXException(KEY_SHARE_ALREADY_EXISTS, "Key share with this name already exists");
}
LevelDB::getLevelDb()->writeString(key, _value);
......@@ -886,7 +893,7 @@ void SGXWalletServer::writeDataToDB(const string &Name, const string &value) {
if (LevelDB::getLevelDb()->readString(Name) != nullptr) {
spdlog::info("name {}", Name, " already exists");
throw RPCException(KEY_SHARE_ALREADY_EXISTS, "Key share already exists");
throw SGXException(KEY_SHARE_ALREADY_EXISTS, "Key share already exists");
}
LevelDB::getLevelDb()->writeString(key, value);
......
......@@ -31,8 +31,10 @@
#endif
EXTERNC void setFullOptions(int _printDebugInfo, int _useHTTPS, int _autoconfirm, int _encryptKeys);
EXTERNC void setOptions(int _printDebugInfo, int _useHTTPS, int _autoconfirm);
EXTERNC void setFullOptions(int _printDebugInfo,
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() {
fprintf(stderr, "-c do not verify client certificate\n");
fprintf(stderr, "-s sign client certificate without human confirmation \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, "-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");
......@@ -69,6 +71,7 @@ int main(int argc, char *argv[]) {
bool encryptKeysOption = false;
bool useHTTPSOption = true;
bool printDebugInfoOption = false;
bool printTraceInfoOption = false;
bool autoconfirmOption = false;
bool checkClientCertOption = true;
bool autoSignClientCertOption = false;
......@@ -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) {
case 'h':
if (strlen(argv[1]) == 2) {
printUsage();
exit(0);
} else {
fprintf(stderr, "unknown flag %s\n", argv[1]);
printUsage();
exit(1);
}
case 'c':
checkClientCertOption = false;
break;
......@@ -103,6 +100,13 @@ int main(int argc, char *argv[]) {
case 'd':
printDebugInfoOption = true;
break;
case 'v':
printDebugInfoOption = true;
break;
case 'V':
printDebugInfoOption = true;
printTraceInfoOption = true;
break;
case '0':
useHTTPSOption = false;
break;
......@@ -115,15 +119,14 @@ int main(int argc, char *argv[]) {
case 'y':
autoconfirmOption = true;
break;
case '?':
default:
printUsage();
exit(1);
default:
break;
}
}
setFullOptions(printDebugInfoOption, useHTTPSOption, autoconfirmOption, encryptKeysOption);
setFullOptions(printDebugInfoOption, printTraceInfoOption, useHTTPSOption, autoconfirmOption, encryptKeysOption);
initAll(checkClientCertOption, autoSignClientCertOption);
......
......@@ -35,7 +35,7 @@
extern int printDebugInfo;
extern int useHTTPS;
extern int encryptKeys;
extern int autoconfirm;
......
......@@ -52,7 +52,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "BLSCrypto.h"
#include "ServerInit.h"
#include "DKGCrypto.h"
#include "RPCException.h"
#include "SGXException.h"
#include "LevelDB.h"
#include "SGXWalletServer.hpp"
......@@ -134,7 +134,7 @@ void destroyEnclave() {
TEST_CASE("BLS key encrypt", "[bls-key-encrypt]") {
resetDB();
setOptions(false, false, true);
setOptions(false, false, false, true);
initAll(false, true);
auto key = encryptTestKey();
REQUIRE(key != nullptr);
......@@ -143,7 +143,7 @@ TEST_CASE("BLS key encrypt", "[bls-key-encrypt]") {
/* Do later
TEST_CASE("BLS key encrypt/decrypt", "[bls-key-encrypt-decrypt]") {
resetDB();
setOptions(false, false, true);
setOptions(false, false, false, true);
initAll(false, true);
//init_enclave();
......@@ -175,7 +175,7 @@ TEST_CASE("BLS key encrypt/decrypt", "[bls-key-encrypt-decrypt]") {
TEST_CASE("DKG gen test", "[dkg-gen]") {
resetDB();
setOptions(false, false, true);
setOptions(false, false, false, true);
initAll(false, true);
......@@ -263,7 +263,7 @@ libff::alt_bn128_G2 VectStringToG2(const vector<string> &G2_str_vect) {
TEST_CASE("DKG public shares test", "[dkg-pub-shares]") {
resetDB();
setOptions(false, false, true);
setOptions(false, false, false, true);
initAll(false, true);
......@@ -338,7 +338,7 @@ TEST_CASE("DKG public shares test", "[dkg-pub-shares]") {
TEST_CASE("DKG encrypted secret shares test", "[dkg-encr-sshares]") {
resetDB();
setOptions(false, false, true);
setOptions(false, false, false, true);
initAll(false, true);
......@@ -375,7 +375,7 @@ TEST_CASE("DKG encrypted secret shares test", "[dkg-encr-sshares]") {
TEST_CASE("DKG verification test", "[dkg-verify]") {
resetDB();
setOptions(false, false, true);
setOptions(false, false, false, true);
initAll(false, true);
......@@ -416,7 +416,7 @@ TEST_CASE("DKG verification test", "[dkg-verify]") {
TEST_CASE("ECDSA keygen and signature test", "[ecdsa]") {
resetDB();
setOptions(false, false, true);
setOptions(false, false, false, true);
initAll(false, true);
......@@ -460,7 +460,7 @@ TEST_CASE("ECDSA keygen and signature test", "[ecdsa]") {
TEST_CASE("Test test", "[test]") {
resetDB();
setOptions(false, false, true);
setOptions(false, false, false, true);
initAll(false, true);
vector<char> errMsg(BUF_LEN, 0);
......@@ -482,7 +482,7 @@ TEST_CASE("Test test", "[test]") {
TEST_CASE("get public ECDSA key", "[get-pub-ecdsa-key]") {
resetDB();
setOptions(false, false, true);
setOptions(false, false, false, true);
initAll(false, true);
int errStatus = 0;
......@@ -550,7 +550,7 @@ string ConvertDecToHex(string dec, int numBytes = 32) {
TEST_CASE("BLS_DKG test", "[bls-dkg]") {
resetDB();
setOptions(false, false, true);
setOptions(false, false, false, true);
initAll(false, true);
HttpClient client("http://localhost:1029");
......@@ -636,7 +636,7 @@ TEST_CASE("BLS_DKG test", "[bls-dkg]") {
auto hash_arr = make_shared<array<uint8_t, 32>>();
uint64_t binLen;
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]") {
}
TEST_CASE("API test", "[api]") {
setOptions(false, false, true);
setOptions(false, false, false, true);
initAll(false, true);
//HttpServer httpserver(1025);
......@@ -733,7 +733,7 @@ TEST_CASE("API test", "[api]") {
TEST_CASE("getServerStatus test", "[get-server-status]") {
resetDB();
setOptions(false, false, true);
setOptions(false, false, false, true);
initAll(false, true);
HttpClient client("http://localhost:1029");
StubClient c(client, JSONRPC_CLIENT_V2);
......@@ -806,7 +806,7 @@ void SendRPCRequest() {
auto hash_arr = make_shared<array<uint8_t, 32>>();
uint64_t binLen;
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;
......@@ -839,7 +839,7 @@ void SendRPCRequest() {
TEST_CASE("ManySimultaneousThreads", "[many-threads-test]") {
resetDB();
setOptions(false, false, true);
setOptions(false, false, false, true);
initAll(false, true);
......@@ -858,7 +858,7 @@ TEST_CASE("ManySimultaneousThreads", "[many-threads-test]") {
TEST_CASE("ecdsa API test", "[ecdsa-api]") {
resetDB();
setOptions(false, false, true);
setOptions(false, false, false, true);
initAll(false, true);
......@@ -906,7 +906,7 @@ TEST_CASE("ecdsa API test", "[ecdsa-api]") {
TEST_CASE("dkg API test", "[dkg-api]") {
resetDB();
setOptions(false, false, true);
setOptions(false, false, false, true);
initAll(false, true);
......@@ -979,7 +979,7 @@ TEST_CASE("dkg API test", "[dkg-api]") {
TEST_CASE("isPolyExists test", "[is-poly]") {
resetDB();
setOptions(false, false, true);
setOptions(false, false, false, true);
initAll(false, true);
......@@ -1005,7 +1005,7 @@ TEST_CASE("isPolyExists test", "[is-poly]") {
TEST_CASE("AES_DKG test", "[aes-dkg]") {
resetDB();
setOptions(false, false, true);
setOptions(false, false, false, true);
initAll(false, true);
......@@ -1078,7 +1078,7 @@ TEST_CASE("AES_DKG test", "[aes-dkg]") {
auto hash_arr = make_shared<array<uint8_t, 32>>();
uint64_t binLen;
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]") {
TEST_CASE("bls_sign_api test", "[bls-sign]") {
resetDB();
setOptions(false, false, true);
setOptions(false, false, false, true);
initAll(false, true);
HttpClient client("http://localhost:1029");
......@@ -1143,7 +1143,7 @@ TEST_CASE("bls_sign_api test", "[bls-sign]") {
TEST_CASE("AES encrypt/decrypt", "[AES-encrypt-decrypt]") {
resetDB();
setOptions(false, false, true);
setOptions(false, false, 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