Skip to content
Snippets Groups Projects
Commit 0a66568d authored by anta999's avatar anta999
Browse files

fixed cert tests

parent 5e4b7a58
No related branches found
No related tags found
1 merge request!24Support 3689
[submodule "libdap"]
path = libdap
url = https://gitlab.demlabs.net/cellframe/libdap
branch = master
[submodule "test/libdap-test"]
path = test/libdap-test
url = https://gitlab.demlabs.net/cellframe/libdap-test/
branch = master
[submodule "libdap-chain"]
path = 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
...@@ -11,7 +11,7 @@ before_install: ...@@ -11,7 +11,7 @@ before_install:
script: script:
- mkdir build - mkdir build
- cd build - cd build
- cmake ../ - cmake -DBUILD_DAP_CHAIN_CRYPTO_TESTS=ON ../
- make - make
- ctest --verbose - ctest --verbose
...@@ -19,3 +19,11 @@ addons: ...@@ -19,3 +19,11 @@ addons:
apt: apt:
sources: sources:
- ubuntu-toolchain-r-test - ubuntu-toolchain-r-test
packages:
- libev-dev
- libjson-c-dev
- libmagic-dev
- libmemcached-dev
- libldb-dev
- libtalloc-dev
- libtevent-dev
cmake_minimum_required(VERSION 2.8) cmake_minimum_required(VERSION 2.8)
project (dap_chain_crypto) project (dap_chain_crypto)
set(DAP_CHAIN_CRYPTO_SRCS set(DAP_CHAIN_CRYPTO_SRCS
dap_hash.c dap_hash.c
dap_hash_fusion.c dap_hash_fusion.c
dap_hash_keccak.c dap_hash_keccak.c
dap_hash_slow.c dap_hash_slow.c
dap_chain_pkey.c dap_chain_pkey.c
dap_chain_sign.c dap_chain_sign.c
dap_chain_cert.c dap_chain_cert.c
dap_chain_cert_file.c dap_chain_cert_file.c
) )
set(DAP_CHAIN_CRYPTO_HEADERS set(DAP_CHAIN_CRYPTO_HEADERS
dap_hash.h dap_hash.h
dap_hash_fusion.h dap_hash_fusion.h
dap_hash_keccak.h dap_hash_keccak.h
dap_hash_slow.h dap_hash_slow.h
dap_chain_pkey.h dap_chain_pkey.h
dap_chain_sign.h dap_chain_sign.h
dap_chain_cert.h dap_chain_cert.h
dap_chain_cert_file.h dap_chain_cert_file.h
) )
if(NOT (${SUBMODULES_NO_BUILD} MATCHES ON)) if(NOT (${SUBMODULES_NO_BUILD} MATCHES ON))
add_subdirectory(libdap) set(SUBMODULES_NO_BUILD ON)
add_subdirectory(libdap-crypto)
add_subdirectory(libdap-chain) # Check whether we're on a 32-bit or 64-bit system
enable_testing() if(CMAKE_SIZEOF_VOID_P EQUAL "8")
add_subdirectory(test) set(DEFAULT_BUILD_64 ON)
endif() else()
set(DEFAULT_BUILD_64 OFF)
add_subdirectory(monero_crypto) endif()
option(BUILD_64 "Build for 64-bit? 'OFF' builds for 32-bit." ${DEFAULT_BUILD_64})
include_directories("${monero_crypto_INCLUDE_DIRS}")
add_definitions ("${monero_crypto_DEFINITIONS}") add_definitions ("-DDAP_SERVER")
add_definitions ("-DNODE_NETNAME=\"kelvin\"")
add_library(${PROJECT_NAME} STATIC ${DAP_CHAIN_CRYPTO_SRCS} ${DAP_CHAIN_CRYPTO_HEADERS})
set(_CCOPT "-Wall -O2 -pg -fPIC -fno-pie -no-pie")
target_include_directories(dap_chain_crypto INTERFACE .) set(_LOPT "-pg")
target_link_libraries(dap_chain_crypto dap_core dap_crypto dap_chain monero_crypto) set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -pg")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${_CCOPT}")
set(${PROJECT_NAME}_DEFINITIONS CACHE INTERNAL "${PROJECT_NAME}: Definitions" FORCE) set(CMAKE_LINKER_FLAGS "${CMAKE_LINKER_FLAGS} ${_LOPT}")
set(${PROJECT_NAME}_INCLUDE_DIRS ${PROJECT_SOURCE_DIR} CACHE INTERNAL "${PROJECT_NAME}: Include Directories" FORCE) 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()
/* /*
* Authors: * Authors:
* Dmitriy A. Gearasimov <kahovski@gmail.com> * Dmitriy A. Gearasimov <kahovski@gmail.com>
* DeM Labs Inc. https://demlabs.net * DeM Labs Inc. https://demlabs.net
* DeM Labs Open source community https://github.com/demlabsinc * DeM Labs Open source community https://github.com/demlabsinc
* Copyright (c) 2017-2018 * Copyright (c) 2017-2018
* All rights reserved. * All rights reserved.
This file is part of DAP (Deus Applications Prototypes) the open source project 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 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 it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or the Free Software Foundation, either version 3 of the License, or
(at your option) any later version. (at your option) any later version.
DAP is distributed in the hope that it will be useful, DAP is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License 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/>. along with any DAP based project. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include "dap_common.h" #include "dap_common.h"
#include "dap_hash.h" #include "dap_hash.h"
#define LOG_TAG "dap_hash" #include "KeccakHash.h"
#include "SimpleFIPS202.h"
int dap_hash_fast(const void *a_data_in, size_t a_data_in_size, dap_chain_hash_fast_t *a_hash_out)
{ #define LOG_TAG "dap_hash"
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), int dap_hash_fast(const void *a_data_in, size_t a_data_in_size, dap_chain_hash_fast_t *a_hash_out)
DAP_HASH_TYPE_KECCAK); {
return 1; 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),
bool dap_hash_fast_is_blank(dap_chain_hash_fast_t *a_hash) // DAP_HASH_TYPE_KECCAK);
{ SHA3_256( (unsigned char *)a_hash_out, (const unsigned char *)a_data_in, a_data_in_size );
if(!a_hash)
return true; return 1;
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(!a_hash1 || !a_hash2)
return false;
if(!memcmp(a_hash1, a_hash2, sizeof(dap_chain_hash_fast_t)))
return true;
return false;
}
/* /*
* Authors: * Authors:
* Dmitriy A. Gearasimov <kahovski@gmail.com> * Dmitriy A. Gearasimov <kahovski@gmail.com>
* DeM Labs Inc. https://demlabs.net * DeM Labs Inc. https://demlabs.net
* DeM Labs Open source community https://github.com/demlabsinc * DeM Labs Open source community https://github.com/demlabsinc
* Copyright (c) 2017-2018 * Copyright (c) 2017-2018
* All rights reserved. * All rights reserved.
This file is part of DAP (Deus Applications Prototypes) the open source project 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 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 it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or the Free Software Foundation, either version 3 of the License, or
(at your option) any later version. (at your option) any later version.
DAP is distributed in the hope that it will be useful, DAP is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License 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/>. along with any DAP based project. If not, see <http://www.gnu.org/licenses/>.
*/ */
#pragma once #pragma once
#include <stddef.h> #include <stddef.h>
#include <stdbool.h> #include <stdbool.h>
#include <stdint.h>
#include "dap_hash_slow.h"
#include "dap_hash_keccak.h" #include "dap_hash_slow.h"
#include "dap_chain_common.h" #include "dap_hash_keccak.h"
#include "dap_chain_common.h"
typedef enum dap_hash_type { #include "KeccakHash.h"
DAP_HASH_TYPE_KECCAK = 0, #include "SimpleFIPS202.h"
DAP_HASH_TYPE_SLOW_0 = 1,
} dap_hash_type_t; #define DAP_HASH_FAST_SIZE 32
static inline void dap_hash(const void * a_data_in, size_t a_data_in_size, typedef enum dap_hash_type {
void * a_data_out, size_t a_data_out_size, DAP_HASH_TYPE_KECCAK = 0,
dap_hash_type_t a_type ){ DAP_HASH_TYPE_SLOW_0 = 1,
switch (a_type){ } dap_hash_type_t;
case DAP_HASH_TYPE_KECCAK:
dap_hash_keccak(a_data_in,a_data_in_size, a_data_out,a_data_out_size); static inline int dap_hash_fast( const void *a_data_in, size_t a_data_in_size, uint8_t *a_hash_out )
break; {
case DAP_HASH_TYPE_SLOW_0: if (!a_data_in || !a_data_in_size || !a_hash_out)
if( a_data_out_size>= dap_hash_slow_size() ){ return -1;
dap_hash_slow(a_data_in,a_data_in_size,(char*) a_data_out);
} // dap_hash(a_data_in, a_data_in_size, a_hash_out->raw, sizeof(a_hash_out->raw),
break; // DAP_HASH_TYPE_KECCAK);
}
SHA3_256( (unsigned char *)a_hash_out, (const unsigned char *)a_data_in, a_data_in_size );
}
return 1;
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); 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);
Subproject commit 67993d1f4cec44de464acee32a4d4f71d51c7e7d
Subproject commit b94cdd0d9ea3e10b5ade8a5f8073d34521a2783a
Subproject commit 6ef661685f2792242433bf340f253d255f39e881
Subproject commit 94d4a28dd97cc1395295e1582839b58ba36e2463
Subproject commit 15d5b398125de01ba2525c76cd76c4ba590c4e2b
Subproject commit 5af381b67ea3e6fcaa76a3620cdc11541a2212bf
Subproject commit be35813a341b88738d909329974407cab87c0143
Subproject commit 892160fc248cccd1d3749fc70766a07128f450ac
Subproject commit 27bef519e72519abbd1c1e8b65274526cd006c3a
Subproject commit 6249887fdd5c9ed88eb26c1e10f853ea9f7001b6
Subproject commit b92bfa29b7994665ea80a98718a121f6e9576c8f
Subproject commit 6778521f9f646e2985994e63f470067b3e2c1e48
Subproject commit bdab475c9dfe0ad876cd642a798e1b0b54ca314e
Subproject commit 08bda8439038c79927427e0e531863a05193d478
Subproject commit 0dcee9fe68ab7daaf42ed76d7bce0a1a5dc51631
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment