Unverified Commit 3b32f8c1 authored by Stan Kladko's avatar Stan Kladko Committed by GitHub

Merge pull request #34 from skalenetwork/enhancement/Rename-data-folder

Enhancement/rename data folder
parents 98bc15d5 cdd84f1d
...@@ -60,7 +60,7 @@ Json::Value SignByHashImpl(const std::string& hash, int status){ ...@@ -60,7 +60,7 @@ Json::Value SignByHashImpl(const std::string& hash, int status){
} }
if (status == 0) { if (status == 0) {
std::string csr_name = "cert/" + hash + ".csr"; std::string csr_name = "sgx_data/cert/" + hash + ".csr";
std::ofstream outfile(csr_name); std::ofstream outfile(csr_name);
outfile << *csr_ptr << std::endl; outfile << *csr_ptr << std::endl;
outfile.close(); outfile.close();
...@@ -69,7 +69,7 @@ Json::Value SignByHashImpl(const std::string& hash, int status){ ...@@ -69,7 +69,7 @@ Json::Value SignByHashImpl(const std::string& hash, int status){
throw RPCException(FILE_NOT_FOUND, "Csr does not exist"); throw RPCException(FILE_NOT_FOUND, "Csr does not exist");
} }
std::string signClientCert = "cd cert && ./create_client_cert " + hash; std::string signClientCert = "cd sgx_data/cert && ./create_client_cert " + hash;
if (system(signClientCert.c_str()) == 0) { if (system(signClientCert.c_str()) == 0) {
spdlog::info("CLIENT CERTIFICATE IS SUCCESSFULLY GENERATED"); spdlog::info("CLIENT CERTIFICATE IS SUCCESSFULLY GENERATED");
......
...@@ -82,8 +82,8 @@ void debug_print(){ ...@@ -82,8 +82,8 @@ void debug_print(){
int init_https_server(bool check_certs) { int init_https_server(bool check_certs) {
std::string rootCAPath = "cert/rootCA.pem"; std::string rootCAPath = std::string(SGXDATA_FOLDER) + "cert_data/rootCA.pem";
std::string keyCAPath = "cert/rootCA.key"; std::string keyCAPath = std::string(SGXDATA_FOLDER) + "cert_data/rootCA.key";
if (access(rootCAPath.c_str(), F_OK) != 0 || access(keyCAPath.c_str(), F_OK) != 0){ if (access(rootCAPath.c_str(), F_OK) != 0 || access(keyCAPath.c_str(), F_OK) != 0){
spdlog::info("YOU DO NOT HAVE ROOT CA CERTIFICATE"); spdlog::info("YOU DO NOT HAVE ROOT CA CERTIFICATE");
...@@ -100,8 +100,8 @@ int init_https_server(bool check_certs) { ...@@ -100,8 +100,8 @@ int init_https_server(bool check_certs) {
} }
} }
std::string certPath = "cert/SGXServerCert.crt"; std::string certPath = std::string(SGXDATA_FOLDER) + "cert_data/SGXServerCert.crt";
std::string keyPath = "cert/SGXServerCert.key"; std::string keyPath = std::string(SGXDATA_FOLDER) + "cert_data/SGXServerCert.key";
if (access(certPath.c_str(), F_OK) != 0 || access(certPath.c_str(), F_OK) != 0){ if (access(certPath.c_str(), F_OK) != 0 || access(certPath.c_str(), F_OK) != 0){
spdlog::info("YOU DO NOT HAVE SERVER CERTIFICATE"); spdlog::info("YOU DO NOT HAVE SERVER CERTIFICATE");
......
...@@ -64,32 +64,33 @@ void init_daemon() { ...@@ -64,32 +64,33 @@ void init_daemon() {
libff::init_alt_bn128_params(); libff::init_alt_bn128_params();
std::string sgx_data_folder = SGXDATA_FOLDER;
struct stat info; struct stat info;
if (stat("SGXData", &info) !=0 ){ if (stat(sgx_data_folder.c_str(), &info) !=0 ){
spdlog::info("going to create SGXData folder"); spdlog::info("going to create sgx_data folder");
if (system("mkdir SGXData") == 0){ std::string make_sgx_data_folder = "mkdir " + sgx_data_folder;
spdlog::info("SGXData folder was created"); if (system(make_sgx_data_folder.c_str()) == 0){
spdlog::info("sgx_data folder was created");
} }
else{ else{
spdlog::info("creating SGXData folder failed"); spdlog::info("creating sgx_data folder failed");
exit(-1); exit(-1);
} }
} }
static std::string dbName("./" WALLETDB_NAME); static std::string dbName = sgx_data_folder + WALLETDB_NAME;
levelDb = new LevelDB(dbName); levelDb = new LevelDB(dbName);
static std::string csr_dbname = "SGXData/CSR_DB"; static std::string csr_dbname = sgx_data_folder + "CSR_DB";
csrDb = new LevelDB(csr_dbname); csrDb = new LevelDB(csr_dbname);
static std::string csr_status_dbname = "SGXData/CSR_STATUS_DB"; static std::string csr_status_dbname = sgx_data_folder + "CSR_STATUS_DB";
csrStatusDb = new LevelDB(csr_status_dbname); csrStatusDb = new LevelDB(csr_status_dbname);
std::shared_ptr<std::string> encr_SEK_ptr = levelDb->readString("SEK"); std::shared_ptr<std::string> encr_SEK_ptr = levelDb->readString("SEK");
if (encr_SEK_ptr == nullptr){ if (encr_SEK_ptr == nullptr){
spdlog::info("SEK was not created yet"); spdlog::info("SEK was not created yet");
} }
} }
......
...@@ -5,16 +5,16 @@ ...@@ -5,16 +5,16 @@
[ CA_CLIENT ] [ CA_CLIENT ]
dir = . # Каталог для служебных файлов dir = . # Каталог для служебных файлов
certs = $dir/certs # Каталог для сертификатов certs = $dir/certs # Каталог для сертификатов
new_certs_dir = $dir/new_certs # Каталог для новых сертификатов new_certs_dir = ../sgx_data/cert_data/new_certs # Каталог для новых сертификатов
database = $dir/index.txt # Файл с базой данных database = ../sgx_data/cert_data/index.txt # Файл с базой данных
# подписанных сертификатов # подписанных сертификатов
serial = $dir/serial # Файл содержащий серийный номер serial = ../sgx_data/cert_data/serial # Файл содержащий серийный номер
RANDFILE = $dir/.rnd RANDFILE = $dir/.rnd
# сертификата # сертификата
# (в шестнадцатиричном формате) # (в шестнадцатиричном формате)
certificate = ./rootCA.pem # Файл сертификата CA certificate = ../sgx_data/cert_data/rootCA.pem # Файл сертификата CA
private_key = ./rootCA.key # Файл закрытого ключа CA private_key = ../sgx_data/cert_data/rootCA.key # Файл закрытого ключа CA
default_days = 3650 # Срок действия подписываемого default_days = 3650 # Срок действия подписываемого
# сертификата # сертификата
......
#!/bin/bash #!/bin/bash
cd ../sgx_data
mkdir cert_data
cd cert_data
mkdir new_certs
touch index.txt
touch index.txt.attr
echo "01" > serial
# Generate root CA key # Generate root CA key
openssl genrsa -out rootCA.key 2048 openssl genrsa -out rootCA.key 2048
# Create an X.509 cert from the CA key # Create an X.509 cert from the CA key
openssl req -x509 -sha256 -nodes -days 1024 -newkey rsa:2048 -key rootCA.key -out rootCA.pem -subj "/CN=SGXCACertificate" openssl req -x509 -sha256 -nodes -days 1024 -newkey rsa:2048 -key rootCA.key -out rootCA.pem -subj "/CN=SGXCACertificate"
mkdir new_certs
touch index.txt
touch index.txt.attr
echo "01" > serial
#!/bin/bash #!/bin/bash
# Generate server key # Generate server key
openssl genrsa -out "SGXServerCert.key" 2048 openssl genrsa -out ../sgx_data/cert_data/SGXServerCert.key 2048
# Create server certificate request # Create server certificate request
#openssl req -new -key "SGXServer.key" -out "SGXServer.csr" -subj "/CN=SGXCACertificate" #openssl req -new -key "SGXServer.key" -out "SGXServer.csr" -subj "/CN=SGXCACertificate"
openssl req -new -sha256 -nodes -out "SGXServerCert.csr" -newkey rsa:2048 -keyout "SGXServerCert.key" -subj /CN=SGXServer openssl req -new -sha256 -nodes -out ../sgx_data/cert_data/SGXServerCert.csr -newkey rsa:2048 -keyout ../sgx_data/cert_data/SGXServerCert.key -subj /CN=SGXServer
# Sign and generate the user certificate from the # Sign and generate the user certificate from the
#openssl x509 -req -in "SGXServer.csr" -CA rootCA.crt -CAkey rootCA.key -CAcreateserial -out "SGXServerCertificate.crt" -days 3650 #openssl x509 -req -in "SGXServer.csr" -CA rootCA.crt -CAkey rootCA.key -CAcreateserial -out "SGXServerCertificate.crt" -days 3650
yes | openssl ca -config ca.config -in "SGXServerCert.csr" -out "SGXServerCert.crt" yes | openssl ca -config ca.config -in ../sgx_data/cert_data/SGXServerCert.csr -out ../sgx_data/cert_data/SGXServerCert.crt
...@@ -53,7 +53,8 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ...@@ -53,7 +53,8 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "../sgxwallet_common.h" #include "../sgxwallet_common.h"
uint8_t Decrypted_dkg_poly[DKG_BUFER_LENGTH] ; uint8_t Decrypted_dkg_poly[DKG_BUFER_LENGTH];
uint8_t SEK[32];
void *(*gmp_realloc_func)(void *, size_t, size_t); void *(*gmp_realloc_func)(void *, size_t, size_t);
...@@ -587,7 +588,6 @@ void get_public_shares(int *err_status, char* err_string, uint8_t* encrypted_dkg ...@@ -587,7 +588,6 @@ void get_public_shares(int *err_status, char* err_string, uint8_t* encrypted_dkg
} }
void set_encrypted_dkg_poly(int *err_status, char *err_string, uint8_t* encrypted_poly){ void set_encrypted_dkg_poly(int *err_status, char *err_string, uint8_t* encrypted_poly){
uint32_t decr_len; uint32_t decr_len;
...@@ -911,7 +911,7 @@ void generate_SEK(int *err_status, char *err_string, ...@@ -911,7 +911,7 @@ void generate_SEK(int *err_status, char *err_string,
*enc_len = sealedLen; *enc_len = sealedLen;
free(rand_char); free(rand_char);
} }
......
...@@ -92,9 +92,9 @@ extern int is_sgx_https; ...@@ -92,9 +92,9 @@ extern int is_sgx_https;
#define BASE_PORT 1026 #define BASE_PORT 1026
#define WALLETDB_NAME "SGXData/sgxwallet.db"//"test_sgxwallet.db"// #define WALLETDB_NAME "sgxwallet.db"//"test_sgxwallet.db"//
#define ENCLAVE_NAME "secure_enclave.signed.so" #define ENCLAVE_NAME "secure_enclave.signed.so"
#define SGXDATA_FOLDER "sgx_data/"
......
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