diff --git a/.gitmodules b/.gitmodules index 592ddeed7c0a2840b78e36d903fd71aa27a873e9..dce1d1ba52ba5138f1240cebfec66923b60777eb 100755 --- a/.gitmodules +++ b/.gitmodules @@ -1,9 +1,77 @@ + [submodule "libdap"] path = libdap - url = https://github.com/kelvinblockchain/libdap + url = https://gitlab.demlabs.net/cellframe/libdap + branch = master [submodule "test/libdap-test"] path = test/libdap-test - url = https://github.com/kelvinblockchain/libdap-test/ + url = https://gitlab.demlabs.net/cellframe/libdap-test/ + branch = master [submodule "libdap-chain"] path = libdap-chain - url = https://github.com/kelvinblockchain/libdap-chain + url = https://gitlab.demlabs.net/cellframe/libdap-chain + branch = master +[submodule "libdap-crypto"] + path = libdap-crypto + url = https://gitlab.demlabs.net/cellframe/libdap-crypto + branch = master +[submodule "libdap-chain-gdb"] + path = libdap-chain-gdb + url = https://gitlab.demlabs.net/cellframe/libdap-chain-gdb.git + branch = master +[submodule "libdap-chain-global-db"] + path = libdap-chain-global-db + url = https://gitlab.demlabs.net/cellframe/libdap-chain-global-db.git + branch = master +[submodule "libdap-chain-mempool"] + path = libdap-chain-mempool + url = https://gitlab.demlabs.net/cellframe/libdap-chain-mempool.git + branch = master +[submodule "libdap-chain-net-srv"] + path = libdap-chain-net-srv + url = https://gitlab.demlabs.net/cellframe/libdap-chain-net-srv.git + branch = master +[submodule "libdap-chain-wallet"] + path = libdap-chain-wallet + url = https://gitlab.demlabs.net/cellframe/libdap-chain-wallet.git + branch = master +[submodule "libdap-client"] + path = libdap-client + url = https://gitlab.demlabs.net/cellframe/libdap-client.git + branch = master +[submodule "libdap-server"] + path = libdap-server + url = https://gitlab.demlabs.net/cellframe/libdap-server.git + branch = master +[submodule "libdap-server-core"] + path = libdap-server-core + url = https://gitlab.demlabs.net/cellframe/libdap-server-core.git + branch = master +[submodule "libdap-server-udp"] + path = libdap-server-udp + url = https://gitlab.demlabs.net/cellframe/libdap-server-udp.git + branch = master +[submodule "libdap-stream"] + path = libdap-stream + url = https://gitlab.demlabs.net/cellframe/libdap-stream.git + branch = master +[submodule "libdap-stream-ch"] + path = libdap-stream-ch + url = https://gitlab.demlabs.net/cellframe/libdap-stream-ch.git + branch = master +[submodule "libdap-stream-ch-chain"] + path = libdap-stream-ch-chain + url = https://gitlab.demlabs.net/cellframe/libdap-stream-ch-chain.git + branch = master +[submodule "libdap-stream-ch-chain-net"] + path = libdap-stream-ch-chain-net + url = https://gitlab.demlabs.net/cellframe/libdap-stream-ch-chain-net.git + branch = master +[submodule "libdap-chain-net"] + path = libdap-chain-net + url = https://gitlab.demlabs.net/cellframe/libdap-chain-net + branch = master +[submodule "libdap-server-http-db-auth"] + path = libdap-server-http-db-auth + url = https://gitlab.demlabs.net/cellframe/libdap-server-http-db-auth.git + branch = master diff --git a/.travis.yml b/.travis.yml index c3f4e90422f4902a3fe6085544711b69f779775e..177fa1db100faf403486d641e75000e97df6efaa 100755 --- a/.travis.yml +++ b/.travis.yml @@ -11,7 +11,7 @@ before_install: script: - mkdir build - cd build - - cmake ../ + - cmake -DBUILD_DAP_CHAIN_CRYPTO_TESTS=ON ../ - make - ctest --verbose @@ -19,3 +19,11 @@ addons: apt: sources: - ubuntu-toolchain-r-test + packages: + - libev-dev + - libjson-c-dev + - libmagic-dev + - libmemcached-dev + - libldb-dev + - libtalloc-dev + - libtevent-dev diff --git a/CMakeLists.txt b/CMakeLists.txt index b59e18f2718cafca285479b9d8bcfc140d79773c..6cc4baae72994d0b188b0aba46e14f598dcd4d4c 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,48 +1,118 @@ -cmake_minimum_required(VERSION 2.8) -project (dap_chain_crypto) - -set(DAP_CHAIN_CRYPTO_SRCS - dap_hash.c - dap_hash_fusion.c - dap_hash_keccak.c - dap_hash_slow.c - dap_chain_pkey.c - dap_chain_sign.c - dap_chain_cert.c - dap_chain_cert_file.c - ) - -set(DAP_CHAIN_CRYPTO_HEADERS - dap_hash.h - dap_hash_fusion.h - dap_hash_keccak.h - dap_hash_slow.h - dap_chain_pkey.h - dap_chain_sign.h - dap_chain_cert.h - dap_chain_cert_file.h - - ) - -if(NOT (${SUBMODULES_NO_BUILD} MATCHES ON)) - add_subdirectory(libdap) - add_subdirectory(libdap-crypto) - add_subdirectory(libdap-chain) - enable_testing() - add_subdirectory(test) -endif() - -add_subdirectory(monero_crypto) - -include_directories("${monero_crypto_INCLUDE_DIRS}") -add_definitions ("${monero_crypto_DEFINITIONS}") - - -add_library(${PROJECT_NAME} STATIC ${DAP_CHAIN_CRYPTO_SRCS} ${DAP_CHAIN_CRYPTO_HEADERS}) - -target_include_directories(dap_chain_crypto INTERFACE .) -target_link_libraries(dap_chain_crypto dap_core dap_crypto dap_chain monero_crypto) - -set(${PROJECT_NAME}_DEFINITIONS CACHE INTERNAL "${PROJECT_NAME}: Definitions" FORCE) - -set(${PROJECT_NAME}_INCLUDE_DIRS ${PROJECT_SOURCE_DIR} CACHE INTERNAL "${PROJECT_NAME}: Include Directories" FORCE) +cmake_minimum_required(VERSION 2.8) +project (dap_chain_crypto) + +set(DAP_CHAIN_CRYPTO_SRCS + dap_hash.c + dap_hash_fusion.c + dap_hash_keccak.c + dap_hash_slow.c + dap_chain_pkey.c + dap_chain_sign.c + dap_chain_cert.c + dap_chain_cert_file.c + ) + +set(DAP_CHAIN_CRYPTO_HEADERS + dap_hash.h + dap_hash_fusion.h + dap_hash_keccak.h + dap_hash_slow.h + dap_chain_pkey.h + dap_chain_sign.h + dap_chain_cert.h + dap_chain_cert_file.h + ) + +if(NOT (${SUBMODULES_NO_BUILD} MATCHES ON)) + set(SUBMODULES_NO_BUILD ON) + + # Check whether we're on a 32-bit or 64-bit system + if(CMAKE_SIZEOF_VOID_P EQUAL "8") + set(DEFAULT_BUILD_64 ON) + else() + set(DEFAULT_BUILD_64 OFF) + endif() + option(BUILD_64 "Build for 64-bit? 'OFF' builds for 32-bit." ${DEFAULT_BUILD_64}) + + add_definitions ("-DDAP_SERVER") + add_definitions ("-DNODE_NETNAME=\"kelvin\"") + + set(_CCOPT "-Wall -O2 -pg -fPIC -fno-pie -no-pie") + set(_LOPT "-pg") + set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -pg") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${_CCOPT}") + set(CMAKE_LINKER_FLAGS "${CMAKE_LINKER_FLAGS} ${_LOPT}") + + if (NOT (TARGET dap_core)) + add_subdirectory(libdap) + endif() + if (NOT (TARGET dap_crypto)) + add_subdirectory(libdap-crypto) + endif() + if (NOT (TARGET dap_chain)) + add_subdirectory(libdap-chain) + endif() + if (NOT (TARGET dap_chain_mempool)) + add_subdirectory(libdap-chain-mempool) + endif() + if (NOT (TARGET dap_server_core)) + add_subdirectory(libdap-server-core) + endif() + if (NOT (TARGET dap_chain_net)) + add_subdirectory(libdap-chain-net) + endif() + if (NOT (TARGET dap_chain_global_db)) + add_subdirectory(libdap-chain-global-db) + endif() + if (NOT (TARGET dap_client)) + add_subdirectory(libdap-client) + endif() + if (NOT (TARGET dap_server)) + add_subdirectory(libdap-server) + endif() + if (NOT (TARGET dap_udp_server)) + add_subdirectory(libdap-server-udp) + endif() + if (NOT (TARGET libdap-stream)) + add_subdirectory(libdap-stream) + endif() + if (NOT (TARGET dap_stream_ch)) + add_subdirectory(libdap-stream-ch) + endif() + if (NOT (TARGET dap_stream_ch_chain)) + add_subdirectory(libdap-stream-ch-chain) + endif() + if (NOT (TARGET dap_stream_ch_chain_net)) + add_subdirectory(libdap-stream-ch-chain-net) + endif() + if (NOT (TARGET dap_chain_wallet)) + add_subdirectory(libdap-chain-wallet) + endif() + if (NOT (TARGET dap_chain_net_srv)) + add_subdirectory(libdap-chain-net-srv) + endif() + if (NOT (TARGET dap_server_http_db_auth)) + add_subdirectory(libdap-server-http-db-auth) + endif() + if (NOT (TARGET dap_chain_gdb)) + add_subdirectory(libdap-chain-gdb) + endif() +endif() + +add_subdirectory(monero_crypto) + +include_directories("${monero_crypto_INCLUDE_DIRS}") +add_definitions ("${monero_crypto_DEFINITIONS}") + +add_library(${PROJECT_NAME} STATIC ${DAP_CHAIN_CRYPTO_SRCS} ${DAP_CHAIN_CRYPTO_HEADERS}) + +target_include_directories(dap_chain_crypto INTERFACE .) +target_link_libraries(dap_chain_crypto dap_core dap_crypto dap_chain monero_crypto) + +set(${PROJECT_NAME}_DEFINITIONS CACHE INTERNAL "${PROJECT_NAME}: Definitions" FORCE) +set(${PROJECT_NAME}_INCLUDE_DIRS ${PROJECT_SOURCE_DIR} CACHE INTERNAL "${PROJECT_NAME}: Include Directories" FORCE) + +if (${BUILD_DAP_CHAIN_CRYPTO_TESTS} MATCHES ON) + enable_testing() + add_subdirectory(test) +endif() diff --git a/dap_chain_cert.c b/dap_chain_cert.c index 80e70c921ee56086edaa42118f0cd5c1e6e14dd7..4abf4de258ee89f922ea5581b6b107a45c20c4cf 100755 --- a/dap_chain_cert.c +++ b/dap_chain_cert.c @@ -31,6 +31,7 @@ #include "uthash.h" #include "utlist.h" #include "dap_common.h" +#include "dap_config.h" #include "dap_string.h" #include "dap_strfuncs.h" #include "dap_chain_cert.h" @@ -276,8 +277,24 @@ dap_chain_cert_t * dap_chain_cert_find_by_name(const char * a_cert_name) HASH_FIND_STR(s_certs,a_cert_name,l_cert_item); if ( l_cert_item ){ return l_cert_item->cert ; - }else - return NULL; + } else { + dap_chain_cert_t *l_cert = NULL; + uint16_t l_ca_folders_size = 0; + char **l_ca_folders; + char *l_cert_path = NULL; + l_ca_folders = dap_config_get_array_str(g_config,"resources","ca_folders",&l_ca_folders_size); + for (uint16_t i=0; i < l_ca_folders_size; ++i) { + l_cert_path = dap_strjoin("", l_ca_folders[i], "/", a_cert_name, ".dcert", (char*)NULL); + l_cert = dap_chain_cert_file_load(l_cert_path); + if (l_cert) { + goto ret; + } + } + ret: + if (l_cert_path) + DAP_DELETE(l_cert_path); + return l_cert; + } } @@ -290,10 +307,10 @@ dap_chain_cert_t * dap_chain_cert_new(const char * a_name) { dap_chain_cert_t * l_ret = DAP_NEW_Z(dap_chain_cert_t); l_ret->_pvt = DAP_NEW_Z(dap_chain_cert_pvt_t); - snprintf(l_ret->name,sizeof(l_ret->name),"%s",a_name); + dap_snprintf(l_ret->name,sizeof(l_ret->name),"%s",a_name); dap_chain_cert_item_t * l_cert_item = DAP_NEW_Z(dap_chain_cert_item_t); - snprintf(l_cert_item->name,sizeof(l_cert_item->name),"%s",a_name); + dap_snprintf(l_cert_item->name,sizeof(l_cert_item->name),"%s",a_name); l_cert_item->cert = l_ret; HASH_ADD_STR(s_certs,name,l_cert_item); @@ -332,7 +349,7 @@ dap_chain_cert_t * dap_chain_cert_add_file(const char * a_cert_name,const char * { size_t l_cert_path_length = strlen(a_cert_name)+8+strlen(a_folder_path); char * l_cert_path = DAP_NEW_Z_SIZE(char,l_cert_path_length); - snprintf(l_cert_path,l_cert_path_length,"%s/%s.dcert",a_folder_path,a_cert_name); + dap_snprintf(l_cert_path,l_cert_path_length,"%s/%s.dcert",a_folder_path,a_cert_name); if( access( l_cert_path, F_OK ) == -1 ) { log_it (L_ERROR, "File %s is not exists! ", l_cert_path); exit(-701); @@ -356,7 +373,7 @@ int dap_chain_cert_save_to_folder(dap_chain_cert_t * a_cert, const char *a_file_ const char * l_cert_name = a_cert->name; size_t l_cert_path_length = strlen(l_cert_name)+8+strlen(a_file_dir_path); char * l_cert_path = DAP_NEW_Z_SIZE(char,l_cert_path_length); - snprintf(l_cert_path,l_cert_path_length,"%s/%s.dcert",a_file_dir_path,l_cert_name); + dap_snprintf(l_cert_path,l_cert_path_length,"%s/%s.dcert",a_file_dir_path,l_cert_name); ret = dap_chain_cert_file_save(a_cert,l_cert_path); DAP_DELETE( l_cert_path); return ret; diff --git a/dap_chain_cert_file.c b/dap_chain_cert_file.c index 6937ae3ebede1d0ea46868a1b74fb8dfd74eaa6a..50e51c1b605368225bdb895ddead5e672c0356f9 100755 --- a/dap_chain_cert_file.c +++ b/dap_chain_cert_file.c @@ -40,7 +40,7 @@ */ int dap_chain_cert_file_save(dap_chain_cert_t * a_cert, const char * a_cert_file_path) { - FILE * l_file = fopen(a_cert_file_path,"w"); + FILE * l_file = fopen(a_cert_file_path,"wb"); if( l_file ){ uint32_t l_data_size = 0; void * l_data = dap_chain_cert_mem_save(a_cert, &l_data_size); @@ -150,7 +150,7 @@ lb_exit: dap_chain_cert_t* dap_chain_cert_file_load(const char * a_cert_file_path) { dap_chain_cert_t * l_ret = NULL; - FILE * l_file = fopen(a_cert_file_path,"r"); + FILE * l_file = fopen(a_cert_file_path,"rb"); if( l_file ){ fseek(l_file, 0L, SEEK_END); diff --git a/dap_hash.c b/dap_hash.c index 72dc340269e058a71bfa466f8cd1ad3a58576ab4..49b0d9138897a1fe3e0d42e867b9e5c5979f374e 100755 --- a/dap_hash.c +++ b/dap_hash.c @@ -1,54 +1,44 @@ -/* - * Authors: - * Dmitriy A. Gearasimov <kahovski@gmail.com> - * DeM Labs Inc. https://demlabs.net - * DeM Labs Open source community https://github.com/demlabsinc - * Copyright (c) 2017-2018 - * All rights reserved. - - This file is part of DAP (Deus Applications Prototypes) the open source project - - DAP (Deus Applicaions Prototypes) is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - DAP is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with any DAP based project. If not, see <http://www.gnu.org/licenses/>. -*/ - -#include "dap_common.h" -#include "dap_hash.h" - -#define LOG_TAG "dap_hash" - -int dap_hash_fast(const void *a_data_in, size_t a_data_in_size, dap_chain_hash_fast_t *a_hash_out) -{ - if(!a_data_in || !a_data_in_size || !a_hash_out) - return -1; - dap_hash(a_data_in, a_data_in_size, a_hash_out->raw, sizeof(a_hash_out->raw), - DAP_HASH_TYPE_KECCAK); - return 1; -} - -bool dap_hash_fast_is_blank(dap_chain_hash_fast_t *a_hash) -{ - uint8_t *l_hast_bytes = (uint8_t*) a_hash; - for(size_t i = 0; i < sizeof(dap_chain_hash_fast_t); i++) { - if(l_hast_bytes[i]) - return false; - } - return true; -} - -bool dap_hash_fast_compare(dap_chain_hash_fast_t *a_hash1, dap_chain_hash_fast_t *a_hash2) -{ - if(!memcmp(a_hash1, a_hash2, sizeof(dap_chain_hash_fast_t))) - return true; - return false; -} +/* + * Authors: + * Dmitriy A. Gearasimov <kahovski@gmail.com> + * DeM Labs Inc. https://demlabs.net + * DeM Labs Open source community https://github.com/demlabsinc + * Copyright (c) 2017-2018 + * All rights reserved. + + This file is part of DAP (Deus Applications Prototypes) the open source project + + DAP (Deus Applicaions Prototypes) is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + DAP is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with any DAP based project. If not, see <http://www.gnu.org/licenses/>. +*/ + +#include "dap_common.h" +#include "dap_hash.h" + +#include "KeccakHash.h" +#include "SimpleFIPS202.h" + +#define LOG_TAG "dap_hash" + +/** +int dap_hash_fast(const void *a_data_in, size_t a_data_in_size, dap_chain_hash_fast_t *a_hash_out) +{ + if(!a_data_in || !a_data_in_size || !a_hash_out) + return -1; +// dap_hash(a_data_in, a_data_in_size, a_hash_out->raw, sizeof(a_hash_out->raw), +// DAP_HASH_TYPE_KECCAK); + SHA3_256( (unsigned char *)a_hash_out, (const unsigned char *)a_data_in, a_data_in_size ); + + return 1; +} +**/ diff --git a/dap_hash.h b/dap_hash.h index 392a26c9040a5c465caf5c7338d4cbc7e2adf324..6b993a5c1101bfe8402fc95896967ef4155420f5 100755 --- a/dap_hash.h +++ b/dap_hash.h @@ -1,57 +1,95 @@ -/* - * Authors: - * Dmitriy A. Gearasimov <kahovski@gmail.com> - * DeM Labs Inc. https://demlabs.net - * DeM Labs Open source community https://github.com/demlabsinc - * Copyright (c) 2017-2018 - * All rights reserved. - - This file is part of DAP (Deus Applications Prototypes) the open source project - - DAP (Deus Applicaions Prototypes) is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - DAP is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with any DAP based project. If not, see <http://www.gnu.org/licenses/>. -*/ -#pragma once -#include <stddef.h> -#include <stdbool.h> - -#include "dap_hash_slow.h" -#include "dap_hash_keccak.h" -#include "dap_chain_common.h" - - -typedef enum dap_hash_type { - DAP_HASH_TYPE_KECCAK = 0, - DAP_HASH_TYPE_SLOW_0 = 1, -} dap_hash_type_t; - - -static inline void dap_hash(const void * a_data_in, size_t a_data_in_size, - void * a_data_out, size_t a_data_out_size, - dap_hash_type_t a_type ){ - switch (a_type){ - case DAP_HASH_TYPE_KECCAK: - dap_hash_keccak(a_data_in,a_data_in_size, a_data_out,a_data_out_size); - break; - case DAP_HASH_TYPE_SLOW_0: - if( a_data_out_size>= dap_hash_slow_size() ){ - dap_hash_slow(a_data_in,a_data_in_size,(char*) a_data_out); - } - break; - } - -} - -int dap_hash_fast(const void *a_data_in, size_t a_data_in_size, dap_chain_hash_fast_t *a_hash_out); -bool dap_hash_fast_is_blank(dap_chain_hash_fast_t *a_hash); -bool dap_hash_fast_compare(dap_chain_hash_fast_t *a_hash1, dap_chain_hash_fast_t *a_hash2); +/* + * Authors: + * Dmitriy A. Gearasimov <kahovski@gmail.com> + * DeM Labs Inc. https://demlabs.net + * DeM Labs Open source community https://github.com/demlabsinc + * Copyright (c) 2017-2018 + * All rights reserved. + + This file is part of DAP (Deus Applications Prototypes) the open source project + + DAP (Deus Applicaions Prototypes) is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + DAP is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with any DAP based project. If not, see <http://www.gnu.org/licenses/>. +*/ +#pragma once +#include <stddef.h> +#include <stdbool.h> +#include <stdint.h> + +#include "dap_hash_slow.h" +#include "dap_hash_keccak.h" +#include "dap_chain_common.h" + +#include "KeccakHash.h" +#include "SimpleFIPS202.h" + +#define DAP_HASH_FAST_SIZE 32 + +typedef enum dap_hash_type { + DAP_HASH_TYPE_KECCAK = 0, + DAP_HASH_TYPE_SLOW_0 = 1, +} dap_hash_type_t; + +static inline int dap_hash_fast( const void *a_data_in, size_t a_data_in_size, void *a_hash_out ) +{ + if (!a_data_in || !a_data_in_size || !a_hash_out) + return -1; + +// dap_hash(a_data_in, a_data_in_size, a_hash_out->raw, sizeof(a_hash_out->raw), +// DAP_HASH_TYPE_KECCAK); + + SHA3_256( (unsigned char *)a_hash_out, (const unsigned char *)a_data_in, a_data_in_size ); + + return 1; +} + +static inline void dap_hash(const void * a_data_in, size_t a_data_in_size, + void * a_data_out, size_t a_data_out_size, + dap_hash_type_t a_type ){ + switch (a_type){ + case DAP_HASH_TYPE_KECCAK: +// dap_hash_keccak( a_data_in, a_data_in_size, a_data_out, a_data_out_size ); + SHA3_256( (unsigned char *)a_data_out, (const unsigned char *)a_data_in, a_data_in_size ); + break; + case DAP_HASH_TYPE_SLOW_0: + if( a_data_out_size>= dap_hash_slow_size() ){ + dap_hash_slow(a_data_in,a_data_in_size,(char*) a_data_out); + } + break; + } +} + +static uint64_t blank_hash[4] = { 0, 0, 0, 0 }; + +static inline bool dap_hash_fast_compare( void *a_hash1, void *a_hash2 ) +{ + if( !memcmp(a_hash1, a_hash2, DAP_HASH_FAST_SIZE) ) + return true; + + return false; +} + +static inline bool dap_hash_fast_is_blank( void *a_hash ) +{ +// uint8_t *l_hast_bytes = (uint8_t*) a_hash; +// for(size_t i = 0; i < sizeof(dap_chain_hash_fast_t); i++) { +// if(l_hast_bytes[i]) +// return false; +// } + return dap_hash_fast_compare( a_hash, &blank_hash[0] ); +} + + +//int dap_hash_fast(const void *a_data_in, size_t a_data_in_size, dap_chain_hash_fast_t *a_hash_out); +//bool dap_hash_fast_is_blank(dap_chain_hash_fast_t *a_hash); +//bool dap_hash_fast_compare(dap_chain_hash_fast_t *a_hash1, dap_chain_hash_fast_t *a_hash2); diff --git a/dap_hash_keccak.h b/dap_hash_keccak.h index 29a4830f1008b5954bdd4fe66fd2e0c6548a77a6..1dfcec53f67b9e71202524a08fb708708dc8bd56 100755 --- a/dap_hash_keccak.h +++ b/dap_hash_keccak.h @@ -25,7 +25,6 @@ #pragma once #include "keccak.h" - static inline void dap_hash_keccak(const void * a_in, size_t a_in_size, void * a_out, size_t a_out_size) { keccak((const uint8_t*) a_in, a_in_size, (uint8_t *) a_out,(int) a_out_size ); diff --git a/libdap b/libdap index ea3bd462382b3ae26885c0633495eb0c9e7d0ab3..67993d1f4cec44de464acee32a4d4f71d51c7e7d 160000 --- a/libdap +++ b/libdap @@ -1 +1 @@ -Subproject commit ea3bd462382b3ae26885c0633495eb0c9e7d0ab3 +Subproject commit 67993d1f4cec44de464acee32a4d4f71d51c7e7d diff --git a/libdap-chain b/libdap-chain index 73c853c47c3524ff55519ed27c5f9f782c031494..b94cdd0d9ea3e10b5ade8a5f8073d34521a2783a 160000 --- a/libdap-chain +++ b/libdap-chain @@ -1 +1 @@ -Subproject commit 73c853c47c3524ff55519ed27c5f9f782c031494 +Subproject commit b94cdd0d9ea3e10b5ade8a5f8073d34521a2783a diff --git a/libdap-chain-gdb b/libdap-chain-gdb new file mode 160000 index 0000000000000000000000000000000000000000..6ef661685f2792242433bf340f253d255f39e881 --- /dev/null +++ b/libdap-chain-gdb @@ -0,0 +1 @@ +Subproject commit 6ef661685f2792242433bf340f253d255f39e881 diff --git a/libdap-chain-global-db b/libdap-chain-global-db new file mode 160000 index 0000000000000000000000000000000000000000..94d4a28dd97cc1395295e1582839b58ba36e2463 --- /dev/null +++ b/libdap-chain-global-db @@ -0,0 +1 @@ +Subproject commit 94d4a28dd97cc1395295e1582839b58ba36e2463 diff --git a/libdap-chain-mempool b/libdap-chain-mempool new file mode 160000 index 0000000000000000000000000000000000000000..15d5b398125de01ba2525c76cd76c4ba590c4e2b --- /dev/null +++ b/libdap-chain-mempool @@ -0,0 +1 @@ +Subproject commit 15d5b398125de01ba2525c76cd76c4ba590c4e2b diff --git a/libdap-chain-net b/libdap-chain-net new file mode 160000 index 0000000000000000000000000000000000000000..5af381b67ea3e6fcaa76a3620cdc11541a2212bf --- /dev/null +++ b/libdap-chain-net @@ -0,0 +1 @@ +Subproject commit 5af381b67ea3e6fcaa76a3620cdc11541a2212bf diff --git a/libdap-chain-net-srv b/libdap-chain-net-srv new file mode 160000 index 0000000000000000000000000000000000000000..be35813a341b88738d909329974407cab87c0143 --- /dev/null +++ b/libdap-chain-net-srv @@ -0,0 +1 @@ +Subproject commit be35813a341b88738d909329974407cab87c0143 diff --git a/libdap-chain-wallet b/libdap-chain-wallet new file mode 160000 index 0000000000000000000000000000000000000000..892160fc248cccd1d3749fc70766a07128f450ac --- /dev/null +++ b/libdap-chain-wallet @@ -0,0 +1 @@ +Subproject commit 892160fc248cccd1d3749fc70766a07128f450ac diff --git a/libdap-client b/libdap-client new file mode 160000 index 0000000000000000000000000000000000000000..27bef519e72519abbd1c1e8b65274526cd006c3a --- /dev/null +++ b/libdap-client @@ -0,0 +1 @@ +Subproject commit 27bef519e72519abbd1c1e8b65274526cd006c3a diff --git a/libdap-crypto b/libdap-crypto new file mode 160000 index 0000000000000000000000000000000000000000..6249887fdd5c9ed88eb26c1e10f853ea9f7001b6 --- /dev/null +++ b/libdap-crypto @@ -0,0 +1 @@ +Subproject commit 6249887fdd5c9ed88eb26c1e10f853ea9f7001b6 diff --git a/libdap-server b/libdap-server new file mode 160000 index 0000000000000000000000000000000000000000..b92bfa29b7994665ea80a98718a121f6e9576c8f --- /dev/null +++ b/libdap-server @@ -0,0 +1 @@ +Subproject commit b92bfa29b7994665ea80a98718a121f6e9576c8f diff --git a/libdap-server-core b/libdap-server-core new file mode 160000 index 0000000000000000000000000000000000000000..6778521f9f646e2985994e63f470067b3e2c1e48 --- /dev/null +++ b/libdap-server-core @@ -0,0 +1 @@ +Subproject commit 6778521f9f646e2985994e63f470067b3e2c1e48 diff --git a/libdap-server-http-db-auth b/libdap-server-http-db-auth new file mode 160000 index 0000000000000000000000000000000000000000..bdab475c9dfe0ad876cd642a798e1b0b54ca314e --- /dev/null +++ b/libdap-server-http-db-auth @@ -0,0 +1 @@ +Subproject commit bdab475c9dfe0ad876cd642a798e1b0b54ca314e diff --git a/libdap-server-udp b/libdap-server-udp new file mode 160000 index 0000000000000000000000000000000000000000..08bda8439038c79927427e0e531863a05193d478 --- /dev/null +++ b/libdap-server-udp @@ -0,0 +1 @@ +Subproject commit 08bda8439038c79927427e0e531863a05193d478 diff --git a/libdap-stream b/libdap-stream new file mode 160000 index 0000000000000000000000000000000000000000..0dcee9fe68ab7daaf42ed76d7bce0a1a5dc51631 --- /dev/null +++ b/libdap-stream @@ -0,0 +1 @@ +Subproject commit 0dcee9fe68ab7daaf42ed76d7bce0a1a5dc51631 diff --git a/libdap-stream-ch b/libdap-stream-ch new file mode 160000 index 0000000000000000000000000000000000000000..9bead7765fba0a633098bf2279547c4dbf62cc4f --- /dev/null +++ b/libdap-stream-ch @@ -0,0 +1 @@ +Subproject commit 9bead7765fba0a633098bf2279547c4dbf62cc4f diff --git a/libdap-stream-ch-chain b/libdap-stream-ch-chain new file mode 160000 index 0000000000000000000000000000000000000000..5f869621cac54e87615ed031aed81b48d38df9b0 --- /dev/null +++ b/libdap-stream-ch-chain @@ -0,0 +1 @@ +Subproject commit 5f869621cac54e87615ed031aed81b48d38df9b0 diff --git a/libdap-stream-ch-chain-net b/libdap-stream-ch-chain-net new file mode 160000 index 0000000000000000000000000000000000000000..b43008b98e4a7220059457732e81aa6a80021739 --- /dev/null +++ b/libdap-stream-ch-chain-net @@ -0,0 +1 @@ +Subproject commit b43008b98e4a7220059457732e81aa6a80021739 diff --git a/monero_crypto/tree-hash.c b/monero_crypto/tree-hash.c index eb98c31b78924245c64c73ff0cf6be64f4b17585..cabb3d2224c3f8851e73c8c635af02cbc866988a 100755 --- a/monero_crypto/tree-hash.c +++ b/monero_crypto/tree-hash.c @@ -34,7 +34,7 @@ #include "hash-ops.h" -#if !defined(__FreeBSD__) && !defined(__OpenBSD__) && !defined(__DragonFly__) +#if !defined(_WIN32) && !defined(__FreeBSD__) && !defined(__OpenBSD__) && !defined(__DragonFly__) #include <alloca.h> #else #include <stdlib.h> @@ -44,24 +44,24 @@ * Round to power of two, for count>=3 and for count being not too large (as reasonable for tree hash calculations) */ size_t tree_hash_cnt(size_t count) { - // This algo has some bad history but all we are doing is 1 << floor(log2(count)) - // There are _many_ ways to do log2, for some reason the one selected was the most obscure one, - // and fixing it made it even more obscure. - // - // Iterative method implemented below aims for clarity over speed, if performance is needed - // then my advice is to use the BSR instruction on x86 - // - // All the paranoid asserts have been removed since it is trivial to mathematically prove that - // the return will always be a power of 2. - // Problem space has been defined as 3 <= count <= 2^28. Of course quarter of a billion transactions - // is not a sane upper limit for a block, so there will be tighter limits in other parts of the code + // This algo has some bad history but all we are doing is 1 << floor(log2(count)) + // There are _many_ ways to do log2, for some reason the one selected was the most obscure one, + // and fixing it made it even more obscure. + // + // Iterative method implemented below aims for clarity over speed, if performance is needed + // then my advice is to use the BSR instruction on x86 + // + // All the paranoid asserts have been removed since it is trivial to mathematically prove that + // the return will always be a power of 2. + // Problem space has been defined as 3 <= count <= 2^28. Of course quarter of a billion transactions + // is not a sane upper limit for a block, so there will be tighter limits in other parts of the code - assert( count >= 3 ); // cases for 0,1,2 are handled elsewhere - assert( count <= 0x10000000 ); // sanity limit to 2^28, MSB=1 will cause an inf loop + assert( count >= 3 ); // cases for 0,1,2 are handled elsewhere + assert( count <= 0x10000000 ); // sanity limit to 2^28, MSB=1 will cause an inf loop - size_t pow = 2; - while(pow < count) pow <<= 1; - return pow >> 1; + size_t pow = 2; + while(pow < count) pow <<= 1; + return pow >> 1; } void tree_hash(const char (*hashes)[HASH_SIZE], size_t count, char *root_hash) { @@ -90,7 +90,7 @@ void tree_hash(const char (*hashes)[HASH_SIZE], size_t count, char *root_hash) { char (*ints)[HASH_SIZE]; size_t ints_size = cnt * HASH_SIZE; - ints = alloca(ints_size); memset( ints , 0 , ints_size); // allocate, and zero out as extra protection for using uninitialized mem + ints = alloca(ints_size); memset( ints , 0 , ints_size); // allocate, and zero out as extra protection for using uninitialized mem memcpy(ints, hashes, (2 * cnt - count) * HASH_SIZE); diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 19060335f8dcd28078d1cd0f9309443fae642bd4..e4e350d47cf261692361b3ff4016a694a609b306 100755 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -1,18 +1,18 @@ -if(TARGET chain_crypto_test) - return() # The project has already been built. -endif() -project(chain_crypto_test) - -add_subdirectory(libdap-test) - -file(GLOB SOURCES *.c) -file(GLOB HEADERS *.h) - -add_executable(${PROJECT_NAME} ${SOURCES} ${HEADERS}) - -target_link_libraries(${PROJECT_NAME} dap_test dap_core dap_crypto dap_chain) - -add_test( - NAME chain_crypto_test - COMMAND chain_crypto_test -) +if(TARGET chain_crypto_test) + return() # The project has already been built. +endif() +project(chain_crypto_test) + +add_subdirectory(libdap-test) + +file(GLOB SOURCES *.c) +file(GLOB HEADERS *.h) + +add_executable(${PROJECT_NAME} ${SOURCES} ${HEADERS}) + +target_link_libraries(${PROJECT_NAME} dap_chain_crypto dap_core dap_crypto dap_chain monero_crypto dap_test) + +add_test( + NAME chain_crypto_test + COMMAND chain_crypto_test +) diff --git a/test/dap_chain_cert_save_tests.c b/test/dap_chain_cert_save_tests.c index 9e1930faedfbbafa3f7d0de5ad4121ccc55fec88..e20ea46d32ccdf7e6e61ff9bf3b79771f0100eb1 100755 --- a/test/dap_chain_cert_save_tests.c +++ b/test/dap_chain_cert_save_tests.c @@ -1,64 +1,65 @@ -#include <stdint.h> -#include <stdlib.h> -#include <unistd.h> - -#include "dap_test.h" -#include "dap_enc_key.h" -#include "dap_chain_cert.h" -#include "dap_chain_cert_file.h" - -#define CERT_FILE_PATH "cert_file_path.tmp" - -static void test_cert_memory_file(dap_enc_key_type_t a_key_type) -{ - uint32_t l_cert_buf_size = 0; - dap_chain_cert_t *l_cert = dap_chain_cert_generate_mem("name 1", a_key_type); - dap_assert_PIF(l_cert, "Fail create cert"); - uint8_t * l_cert_buf = dap_chain_cert_save_mem(l_cert, &l_cert_buf_size); - dap_assert_PIF(l_cert_buf, "Fail save cert to memory"); - dap_chain_cert_delete(l_cert); - - dap_chain_cert_t *l_cert2 = dap_chain_cert_mem_load(l_cert_buf, l_cert_buf_size); - dap_assert_PIF(l_cert2, "Fail read cert from memory"); - - dap_chain_cert_delete(l_cert2); - DAP_DELETE(l_cert_buf); - - dap_pass_msg("Save and load cert in memory successfully"); - - dap_chain_cert_t *l_certf = dap_chain_cert_generate_mem("name 2", a_key_type); - int l_res = dap_chain_cert_save_file(l_certf, CERT_FILE_PATH); - dap_assert_PIF(!l_res, "Fail save cert to file"); - dap_chain_cert_delete(l_certf); - - dap_chain_cert_t *l_certf2 = dap_chain_cert_file_load(CERT_FILE_PATH); - dap_assert_PIF(l_certf2, "Fail load cert from file"); - dap_chain_cert_delete(l_certf2); - // delete temp file - unlink(CERT_FILE_PATH); - - dap_pass_msg("Save and load cert in file successfully"); - -} - -void init_test_case() -{ - dap_enc_key_init(); -} - -void cleanup_test_case() -{ - dap_enc_key_deinit(); -} - -void dap_chain_cert_save_tests_run(void) -{ - dap_print_module_name("dap_chain_cert_save"); - init_test_case(); - - test_cert_memory_file(DAP_ENC_KEY_TYPE_SIG_BLISS); - test_cert_memory_file(DAP_ENC_KEY_TYPE_SIG_TESLA); - test_cert_memory_file(DAP_ENC_KEY_TYPE_SIG_PICNIC); - - cleanup_test_case(); -} +#include <stdint.h> +#include <stdlib.h> +#include <unistd.h> + +#include "dap_test.h" +#include "dap_enc_key.h" +#include "dap_chain_cert.h" +#include "dap_chain_cert_file.h" + +#define CERT_FILE_PATH "cert_file_path.tmp" + +static void test_cert_memory_file(dap_enc_key_type_t a_key_type) +{ + uint32_t l_cert_buf_size = 0; + + dap_chain_cert_t *l_cert = dap_chain_cert_generate_mem("name 1", a_key_type); + dap_assert_PIF(l_cert, "Fail create cert"); + + uint8_t * l_cert_buf = dap_chain_cert_mem_save(l_cert, &l_cert_buf_size); + dap_assert_PIF(l_cert_buf, "Fail save cert to memory"); + dap_chain_cert_delete(l_cert); + + dap_chain_cert_t *l_cert2 = dap_chain_cert_mem_load(l_cert_buf, l_cert_buf_size); + dap_assert_PIF(l_cert2, "Fail read cert from memory"); + dap_chain_cert_delete(l_cert2); + DAP_DELETE(l_cert_buf); + + dap_pass_msg("Save and load cert in memory successfully"); + + dap_chain_cert_t *l_certf = dap_chain_cert_generate_mem("name 2", a_key_type); + int l_res = dap_chain_cert_file_save(l_certf, CERT_FILE_PATH); + dap_assert_PIF(!l_res, "Fail save cert to file"); + dap_chain_cert_delete(l_certf); + + dap_chain_cert_t *l_certf2 = dap_chain_cert_file_load(CERT_FILE_PATH); + dap_assert_PIF(l_certf2, "Fail load cert from file"); + dap_chain_cert_delete(l_certf2); + + // delete temp file + unlink(CERT_FILE_PATH); + + dap_pass_msg("Save and load cert in file successfully"); +} + +void init_test_case() +{ + dap_enc_key_init(); +} + +void cleanup_test_case() +{ + dap_enc_key_deinit(); +} + +void dap_chain_cert_save_tests_run(void) +{ + dap_print_module_name("dap_chain_cert_save"); + init_test_case(); + + test_cert_memory_file(DAP_ENC_KEY_TYPE_SIG_BLISS); + test_cert_memory_file(DAP_ENC_KEY_TYPE_SIG_TESLA); + test_cert_memory_file(DAP_ENC_KEY_TYPE_SIG_PICNIC); + + cleanup_test_case(); +} diff --git a/test/dap_sha3_tests.c b/test/dap_sha3_tests.c new file mode 100644 index 0000000000000000000000000000000000000000..7a58271861c6fb8eed36f2a291b0479e8d4df87d --- /dev/null +++ b/test/dap_sha3_tests.c @@ -0,0 +1,211 @@ +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <stdint.h> +#include <memory.h> +#include <time.h> +#include <stdbool.h> + +#ifdef _WIN32 +#include <windows.h> +#endif + +#include <pthread.h> + +#include "dap_test.h" + +#define BUFSIZE 512 + +#ifdef _MSC_VER + #define DAP_STATIC_INLINE static __forceinline + #define DAP_INLINE __forceinline + #define DAP_ALIGNED(x) __declspec( align(x) ) +#else + #define DAP_STATIC_INLINE static __attribute__((always_inline)) inline + #define DAP_INLINE __attribute__((always_inline)) inline + #define DAP_ALIGNED(x) __attribute__ ((aligned (x))) +#endif + +uint32_t xs30_seed[4] = { 0x3D696D09, 0xCD6BEB33, 0x9D1A0022, 0x9D1B0022 }; + +static inline void zRAND_reset( void ) { + + xs30_seed[0] = 0x3D696D09; + xs30_seed[1] = 0xCD6BEB33; + xs30_seed[2] = 0x9D1A0022; + xs30_seed[3] = 0x9D1B0022; +} + +static inline uint32_t zRAND( void ) { //period 2^96-1 + + uint32_t *zseed = &xs30_seed[0]; + + uint32_t t; + + zseed[0] ^= zseed[0] << 16; + zseed[0] ^= zseed[0] >> 5; + zseed[0] ^= zseed[0] << 1; + + t = zseed[0]; + zseed[0] = zseed[1]; + zseed[1] = zseed[2]; + + zseed[2] = t ^ zseed[0] ^ zseed[1]; + + return zseed[0]; +} + +static inline uint64_t gettime64( void ) +{ + uint64_t t64; + struct timespec now; + + clock_gettime( CLOCK_MONOTONIC, &now ); + t64 = now.tv_sec; + t64 *= 1000000000; + t64 += now.tv_nsec; + + return t64; +} + +static inline double gettimefloat( void ) +{ + return (double)gettime64() / 1000000000.0; +} + +#include "keccak.h" +#include "XKCP/lib/high/Keccak/FIPS202/KeccakHash.h" +#include "fips202.h" +#include "SimpleFIPS202.h" + +#define DAP_CHAIN_HASH_FAST_SIZE 32 + +typedef union dap_chain_hash_fast{ + uint8_t raw[DAP_CHAIN_HASH_FAST_SIZE]; +} dap_chain_hash_fast_t; + +typedef enum dap_hash_type { + DAP_HASH_TYPE_KECCAK = 0, + DAP_HASH_TYPE_SLOW_0 = 1, +} dap_hash_type_t; + +static inline void dap_hash_keccak( const void * a_in, size_t a_in_size, void *a_out, size_t a_out_size ) +{ + keccak((const uint8_t*) a_in, a_in_size, (uint8_t *) a_out,(int) a_out_size ); +} + +static inline void dap_hash(const void * a_data_in, size_t a_data_in_size, + void * a_data_out, size_t a_data_out_size, + dap_hash_type_t a_type ){ + switch (a_type){ + case DAP_HASH_TYPE_KECCAK: + dap_hash_keccak(a_data_in,a_data_in_size, a_data_out,a_data_out_size); + break; +// case DAP_HASH_TYPE_SLOW_0: +// if( a_data_out_size>= dap_hash_slow_size() ){ +// dap_hash_slow(a_data_in,a_data_in_size,(char*) a_data_out); +// } +// break; + } +} + +int dap_hash_fast( const void *a_data_in, size_t a_data_in_size, dap_chain_hash_fast_t *a_hash_out ) +{ + if(!a_data_in || !a_data_in_size || !a_hash_out) + return -1; + + dap_hash( a_data_in, a_data_in_size, a_hash_out->raw, sizeof(a_hash_out->raw), + DAP_HASH_TYPE_KECCAK); + + return 1; +} + +#define DATA_SIZE 2048 + +uint8_t data[8192]; +uint8_t data2[8192]; + +Keccak_HashInstance ki0; + +#define print_hash( x ) \ + printf( " hash = " ); \ + for( int g = 0; g < 32; ++g ) \ + printf( "%02X", x[g] ); \ + printf( "\n" ); \ + +void dap_sha3_tests_run(void) +{ + dap_chain_hash_fast_t hash0; + uint64_t start; + double t; + + uint8_t hash2[32]; + + dap_print_module_name("dap_sha3_tests_run( )"); + +// printf("dap_hash_fast( ) of %u data x %u ...\n", DATA_SIZE, 65536 ); + + for (int i = 0; i < DATA_SIZE; ++ i ) { + data[i] = zRAND( ) & 255; + } + + zRAND_reset( ); + start = gettime64( ); + + for (int h = 0; h < 65536; h ++ ) { + dap_hash_fast( &data[0], DATA_SIZE, &hash0 ); + } + + t = (double)(gettime64( ) - start) / 1000000000.0; + benchmark_mgs_rate( "dap_hash_fast_sha3(monero_crypto)(2048)", 65536.0 / t ); + print_hash( hash0.raw ); + +// printf("Keccak_sha_256( ) of %u data x %u ...\n", DATA_SIZE, 65536 ); + start = gettime64( ); + + for (int h = 0; h < 65536; h ++ ) { + SHA3_256( &hash2[0], &data[0], DATA_SIZE ); + } + t = (double)(gettime64( ) - start) / 1000000000.0; + benchmark_mgs_rate( "SHA_256(XKCP)(2048)", 65536.0 / t ); + print_hash( hash2 ); + +// printf("sha3_512(dap_crypto) of %u data x %u ...\n", DATA_SIZE, 65536 ); + start = gettime64( ); + + for (int h = 0; h < 65536; h ++ ) { + sha3_256( &hash2[0], &data[0], DATA_SIZE ); + } + + t = (double)(gettime64( ) - start) / 1000000000.0; + benchmark_mgs_rate( "sha3_256(dap_crypto)(2048)", 65536.0 / t ); + + print_hash( hash2 ); + +// printf("shake256(dap_crypto) of %u data x %u ...\n", DATA_SIZE, 65536 ); + start = gettime64( ); + + for (int h = 0; h < 65536; h ++ ) { + shake256( &hash2[0], 32, &data[0], DATA_SIZE ); + } + + t = (double)(gettime64( ) - start) / 1000000000.0; + benchmark_mgs_rate( "shake256(dap_crypto)(2048)", 65536.0 / t ); + print_hash( hash2 ); + +// printf("SHAKE256 of %u data x %u ...\n", DATA_SIZE, 65536 ); + start = gettime64( ); + + for (int h = 0; h < 65536; h ++ ) { + SHAKE256( &hash2[0], 32, &data[0], DATA_SIZE ); + } + + t = (double)(gettime64( ) - start) / 1000000000.0; + benchmark_mgs_rate( "SHAKE256(XKCP)(2048)", 65536.0 / t ); + + print_hash( hash2 ); + + dap_pass_msg("dap_sha3_tests_run( )"); + + return; +} \ No newline at end of file diff --git a/test/main.c b/test/main.c index fd16469cbd7f6f591504a065d93d4de445e09b7b..865be7a077b3b7ddc336dcb1449eb046528b1e77 100755 --- a/test/main.c +++ b/test/main.c @@ -1,9 +1,12 @@ -#include "dap_common.h" -#include "dap_chain_cert_save_tests.h" - -int main(void) { - // switch off debug info from library - set_log_level(L_CRITICAL); - dap_chain_cert_save_tests_run(); - return 0; -} +#include "dap_common.h" +#include "dap_chain_cert_save_tests.h" + +void dap_sha3_tests_run(void); + +int main(void) { + // switch off debug info from library + dap_log_level_set(L_CRITICAL); + dap_chain_cert_save_tests_run(); + dap_sha3_tests_run(); + return 0; +}