Unverified Commit 056c1b73 authored by kladko's avatar kladko

SKALE-2167 Adding tests

parent f0f84a0f
......@@ -146,7 +146,8 @@ vector <vector<string>> get_verif_vect(const char* encryptedPolyHex, int t, int
// printf(" %d ", encr_dkg_poly[i] );
}
uint32_t len;
uint32_t len = 0;
if (!is_aes)
status = get_public_shares(eid, &err_status, errMsg1, encr_dkg_poly, len, public_shares, t, n);
else {
......@@ -170,7 +171,7 @@ vector <vector<string>> get_verif_vect(const char* encryptedPolyHex, int t, int
vector <string> G2_strings = SplitString( public_shares, ',');
vector <vector <string>> pub_shares_vect;
for ( int i = 0; i < G2_strings.size(); i++){
for ( uint64_t i = 0; i < G2_strings.size(); i++){
vector <string> koef_str = SplitString(G2_strings.at(i).c_str(), ':');
pub_shares_vect.push_back(koef_str);
}
......@@ -382,7 +383,6 @@ vector<string> GetBLSPubKey(const char * encryptedKeyHex){
int err_status = 0;
uint64_t dec_key_len ;
uint8_t encr_bls_key[BUF_LEN];
uint8_t encr_key[BUF_LEN];
if (!hex2carray(encryptedKeyHex, &dec_key_len, encr_key)){
throw RPCException(INVALID_HEX, "Invalid encryptedKeyHex");
......
......@@ -44,8 +44,8 @@ secure_enclave.edl: secure_enclave/secure_enclave.edl
##
#AM_CPPFLAGS += -g -Og
AM_CFLAGS = -g -Og -rdynamic -Wl,--no-as-needed -lSegFault -fsanitize=address
AM_CXXFLAGS = ${AM_CPPFLAGS} -rdynamic -Wl,--no-as-needed -lSegFault -fsanitize=address
AM_CFLAGS = -g -Og -rdynamic -Wl,--no-as-needed -lSegFault
AM_CXXFLAGS = ${AM_CPPFLAGS} -rdynamic -Wl,--no-as-needed -lSegFault
AM_CPPFLAGS += -Wall -DSKALE_SGX=1 -DBINARY_OUTPUT=1 -Ileveldb/include -IlibBLS/bls -IlibBLS/libff -IlibBLS -fno-builtin-memset $(GMP_CPPFLAGS) -I. -I./libBLS/deps/deps_inst/x86_or_x64/include
......
......@@ -154,7 +154,11 @@ void gen_SEK(){
std::getline(std::cin, buffer);
} while (case_insensitive_match(confirm_str, buffer)); //(strcmp(confirm_str.c_str(), buffer.c_str()) != 0);
}
system("reset");
if (system("reset") != 0) {
cerr << "Could not execute reset" << endl;
}
LevelDB::getLevelDb()->writeDataUnique("SEK", hexEncrKey.data());
create_test_key();
......
......@@ -493,7 +493,7 @@ Json::Value getSecretShareImpl(const string& polyName, const Json::Value& public
result["errorMessage"] = "";
try {
if (publicKeys.size() != n){
if (publicKeys.size() != (uint64_t) n){
throw RPCException(INVALID_DKG_PARAMS, "wrong number of public keys");
}
if ( !checkName(polyName, "POLY")){
......@@ -549,7 +549,7 @@ Json::Value dkgVerificationImpl(const string& publicShares, const string& ethKey
if ( !checkHex(SecretShare, SECRET_SHARE_NUM_BYTES)){
throw RPCException(INVALID_HEX, "Invalid Secret share");
}
if (publicShares.length() != 256 * t){
if (publicShares.length() != (uint64_t ) 256 * t){
throw RPCException(INVALID_DKG_PARAMS, "Invalid length of public shares");
}
......@@ -579,7 +579,7 @@ Json::Value createBLSPrivateKeyImpl(const string & blsKeyName, const string& eth
try {
if (SecretShare.length() != n * 192){
if (SecretShare.length() != (uint64_t ) n * 192){
spdlog::info("wrong length of secret shares - {}", SecretShare.length());
spdlog::info("secret shares - {}", SecretShare);
throw RPCException(INVALID_SECRET_SHARES_LENGTH, "Invalid secret share length");
......
......@@ -124,8 +124,9 @@ TEST_CASE("BLS key encrypt", "[bls-key-encrypt]") {
DEBUG_PRINT = 1;
is_sgx_https = 0;
init_all(false, false, init_SEK);
auto key = shared_ptr<char>(encryptTestKey());
auto key = encryptTestKey();
REQUIRE(key != nullptr);
free(key);
}
......@@ -146,7 +147,6 @@ TEST_CASE("BLS key encrypt/decrypt", "[bls-key-encrypt-decrypt]") {
char *encryptedKey = encryptTestKey();
REQUIRE(encryptedKey != nullptr);
char *plaintextKey = decryptBLSKeyShareFromHex(&errStatus, errMsg.data(), encryptedKey);
free(encryptedKey);
REQUIRE(errStatus == 0);
......@@ -155,6 +155,7 @@ TEST_CASE("BLS key encrypt/decrypt", "[bls-key-encrypt-decrypt]") {
printf("Decrypt key completed with status: %d %s \n", errStatus, errMsg.data());
printf("Decrypted key len %d\n", (int) strlen(plaintextKey));
printf("Decrypted key: %s\n", plaintextKey);
free(plaintextKey);
sgx_destroy_enclave(eid);
......
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