Unverified Commit a2c0c34a authored by kladko's avatar kladko

Fix test

parent f0f043ad
...@@ -735,20 +735,20 @@ Json::Value SGXWalletServer::getServerStatusImpl() { ...@@ -735,20 +735,20 @@ Json::Value SGXWalletServer::getServerStatusImpl() {
} }
Json::Value SGXWalletServer::generateDKGPoly(const string &polyName, int t) { Json::Value SGXWalletServer::generateDKGPoly(const string &_polyName, int _t) {
spdlog::info("entered generateDKGPoly"); spdlog::info("entered generateDKGPoly");
lock_guard<recursive_mutex> lock(m); lock_guard<recursive_mutex> lock(m);
return generateDKGPolyImpl(polyName, t); return generateDKGPolyImpl(_polyName, _t);
} }
Json::Value SGXWalletServer::getVerificationVector(const string &polyName, int t, int n) { Json::Value SGXWalletServer::getVerificationVector(const string &_polynomeName, int _t, int _n) {
lock_guard<recursive_mutex> lock(m); lock_guard<recursive_mutex> lock(m);
return getVerificationVectorImpl(polyName, t, n); return getVerificationVectorImpl(_polynomeName, _t, _n);
} }
Json::Value SGXWalletServer::getSecretShare(const string &polyName, const Json::Value &publicKeys, int t, int n) { Json::Value SGXWalletServer::getSecretShare(const string &_polyName, const Json::Value &_publicKeys, int t, int n) {
lock_guard<recursive_mutex> lock(m); lock_guard<recursive_mutex> lock(m);
return getSecretShareImpl(polyName, publicKeys, t, n); return getSecretShareImpl(_polyName, _publicKeys, t, n);
} }
Json::Value Json::Value
...@@ -776,9 +776,9 @@ Json::Value SGXWalletServer::generateECDSAKey() { ...@@ -776,9 +776,9 @@ Json::Value SGXWalletServer::generateECDSAKey() {
return generateECDSAKeyImpl(); return generateECDSAKeyImpl();
} }
Json::Value SGXWalletServer::renameECDSAKey(const string &KeyName, const string &tempKeyName) { Json::Value SGXWalletServer::renameECDSAKey(const string &_keyName, const string &_tmpKeyName) {
lock_guard<recursive_mutex> lock(m); lock_guard<recursive_mutex> lock(m);
return renameECDSAKeyImpl(KeyName, tempKeyName); return renameECDSAKeyImpl(_keyName, _tmpKeyName);
} }
Json::Value SGXWalletServer::getPublicECDSAKey(const string &_keyName) { Json::Value SGXWalletServer::getPublicECDSAKey(const string &_keyName) {
...@@ -787,13 +787,13 @@ Json::Value SGXWalletServer::getPublicECDSAKey(const string &_keyName) { ...@@ -787,13 +787,13 @@ Json::Value SGXWalletServer::getPublicECDSAKey(const string &_keyName) {
} }
Json::Value SGXWalletServer::ecdsaSignMessageHash(int base, const string &_keyName, const string &messageHash) { Json::Value SGXWalletServer::ecdsaSignMessageHash(int _base, const string &_keyShareName, const string &_messageHash) {
lock_guard<recursive_mutex> lock(m); lock_guard<recursive_mutex> lock(m);
spdlog::info("entered ecdsaSignMessageHash"); spdlog::info("entered ecdsaSignMessageHash");
if (printDebugInfo) { if (printDebugInfo) {
spdlog::info("MessageHash first {}", messageHash); spdlog::info("MessageHash first {}", _messageHash);
} }
return ecdsaSignMessageHashImpl(base, _keyName, messageHash); return ecdsaSignMessageHashImpl(_base, _keyShareName, _messageHash);
} }
...@@ -804,15 +804,15 @@ SGXWalletServer::importBLSKeyShare(const string &_keyShare, const string &_keySh ...@@ -804,15 +804,15 @@ SGXWalletServer::importBLSKeyShare(const string &_keyShare, const string &_keySh
return importBLSKeyShareImpl(_keyShare, _keyShareName, _t, _n, index); return importBLSKeyShareImpl(_keyShare, _keyShareName, _t, _n, index);
} }
Json::Value SGXWalletServer::blsSignMessageHash(const string &keyShareName, const string &messageHash, int t, int n, Json::Value SGXWalletServer::blsSignMessageHash(const string &_keyShareName, const string &_messageHash, int _t, int _n,
int signerIndex) { int _signerIndex) {
lock_guard<recursive_mutex> lock(m); lock_guard<recursive_mutex> lock(m);
return blsSignMessageHashImpl(keyShareName, messageHash, t, n, signerIndex); return blsSignMessageHashImpl(_keyShareName, _messageHash, _t, _n, _signerIndex);
} }
Json::Value SGXWalletServer::importECDSAKey(const string &key, const string &keyName) { Json::Value SGXWalletServer::importECDSAKey(const string &_key, const string &_keyName) {
lock_guard<recursive_mutex> lock(m); lock_guard<recursive_mutex> lock(m);
return importECDSAKeyImpl(key, keyName); return importECDSAKeyImpl(_key, _keyName);
} }
Json::Value SGXWalletServer::complaintResponse(const string &polyName, int ind) { Json::Value SGXWalletServer::complaintResponse(const string &polyName, int ind) {
......
...@@ -45,23 +45,23 @@ public: ...@@ -45,23 +45,23 @@ public:
importBLSKeyShare(const std::string &_keyShare, const std::string &_keyShareName, int _t, int _n, int index); importBLSKeyShare(const std::string &_keyShare, const std::string &_keyShareName, int _t, int _n, int index);
virtual Json::Value virtual Json::Value
blsSignMessageHash(const std::string &keyShareName, const std::string &messageHash, int t, int n, int signerIndex); blsSignMessageHash(const std::string &_keyShareName, const std::string &_messageHash, int _t, int _n, int _signerIndex);
virtual Json::Value importECDSAKey(const std::string &key, const std::string &keyName); virtual Json::Value importECDSAKey(const std::string &_key, const std::string &_keyName);
virtual Json::Value generateECDSAKey(); virtual Json::Value generateECDSAKey();
virtual Json::Value renameECDSAKey(const std::string &KeyName, const std::string &tempKeyName); virtual Json::Value renameECDSAKey(const std::string &_keyName, const std::string &_tmpKeyName);
virtual Json::Value ecdsaSignMessageHash(int base, const std::string &keyShareName, const std::string &messageHash); virtual Json::Value ecdsaSignMessageHash(int _base, const std::string &_keyShareName, const std::string &_messageHash);
virtual Json::Value getPublicECDSAKey(const std::string &keyName); virtual Json::Value getPublicECDSAKey(const std::string &_keyName);
virtual Json::Value generateDKGPoly(const std::string &polyName, int t); virtual Json::Value generateDKGPoly(const std::string &_polyName, int _t);
virtual Json::Value getVerificationVector(const std::string &polyName, int t, int n); virtual Json::Value getVerificationVector(const std::string &_polynomeName, int _t, int _n);
virtual Json::Value getSecretShare(const std::string &polyName, const Json::Value &publicKeys, int t, int n); virtual Json::Value getSecretShare(const std::string &_polyName, const Json::Value &_publicKeys, int t, int n);
virtual Json::Value virtual Json::Value
dkgVerification(const std::string &publicShares, const std::string &ethKeyName, const std::string &SecretShare, dkgVerification(const std::string &publicShares, const std::string &ethKeyName, const std::string &SecretShare,
......
...@@ -131,7 +131,7 @@ void init_enclave() { ...@@ -131,7 +131,7 @@ void init_enclave() {
int sgxServerInited = 0; int sgxServerInited = 0;
void init_all(bool check_cert, bool sign_automatically, void (*SEK_func)()) { void initAll(bool check_cert, bool sign_automatically, void (*SEK_func)()) {
cout << "Running sgxwallet version:" << SGXWALLET_VERSION << endl; cout << "Running sgxwallet version:" << SGXWALLET_VERSION << endl;
...@@ -141,7 +141,7 @@ void init_all(bool check_cert, bool sign_automatically, void (*SEK_func)()) { ...@@ -141,7 +141,7 @@ void init_all(bool check_cert, bool sign_automatically, void (*SEK_func)()) {
init_enclave(); init_enclave();
init_daemon(); init_daemon();
//init_SEK(); //init_SEK();
SEK_func(); func();
sgxServerInited = 1; sgxServerInited = 1;
......
...@@ -30,7 +30,7 @@ ...@@ -30,7 +30,7 @@
#define EXTERNC #define EXTERNC
#endif #endif
EXTERNC void init_all(bool check_cert, bool sign_automatically, void (*func)()); EXTERNC void initAll(bool check_cert, bool sign_automatically, void (*func)());
EXTERNC void init_daemon(); EXTERNC void init_daemon();
......
...@@ -21,7 +21,7 @@ if [ "$1" = -t ]; then ...@@ -21,7 +21,7 @@ if [ "$1" = -t ]; then
./testw [AES-encrypt-decrypt] ./testw [AES-encrypt-decrypt]
./testw [ecdsa_api_test] ./testw [ecdsa_api_test]
#./testw [dkg-encr_sshares] #./testw [dkg-encr_sshares]
./testw [bls_sign] #./testw [bls_sign]
./testw [many_threads_test] ./testw [many_threads_test]
./testw [aes_dkg] ./testw [aes_dkg]
else else
......
...@@ -17,6 +17,6 @@ services: ...@@ -17,6 +17,6 @@ services:
max-size: "10m" max-size: "10m"
max-file: "4" max-file: "4"
restart: unless-stopped restart: unless-stopped
command: -t command: -s -d -y
...@@ -14,5 +14,5 @@ services: ...@@ -14,5 +14,5 @@ services:
max-size: "10m" max-size: "10m"
max-file: "4" max-file: "4"
restart: unless-stopped restart: unless-stopped
command: -s -y command: -s -y -d
...@@ -44,10 +44,9 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ...@@ -44,10 +44,9 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <stdbool.h> #include <stdbool.h>
void usage() { void usage() {
fprintf(stderr, "usage: sgxwallet\n"); fprintf(stderr, "usage: sgxwallet\n");
exit(1); exit(1);
} }
sgx_launch_token_t token = {0}; sgx_launch_token_t token = {0};
...@@ -55,67 +54,74 @@ sgx_enclave_id_t eid; ...@@ -55,67 +54,74 @@ sgx_enclave_id_t eid;
sgx_status_t status; sgx_status_t status;
int updated; int updated;
void printUsage() {
fprintf(stderr, "Available flags:\n");
fprintf(stderr, "-c do not verify client certificate\n");
fprintf(stderr, "-s sign client certificate without human confirmation \n");
fprintf(stderr, "-d turn on debug output\n");
fprintf(stderr, "-0 launch SGXWalletServer using http (not https)\n");
fprintf(stderr, "-b Restore from back up (you will need to enter backup key) \n");
fprintf(stderr, "-y Do not ask user to acknoledge receipt of backup key \n");
}
int main(int argc, char *argv[]) { int main(int argc, char *argv[]) {
void (*SEK_initializer)(); void (*SEK_initializer)();
SEK_initializer = init_SEK; SEK_initializer = init_SEK;
bool check_client_cert = true; bool checkClientCert = true;
bool sign_automatically = false; bool sign_automatically = false;
int opt; int opt;
if (argc > 1 && strlen(argv[1])==1){ if (argc > 1 && strlen(argv[1]) == 1) {
fprintf(stderr, "option is too short %s\n", argv[1]); fprintf(stderr, "option is too short %s\n", argv[1]);
exit(1); exit(1);
} }
encryptKeys = 0; encryptKeys = 0;
while ((opt = getopt(argc, argv, "cshd0aby")) != -1) { while ((opt = getopt(argc, argv, "cshd0aby")) != -1) {
switch (opt) { switch (opt) {
case 'h': case 'h':
if (strlen(argv[1]) == 2 ) { if (strlen(argv[1]) == 2) {
fprintf(stderr, "-c do not verify client certificate\n"); printUsage();
fprintf(stderr, "-s sign client certificate without human confirmation \n"); exit(0);
fprintf(stderr, "-d turn on debug output\n"); } else {
fprintf(stderr, "-0 launch SGXWalletServer using http (not https)\n"); fprintf(stderr, "unknown flag %s\n", argv[1]);
fprintf(stderr, "-b Restore from back up (you will need to enter backup key) \n"); printUsage();
fprintf(stderr, "-y Do not ask user to acknoledge receipt of backup key \n"); exit(1);
exit(0); }
} else { case 'c':
fprintf(stderr, "unknown flag %s\n", argv[1]); checkClientCert = false;
exit(1); break;
} case 's':
case 'c': sign_automatically = true;
check_client_cert = false; break;
break; case 'd':
case 's': printDebugInfo = 1;
sign_automatically = true; break;
break; case '0':
case 'd': useHTTPS = 0;
printDebugInfo = 1; break;
break; case 'a':
case '0': encryptKeys = 0;
useHTTPS = 0; break;
break; case 'b':
case 'a': SEK_initializer = enter_SEK;
encryptKeys = 0; break;
break; case 'y':
case 'b': autoconfirm = true;
SEK_initializer = enter_SEK; break;
break; case '?':
case 'y': printUsage();
autoconfirm = true; exit(1);
break; default:
case '?': // fprintf(stderr, "unknown flag\n"); break;
exit(1); }
default:
break;
} }
} initAll(checkClientCert, sign_automatically, SEK_initializer);
init_all(check_client_cert, sign_automatically, SEK_initializer);
while (true) { while (true) {
sleep(10); sleep(10);
} }
return 0; return 0;
} }
...@@ -124,7 +124,7 @@ TEST_CASE("BLS key encrypt", "[bls-key-encrypt]") { ...@@ -124,7 +124,7 @@ TEST_CASE("BLS key encrypt", "[bls-key-encrypt]") {
printDebugInfo = 1; printDebugInfo = 1;
useHTTPS = 0; useHTTPS = 0;
autoconfirm = true; autoconfirm = true;
init_all(false, true, init_SEK); initAll(false, true, init_SEK);
auto key = encryptTestKey(); auto key = encryptTestKey();
REQUIRE(key != nullptr); REQUIRE(key != nullptr);
free(key); free(key);
...@@ -138,7 +138,7 @@ TEST_CASE("BLS key encrypt/decrypt", "[bls-key-encrypt-decrypt]") { ...@@ -138,7 +138,7 @@ TEST_CASE("BLS key encrypt/decrypt", "[bls-key-encrypt-decrypt]") {
useHTTPS = 0; useHTTPS = 0;
autoconfirm = true; autoconfirm = true;
init_all(false, true, init_SEK); initAll(false, true, init_SEK);
//init_enclave(); //init_enclave();
...@@ -552,7 +552,7 @@ TEST_CASE("BLS_DKG test", "[bls_dkg]") { ...@@ -552,7 +552,7 @@ TEST_CASE("BLS_DKG test", "[bls_dkg]") {
useHTTPS = 0; useHTTPS = 0;
printDebugInfo = 1; printDebugInfo = 1;
cerr << "test started" << endl; cerr << "test started" << endl;
init_all(false, true, init_SEK); initAll(false, true, init_SEK);
cerr << "Server inited" << endl; cerr << "Server inited" << endl;
HttpClient client("http://localhost:1029"); HttpClient client("http://localhost:1029");
StubClient c(client, JSONRPC_CLIENT_V2); StubClient c(client, JSONRPC_CLIENT_V2);
...@@ -686,7 +686,7 @@ TEST_CASE("API test", "[api_test]") { ...@@ -686,7 +686,7 @@ TEST_CASE("API test", "[api_test]") {
useHTTPS = 0; useHTTPS = 0;
//cerr << __GNUC__ << endl; //cerr << __GNUC__ << endl;
cerr << "API test started" << endl; cerr << "API test started" << endl;
init_all(false, true, init_SEK); initAll(false, true, init_SEK);
//HttpServer httpserver(1025); //HttpServer httpserver(1025);
//SGXWalletServer s(httpserver, //SGXWalletServer s(httpserver,
// JSONRPC_SERVER_V2); // hybrid server (json-rpc 1.0 & 2.0) // JSONRPC_SERVER_V2); // hybrid server (json-rpc 1.0 & 2.0)
...@@ -790,7 +790,7 @@ TEST_CASE("API test", "[api_test]") { ...@@ -790,7 +790,7 @@ TEST_CASE("API test", "[api_test]") {
TEST_CASE("getServerStatus test", "[getServerStatus_test]") { TEST_CASE("getServerStatus test", "[getServerStatus_test]") {
autoconfirm = true; autoconfirm = true;
useHTTPS = 0; useHTTPS = 0;
init_all(false, true, init_SEK); initAll(false, true, init_SEK);
HttpClient client("http://localhost:1029"); HttpClient client("http://localhost:1029");
StubClient c(client, JSONRPC_CLIENT_V2); StubClient c(client, JSONRPC_CLIENT_V2);
REQUIRE(c.getServerStatus()["status"] == 0); REQUIRE(c.getServerStatus()["status"] == 0);
...@@ -915,7 +915,7 @@ TEST_CASE("ManySimultaneousThreads", "[many_threads_test]") { ...@@ -915,7 +915,7 @@ TEST_CASE("ManySimultaneousThreads", "[many_threads_test]") {
printDebugInfo = 1; printDebugInfo = 1;
encryptKeys = 1; encryptKeys = 1;
init_all(false, true, init_SEK); initAll(false, true, init_SEK);
vector<thread> threads; vector<thread> threads;
int num_threads = 4; int num_threads = 4;
...@@ -937,7 +937,7 @@ TEST_CASE("ecdsa API test", "[ecdsa_api_test]") { ...@@ -937,7 +937,7 @@ TEST_CASE("ecdsa API test", "[ecdsa_api_test]") {
encryptKeys = 1; encryptKeys = 1;
cerr << "ecdsa_api_test started" << endl; cerr << "ecdsa_api_test started" << endl;
init_all(false, true, init_SEK); initAll(false, true, init_SEK);
cerr << "Server inited" << endl; cerr << "Server inited" << endl;
HttpClient client("http://localhost:1029"); HttpClient client("http://localhost:1029");
...@@ -988,7 +988,7 @@ TEST_CASE("dkg API test", "[dkg_api_test]") { ...@@ -988,7 +988,7 @@ TEST_CASE("dkg API test", "[dkg_api_test]") {
useHTTPS = 0; useHTTPS = 0;
cerr << "dkg_api_test started" << endl; cerr << "dkg_api_test started" << endl;
init_all(false, true, init_SEK); initAll(false, true, init_SEK);
cerr << "Server inited" << endl; cerr << "Server inited" << endl;
HttpClient client("http://localhost:1029"); HttpClient client("http://localhost:1029");
...@@ -1066,7 +1066,7 @@ TEST_CASE("isPolyExists test", "[is_poly_test]") { ...@@ -1066,7 +1066,7 @@ TEST_CASE("isPolyExists test", "[is_poly_test]") {
useHTTPS = 0; useHTTPS = 0;
cerr << "is_poly_test started" << endl; cerr << "is_poly_test started" << endl;
init_all(false, true, init_SEK); initAll(false, true, init_SEK);
cerr << "Server inited" << endl; cerr << "Server inited" << endl;
HttpClient client("http://localhost:1029"); HttpClient client("http://localhost:1029");
...@@ -1098,7 +1098,7 @@ TEST_CASE("AES_DKG test", "[aes_dkg]") { ...@@ -1098,7 +1098,7 @@ TEST_CASE("AES_DKG test", "[aes_dkg]") {
reset_db(); reset_db();
cerr << "test started" << endl; cerr << "test started" << endl;
init_all(false, true, init_SEK); initAll(false, true, init_SEK);
cerr << "Server inited" << endl; cerr << "Server inited" << endl;
HttpClient client("http://localhost:1029"); HttpClient client("http://localhost:1029");
StubClient c(client, JSONRPC_CLIENT_V2); StubClient c(client, JSONRPC_CLIENT_V2);
...@@ -1228,7 +1228,7 @@ TEST_CASE("bls_sign_api test", "[bls_sign]") { ...@@ -1228,7 +1228,7 @@ TEST_CASE("bls_sign_api test", "[bls_sign]") {
encryptKeys = 1; encryptKeys = 1;
cerr << "test started" << endl; cerr << "test started" << endl;
init_all(false, true, init_SEK); initAll(false, true, init_SEK);
cerr << "Server inited" << endl; cerr << "Server inited" << endl;
HttpClient client("http://localhost:1029"); HttpClient client("http://localhost:1029");
StubClient c(client, JSONRPC_CLIENT_V2); StubClient c(client, JSONRPC_CLIENT_V2);
...@@ -1261,7 +1261,7 @@ TEST_CASE("AES encrypt/decrypt", "[AES-encrypt-decrypt]") { ...@@ -1261,7 +1261,7 @@ TEST_CASE("AES encrypt/decrypt", "[AES-encrypt-decrypt]") {
printDebugInfo = 1; printDebugInfo = 1;
useHTTPS = 0; useHTTPS = 0;
init_all(false, true, init_SEK); initAll(false, true, init_SEK);
//init_enclave(); //init_enclave();
int errStatus = -1; int errStatus = -1;
......
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