diff --git a/crypto/src/dap_enc_ecdsa.c b/crypto/src/dap_enc_ecdsa.c index 3122b5a7bb35ed36d1d6e3e56b013c7aa35bb847..c61882a7da2eda277d2aa93d823f75a35e1e04e2 100644 --- a/crypto/src/dap_enc_ecdsa.c +++ b/crypto/src/dap_enc_ecdsa.c @@ -89,7 +89,7 @@ void dap_enc_sig_ecdsa_key_new_generate(dap_enc_key_t *a_key, UNUSED_ARG const v } // keypair generate if(a_seed && a_seed_size > 0) { - dap_enc_sig_ecdsa_hash_fast((const unsigned char *)a_seed, a_seed_size, (unsigned char *)a_key->priv_key_data); + dap_enc_sig_ecdsa_hash_fast((const unsigned char *)a_seed, a_seed_size, (dap_hash_fast_t *)a_key->priv_key_data); if (!secp256k1_ec_seckey_verify(l_ctx, (const unsigned char*)a_key->priv_key_data)) { log_it(L_ERROR, "Error verify ECDSA private key"); DAP_DEL_Z(a_key->priv_key_data); @@ -125,7 +125,7 @@ int dap_enc_sig_ecdsa_get_sign(struct dap_enc_key *l_key, const void *a_msg, con dap_return_val_if_pass_err(l_key->priv_key_data_size != sizeof(ecdsa_private_key_t), -3, "Invalid ecdsa private key size"); // msg hashing byte_t l_msghash[32] = { '\0' }; - dap_enc_sig_ecdsa_hash_fast(a_msg, a_msg_size, l_msghash); + dap_enc_sig_ecdsa_hash_fast(a_msg, a_msg_size, (dap_hash_fast_t *)l_msghash); // context create int l_ret = 0; ecdsa_context_t *l_ctx = s_context_create(); @@ -144,7 +144,7 @@ int dap_enc_sig_ecdsa_verify_sign(struct dap_enc_key *l_key, const void *a_msg, dap_return_val_if_pass_err(l_key->pub_key_data_size != sizeof(ecdsa_public_key_t), -3, "Invalid ecdsa public key size"); // msg hashing byte_t l_msghash[32] = { '\0' }; - dap_enc_sig_ecdsa_hash_fast(a_msg, a_msg_size, l_msghash); + dap_enc_sig_ecdsa_hash_fast(a_msg, a_msg_size, (dap_hash_fast_t *)l_msghash); // context create int l_ret = 0; ecdsa_context_t *l_ctx = s_context_create(); @@ -221,7 +221,8 @@ void dap_enc_sig_ecdsa_signature_delete(void *a_sig){ } void dap_enc_sig_ecdsa_private_key_delete(void *a_private_key) { - dap_return_if_pass(!a_private_key); + if (!a_private_key) + return; memset_safe( ((ecdsa_private_key_t*)a_private_key)->data, 0, ECDSA_PRIVATE_KEY_SIZE); DAP_DELETE(a_private_key); } diff --git a/crypto/test/crypto/dap_enc_multithread_test.c b/crypto/test/crypto/dap_enc_multithread_test.c index 08e15d7a9015ba4183569cc7ae71003e6d572c63..92c7e657e4afb26f08357a8226a2429628e2dc72 100644 --- a/crypto/test/crypto/dap_enc_multithread_test.c +++ b/crypto/test/crypto/dap_enc_multithread_test.c @@ -6,6 +6,8 @@ #include "dap_enc_sphincsplus.h" #define LOG_TAG "dap_crypto_multithread_tests" +void dap_enc_sig_sphincsplus_set_default_config(sphincsplus_config_t a_new_config); +int dap_enc_sig_sphincsplus_get_configs_count(); static dap_enc_key_t *s_enc_key_new_generate(dap_enc_key_type_t a_key_type, const void *a_kex_buf, size_t a_kex_size, const void *a_seed, size_t a_seed_size, size_t a_key_size) { switch (a_key_type) diff --git a/global-db/dap_global_db_driver_pgsql.c b/global-db/dap_global_db_driver_pgsql.c index 716e88c43630b6c7b617ddf9eb51cddc989c6ad7..ceefbf1d2f2dd18089280751856312be34a90271 100644 --- a/global-db/dap_global_db_driver_pgsql.c +++ b/global-db/dap_global_db_driver_pgsql.c @@ -395,7 +395,7 @@ static dap_global_db_pkt_pack_t *s_db_pgsql_get_by_hash(const char *a_group, dap } l_blob_str->str[l_blob_str->len - 1] = '\0'; --l_blob_str->len; - char *l_query_size_str = dap_strdup_printf("SELECT COALESCE(SUM(LENGTH(key)), 0) + COALESCE(SUM(LENGTH(value)), 0) + COALESCE(SUM(LENGTH(sign)), 0) FROM \"%s\" " + char *l_query_size_str = dap_strdup_printf("SELECT SUM(LENGTH(key)) + COALESCE(SUM(LENGTH(value)), 0) + COALESCE(SUM(LENGTH(sign)), 0) FROM \"%s\" " " WHERE driver_key IN (%s);", a_group, l_blob_str->str); char *l_query_str = dap_strdup_printf("SELECT * FROM \"%s\"" diff --git a/global-db/dap_global_db_driver_sqlite.c b/global-db/dap_global_db_driver_sqlite.c index 985586b2e8aa90537741659ed8d5f328dc17b050..a8a9892dfef5ccd3ddc26543efa32600dce8108e 100644 --- a/global-db/dap_global_db_driver_sqlite.c +++ b/global-db/dap_global_db_driver_sqlite.c @@ -483,7 +483,7 @@ static dap_global_db_pkt_pack_t *s_db_sqlite_get_by_hash(const char *a_group, da char *l_query_count_str = sqlite3_mprintf("SELECT COUNT(*) FROM \"%s\" " " WHERE driver_key IN (%s)", a_group, l_blob_str); - char *l_query_size_str = sqlite3_mprintf("SELECT COALESCE(SUM(LENGTH(key)), 0) + COALESCE(SUM(LENGTH(value)), 0) + COALESCE(SUM(LENGTH(sign)), 0) FROM \"%s\" " + char *l_query_size_str = sqlite3_mprintf("SELECT SUM(LENGTH(key)) + COALESCE(SUM(LENGTH(value)), 0) + COALESCE(SUM(LENGTH(sign)), 0) FROM \"%s\" " " WHERE driver_key IN (%s)", a_group, l_blob_str); char *l_query_str = sqlite3_mprintf("SELECT * FROM \"%s\"" diff --git a/global-db/test/dap_global_db_test.c b/global-db/test/dap_global_db_test.c index 86bec52c4b63edd511c9cab8c8b0eec6d239216b..4c414652b8c0fa354a8a75db009455136dafd630 100644 --- a/global-db/test/dap_global_db_test.c +++ b/global-db/test/dap_global_db_test.c @@ -98,7 +98,7 @@ static int s_test_create_db(const char *db_type) return l_rc; } -static int s_test_write(size_t a_count, bool a_with_value) +static int s_test_write(size_t a_count) { dap_store_obj_t l_store_obj = {0}; int l_value_len = 0, *l_pvalue, i, ret; @@ -114,7 +114,6 @@ static int s_test_write(size_t a_count, bool a_with_value) /* "Table" name */ l_store_obj.key = l_key; /* Point <.key> to the buffer with the key of record */ - l_store_obj.value = a_with_value ? (uint8_t *) l_value : NULL; /* Point <.value> to static buffer area */ prec = (dap_db_test_record_t *) l_value; size_t l_rewrite_count = rand() % (a_count / 2) + 2; for (size_t i = 0; i < a_count; ++i) @@ -126,7 +125,8 @@ static int s_test_write(size_t a_count, bool a_with_value) clock_gettime(CLOCK_REALTIME, &now); /* Get and save record's timestamp */ l_store_obj.timestamp = ((uint64_t)now.tv_sec << 32) | ((uint32_t) (now.tv_nsec)); - if (a_with_value) { + if (i % 2) { + l_store_obj.value = (uint8_t *) l_value; /* Point <.value> to static buffer area */ prec->len = rand() % DAP_DB$SZ_DATA + 1; /* Variable payload length */ l_pvalue = (int *) prec->data; for (int i = prec->len / sizeof(int); i--; l_pvalue++) /* Fill record's payload with random data */ @@ -136,6 +136,9 @@ static int s_test_write(size_t a_count, bool a_with_value) l_store_obj.value_len = l_value_len; assert(l_store_obj.value_len < sizeof(l_value)); dap_hash_fast (prec->data, prec->len, &prec->csum); /* Compute a hash of the payload part of the record */ + } else { + l_store_obj.value = NULL; + l_store_obj.value_len = 0; } if (i >= l_rewrite_count) { @@ -672,9 +675,9 @@ static void s_test_close_db(void) } -static void s_test_all(size_t a_count, bool a_with_value) +static void s_test_all(size_t a_count) { - s_test_write(a_count, a_with_value); + s_test_write(a_count); s_test_read(a_count, true); s_test_read_all(a_count); s_test_read_cond_store(a_count, true); @@ -803,7 +806,7 @@ void s_test_table_erase() { dap_assert(true, "Table erased"); } -static void s_test_full(size_t a_db_count, size_t a_count, bool a_with_value) +static void s_test_full(size_t a_db_count, size_t a_count) { for (size_t i = 0; i < a_db_count; ++i) { s_write = 0; @@ -847,7 +850,7 @@ static void s_test_full(size_t a_db_count, size_t a_count, bool a_with_value) dap_print_module_name(s_db_types[i]); s_test_create_db(s_db_types[i]); uint64_t l_t1 = get_cur_time_nsec(); - s_test_all(a_count, true); + s_test_all(a_count); uint64_t l_t2 = get_cur_time_nsec(); char l_msg[120] = {0}; sprintf(l_msg, "All tests to %zu records", a_count); @@ -902,10 +905,8 @@ int main(int argc, char **argv) sprintf(s_group_wrong, "%s", DAP_DB$T_GROUP_WRONG_PREF); sprintf(s_group_not_existed, "%s", DAP_DB$T_GROUP_NOT_EXISTED_PREF); - dap_print_module_name("Tests with value"); - s_test_full(l_db_count, l_count, true); - dap_print_module_name("Tests without value"); - s_test_full(l_db_count, l_count, false); + dap_print_module_name("Tests with combined value"); + s_test_full(l_db_count, l_count); }