Unverified Commit a2c0c34a authored by kladko's avatar kladko

Fix test

parent f0f043ad
......@@ -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");
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);
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);
return getSecretShareImpl(polyName, publicKeys, t, n);
return getSecretShareImpl(_polyName, _publicKeys, t, n);
}
Json::Value
......@@ -776,9 +776,9 @@ Json::Value SGXWalletServer::generateECDSAKey() {
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);
return renameECDSAKeyImpl(KeyName, tempKeyName);
return renameECDSAKeyImpl(_keyName, _tmpKeyName);
}
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);
spdlog::info("entered ecdsaSignMessageHash");
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
return importBLSKeyShareImpl(_keyShare, _keyShareName, _t, _n, index);
}
Json::Value SGXWalletServer::blsSignMessageHash(const string &keyShareName, const string &messageHash, int t, int n,
int signerIndex) {
Json::Value SGXWalletServer::blsSignMessageHash(const string &_keyShareName, const string &_messageHash, int _t, int _n,
int _signerIndex) {
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);
return importECDSAKeyImpl(key, keyName);
return importECDSAKeyImpl(_key, _keyName);
}
Json::Value SGXWalletServer::complaintResponse(const string &polyName, int ind) {
......
......@@ -45,23 +45,23 @@ public:
importBLSKeyShare(const std::string &_keyShare, const std::string &_keyShareName, int _t, int _n, int index);
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 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
dkgVerification(const std::string &publicShares, const std::string &ethKeyName, const std::string &SecretShare,
......
......@@ -131,7 +131,7 @@ void init_enclave() {
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;
......@@ -141,7 +141,7 @@ void init_all(bool check_cert, bool sign_automatically, void (*SEK_func)()) {
init_enclave();
init_daemon();
//init_SEK();
SEK_func();
func();
sgxServerInited = 1;
......
......@@ -30,7 +30,7 @@
#define EXTERNC
#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();
......
......@@ -21,7 +21,7 @@ if [ "$1" = -t ]; then
./testw [AES-encrypt-decrypt]
./testw [ecdsa_api_test]
#./testw [dkg-encr_sshares]
./testw [bls_sign]
#./testw [bls_sign]
./testw [many_threads_test]
./testw [aes_dkg]
else
......
......@@ -17,6 +17,6 @@ services:
max-size: "10m"
max-file: "4"
restart: unless-stopped
command: -t
command: -s -d -y
......@@ -14,5 +14,5 @@ services:
max-size: "10m"
max-file: "4"
restart: unless-stopped
command: -s -y
command: -s -y -d
......@@ -44,10 +44,9 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <stdbool.h>
void usage() {
fprintf(stderr, "usage: sgxwallet\n");
exit(1);
fprintf(stderr, "usage: sgxwallet\n");
exit(1);
}
sgx_launch_token_t token = {0};
......@@ -55,67 +54,74 @@ sgx_enclave_id_t eid;
sgx_status_t status;
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[]) {
void (*SEK_initializer)();
SEK_initializer = init_SEK;
bool check_client_cert = true;
bool sign_automatically = false;
int opt;
if (argc > 1 && strlen(argv[1])==1){
fprintf(stderr, "option is too short %s\n", argv[1]);
exit(1);
}
void (*SEK_initializer)();
SEK_initializer = init_SEK;
bool checkClientCert = true;
bool sign_automatically = false;
int opt;
if (argc > 1 && strlen(argv[1]) == 1) {
fprintf(stderr, "option is too short %s\n", argv[1]);
exit(1);
}
encryptKeys = 0;
while ((opt = getopt(argc, argv, "cshd0aby")) != -1) {
switch (opt) {
case 'h':
if (strlen(argv[1]) == 2 ) {
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");
exit(0);
} else {
fprintf(stderr, "unknown flag %s\n", argv[1]);
exit(1);
}
case 'c':
check_client_cert = false;
break;
case 's':
sign_automatically = true;
break;
case 'd':
printDebugInfo = 1;
break;
case '0':
useHTTPS = 0;
break;
case 'a':
encryptKeys = 0;
break;
case 'b':
SEK_initializer = enter_SEK;
break;
case 'y':
autoconfirm = true;
break;
case '?': // fprintf(stderr, "unknown flag\n");
exit(1);
default:
break;
while ((opt = getopt(argc, argv, "cshd0aby")) != -1) {
switch (opt) {
case 'h':
if (strlen(argv[1]) == 2) {
printUsage();
exit(0);
} else {
fprintf(stderr, "unknown flag %s\n", argv[1]);
printUsage();
exit(1);
}
case 'c':
checkClientCert = false;
break;
case 's':
sign_automatically = true;
break;
case 'd':
printDebugInfo = 1;
break;
case '0':
useHTTPS = 0;
break;
case 'a':
encryptKeys = 0;
break;
case 'b':
SEK_initializer = enter_SEK;
break;
case 'y':
autoconfirm = true;
break;
case '?':
printUsage();
exit(1);
default:
break;
}
}
}
init_all(check_client_cert, sign_automatically, SEK_initializer);
initAll(checkClientCert, sign_automatically, SEK_initializer);
while (true) {
sleep(10);
}
while (true) {
sleep(10);
}
return 0;
return 0;
}
......@@ -124,7 +124,7 @@ TEST_CASE("BLS key encrypt", "[bls-key-encrypt]") {
printDebugInfo = 1;
useHTTPS = 0;
autoconfirm = true;
init_all(false, true, init_SEK);
initAll(false, true, init_SEK);
auto key = encryptTestKey();
REQUIRE(key != nullptr);
free(key);
......@@ -138,7 +138,7 @@ TEST_CASE("BLS key encrypt/decrypt", "[bls-key-encrypt-decrypt]") {
useHTTPS = 0;
autoconfirm = true;
init_all(false, true, init_SEK);
initAll(false, true, init_SEK);
//init_enclave();
......@@ -552,7 +552,7 @@ TEST_CASE("BLS_DKG test", "[bls_dkg]") {
useHTTPS = 0;
printDebugInfo = 1;
cerr << "test started" << endl;
init_all(false, true, init_SEK);
initAll(false, true, init_SEK);
cerr << "Server inited" << endl;
HttpClient client("http://localhost:1029");
StubClient c(client, JSONRPC_CLIENT_V2);
......@@ -686,7 +686,7 @@ TEST_CASE("API test", "[api_test]") {
useHTTPS = 0;
//cerr << __GNUC__ << endl;
cerr << "API test started" << endl;
init_all(false, true, init_SEK);
initAll(false, true, init_SEK);
//HttpServer httpserver(1025);
//SGXWalletServer s(httpserver,
// JSONRPC_SERVER_V2); // hybrid server (json-rpc 1.0 & 2.0)
......@@ -790,7 +790,7 @@ TEST_CASE("API test", "[api_test]") {
TEST_CASE("getServerStatus test", "[getServerStatus_test]") {
autoconfirm = true;
useHTTPS = 0;
init_all(false, true, init_SEK);
initAll(false, true, init_SEK);
HttpClient client("http://localhost:1029");
StubClient c(client, JSONRPC_CLIENT_V2);
REQUIRE(c.getServerStatus()["status"] == 0);
......@@ -915,7 +915,7 @@ TEST_CASE("ManySimultaneousThreads", "[many_threads_test]") {
printDebugInfo = 1;
encryptKeys = 1;
init_all(false, true, init_SEK);
initAll(false, true, init_SEK);
vector<thread> threads;
int num_threads = 4;
......@@ -937,7 +937,7 @@ TEST_CASE("ecdsa API test", "[ecdsa_api_test]") {
encryptKeys = 1;
cerr << "ecdsa_api_test started" << endl;
init_all(false, true, init_SEK);
initAll(false, true, init_SEK);
cerr << "Server inited" << endl;
HttpClient client("http://localhost:1029");
......@@ -988,7 +988,7 @@ TEST_CASE("dkg API test", "[dkg_api_test]") {
useHTTPS = 0;
cerr << "dkg_api_test started" << endl;
init_all(false, true, init_SEK);
initAll(false, true, init_SEK);
cerr << "Server inited" << endl;
HttpClient client("http://localhost:1029");
......@@ -1066,7 +1066,7 @@ TEST_CASE("isPolyExists test", "[is_poly_test]") {
useHTTPS = 0;
cerr << "is_poly_test started" << endl;
init_all(false, true, init_SEK);
initAll(false, true, init_SEK);
cerr << "Server inited" << endl;
HttpClient client("http://localhost:1029");
......@@ -1098,7 +1098,7 @@ TEST_CASE("AES_DKG test", "[aes_dkg]") {
reset_db();
cerr << "test started" << endl;
init_all(false, true, init_SEK);
initAll(false, true, init_SEK);
cerr << "Server inited" << endl;
HttpClient client("http://localhost:1029");
StubClient c(client, JSONRPC_CLIENT_V2);
......@@ -1228,7 +1228,7 @@ TEST_CASE("bls_sign_api test", "[bls_sign]") {
encryptKeys = 1;
cerr << "test started" << endl;
init_all(false, true, init_SEK);
initAll(false, true, init_SEK);
cerr << "Server inited" << endl;
HttpClient client("http://localhost:1029");
StubClient c(client, JSONRPC_CLIENT_V2);
......@@ -1261,7 +1261,7 @@ TEST_CASE("AES encrypt/decrypt", "[AES-encrypt-decrypt]") {
printDebugInfo = 1;
useHTTPS = 0;
init_all(false, true, init_SEK);
initAll(false, true, init_SEK);
//init_enclave();
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