SKALE-4262 add -e flag

parent 72bb58de
...@@ -160,7 +160,7 @@ uint64_t initEnclave() { ...@@ -160,7 +160,7 @@ uint64_t initEnclave() {
} }
void initAll(uint32_t _logLevel, bool _checkCert, void initAll(uint32_t _logLevel, bool _checkCert,
bool _checkZMQSig, bool _autoSign, bool _generateTestKeys) { bool _checkZMQSig, bool _autoSign, bool _generateTestKeys, bool _checkKeyOwnership) {
static atomic<bool> sgxServerInited(false); static atomic<bool> sgxServerInited(false);
static mutex initMutex; static mutex initMutex;
...@@ -209,7 +209,7 @@ void initAll(uint32_t _logLevel, bool _checkCert, ...@@ -209,7 +209,7 @@ void initAll(uint32_t _logLevel, bool _checkCert,
SGXRegistrationServer::initRegistrationServer(_autoSign); SGXRegistrationServer::initRegistrationServer(_autoSign);
CSRManagerServer::initCSRManagerServer(); CSRManagerServer::initCSRManagerServer();
SGXInfoServer::initInfoServer(_logLevel, _checkCert, _autoSign, _generateTestKeys); SGXInfoServer::initInfoServer(_logLevel, _checkCert, _autoSign, _generateTestKeys);
ZMQServer::initZMQServer(_checkZMQSig, useHTTPS); ZMQServer::initZMQServer(_checkZMQSig, _checkKeyOwnership);
sgxServerInited = true; sgxServerInited = true;
} catch (SGXException &_e) { } catch (SGXException &_e) {
......
...@@ -32,7 +32,7 @@ ...@@ -32,7 +32,7 @@
#define EXTERNC #define EXTERNC
#endif #endif
EXTERNC void initAll(uint32_t _logLevel, bool _checkCert, bool _checkZMQSig, bool _autoSign, bool _generateTestKeys); EXTERNC void initAll(uint32_t _logLevel, bool _checkCert, bool _checkZMQSig, bool _autoSign, bool _generateTestKeys, bool _checkKeyOwnership);
void exitAll(); void exitAll();
......
...@@ -47,6 +47,6 @@ sleep 5 ...@@ -47,6 +47,6 @@ sleep 5
./testw.py ./testw.py
else else
sleep 3 sleep 3
./sgxwallet $1 $2 $3 $4 $5 ./sgxwallet $1 $2 $3 $4 $5 $6
fi fi
...@@ -21,7 +21,7 @@ services: ...@@ -21,7 +21,7 @@ services:
options: options:
max-size: "10m" max-size: "10m"
max-file: "4" max-file: "4"
command: -s -y -d command: -s -y -d -e
healthcheck: healthcheck:
test: ["CMD", "ls", "/dev/isgx", "/dev/mei0"] test: ["CMD", "ls", "/dev/isgx", "/dev/mei0"]
...@@ -18,4 +18,4 @@ services: ...@@ -18,4 +18,4 @@ services:
options: options:
max-size: "10m" max-size: "10m"
max-file: "4" max-file: "4"
command: -s -y command: -s -y -e
...@@ -55,6 +55,7 @@ void SGXWallet::printUsage() { ...@@ -55,6 +55,7 @@ void SGXWallet::printUsage() {
cerr << " -n Use http instead of https. Default is to use https with a selg-signed server cert. Insecure! \n"; cerr << " -n Use http instead of https. Default is to use https with a selg-signed server cert. Insecure! \n";
cerr << " -c Disable client authentication using certificates. Insecure!\n"; cerr << " -c Disable client authentication using certificates. Insecure!\n";
cerr << " -s Sign client certificates without human confirmation. Insecure! \n"; cerr << " -s Sign client certificates without human confirmation. Insecure! \n";
cerr << " -e Only owner of the key can access it.\n";
} }
...@@ -100,6 +101,7 @@ int main(int argc, char *argv[]) { ...@@ -100,6 +101,7 @@ int main(int argc, char *argv[]) {
bool checkClientCertOption = true; bool checkClientCertOption = true;
bool autoSignClientCertOption = false; bool autoSignClientCertOption = false;
bool generateTestKeys = false; bool generateTestKeys = false;
bool checkKeyOwnership = true;
std::signal(SIGABRT, SGXWallet::signalHandler); std::signal(SIGABRT, SGXWallet::signalHandler);
...@@ -110,7 +112,7 @@ int main(int argc, char *argv[]) { ...@@ -110,7 +112,7 @@ int main(int argc, char *argv[]) {
exit(-21); exit(-21);
} }
while ((opt = getopt(argc, argv, "cshd0abyvVnT")) != -1) { while ((opt = getopt(argc, argv, "cshd0abyvVneT")) != -1) {
switch (opt) { switch (opt) {
case 'h': case 'h':
SGXWallet::printUsage(); SGXWallet::printUsage();
...@@ -136,6 +138,10 @@ int main(int argc, char *argv[]) { ...@@ -136,6 +138,10 @@ int main(int argc, char *argv[]) {
break; break;
case 'n': case 'n':
useHTTPSOption = false; useHTTPSOption = false;
checkKeyOwnership = false;
break;
case 'e':
checkKeyOwnership = true;
break; break;
case 'a': case 'a':
enterBackupKeyOption = false; enterBackupKeyOption = false;
...@@ -179,7 +185,7 @@ int main(int argc, char *argv[]) { ...@@ -179,7 +185,7 @@ int main(int argc, char *argv[]) {
} }
cerr << "Calling initAll ..." << endl; cerr << "Calling initAll ..." << endl;
initAll(enclaveLogLevel, checkClientCertOption, checkClientCertOption, autoSignClientCertOption, generateTestKeys); initAll(enclaveLogLevel, checkClientCertOption, checkClientCertOption, autoSignClientCertOption, generateTestKeys, checkKeyOwnership);
cerr << "Completed initAll." << endl; cerr << "Completed initAll." << endl;
//check if test keys already exist //check if test keys already exist
......
...@@ -73,7 +73,7 @@ public: ...@@ -73,7 +73,7 @@ public:
TestFixture() { TestFixture() {
TestUtils::resetDB(); TestUtils::resetDB();
setOptions(L_INFO, false, true); setOptions(L_INFO, false, true);
initAll(L_INFO, false, false, true, false); initAll(L_INFO, false, false, true, false, false);
} }
~TestFixture() { ~TestFixture() {
...@@ -87,7 +87,7 @@ public: ...@@ -87,7 +87,7 @@ public:
TestFixtureHTTPS() { TestFixtureHTTPS() {
TestUtils::resetDB(); TestUtils::resetDB();
setOptions(L_INFO, true, true); setOptions(L_INFO, true, true);
initAll(L_INFO, false, true, true, false); initAll(L_INFO, false, true, true, false, true);
} }
~TestFixtureHTTPS() { ~TestFixtureHTTPS() {
...@@ -101,7 +101,7 @@ public: ...@@ -101,7 +101,7 @@ public:
TestFixtureZMQSign() { TestFixtureZMQSign() {
TestUtils::resetDB(); TestUtils::resetDB();
setOptions(L_INFO, false, true); setOptions(L_INFO, false, true);
initAll(L_INFO, false, true, true, false); initAll(L_INFO, false, true, true, false, false);
} }
~TestFixtureZMQSign() { ~TestFixtureZMQSign() {
...@@ -114,7 +114,7 @@ class TestFixtureNoResetFromBackup { ...@@ -114,7 +114,7 @@ class TestFixtureNoResetFromBackup {
public: public:
TestFixtureNoResetFromBackup() { TestFixtureNoResetFromBackup() {
setFullOptions(L_INFO, false, true, true); setFullOptions(L_INFO, false, true, true);
initAll(L_INFO, false, false, true, false); initAll(L_INFO, false, false, true, false, false);
} }
~TestFixtureNoResetFromBackup() { ~TestFixtureNoResetFromBackup() {
...@@ -128,7 +128,7 @@ class TestFixtureNoReset { ...@@ -128,7 +128,7 @@ class TestFixtureNoReset {
public: public:
TestFixtureNoReset() { TestFixtureNoReset() {
setOptions(L_INFO, false, true); setOptions(L_INFO, false, true);
initAll(L_INFO, false, false, true, false); initAll(L_INFO, false, false, true, false, false);
} }
~TestFixtureNoReset() { ~TestFixtureNoReset() {
......
...@@ -155,7 +155,7 @@ Json::Value createBLSPrivateKeyReqMessage::process() { ...@@ -155,7 +155,7 @@ Json::Value createBLSPrivateKeyReqMessage::process() {
auto secretShare = getStringRapid("secretShare"); auto secretShare = getStringRapid("secretShare");
auto t = getInt64Rapid("t"); auto t = getInt64Rapid("t");
auto n = getInt64Rapid("n"); auto n = getInt64Rapid("n");
if (checkKeyOwnership && !isKeyByOwner(ethKeyName, getStringRapid("cert")) || !isKeyByOwner(polyName, getStringRapid("cert"))) { if (checkKeyOwnership && (!isKeyByOwner(ethKeyName, getStringRapid("cert")) || !isKeyByOwner(polyName, getStringRapid("cert")))) {
throw std::invalid_argument("Only owner of the key can access it"); throw std::invalid_argument("Only owner of the key can access it");
} }
auto result = SGXWalletServer::createBLSPrivateKeyV2Impl(blsKeyName, ethKeyName, polyName, secretShare, t, n); auto result = SGXWalletServer::createBLSPrivateKeyV2Impl(blsKeyName, ethKeyName, polyName, secretShare, t, n);
......
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