Unverified Commit 1d56b136 authored by kladko's avatar kladko

SKALE-2454-add-logs-to-enclave

parent 83409277
...@@ -30,11 +30,8 @@ ...@@ -30,11 +30,8 @@
#define EXTERNC #define EXTERNC
#endif #endif
//EXTERNC void init_all(); #include "stddef.h"
// #include "stdint.h"
//EXTERNC void init_daemon();
//
//EXTERNC void init_enclave();
EXTERNC bool bls_sign(const char* encryptedKeyHex, const char* hashHex, size_t t, size_t n, EXTERNC bool bls_sign(const char* encryptedKeyHex, const char* hashHex, size_t t, size_t n,
size_t signerIndex, char* _sig); size_t signerIndex, char* _sig);
......
...@@ -33,6 +33,8 @@ ...@@ -33,6 +33,8 @@
EXTERNC void setFullOptions(int _printDebugInfo, EXTERNC void setFullOptions(int _printDebugInfo,
int _printTraceInfo, int _useHTTPS, int _autoconfirm, int _encryptKeys); int _printTraceInfo, int _useHTTPS, int _autoconfirm, int _encryptKeys);
EXTERNC void setOptions(int _printDebugInfo, EXTERNC void setOptions(int _printDebugInfo,
int _printTraceInfo, int _useHTTPS, int _autoconfirm); int _printTraceInfo, int _useHTTPS, int _autoconfirm);
......
...@@ -62,7 +62,7 @@ void initUserSpace() { ...@@ -62,7 +62,7 @@ void initUserSpace() {
} }
void initEnclave() { void initEnclave(uint32_t _logLevel) {
eid = 0; eid = 0;
updated = 0; updated = 0;
...@@ -95,7 +95,7 @@ void initEnclave() { ...@@ -95,7 +95,7 @@ void initEnclave() {
spdlog::info("Enclave created and started successfully"); spdlog::info("Enclave created and started successfully");
status = trustedEnclaveInit(eid, 0); status = trustedEnclaveInit(eid, _logLevel);
if (status != SGX_SUCCESS) { if (status != SGX_SUCCESS) {
spdlog::error("trustedEnclaveInit failed: {}", status); spdlog::error("trustedEnclaveInit failed: {}", status);
exit(1); exit(1);
...@@ -108,12 +108,12 @@ void initEnclave() { ...@@ -108,12 +108,12 @@ void initEnclave() {
int sgxServerInited = 0; int sgxServerInited = 0;
void initAll(bool _checkCert, bool _autoSign) { void initAll(uint32_t _logLevel, bool _checkCert, bool _autoSign) {
cout << "Running sgxwallet version:" << SGXWALLET_VERSION << endl; cout << "Running sgxwallet version:" << SGXWALLET_VERSION << endl;
CHECK_STATE(sgxServerInited == 0) CHECK_STATE(sgxServerInited == 0)
sgxServerInited = 1; sgxServerInited = 1;
initEnclave(); initEnclave(_logLevel);
initUserSpace(); initUserSpace();
initSEK(); initSEK();
......
...@@ -24,17 +24,19 @@ ...@@ -24,17 +24,19 @@
#ifndef SGXWALLET_SERVERINIT_H #ifndef SGXWALLET_SERVERINIT_H
#define SGXWALLET_SERVERINIT_H #define SGXWALLET_SERVERINIT_H
#include "stdint.h"
#ifdef __cplusplus #ifdef __cplusplus
#define EXTERNC extern "C" #define EXTERNC extern "C"
#else #else
#define EXTERNC #define EXTERNC
#endif #endif
EXTERNC void initAll(bool _checkCert, bool _autoSign); EXTERNC void initAll(uint32_t _logLevel, bool _checkCert, bool _autoSign);
EXTERNC void initUserSpace(); EXTERNC void initUserSpace();
EXTERNC void initEnclave(); EXTERNC void initEnclave(uint32_t _logLevel);
......
...@@ -47,7 +47,7 @@ void oc_printf (const char *str) { ...@@ -47,7 +47,7 @@ void oc_printf (const char *str) {
/* Proxy/Bridge will check the length and null-terminate /* Proxy/Bridge will check the length and null-terminate
* the input string to prevent buffer overflow. * the input string to prevent buffer overflow.
* */ * */
fprintf(stderr, "***ENCLAVE_LOG***: %s", str); fprintf(stderr, "%s", str);
} }
......
...@@ -37,11 +37,12 @@ ...@@ -37,11 +37,12 @@
#include "DHDkg.h" #include "DHDkg.h"
using namespace std;
std::string stringFromFr(libff::alt_bn128_Fr& _el) { string stringFromFr(libff::alt_bn128_Fr& _el) {
mpz_t t; mpz_t t;
mpz_init(t); mpz_init(t);
...@@ -53,11 +54,11 @@ std::string stringFromFr(libff::alt_bn128_Fr& _el) { ...@@ -53,11 +54,11 @@ std::string stringFromFr(libff::alt_bn128_Fr& _el) {
char *tmp = mpz_get_str(arr, 10, t); char *tmp = mpz_get_str(arr, 10, t);
mpz_clear(t); mpz_clear(t);
return std::string(tmp); return string(tmp);
} }
template<class T> template<class T>
std::string ConvertToString(T field_elem, int base = 10) { string ConvertToString(T field_elem, int base = 10) {
mpz_t t; mpz_t t;
mpz_init(t); mpz_init(t);
...@@ -68,13 +69,13 @@ std::string ConvertToString(T field_elem, int base = 10) { ...@@ -68,13 +69,13 @@ std::string ConvertToString(T field_elem, int base = 10) {
char * tmp = mpz_get_str(arr, base, t); char * tmp = mpz_get_str(arr, base, t);
mpz_clear(t); mpz_clear(t);
std::string output = tmp; string output = tmp;
return output; return output;
} }
std::string ConvertG2ToString(const libff::alt_bn128_G2 & elem, int base = 10, std::string delim = ":"){ string ConvertG2ToString(const libff::alt_bn128_G2 & elem, int base = 10, string delim = ":"){
std::string result; string result;
result += ConvertToString(elem.X.c0); result += ConvertToString(elem.X.c0);
result += delim; result += delim;
result += ConvertToString(elem.X.c1); result += ConvertToString(elem.X.c1);
...@@ -86,17 +87,17 @@ std::string ConvertG2ToString(const libff::alt_bn128_G2 & elem, int base = 10, s ...@@ -86,17 +87,17 @@ std::string ConvertG2ToString(const libff::alt_bn128_G2 & elem, int base = 10, s
return result; return result;
} }
std::vector<libff::alt_bn128_Fr> SplitStringToFr(const char* coeffs, const char symbol){ vector<libff::alt_bn128_Fr> SplitStringToFr(const char* coeffs, const char symbol){
std::string str(coeffs); string str(coeffs);
std::string delim; string delim;
delim.push_back(symbol); delim.push_back(symbol);
std::vector<libff::alt_bn128_Fr> tokens; vector<libff::alt_bn128_Fr> tokens;
size_t prev = 0, pos = 0; size_t prev = 0, pos = 0;
do do
{ {
pos = str.find(delim, prev); pos = str.find(delim, prev);
if (pos == std::string::npos) pos = str.length(); if (pos == string::npos) pos = str.length();
std::string token = str.substr(prev, pos-prev); string token = str.substr(prev, pos-prev);
if (!token.empty()) { if (!token.empty()) {
libff::alt_bn128_Fr coeff(token.c_str()); libff::alt_bn128_Fr coeff(token.c_str());
tokens.push_back(coeff); tokens.push_back(coeff);
...@@ -110,7 +111,7 @@ std::vector<libff::alt_bn128_Fr> SplitStringToFr(const char* coeffs, const char ...@@ -110,7 +111,7 @@ std::vector<libff::alt_bn128_Fr> SplitStringToFr(const char* coeffs, const char
int gen_dkg_poly( char* secret, unsigned _t ){ int gen_dkg_poly( char* secret, unsigned _t ){
libff::init_alt_bn128_params(); libff::init_alt_bn128_params();
std::string result; string result;
for (size_t i = 0; i < _t; ++i) { for (size_t i = 0; i < _t; ++i) {
libff::alt_bn128_Fr cur_coef = libff::alt_bn128_Fr::random_element(); libff::alt_bn128_Fr cur_coef = libff::alt_bn128_Fr::random_element();
...@@ -129,7 +130,7 @@ int gen_dkg_poly( char* secret, unsigned _t ){ ...@@ -129,7 +130,7 @@ int gen_dkg_poly( char* secret, unsigned _t ){
return 0; return 0;
} }
libff::alt_bn128_Fr PolynomialValue(const std::vector<libff::alt_bn128_Fr>& pol, libff::alt_bn128_Fr point, unsigned _t) { libff::alt_bn128_Fr PolynomialValue(const vector<libff::alt_bn128_Fr>& pol, libff::alt_bn128_Fr point, unsigned _t) {
libff::alt_bn128_Fr value = libff::alt_bn128_Fr::zero(); libff::alt_bn128_Fr value = libff::alt_bn128_Fr::zero();
...@@ -149,9 +150,9 @@ libff::alt_bn128_Fr PolynomialValue(const std::vector<libff::alt_bn128_Fr>& pol, ...@@ -149,9 +150,9 @@ libff::alt_bn128_Fr PolynomialValue(const std::vector<libff::alt_bn128_Fr>& pol,
void calc_secret_shares(const char* decrypted_coeffs, char * secret_shares, // calculates secret shares in base 10 to a string secret_shares, void calc_secret_shares(const char* decrypted_coeffs, char * secret_shares, // calculates secret shares in base 10 to a string secret_shares,
unsigned _t, unsigned _n) { // separated by ":" unsigned _t, unsigned _n) { // separated by ":"
// calculate for each node a list of secret values that will be used for verification // calculate for each node a list of secret values that will be used for verification
std::string result; string result;
char symbol = ':'; char symbol = ':';
std::vector<libff::alt_bn128_Fr> poly = SplitStringToFr(decrypted_coeffs, symbol); vector<libff::alt_bn128_Fr> poly = SplitStringToFr(decrypted_coeffs, symbol);
for (size_t i = 0; i < _n; ++i) { for (size_t i = 0; i < _n; ++i) {
libff::alt_bn128_Fr secret_share = PolynomialValue(poly, libff::alt_bn128_Fr(i + 1), _t); libff::alt_bn128_Fr secret_share = PolynomialValue(poly, libff::alt_bn128_Fr(i + 1), _t);
...@@ -167,13 +168,13 @@ int calc_secret_share(const char* decrypted_coeffs, char * s_share, ...@@ -167,13 +168,13 @@ int calc_secret_share(const char* decrypted_coeffs, char * s_share,
libff::init_alt_bn128_params(); libff::init_alt_bn128_params();
char symbol = ':'; char symbol = ':';
std::vector<libff::alt_bn128_Fr> poly = SplitStringToFr(decrypted_coeffs, symbol); vector<libff::alt_bn128_Fr> poly = SplitStringToFr(decrypted_coeffs, symbol);
if ( poly.size() != _t){ if ( poly.size() != _t){
return 1; return 1;
} }
libff::alt_bn128_Fr secret_share = PolynomialValue(poly, libff::alt_bn128_Fr(ind), _t); libff::alt_bn128_Fr secret_share = PolynomialValue(poly, libff::alt_bn128_Fr(ind), _t);
std::string cur_share = ConvertToString(secret_share, 16);//stringFromFr(secret_share); string cur_share = ConvertToString(secret_share, 16);//stringFromFr(secret_share);
int n_zeroes = 64 - cur_share.size(); int n_zeroes = 64 - cur_share.size();
cur_share.insert(0, n_zeroes, '0'); cur_share.insert(0, n_zeroes, '0');
...@@ -187,17 +188,17 @@ void calc_secret_shareG2_old(const char* decrypted_coeffs, char * s_shareG2, ...@@ -187,17 +188,17 @@ void calc_secret_shareG2_old(const char* decrypted_coeffs, char * s_shareG2,
libff::init_alt_bn128_params(); libff::init_alt_bn128_params();
char symbol = ':'; char symbol = ':';
std::vector<libff::alt_bn128_Fr> poly = SplitStringToFr(decrypted_coeffs, symbol); vector<libff::alt_bn128_Fr> poly = SplitStringToFr(decrypted_coeffs, symbol);
// if ( poly.size() != _t){ // if ( poly.size() != _t){
// //"t != poly.size()" + // //"t != poly.size()" +
// //strncpy(s_shareG2, std::to_string(poly.size()).c_str(), 18); // //strncpy(s_shareG2, to_string(poly.size()).c_str(), 18);
// } // }
libff::alt_bn128_Fr secret_share = PolynomialValue(poly, libff::alt_bn128_Fr(ind), _t); libff::alt_bn128_Fr secret_share = PolynomialValue(poly, libff::alt_bn128_Fr(ind), _t);
libff::alt_bn128_G2 secret_shareG2 = secret_share * libff::alt_bn128_G2::one(); libff::alt_bn128_G2 secret_shareG2 = secret_share * libff::alt_bn128_G2::one();
std::string secret_shareG2_str = ConvertG2ToString(secret_shareG2); string secret_shareG2_str = ConvertG2ToString(secret_shareG2);
strncpy(s_shareG2, secret_shareG2_str.c_str(), secret_shareG2_str.length() + 1); strncpy(s_shareG2, secret_shareG2_str.c_str(), secret_shareG2_str.length() + 1);
//strncpy(s_shareG2, decrypted_coeffs, 320); //strncpy(s_shareG2, decrypted_coeffs, 320);
...@@ -222,7 +223,7 @@ int calc_secret_shareG2(const char* s_share, char * s_shareG2){ ...@@ -222,7 +223,7 @@ int calc_secret_shareG2(const char* s_share, char * s_shareG2){
secret_shareG2.to_affine_coordinates(); secret_shareG2.to_affine_coordinates();
std::string secret_shareG2_str = ConvertG2ToString(secret_shareG2); string secret_shareG2_str = ConvertG2ToString(secret_shareG2);
strncpy(s_shareG2, secret_shareG2_str.c_str(), secret_shareG2_str.length() + 1); strncpy(s_shareG2, secret_shareG2_str.c_str(), secret_shareG2_str.length() + 1);
...@@ -233,16 +234,16 @@ int calc_public_shares(const char* decrypted_coeffs, char * public_shares, ...@@ -233,16 +234,16 @@ int calc_public_shares(const char* decrypted_coeffs, char * public_shares,
unsigned _t) { unsigned _t) {
libff::init_alt_bn128_params(); libff::init_alt_bn128_params();
// calculate for each node a list of public shares // calculate for each node a list of public shares
std::string result; string result;
char symbol = ':'; char symbol = ':';
std::vector<libff::alt_bn128_Fr> poly = SplitStringToFr(decrypted_coeffs, symbol); vector<libff::alt_bn128_Fr> poly = SplitStringToFr(decrypted_coeffs, symbol);
if (poly.size() != _t){ if (poly.size() != _t){
return 1; return 1;
} }
for (size_t i = 0; i < _t; ++i) { for (size_t i = 0; i < _t; ++i) {
libff::alt_bn128_G2 pub_share = poly.at(i) * libff::alt_bn128_G2::one() ; libff::alt_bn128_G2 pub_share = poly.at(i) * libff::alt_bn128_G2::one() ;
pub_share.to_affine_coordinates(); pub_share.to_affine_coordinates();
std::string pub_share_str = ConvertG2ToString(pub_share); string pub_share_str = ConvertG2ToString(pub_share);
result += pub_share_str + ","; result += pub_share_str + ",";
} }
strncpy(public_shares, result.c_str(), result.length()); strncpy(public_shares, result.c_str(), result.length());
...@@ -250,7 +251,7 @@ int calc_public_shares(const char* decrypted_coeffs, char * public_shares, ...@@ -250,7 +251,7 @@ int calc_public_shares(const char* decrypted_coeffs, char * public_shares,
} }
//extern "C" int __gmpz_set_str (mpz_ptr, const char *, int); //extern "C" int __gmpz_set_str (mpz_ptr, const char *, int);
std::string ConvertHexToDec(std::string hex_str){ string ConvertHexToDec(string hex_str){
mpz_t dec; mpz_t dec;
mpz_init(dec); mpz_init(dec);
...@@ -269,10 +270,10 @@ std::string ConvertHexToDec(std::string hex_str){ ...@@ -269,10 +270,10 @@ std::string ConvertHexToDec(std::string hex_str){
int Verification ( char * public_shares, mpz_t decr_secret_share, int _t, int ind ){ int Verification ( char * public_shares, mpz_t decr_secret_share, int _t, int ind ){
std::string pub_shares_str = public_shares; string pub_shares_str = public_shares;
libff::init_alt_bn128_params(); libff::init_alt_bn128_params();
std::vector<libff::alt_bn128_G2> pub_shares; vector<libff::alt_bn128_G2> pub_shares;
uint64_t share_length = 256; uint64_t share_length = 256;
uint8_t coord_length = 64; uint8_t coord_length = 64;
...@@ -280,10 +281,10 @@ int Verification ( char * public_shares, mpz_t decr_secret_share, int _t, int in ...@@ -280,10 +281,10 @@ int Verification ( char * public_shares, mpz_t decr_secret_share, int _t, int in
libff::alt_bn128_G2 pub_share; libff::alt_bn128_G2 pub_share;
uint64_t pos0 = share_length * i; uint64_t pos0 = share_length * i;
std::string x_c0_str = ConvertHexToDec(pub_shares_str.substr(pos0, coord_length)); string x_c0_str = ConvertHexToDec(pub_shares_str.substr(pos0, coord_length));
std::string x_c1_str = ConvertHexToDec(pub_shares_str.substr(pos0 + coord_length, coord_length)); string x_c1_str = ConvertHexToDec(pub_shares_str.substr(pos0 + coord_length, coord_length));
std::string y_c0_str = ConvertHexToDec(pub_shares_str.substr(pos0 + 2 * coord_length, coord_length)); string y_c0_str = ConvertHexToDec(pub_shares_str.substr(pos0 + 2 * coord_length, coord_length));
std::string y_c1_str = ConvertHexToDec(pub_shares_str.substr(pos0 + 3 * coord_length, coord_length)); string y_c1_str = ConvertHexToDec(pub_shares_str.substr(pos0 + 3 * coord_length, coord_length));
if (x_c0_str == "false" || x_c1_str == "false" || y_c0_str == "false" || y_c1_str == "false"){ if (x_c0_str == "false" || x_c1_str == "false" || y_c0_str == "false" || y_c1_str == "false"){
return 2; return 2;
} }
...@@ -296,10 +297,10 @@ int Verification ( char * public_shares, mpz_t decr_secret_share, int _t, int in ...@@ -296,10 +297,10 @@ int Verification ( char * public_shares, mpz_t decr_secret_share, int _t, int in
//for ( int j = 0; j < 4; j++) { //for ( int j = 0; j < 4; j++) {
//uint64_t pos0 = share_length * j; //uint64_t pos0 = share_length * j;
//std::string coord = ConvertHexToDec(pub_shares_str.substr(pos0 + j * coord_length, coord_length)); //string coord = ConvertHexToDec(pub_shares_str.substr(pos0 + j * coord_length, coord_length));
// if ( i == 0) { // if ( i == 0) {
// memset(public_shares, 0, strlen(public_shares)); // memset(public_shares, 0, strlen(public_shares));
// std::string coord = ConvertToString(pub_share.Y.c1); // string coord = ConvertToString(pub_share.Y.c1);
// strncpy(public_shares, coord.c_str(), coord.length()); // strncpy(public_shares, coord.c_str(), coord.length());
// } // }
//} //}
...@@ -318,7 +319,7 @@ int Verification ( char * public_shares, mpz_t decr_secret_share, int _t, int in ...@@ -318,7 +319,7 @@ int Verification ( char * public_shares, mpz_t decr_secret_share, int _t, int in
libff::alt_bn128_Fr sshare(tmp); libff::alt_bn128_Fr sshare(tmp);
// strncpy(public_shares, tmp, strlen(tmp)); // strncpy(public_shares, tmp, strlen(tmp));
// std::string res = ConvertHexToDec("fe43567238abcdef98760"); // string res = ConvertHexToDec("fe43567238abcdef98760");
// strncpy(public_shares, res.c_str(), res.length()); // strncpy(public_shares, res.c_str(), res.length());
...@@ -367,7 +368,7 @@ int calc_bls_public_key(char* skey_hex, char* pub_key){ ...@@ -367,7 +368,7 @@ int calc_bls_public_key(char* skey_hex, char* pub_key){
libff::alt_bn128_G2 public_key = bls_skey * libff::alt_bn128_G2::one(); libff::alt_bn128_G2 public_key = bls_skey * libff::alt_bn128_G2::one();
public_key.to_affine_coordinates(); public_key.to_affine_coordinates();
std::string result = ConvertG2ToString(public_key); string result = ConvertG2ToString(public_key);
strncpy(pub_key, result.c_str(), result.length()); strncpy(pub_key, result.c_str(), result.length());
......
...@@ -277,11 +277,11 @@ bool hex2carray(const char * _hex, uint64_t *_bin_len, ...@@ -277,11 +277,11 @@ bool hex2carray(const char * _hex, uint64_t *_bin_len,
enum log_level {L_TRACE = 0, L_DEBUG = 1, L_INFO = 2,L_WARNING = 3, L_ERROR = 4 }; enum log_level {L_TRACE = 0, L_DEBUG = 1, L_INFO = 2,L_WARNING = 3, L_ERROR = 4 };
uint32_t logLevel = 2; uint32_t globalLogLevel_ = 2;
void logMsg(log_level _level, char* _msg) { void logMsg(log_level _level, char* _msg) {
if (_level < logLevel) if (_level < globalLogLevel_)
return; return;
if (!_msg) { if (!_msg) {
...@@ -289,13 +289,26 @@ void logMsg(log_level _level, char* _msg) { ...@@ -289,13 +289,26 @@ void logMsg(log_level _level, char* _msg) {
return; return;
} }
oc_printf("***ENCLAVE_LOG***:");
oc_printf(_msg); oc_printf(_msg);
oc_printf("\n");
} }
EXTERNC void LOG_INFO(char* msg) {}; EXTERNC void LOG_INFO(char* _msg) {
EXTERNC void LOG_WARNING(char* _msg) {}; logMsg(L_INFO, _msg);
EXTERNC void LOG_ERROR(char* _msg) {}; };
EXTERNC void LOG_DEBUG(char* _msg) {}; EXTERNC void LOG_WARNING(char* _msg) {
EXTERNC void LOG_TRACE(char* _msg) {}; logMsg(L_WARNING, _msg);
};
EXTERNC void LOG_ERROR(char* _msg) {
logMsg(L_ERROR, _msg);
};
EXTERNC void LOG_DEBUG(char* _msg) {
logMsg(L_DEBUG, _msg);
};
EXTERNC void LOG_TRACE(char* _msg) {
logMsg(L_TRACE, _msg);
};
...@@ -59,6 +59,8 @@ EXTERNC void LOG_DEBUG(char* _msg); ...@@ -59,6 +59,8 @@ EXTERNC void LOG_DEBUG(char* _msg);
EXTERNC void LOG_TRACE(char* _msg); EXTERNC void LOG_TRACE(char* _msg);
extern uint32_t globalLogLevel_;
#endif //SGXWALLET_ENCLAVECOMMON_H #endif //SGXWALLET_ENCLAVECOMMON_H
This diff is collapsed.
...@@ -33,15 +33,14 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ...@@ -33,15 +33,14 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
#include <stdbool.h>
#include "sgxwallet.h"
#include "BLSCrypto.h" #include "BLSCrypto.h"
#include "ServerInit.h" #include "ServerInit.h"
#include "SEKManager.h" #include "SEKManager.h"
#include "SGXWalletServer.h"
#include "sgxwallet.h"
#include <stdbool.h>
void usage() { void usage() {
...@@ -66,6 +65,8 @@ void printUsage() { ...@@ -66,6 +65,8 @@ void printUsage() {
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");
} }
enum log_level {L_TRACE = 0, L_DEBUG = 1, L_INFO = 2,L_WARNING = 3, L_ERROR = 4 };
int main(int argc, char *argv[]) { int main(int argc, char *argv[]) {
bool encryptKeysOption = false; bool encryptKeysOption = false;
...@@ -128,7 +129,17 @@ int main(int argc, char *argv[]) { ...@@ -128,7 +129,17 @@ int main(int argc, char *argv[]) {
setFullOptions(printDebugInfoOption, printTraceInfoOption, useHTTPSOption, autoconfirmOption, encryptKeysOption); setFullOptions(printDebugInfoOption, printTraceInfoOption, useHTTPSOption, autoconfirmOption, encryptKeysOption);
initAll(checkClientCertOption, autoSignClientCertOption);
uint32_t enclaveLogLevel = L_INFO;
if (printTraceInfoOption) {
enclaveLogLevel = L_TRACE;
} else if (printDebugInfoOption) {
enclaveLogLevel = L_DEBUG;
}
initAll(enclaveLogLevel, checkClientCertOption, autoSignClientCertOption);
while (true) { while (true) {
sleep(10); sleep(10);
......
...@@ -135,7 +135,7 @@ void destroyEnclave() { ...@@ -135,7 +135,7 @@ void destroyEnclave() {
TEST_CASE("BLS key encrypt", "[bls-key-encrypt]") { TEST_CASE("BLS key encrypt", "[bls-key-encrypt]") {
resetDB(); resetDB();
setOptions(false, false, false, true); setOptions(false, false, false, true);
initAll(false, true); initAll(0, false, true);
auto key = encryptTestKey(); auto key = encryptTestKey();
REQUIRE(key != nullptr); REQUIRE(key != nullptr);
} }
...@@ -144,7 +144,7 @@ TEST_CASE("BLS key encrypt", "[bls-key-encrypt]") { ...@@ -144,7 +144,7 @@ TEST_CASE("BLS key encrypt", "[bls-key-encrypt]") {
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, false, true); setOptions(false, false, false, true);
initAll(false, true); initAll(0, false, true);
//init_enclave(); //init_enclave();
...@@ -176,7 +176,7 @@ TEST_CASE("BLS key encrypt/decrypt", "[bls-key-encrypt-decrypt]") { ...@@ -176,7 +176,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, false, true); setOptions(false, false, false, true);
initAll(false, true); initAll(0, false, true);
vector<uint8_t> encryptedDKGSecret(BUF_LEN, 0); vector<uint8_t> encryptedDKGSecret(BUF_LEN, 0);
...@@ -264,7 +264,7 @@ libff::alt_bn128_G2 VectStringToG2(const vector<string> &G2_str_vect) { ...@@ -264,7 +264,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, false, true); setOptions(false, false, false, true);
initAll(false, true); initAll(0, false, true);
libff::init_alt_bn128_params(); libff::init_alt_bn128_params();
...@@ -339,7 +339,7 @@ TEST_CASE("DKG public shares test", "[dkg-pub-shares]") { ...@@ -339,7 +339,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, false, true); setOptions(false, false, false, true);
initAll(false, true); initAll(0, false, true);
vector<char> errMsg(BUF_LEN, 0); vector<char> errMsg(BUF_LEN, 0);
...@@ -376,7 +376,7 @@ TEST_CASE("DKG encrypted secret shares test", "[dkg-encr-sshares]") { ...@@ -376,7 +376,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, false, true); setOptions(false, false, false, true);
initAll(false, true); initAll(0, false, true);
vector<char> errMsg(BUF_LEN, 0); vector<char> errMsg(BUF_LEN, 0);
...@@ -417,7 +417,7 @@ TEST_CASE("DKG verification test", "[dkg-verify]") { ...@@ -417,7 +417,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, false, true); setOptions(false, false, false, true);
initAll(false, true); initAll(0, false, true);
vector<char> errMsg(BUF_LEN, 0); vector<char> errMsg(BUF_LEN, 0);
...@@ -461,7 +461,7 @@ TEST_CASE("ECDSA keygen and signature test", "[ecdsa]") { ...@@ -461,7 +461,7 @@ TEST_CASE("ECDSA keygen and signature test", "[ecdsa]") {
TEST_CASE("Test test", "[test]") { TEST_CASE("Test test", "[test]") {
resetDB(); resetDB();
setOptions(false, false, false, true); setOptions(false, false, false, true);
initAll(false, true); initAll(0, false, true);
vector<char> errMsg(BUF_LEN, 0); vector<char> errMsg(BUF_LEN, 0);
int errStatus = 0; int errStatus = 0;
...@@ -483,7 +483,7 @@ TEST_CASE("Test test", "[test]") { ...@@ -483,7 +483,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, false, true); setOptions(false, false, false, true);
initAll(false, true); initAll(0, false, true);
int errStatus = 0; int errStatus = 0;
vector<char> errMsg(BUF_LEN, 0); vector<char> errMsg(BUF_LEN, 0);
...@@ -551,7 +551,7 @@ string ConvertDecToHex(string dec, int numBytes = 32) { ...@@ -551,7 +551,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, false, true); setOptions(false, false, false, true);
initAll(false, true); initAll(0, false, true);
HttpClient client("http://localhost:1029"); HttpClient client("http://localhost:1029");
StubClient c(client, JSONRPC_CLIENT_V2); StubClient c(client, JSONRPC_CLIENT_V2);
...@@ -679,7 +679,7 @@ TEST_CASE("BLS_DKG test", "[bls-dkg]") { ...@@ -679,7 +679,7 @@ TEST_CASE("BLS_DKG test", "[bls-dkg]") {
TEST_CASE("API test", "[api]") { TEST_CASE("API test", "[api]") {
setOptions(false, false, false, true); setOptions(false, false, false, true);
initAll(false, true); initAll(0, false, true);
//HttpServer httpserver(1025); //HttpServer httpserver(1025);
//SGXWalletServer s(httpserver, //SGXWalletServer s(httpserver,
...@@ -734,7 +734,7 @@ TEST_CASE("API test", "[api]") { ...@@ -734,7 +734,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, false, true); setOptions(false, false, false, true);
initAll(false, true); initAll(0, false, true);
HttpClient client("http://localhost:1029"); HttpClient client("http://localhost:1029");
StubClient c(client, JSONRPC_CLIENT_V2); StubClient c(client, JSONRPC_CLIENT_V2);
REQUIRE(c.getServerStatus()["status"] == 0); REQUIRE(c.getServerStatus()["status"] == 0);
...@@ -841,7 +841,7 @@ TEST_CASE("ManySimultaneousThreads", "[many-threads-test]") { ...@@ -841,7 +841,7 @@ TEST_CASE("ManySimultaneousThreads", "[many-threads-test]") {
resetDB(); resetDB();
setOptions(false, false, false, true); setOptions(false, false, false, true);
initAll(false, true); initAll(0, false, true);
vector<thread> threads; vector<thread> threads;
int num_threads = 4; int num_threads = 4;
...@@ -859,7 +859,7 @@ TEST_CASE("ManySimultaneousThreads", "[many-threads-test]") { ...@@ -859,7 +859,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, false, true); setOptions(false, false, false, true);
initAll(false, true); initAll(0, false, true);
HttpClient client("http://localhost:1029"); HttpClient client("http://localhost:1029");
...@@ -907,7 +907,7 @@ TEST_CASE("ecdsa API test", "[ecdsa-api]") { ...@@ -907,7 +907,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, false, true); setOptions(false, false, false, true);
initAll(false, true); initAll(0, false, true);
HttpClient client("http://localhost:1029"); HttpClient client("http://localhost:1029");
...@@ -980,7 +980,7 @@ TEST_CASE("dkg API test", "[dkg-api]") { ...@@ -980,7 +980,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, false, true); setOptions(false, false, false, true);
initAll(false, true); initAll(0, false, true);
HttpClient client("http://localhost:1029"); HttpClient client("http://localhost:1029");
...@@ -1008,7 +1008,7 @@ TEST_CASE("AES_DKG test", "[aes-dkg]") { ...@@ -1008,7 +1008,7 @@ TEST_CASE("AES_DKG test", "[aes-dkg]") {
setOptions(false, false, false, true); setOptions(false, false, false, true);
initAll(false, true); initAll(0, false, true);
HttpClient client("http://localhost:1029"); HttpClient client("http://localhost:1029");
StubClient c(client, JSONRPC_CLIENT_V2); StubClient c(client, JSONRPC_CLIENT_V2);
...@@ -1122,7 +1122,7 @@ TEST_CASE("AES_DKG test", "[aes-dkg]") { ...@@ -1122,7 +1122,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, false, true); setOptions(false, false, false, true);
initAll(false, true); initAll(0, false, true);
HttpClient client("http://localhost:1029"); HttpClient client("http://localhost:1029");
StubClient c(client, JSONRPC_CLIENT_V2); StubClient c(client, JSONRPC_CLIENT_V2);
...@@ -1144,7 +1144,7 @@ TEST_CASE("bls_sign_api test", "[bls-sign]") { ...@@ -1144,7 +1144,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, false, true); setOptions(false, false, false, true);
initAll(false, true); initAll(0, false, true);
int errStatus = -1; int errStatus = -1;
......
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