SKALE-2002 add backup logic to init proccess

parent 07c553db
...@@ -209,8 +209,7 @@ void enter_SEK(){ ...@@ -209,8 +209,7 @@ void enter_SEK(){
// if (DEBUG_PRINT) // if (DEBUG_PRINT)
// std::cerr << "your key is " << SEK << std::endl; // std::cerr << "your key is " << SEK << std::endl;
status = trustedSetSEK_backup(eid, &err_status, errMsg.data(), encr_SEK.data(), &enc_len, SEK.c_str());
status = trustedSetSEK_backup(eid, &err_status, errMsg.data(), encr_SEK.data(), &enc_len, SEK.c_str() );
if (status != SGX_SUCCESS){ if (status != SGX_SUCCESS){
cerr << "RPCException thrown with status " << status << endl; cerr << "RPCException thrown with status " << status << endl;
throw SGXException(status, errMsg.data()); throw SGXException(status, errMsg.data());
...@@ -226,13 +225,16 @@ void enter_SEK(){ ...@@ -226,13 +225,16 @@ void enter_SEK(){
void initSEK(){ void initSEK(){
std::shared_ptr<std::string> encr_SEK_ptr = LevelDB::getLevelDb()->readString("SEK"); std::shared_ptr<std::string> encr_SEK_ptr = LevelDB::getLevelDb()->readString("SEK");
if (encr_SEK_ptr == nullptr){ if (encryptKeys) {
spdlog::error("SEK was not created yet. Going to create SEK"); enter_SEK();
gen_SEK(); } else {
} if (encr_SEK_ptr == nullptr) {
else{ spdlog::error("SEK was not created yet. Going to create SEK");
trustedSetSEK(encr_SEK_ptr); gen_SEK();
} else {
trustedSetSEK(encr_SEK_ptr);
}
} }
} }
//a002e7ca685d46a32771d16fe2518e58 //a002e7ca685d46a32771d16fe2518e58
\ No newline at end of file
...@@ -118,7 +118,7 @@ int main(int argc, char *argv[]) { ...@@ -118,7 +118,7 @@ int main(int argc, char *argv[]) {
encryptKeysOption = false; encryptKeysOption = false;
break; break;
case 'b': case 'b':
encryptKeysOption = false; encryptKeysOption = true;
break; break;
case 'y': case 'y':
autoconfirmOption = true; autoconfirmOption = true;
...@@ -132,8 +132,6 @@ int main(int argc, char *argv[]) { ...@@ -132,8 +132,6 @@ int main(int argc, char *argv[]) {
setFullOptions(printDebugInfoOption, printTraceInfoOption, useHTTPSOption, autoconfirmOption, encryptKeysOption); setFullOptions(printDebugInfoOption, printTraceInfoOption, useHTTPSOption, autoconfirmOption, encryptKeysOption);
uint32_t enclaveLogLevel = L_INFO; uint32_t enclaveLogLevel = L_INFO;
if (printTraceInfoOption) { if (printTraceInfoOption) {
......
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