SKALE-2941 -s flag

parent eec2b6a5
...@@ -28,7 +28,6 @@ ...@@ -28,7 +28,6 @@
#include "third_party/spdlog/spdlog.h" #include "third_party/spdlog/spdlog.h"
#include "sgxwallet_common.h" #include "sgxwallet_common.h"
#include "common.h" #include "common.h"
#include "sgxwallet.h" #include "sgxwallet.h"
...@@ -76,7 +75,6 @@ void create_test_key() { ...@@ -76,7 +75,6 @@ void create_test_key() {
LevelDB::getLevelDb()->writeDataUnique("TEST_KEY", hexEncrKey.data()); LevelDB::getLevelDb()->writeDataUnique("TEST_KEY", hexEncrKey.data());
} }
void validate_SEK() { void validate_SEK() {
shared_ptr <string> test_key_ptr = LevelDB::getLevelDb()->readString("TEST_KEY"); shared_ptr <string> test_key_ptr = LevelDB::getLevelDb()->readString("TEST_KEY");
...@@ -112,7 +110,6 @@ void validate_SEK() { ...@@ -112,7 +110,6 @@ void validate_SEK() {
} }
} }
shared_ptr <vector<uint8_t>> check_and_set_SEK(const string &SEK) { shared_ptr <vector<uint8_t>> check_and_set_SEK(const string &SEK) {
vector<char> decr_key(BUF_LEN, 0); vector<char> decr_key(BUF_LEN, 0);
...@@ -131,7 +128,6 @@ shared_ptr <vector<uint8_t>> check_and_set_SEK(const string &SEK) { ...@@ -131,7 +128,6 @@ shared_ptr <vector<uint8_t>> check_and_set_SEK(const string &SEK) {
SEK.c_str()); SEK.c_str());
} }
HANDLE_TRUSTED_FUNCTION_ERROR(status, err_status, errMsg.data()); HANDLE_TRUSTED_FUNCTION_ERROR(status, err_status, errMsg.data());
encrypted_SEK->resize(l); encrypted_SEK->resize(l);
...@@ -151,7 +147,6 @@ void gen_SEK() { ...@@ -151,7 +147,6 @@ void gen_SEK() {
spdlog::info("Generating backup key. Will be stored in backup_key.txt ... "); spdlog::info("Generating backup key. Will be stored in backup_key.txt ... ");
sgx_status_t status = SGX_SUCCESS; sgx_status_t status = SGX_SUCCESS;
{ {
...@@ -160,7 +155,6 @@ void gen_SEK() { ...@@ -160,7 +155,6 @@ void gen_SEK() {
HANDLE_TRUSTED_FUNCTION_ERROR(status, err_status, errMsg.data()); HANDLE_TRUSTED_FUNCTION_ERROR(status, err_status, errMsg.data());
if (strnlen(SEK, 33) != 32) { if (strnlen(SEK, 33) != 32) {
throw SGXException(-1, "strnlen(SEK,33) != 32"); throw SGXException(-1, "strnlen(SEK,33) != 32");
} }
...@@ -174,12 +168,10 @@ void gen_SEK() { ...@@ -174,12 +168,10 @@ void gen_SEK() {
sek_file << SEK; sek_file << SEK;
cout << "ATTENTION! YOUR BACKUP KEY HAS BEEN WRITTEN INTO sgx_data/backup_key.txt \n" << cout << "ATTENTION! YOUR BACKUP KEY HAS BEEN WRITTEN INTO sgx_data/backup_key.txt \n" <<
"PLEASE COPY IT TO THE SAFE PLACE AND THEN DELETE THE FILE MANUALLY BY RUNNING THE FOLLOWING COMMAND:\n" << "PLEASE COPY IT TO THE SAFE PLACE AND THEN DELETE THE FILE MANUALLY BY RUNNING THE FOLLOWING COMMAND:\n" <<
"apt-get install secure-delete && srm -vz sgx_data/backup_key.txt" << endl; "apt-get install secure-delete && srm -vz sgx_data/backup_key.txt" << endl;
if (!autoconfirm) { if (!autoconfirm) {
string confirm_str = "I confirm"; string confirm_str = "I confirm";
string buffer; string buffer;
...@@ -191,7 +183,6 @@ void gen_SEK() { ...@@ -191,7 +183,6 @@ void gen_SEK() {
} while (case_insensitive_match(confirm_str, buffer)); } while (case_insensitive_match(confirm_str, buffer));
} }
LevelDB::getLevelDb()->writeDataUnique("SEK", hexEncrKey.data()); LevelDB::getLevelDb()->writeDataUnique("SEK", hexEncrKey.data());
create_test_key(); create_test_key();
...@@ -242,7 +233,6 @@ void enter_SEK() { ...@@ -242,7 +233,6 @@ void enter_SEK() {
throw SGXException(CORRUPT_DATABASE, "Could not find TEST_KEY in database."); throw SGXException(CORRUPT_DATABASE, "Could not find TEST_KEY in database.");
} }
if (!experimental::filesystem::is_regular_file(BACKUP_PATH)) { if (!experimental::filesystem::is_regular_file(BACKUP_PATH)) {
spdlog::error("File does not exist: " BACKUP_PATH); spdlog::error("File does not exist: " BACKUP_PATH);
throw SGXException(FILE_NOT_FOUND, "File does not exist: " BACKUP_PATH); throw SGXException(FILE_NOT_FOUND, "File does not exist: " BACKUP_PATH);
......
...@@ -90,22 +90,18 @@ Json::Value signCertificateImpl(const string &_csr, bool _autoSign = false) { ...@@ -90,22 +90,18 @@ Json::Value signCertificateImpl(const string &_csr, bool _autoSign = false) {
} }
if (_autoSign) { if (_autoSign) {
string genCert = string("cd ") + CERT_DIR + "&& ./" string genCert = string("cd ") + CERT_DIR + "&& ./" + CERT_CREATE_COMMAND + " " + hash ;
+ CERT_CREATE_COMMAND + " " + hash ;
if (system(genCert.c_str()) == 0) { if (system(genCert.c_str()) == 0) {
spdlog::info("Client cert " + hash + " generated"); spdlog::info("Client cert " + hash + " generated");
string db_key = "CSR:HASH:" + hash + "STATUS:";
string status = "0";
LevelDB::getCsrStatusDb()->writeDataUnique(db_key, status);
} else { } else {
spdlog::error("Client cert generation failed: {} ", genCert); spdlog::error("Client cert generation failed: {} ", genCert);
throw SGXException(FAIL_TO_CREATE_CERTIFICATE, "CLIENT CERTIFICATE GENERATION FAILED"); throw SGXException(FAIL_TO_CREATE_CERTIFICATE, "CLIENT CERTIFICATE GENERATION FAILED");
} }
} else {
string db_key = "CSR:HASH:" + hash;
LevelDB::getCsrStatusDb()->writeDataUnique(db_key, _csr);
} }
string db_key = "CSR:HASH:" + hash + "STATUS:";
string status = "0";
LevelDB::getCsrStatusDb()->writeDataUnique(db_key, status);
result["result"] = true; result["result"] = true;
result["hash"] = hash; result["hash"] = hash;
......
...@@ -42,20 +42,16 @@ class SGXRegistrationServer : public AbstractRegServer { ...@@ -42,20 +42,16 @@ class SGXRegistrationServer : public AbstractRegServer {
recursive_mutex m; recursive_mutex m;
bool autoSign; bool autoSign;
static shared_ptr <HttpServer> httpServer; static shared_ptr <HttpServer> httpServer;
static shared_ptr <SGXRegistrationServer> server; static shared_ptr <SGXRegistrationServer> server;
public: public:
static shared_ptr <SGXRegistrationServer> getServer(); static shared_ptr <SGXRegistrationServer> getServer();
SGXRegistrationServer(AbstractServerConnector &connector, serverVersion_t type, bool _autoSign = false); SGXRegistrationServer(AbstractServerConnector &connector, serverVersion_t type, bool _autoSign = false);
virtual Json::Value SignCertificate(const string &csr); virtual Json::Value SignCertificate(const string &csr);
virtual Json::Value GetCertificate(const string &hash); virtual Json::Value GetCertificate(const string &hash);
......
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