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;
......
This diff is collapsed.
......@@ -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