Unverified Commit 1a0d5457 authored by svetaro's avatar svetaro

SKALE-2003 Add changed files to git

parent 03c6d6dd
...@@ -26,7 +26,6 @@ ...@@ -26,7 +26,6 @@
#include "sgxwallet.h" #include "sgxwallet.h"
#include <iostream> #include <iostream>
#include <memory>
#include <memory> #include <memory>
#include "SGXWalletServer.hpp" #include "SGXWalletServer.hpp"
#include "RPCException.h" #include "RPCException.h"
......
...@@ -67,7 +67,7 @@ COMMON_SRC = sgx_stub.c sgx_detect_linux.c create_enclave.c oc_alloc.c ...@@ -67,7 +67,7 @@ COMMON_SRC = sgx_stub.c sgx_detect_linux.c create_enclave.c oc_alloc.c
COMMON_ENCLAVE_SRC = secure_enclave_u.c secure_enclave_u.h COMMON_ENCLAVE_SRC = secure_enclave_u.c secure_enclave_u.h
sgxwallet_SOURCES = sgxwallet.c SGXWalletServer.cpp SGXRegistrationServer.cpp CSRManagerServer.cpp RPCException.cpp BLSCrypto.cpp ECDSACrypto.cpp \ sgxwallet_SOURCES = sgxwallet.c SGXWalletServer.cpp SGXRegistrationServer.cpp CSRManagerServer.cpp RPCException.cpp BLSCrypto.cpp ECDSACrypto.cpp \
DKGCrypto.cpp ServerInit.cpp BLSPrivateKeyShareSGX.cpp LevelDB.cpp ServerDataChecker.cpp $(COMMON_SRC) DKGCrypto.cpp ServerInit.cpp BLSPrivateKeyShareSGX.cpp LevelDB.cpp ServerDataChecker.cpp SEKManager.cpp $(COMMON_SRC)
nodist_sgxwallet_SOURCES = $(COMMON_ENCLAVE_SRC) nodist_sgxwallet_SOURCES = $(COMMON_ENCLAVE_SRC)
...@@ -102,7 +102,7 @@ sgxwallet_LDADD=-l$(SGX_URTS_LIB) -LlibBLS/deps/deps_inst/x86_or_x64/lib -Llevel ...@@ -102,7 +102,7 @@ sgxwallet_LDADD=-l$(SGX_URTS_LIB) -LlibBLS/deps/deps_inst/x86_or_x64/lib -Llevel
testw_SOURCES=testw.cpp stubclient.cpp SGXWalletServer.cpp RPCException.cpp BLSCrypto.cpp ServerInit.cpp LevelDB.cpp \ testw_SOURCES=testw.cpp stubclient.cpp SGXWalletServer.cpp RPCException.cpp BLSCrypto.cpp ServerInit.cpp LevelDB.cpp \
DKGCrypto.cpp BLSPrivateKeyShareSGX.cpp ECDSACrypto.cpp ServerDataChecker.cpp SGXRegistrationServer.cpp CSRManagerServer.cpp $(COMMON_SRC) DKGCrypto.cpp BLSPrivateKeyShareSGX.cpp ECDSACrypto.cpp ServerDataChecker.cpp SEKManager.cpp SGXRegistrationServer.cpp CSRManagerServer.cpp $(COMMON_SRC)
nodist_testw_SOURCES=${nodist_sgxwallet_SOURCES} nodist_testw_SOURCES=${nodist_sgxwallet_SOURCES}
EXTRA_testw_DEPENDENCIES=${EXTRA_sgxwallet_DEPENDENCIES} EXTRA_testw_DEPENDENCIES=${EXTRA_sgxwallet_DEPENDENCIES}
testw_LDADD= ${sgxwallet_LDADD} testw_LDADD= ${sgxwallet_LDADD}
......
...@@ -52,6 +52,8 @@ ...@@ -52,6 +52,8 @@
#include "BLSCrypto.h" #include "BLSCrypto.h"
#include "ServerInit.h" #include "ServerInit.h"
#include "SEKManager.h"
#include <iostream> #include <iostream>
#include "spdlog/spdlog.h" #include "spdlog/spdlog.h"
...@@ -88,6 +90,7 @@ void init_daemon() { ...@@ -88,6 +90,7 @@ void init_daemon() {
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");
generate_SEK();
} }
} }
......
...@@ -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);
...@@ -900,9 +901,12 @@ void generate_SEK(int *err_status, char *err_string, ...@@ -900,9 +901,12 @@ void generate_SEK(int *err_status, char *err_string,
unsigned char* rand_char = (unsigned char*)malloc(16); unsigned char* rand_char = (unsigned char*)malloc(16);
sgx_read_rand( rand_char, 16); sgx_read_rand( rand_char, 16);
carray2Hex(rand_char, 16, SEK);
uint32_t sealedLen = sgx_calc_sealed_data_size(0, 32); uint32_t sealedLen = sgx_calc_sealed_data_size(0, 32);
memcpy(err_string, 32, SEK);
sgx_status_t status = sgx_seal_data(0, NULL, 32, (uint8_t *)rand_char, sealedLen,(sgx_sealed_data_t*)encrypted_SEK); sgx_status_t status = sgx_seal_data(0, NULL, 32, (uint8_t *)SEK, sealedLen,(sgx_sealed_data_t*)encrypted_SEK);
if( status != SGX_SUCCESS) { if( status != SGX_SUCCESS) {
snprintf(err_string, BUF_LEN,"seal SEK failed"); snprintf(err_string, BUF_LEN,"seal SEK failed");
*err_status = status; *err_status = status;
...@@ -911,7 +915,7 @@ void generate_SEK(int *err_status, char *err_string, ...@@ -911,7 +915,7 @@ void generate_SEK(int *err_status, char *err_string,
*enc_len = sealedLen; *enc_len = sealedLen;
free(rand_char); free(rand_char);
} }
......
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