Unverified Commit cff22509 authored by kladko's avatar kladko

SKALE-2341 Added tags for older commits

parent 1fa379be
......@@ -273,12 +273,17 @@ bool LevelDB::isInited = false;
void LevelDB::initDataFolderAndDBs() {
if (isInited)
return;
CHECK_STATE(!isInited)
isInited = true;
spdlog::info("Initing wallet database ... ");
char cwd[PATH_MAX];
if (getcwd(cwd, sizeof(cwd)) == NULL) {
spdlog::error("could not get cwd");
spdlog::error("could not get current workin directory");
exit(-1);
}
......@@ -286,17 +291,20 @@ void LevelDB::initDataFolderAndDBs() {
struct stat info;
if (stat(sgx_data_folder.c_str(), &info) !=0 ){
spdlog::info("going to create sgx_data folder");
std::string make_sgx_data_folder = "mkdir " + sgx_data_folder;
if (system(make_sgx_data_folder.c_str()) == 0){
spdlog::info("sgx_data folder was created");
spdlog::info("sgx_data folder does not exist. Creating ...");
if (system(("mkdir " + sgx_data_folder).c_str()) == 0){
spdlog::info("Successfully created sgx_data folder");
}
else{
spdlog::error("creating sgx_data folder failed");
spdlog::error("Couldnt create creating sgx_data folder");
exit(-1);
}
}
spdlog::info("Opening wallet databases");
auto dbName = sgx_data_folder + WALLETDB_NAME;
levelDb = make_shared<LevelDB>(dbName);
......@@ -306,6 +314,8 @@ void LevelDB::initDataFolderAndDBs() {
auto csr_status_dbname = sgx_data_folder + "CSR_STATUS_DB";
csrStatusDb = make_shared<LevelDB>(csr_status_dbname);
spdlog::info("Successfully opened databases");
}
const string &LevelDB::getSgxDataFolder() {
......
......@@ -22,64 +22,46 @@
*/
#include <memory>
#include <iostream>
#include <unistd.h>
#include <stdio.h>
#include <limits.h>
#include <sys/types.h>
#include <sys/stat.h>
#include "libff/algebra/curves/alt_bn128/alt_bn128_init.hpp"
#include "bls.h"
#include "leveldb/db.h"
#include <jsonrpccpp/server/connectors/httpserver.h>
#include "BLSPrivateKeyShareSGX.h"
#include "spdlog/spdlog.h"
#include <gmp.h>
#include <sgx_urts.h>
#include "BLSPrivateKeyShareSGX.h"
#include "sgxwallet_common.h"
#include "create_enclave.h"
#include "secure_enclave_u.h"
#include "sgx_detect.h"
#include <gmp.h>
#include <sgx_urts.h>
#include "sgxwallet.h"
#include "LevelDB.h"
#include "SGXWalletServer.h"
#include "SGXRegistrationServer.h"
#include "SEKManager.h"
#include "CSRManagerServer.h"
#include "BLSCrypto.h"
#include "ServerInit.h"
#include <iostream>
#include "spdlog/spdlog.h"
#include <unistd.h>
#include <stdio.h>
#include <limits.h>
#include <sys/types.h>
#include <sys/stat.h>
#include "SGXWalletServer.hpp"
#include "SGXWALLET_VERSION"
//#include <system>
void initDaemon() {
void initUserSpace() {
libff::init_alt_bn128_params();
LevelDB::initDataFolderAndDBs();
}
void initEnclave() {
eid = 0;
......@@ -95,7 +77,7 @@ void initEnclave() {
}
#endif
if ( printDebugInfo) {
if (printDebugInfo) {
spdlog::info("SGX_DEBUG_FLAG = {}", SGX_DEBUG_FLAG);
}
......@@ -113,8 +95,7 @@ void initEnclave() {
exit(1);
}
//fprintf(stderr, "Enclave launched\n");
spdlog::error( "Enclave created and started successfully");
spdlog::error("Enclave created and started successfully");
status = tgmp_init(eid);
if (status != SGX_SUCCESS) {
......@@ -129,29 +110,20 @@ void initEnclave() {
int sgxServerInited = 0;
void initAll(bool _checkCert, bool _autoSign, void (*SEK_func)()) {
void initAll(bool _checkCert, bool _autoSign) {
cout << "Running sgxwallet version:" << SGXWALLET_VERSION << endl;
//spdlog::set_pattern("%c");
if (sgxServerInited == 1)
return;
initEnclave();
initDaemon();
//init_SEK();
SEK_func();
CHECK_STATE(sgxServerInited == 0)
sgxServerInited = 1;
initEnclave();
initUserSpace();
init_SEK();
if (useHTTPS) {
SGXWalletServer::initHttpsServer(_checkCert);
initRegistrationServer(_autoSign);
init_csrmanager_server();
}
else {
} else {
SGXWalletServer::initHttpServer();
}
//std::cerr << "enclave inited" << std::endl;
}
......@@ -30,9 +30,9 @@
#define EXTERNC
#endif
EXTERNC void initAll(bool _checkCert, bool _autoSign, void (*func)());
EXTERNC void initAll(bool _checkCert, bool _autoSign);
EXTERNC void initDaemon();
EXTERNC void initUserSpace();
EXTERNC void initEnclave();
......
......@@ -73,8 +73,6 @@ int main(int argc, char *argv[]) {
bool checkClientCertOption = true;
bool autoSignClientCertOption = false;
void (*SEK_initializer)();
SEK_initializer = init_SEK;
int opt;
if (argc > 1 && strlen(argv[1]) == 1) {
......@@ -112,7 +110,7 @@ int main(int argc, char *argv[]) {
encryptKeysOption = false;
break;
case 'b':
SEK_initializer = enter_SEK;
encryptKeysOption = false;
break;
case 'y':
autoconfirmOption = true;
......@@ -127,7 +125,7 @@ int main(int argc, char *argv[]) {
setFullOptions(printDebugInfoOption, useHTTPSOption, autoconfirmOption, encryptKeysOption);
initAll(checkClientCertOption, autoSignClientCertOption, SEK_initializer);
initAll(checkClientCertOption, autoSignClientCertOption);
while (true) {
sleep(10);
......
......@@ -124,18 +124,18 @@ char *encryptTestKey() {
TEST_CASE("BLS key encrypt", "[bls-key-encrypt]") {
resetDB();
setOptions(true, false, true);
initAll(false, true, init_SEK);
initAll(false, true);
auto key = encryptTestKey();
REQUIRE(key != nullptr);
free(key);
sgx_destroy_enclave(eid);
}
/* Do later
TEST_CASE("BLS key encrypt/decrypt", "[bls-key-encrypt-decrypt]") {
resetDB();
setOptions(true, false, true);
initAll(false, true, init_SEK);
initAll(false, true);
//init_enclave();
......@@ -160,6 +160,8 @@ TEST_CASE("BLS key encrypt/decrypt", "[bls-key-encrypt-decrypt]") {
}
*/
void destroyEnclave() {
if (eid != 0) {
sgx_destroy_enclave(eid);
......@@ -171,7 +173,7 @@ void destroyEnclave() {
TEST_CASE("DKG gen test", "[dkg-gen]") {
resetDB();
setOptions(true, false, true);
initAll(false, true, init_SEK);
initAll(false, true);
vector<uint8_t> encrypted_dkg_secret(DKG_MAX_SEALED_LEN, 0);
......@@ -260,7 +262,7 @@ libff::alt_bn128_G2 VectStringToG2(const vector<string> &G2_str_vect) {
TEST_CASE("DKG public shares test", "[dkg-pub_shares]") {
resetDB();
setOptions(true, false, true);
initAll(false, true, init_SEK);
initAll(false, true);
libff::init_alt_bn128_params();
......@@ -334,7 +336,7 @@ TEST_CASE("DKG public shares test", "[dkg-pub_shares]") {
TEST_CASE("DKG encrypted secret shares test", "[dkg-encr_sshares]") {
resetDB();
setOptions(true, false, true);
initAll(false, true, init_SEK);
initAll(false, true);
vector<char> errMsg(1024, 1);
......@@ -371,7 +373,7 @@ TEST_CASE("DKG encrypted secret shares test", "[dkg-encr_sshares]") {
TEST_CASE("DKG verification test", "[dkg-verify]") {
resetDB();
setOptions(true, false, true);
initAll(false, true, init_SEK);
initAll(false, true);
vector<char> errMsg(1024, 0);
......@@ -412,7 +414,7 @@ TEST_CASE("DKG verification test", "[dkg-verify]") {
TEST_CASE("ECDSA keygen and signature test", "[ecdsa_test]") {
resetDB();
setOptions(true, false, true);
initAll(false, true, init_SEK);
initAll(false, true);
vector<char> errMsg(1024, 0);
......@@ -456,7 +458,7 @@ TEST_CASE("ECDSA keygen and signature test", "[ecdsa_test]") {
TEST_CASE("Test test", "[test_test]") {
resetDB();
setOptions(true, false, true);
initAll(false, true, init_SEK);
initAll(false, true);
vector<char> errMsg(1024, 0);
int err_status = 0;
......@@ -478,7 +480,7 @@ TEST_CASE("Test test", "[test_test]") {
TEST_CASE("get public ECDSA key", "[get_pub_ecdsa_key_test]") {
resetDB();
setOptions(true, false, true);
initAll(false, true, init_SEK);
initAll(false, true);
int err_status = 0;
vector<char> errMsg(1024, 0);
......@@ -553,7 +555,7 @@ string ConvertDecToHex(string dec, int numBytes = 32) {
TEST_CASE("BLS_DKG test", "[bls_dkg]") {
resetDB();
setOptions(true, false, true);
initAll(false, true, init_SEK);
initAll(false, true);
HttpClient client("http://localhost:1029");
StubClient c(client, JSONRPC_CLIENT_V2);
......@@ -683,7 +685,7 @@ TEST_CASE("BLS_DKG test", "[bls_dkg]") {
TEST_CASE("API test", "[api_test]") {
setOptions(true, false, true);
initAll(false, true, init_SEK);
initAll(false, true);
//HttpServer httpserver(1025);
//SGXWalletServer s(httpserver,
......@@ -788,7 +790,7 @@ TEST_CASE("API test", "[api_test]") {
TEST_CASE("getServerStatus test", "[getServerStatus_test]") {
resetDB();
setOptions(true, false, true);
initAll(false, true, init_SEK);
initAll(false, true);
HttpClient client("http://localhost:1029");
StubClient c(client, JSONRPC_CLIENT_V2);
REQUIRE(c.getServerStatus()["status"] == 0);
......@@ -910,7 +912,7 @@ TEST_CASE("ManySimultaneousThreads", "[many_threads_test]") {
resetDB();
setOptions(true, false, true);
initAll(false, true, init_SEK);
initAll(false, true);
vector<thread> threads;
int num_threads = 4;
......@@ -928,7 +930,7 @@ TEST_CASE("ManySimultaneousThreads", "[many_threads_test]") {
TEST_CASE("ecdsa API test", "[ecdsa_api_test]") {
resetDB();
setOptions(true, false, true);
initAll(false, true, init_SEK);
initAll(false, true);
HttpClient client("http://localhost:1029");
......@@ -976,7 +978,7 @@ TEST_CASE("ecdsa API test", "[ecdsa_api_test]") {
TEST_CASE("dkg API test", "[dkg_api_test]") {
resetDB();
setOptions(true, false, true);
initAll(false, true, init_SEK);
initAll(false, true);
HttpClient client("http://localhost:1029");
......@@ -1048,7 +1050,7 @@ TEST_CASE("dkg API test", "[dkg_api_test]") {
TEST_CASE("isPolyExists test", "[is_poly_test]") {
resetDB();
setOptions(true, false, true);
initAll(false, true, init_SEK);
initAll(false, true);
HttpClient client("http://localhost:1029");
......@@ -1076,7 +1078,7 @@ TEST_CASE("AES_DKG test", "[aes_dkg]") {
setOptions(true, false, true);
cerr << "test started" << endl;
initAll(false, true, init_SEK);
initAll(false, true);
HttpClient client("http://localhost:1029");
StubClient c(client, JSONRPC_CLIENT_V2);
cerr << "Client inited" << endl;
......@@ -1201,7 +1203,7 @@ TEST_CASE("AES_DKG test", "[aes_dkg]") {
TEST_CASE("bls_sign_api test", "[bls_sign]") {
resetDB();
setOptions(true, false, true);
initAll(false, true, init_SEK);
initAll(false, true);
HttpClient client("http://localhost:1029");
StubClient c(client, JSONRPC_CLIENT_V2);
......@@ -1233,7 +1235,7 @@ TEST_CASE("bls_sign_api test", "[bls_sign]") {
TEST_CASE("AES encrypt/decrypt", "[AES-encrypt-decrypt]") {
resetDB();
setOptions(true, false, true);
initAll(false, true, init_SEK);
initAll(false, true);
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