From ea2107d33af86819e961a17c30a6e3a10908b84a Mon Sep 17 00:00:00 2001 From: Nathan Hourt Date: Thu, 17 Mar 2016 17:27:21 -0500 Subject: [PATCH 001/260] Prevent websocketpp from polluting installs When clients of fc (such as graphene) do an install (via `make install` or similar), websocketpp was installing as well. This commit prevents this from happening. --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index eeadd2b0b..53ac49f5e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -249,7 +249,7 @@ configure_file("${CMAKE_CURRENT_SOURCE_DIR}/src/git_revision.cpp.in" "${CMAKE_CU list(APPEND sources "${CMAKE_CURRENT_BINARY_DIR}/git_revision.cpp") list(APPEND sources ${fc_headers}) -add_subdirectory( vendor/websocketpp ) +add_subdirectory( vendor/websocketpp EXCLUDE_FROM_ALL ) add_subdirectory( vendor/udt4 ) setup_library( fc SOURCES ${sources} LIBRARY_TYPE STATIC DONT_INSTALL_LIBRARY ) From 397c10ce1982f1c007a1efc38454ff63f85c1eed Mon Sep 17 00:00:00 2001 From: Nathan Hourt Date: Thu, 17 Mar 2016 17:41:22 -0500 Subject: [PATCH 002/260] Fix installation FC now installs properly with a `make install` --- CMakeLists.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 53ac49f5e..f1bcdcea8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -252,7 +252,8 @@ list(APPEND sources ${fc_headers}) add_subdirectory( vendor/websocketpp EXCLUDE_FROM_ALL ) add_subdirectory( vendor/udt4 ) -setup_library( fc SOURCES ${sources} LIBRARY_TYPE STATIC DONT_INSTALL_LIBRARY ) +setup_library( fc SOURCES ${sources} LIBRARY_TYPE STATIC ) +install( DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/include/" DESTINATION include ) # begin readline stuff find_package(Curses) From 2bd8e92a756c4e9e3d43c6e5c2aebddaf6b7db27 Mon Sep 17 00:00:00 2001 From: Eric Frias Date: Fri, 18 Mar 2016 09:32:55 -0400 Subject: [PATCH 003/260] Windows build fixes (disable compiling permessage-deflate, which isn't very useful right now. The build error will probably be resolved in websocketpp by the time we need it) --- CMakeLists.txt | 1 + src/network/http/websocket.cpp | 42 +++++++++++++++++++++++++++++----- 2 files changed, 37 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index eeadd2b0b..69c4dffd1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -316,6 +316,7 @@ target_include_directories(fc ${CMAKE_CURRENT_SOURCE_DIR}/vendor/udt4/src ${CMAKE_CURRENT_SOURCE_DIR}/vendor/websocketpp ${CMAKE_CURRENT_SOURCE_DIR}/vendor/secp256k1-zkp + ${ZLIB_INCLUDE_DIR} ) #target_link_libraries( fc PUBLIC udt ${Boost_LIBRARIES} ${OPENSSL_LIBRARIES} ${ZLIB_LIBRARIES} ${PLATFORM_SPECIFIC_LIBS} ${RPCRT4} ${CMAKE_DL_LIBS} ${rt_library} ${ECC_LIB} ) diff --git a/src/network/http/websocket.cpp b/src/network/http/websocket.cpp index 81a7cad11..b8a3d3cb7 100644 --- a/src/network/http/websocket.cpp +++ b/src/network/http/websocket.cpp @@ -1,9 +1,19 @@ #include + +#ifndef WIN32 +// websocket++ currently does not build correctly with permessage deflate enabled +// since chrome does not work with websocketpp's implementation of permessage-deflate +// yet, I'm just disabling it on windows instead of trying to fix the build error. +# define ENABLE_WEBSOCKET_PERMESSAGE_DEFLATE +#endif + #include #include #include #include -#include +#ifdef ENABLE_WEBSOCKET_PERMESSAGE_DEFLATE +# include +#endif #include #include @@ -56,7 +66,8 @@ namespace fc { namespace http { // override default value of 5 sec timeout static const long timeout_open_handshake = 0; }; - + +#ifdef ENABLE_WEBSOCKET_PERMESSAGE_DEFLATE struct asio_with_stub_log_and_deflate : public websocketpp::config::asio { typedef asio_with_stub_log_and_deflate type; typedef asio base; @@ -98,6 +109,7 @@ namespace fc { namespace http { // override default value of 5 sec timeout static const long timeout_open_handshake = 0; }; +#endif ENABLE_WEBSOCKET_PERMESSAGE_DEFLATE struct asio_tls_stub_log : public websocketpp::config::asio_tls { typedef asio_tls_stub_log type; @@ -132,6 +144,7 @@ namespace fc { namespace http { transport_type; }; +#ifdef ENABLE_WEBSOCKET_PERMESSAGE_DEFLATE struct asio_tls_stub_log_and_deflate : public websocketpp::config::asio_tls { typedef asio_tls_stub_log_and_deflate type; typedef asio_tls base; @@ -169,6 +182,7 @@ namespace fc { namespace http { typedef websocketpp::extensions::permessage_deflate::enabled permessage_deflate_type; }; +#endif using websocketpp::connection_hdl; @@ -513,10 +527,18 @@ namespace fc { namespace http { } // namespace detail websocket_server::websocket_server(bool enable_permessage_deflate /* = true */) : - my( enable_permessage_deflate ? + my( +#ifdef ENABLE_WEBSOCKET_PERMESSAGE_DEFLATE + enable_permessage_deflate ? (detail::abstract_websocket_server*)new detail::websocket_server_impl : +#endif (detail::abstract_websocket_server*)new detail::websocket_server_impl ) - {} + { +#ifndef ENABLE_WEBSOCKET_PERMESSAGE_DEFLATE + if (enable_permessage_deflate) + elog("Websocket permessage-deflate requested but not enabled during compile"); +#endif + } websocket_server::~websocket_server(){} void websocket_server::on_connection( const on_connection_handler& handler ) @@ -543,10 +565,18 @@ namespace fc { namespace http { websocket_tls_server::websocket_tls_server(const string& server_pem, const string& ssl_password, bool enable_permessage_deflate /* = true */) : - my( enable_permessage_deflate ? + my( +#ifdef ENABLE_WEBSOCKET_PERMESSAGE_DEFLATE + enable_permessage_deflate ? (detail::abstract_websocket_server*)new detail::websocket_tls_server_impl(server_pem, ssl_password) : +#endif (detail::abstract_websocket_server*)new detail::websocket_tls_server_impl(server_pem, ssl_password) ) - {} + { +#ifndef ENABLE_WEBSOCKET_PERMESSAGE_DEFLATE + if (enable_permessage_deflate) + elog("Websocket permessage-deflate requested but not enabled during compile"); +#endif + } websocket_tls_server::~websocket_tls_server(){} void websocket_tls_server::on_connection( const on_connection_handler& handler ) From 5e83b581c0ab466c47b276c56a36e2d922175f90 Mon Sep 17 00:00:00 2001 From: Nathan Hourt Date: Thu, 17 Mar 2016 17:27:21 -0500 Subject: [PATCH 004/260] Prevent websocketpp from polluting installs When clients of fc (such as graphene) do an install (via `make install` or similar), websocketpp was installing as well. This commit prevents this from happening. --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b6d777442..af13b228f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -251,7 +251,7 @@ configure_file("${CMAKE_CURRENT_SOURCE_DIR}/src/git_revision.cpp.in" "${CMAKE_CU list(APPEND sources "${CMAKE_CURRENT_BINARY_DIR}/git_revision.cpp") list(APPEND sources ${fc_headers}) -add_subdirectory( vendor/websocketpp ) +add_subdirectory( vendor/websocketpp EXCLUDE_FROM_ALL ) add_subdirectory( vendor/equihash ) setup_library( fc SOURCES ${sources} LIBRARY_TYPE STATIC DONT_INSTALL_LIBRARY ) From 159daffb25ba33d5bbceda312b8c75df5129f90f Mon Sep 17 00:00:00 2001 From: Nathan Hourt Date: Thu, 17 Mar 2016 17:41:22 -0500 Subject: [PATCH 005/260] Fix installation FC now installs properly with a `make install` --- CMakeLists.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index af13b228f..39f1dca14 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -254,7 +254,8 @@ list(APPEND sources ${fc_headers}) add_subdirectory( vendor/websocketpp EXCLUDE_FROM_ALL ) add_subdirectory( vendor/equihash ) -setup_library( fc SOURCES ${sources} LIBRARY_TYPE STATIC DONT_INSTALL_LIBRARY ) +setup_library( fc SOURCES ${sources} LIBRARY_TYPE STATIC ) +install( DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/include/" DESTINATION include ) # begin readline stuff find_package(Curses) From ca9a6977d93df48e12d92e675c1a66fa9f6065cf Mon Sep 17 00:00:00 2001 From: Nathan Hourt Date: Tue, 22 Mar 2016 17:19:47 -0500 Subject: [PATCH 006/260] Add cryptonomex's custom secp256k1 to install on non-Windows This should be done on Windows too, but I don't know how and I don't have a Windows test box anyways. --- CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 39f1dca14..fd6d2019f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -98,6 +98,7 @@ else ( MSVC ) set_property(TARGET secp256k1 PROPERTY IMPORTED_LOCATION ${binary_dir}/.libs/libsecp256k1${CMAKE_STATIC_LIBRARY_SUFFIX}) set_property(TARGET secp256k1 PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${CMAKE_CURRENT_SOURCE_DIR}/vendor/secp256k1-zkp/include) add_dependencies(secp256k1 project_secp256k1) + install( FILES ${binary_dir}/.libs/libsecp256k1${CMAKE_STATIC_LIBRARY_SUFFIX} DESTINATION lib/cryptonomex ) endif ( MSVC ) # End configure secp256k1-zkp From df2642e9311b6d4d29729ac6a7d9ef65206afc89 Mon Sep 17 00:00:00 2001 From: Vikram Rajkumar Date: Fri, 13 Jan 2017 13:34:44 -0600 Subject: [PATCH 007/260] Revert "Windows build fixes (disable compiling permessage-deflate, which isn't very useful right now. The build error will probably be resolved in websocketpp by the time we need it)" This reverts commit 2bd8e92a756c4e9e3d43c6e5c2aebddaf6b7db27. --- CMakeLists.txt | 1 - src/network/http/websocket.cpp | 42 +++++----------------------------- 2 files changed, 6 insertions(+), 37 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 73e6b1bd2..f1bcdcea8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -317,7 +317,6 @@ target_include_directories(fc ${CMAKE_CURRENT_SOURCE_DIR}/vendor/udt4/src ${CMAKE_CURRENT_SOURCE_DIR}/vendor/websocketpp ${CMAKE_CURRENT_SOURCE_DIR}/vendor/secp256k1-zkp - ${ZLIB_INCLUDE_DIR} ) #target_link_libraries( fc PUBLIC udt ${Boost_LIBRARIES} ${OPENSSL_LIBRARIES} ${ZLIB_LIBRARIES} ${PLATFORM_SPECIFIC_LIBS} ${RPCRT4} ${CMAKE_DL_LIBS} ${rt_library} ${ECC_LIB} ) diff --git a/src/network/http/websocket.cpp b/src/network/http/websocket.cpp index b8a3d3cb7..81a7cad11 100644 --- a/src/network/http/websocket.cpp +++ b/src/network/http/websocket.cpp @@ -1,19 +1,9 @@ #include - -#ifndef WIN32 -// websocket++ currently does not build correctly with permessage deflate enabled -// since chrome does not work with websocketpp's implementation of permessage-deflate -// yet, I'm just disabling it on windows instead of trying to fix the build error. -# define ENABLE_WEBSOCKET_PERMESSAGE_DEFLATE -#endif - #include #include #include #include -#ifdef ENABLE_WEBSOCKET_PERMESSAGE_DEFLATE -# include -#endif +#include #include #include @@ -66,8 +56,7 @@ namespace fc { namespace http { // override default value of 5 sec timeout static const long timeout_open_handshake = 0; }; - -#ifdef ENABLE_WEBSOCKET_PERMESSAGE_DEFLATE + struct asio_with_stub_log_and_deflate : public websocketpp::config::asio { typedef asio_with_stub_log_and_deflate type; typedef asio base; @@ -109,7 +98,6 @@ namespace fc { namespace http { // override default value of 5 sec timeout static const long timeout_open_handshake = 0; }; -#endif ENABLE_WEBSOCKET_PERMESSAGE_DEFLATE struct asio_tls_stub_log : public websocketpp::config::asio_tls { typedef asio_tls_stub_log type; @@ -144,7 +132,6 @@ namespace fc { namespace http { transport_type; }; -#ifdef ENABLE_WEBSOCKET_PERMESSAGE_DEFLATE struct asio_tls_stub_log_and_deflate : public websocketpp::config::asio_tls { typedef asio_tls_stub_log_and_deflate type; typedef asio_tls base; @@ -182,7 +169,6 @@ namespace fc { namespace http { typedef websocketpp::extensions::permessage_deflate::enabled permessage_deflate_type; }; -#endif using websocketpp::connection_hdl; @@ -527,18 +513,10 @@ namespace fc { namespace http { } // namespace detail websocket_server::websocket_server(bool enable_permessage_deflate /* = true */) : - my( -#ifdef ENABLE_WEBSOCKET_PERMESSAGE_DEFLATE - enable_permessage_deflate ? + my( enable_permessage_deflate ? (detail::abstract_websocket_server*)new detail::websocket_server_impl : -#endif (detail::abstract_websocket_server*)new detail::websocket_server_impl ) - { -#ifndef ENABLE_WEBSOCKET_PERMESSAGE_DEFLATE - if (enable_permessage_deflate) - elog("Websocket permessage-deflate requested but not enabled during compile"); -#endif - } + {} websocket_server::~websocket_server(){} void websocket_server::on_connection( const on_connection_handler& handler ) @@ -565,18 +543,10 @@ namespace fc { namespace http { websocket_tls_server::websocket_tls_server(const string& server_pem, const string& ssl_password, bool enable_permessage_deflate /* = true */) : - my( -#ifdef ENABLE_WEBSOCKET_PERMESSAGE_DEFLATE - enable_permessage_deflate ? + my( enable_permessage_deflate ? (detail::abstract_websocket_server*)new detail::websocket_tls_server_impl(server_pem, ssl_password) : -#endif (detail::abstract_websocket_server*)new detail::websocket_tls_server_impl(server_pem, ssl_password) ) - { -#ifndef ENABLE_WEBSOCKET_PERMESSAGE_DEFLATE - if (enable_permessage_deflate) - elog("Websocket permessage-deflate requested but not enabled during compile"); -#endif - } + {} websocket_tls_server::~websocket_tls_server(){} void websocket_tls_server::on_connection( const on_connection_handler& handler ) From 9d383077fa754fb872184526c2d5b9ba04708c86 Mon Sep 17 00:00:00 2001 From: Vikram Rajkumar Date: Fri, 13 Jan 2017 13:35:48 -0600 Subject: [PATCH 008/260] Revert "change json seralization of map to be object rather than array of pairs" This reverts commit a421e280488385cab26a42153f7ce3c8d5b6281f. --- include/fc/variant.hpp | 9 --------- include/fc/variant_object.hpp | 36 ----------------------------------- src/rpc/websocket_api.cpp | 1 - src/variant_object.cpp | 1 - 4 files changed, 47 deletions(-) diff --git a/include/fc/variant.hpp b/include/fc/variant.hpp index ccb2960d7..092de0aa7 100644 --- a/include/fc/variant.hpp +++ b/include/fc/variant.hpp @@ -93,17 +93,10 @@ namespace fc template void from_variant( const variant& var, fc::flat_map& vo ); - template - void to_variant( const std::map& var, variant& vo ); - template - void from_variant( const variant& var, std::map& vo ); - template void to_variant( const std::map& var, variant& vo ); template void from_variant( const variant& var, std::map& vo ); - - template void to_variant( const std::multimap& var, variant& vo ); template @@ -414,8 +407,6 @@ namespace fc vo.insert( itr->as< std::pair >() ); } - - template void to_variant( const std::map& var, variant& vo ) { diff --git a/include/fc/variant_object.hpp b/include/fc/variant_object.hpp index 99b0d869d..5a39c8074 100644 --- a/include/fc/variant_object.hpp +++ b/include/fc/variant_object.hpp @@ -5,7 +5,6 @@ namespace fc { - using std::map; class mutable_variant_object; /** @@ -67,15 +66,6 @@ namespace fc /** initializes the first key/value pair in the object */ variant_object( string key, variant val ); - - template - variant_object( const map& values ) - :_key_value( new std::vector() ) { - _key_value->reserve( values.size() ); - for( const auto& item : values ) { - _key_value->emplace_back( entry( item.first, fc::variant(item.second) ) ); - } - } template variant_object( string key, T&& val ) @@ -206,15 +196,6 @@ namespace fc mutable_variant_object(); - template - mutable_variant_object( const map& values ) - :_key_value( new std::vector() ) { - _key_value->reserve( values.size() ); - for( const auto& item : values ) { - _key_value->emplace_back( variant_object::entry( item.first, fc::variant(item.second) ) ); - } - } - /** initializes the first key/value pair in the object */ mutable_variant_object( string key, variant val ); template @@ -231,8 +212,6 @@ namespace fc mutable_variant_object& operator=( mutable_variant_object&& ); mutable_variant_object& operator=( const mutable_variant_object& ); mutable_variant_object& operator=( const variant_object& ); - - private: std::unique_ptr< std::vector< entry > > _key_value; friend class variant_object; @@ -242,19 +221,4 @@ namespace fc /** @ingroup Serializable */ void from_variant( const variant& var, mutable_variant_object& vo ); - template - void to_variant( const std::map& var, variant& vo ) - { - vo = variant_object( var ); - } - - template - void from_variant( const variant& var, std::map& vo ) - { - const auto& obj = var.get_object(); - vo.clear(); - for( auto itr = obj.begin(); itr != obj.end(); ++itr ) - vo[itr->key()] = itr->value().as(); - } - } // namespace fc diff --git a/src/rpc/websocket_api.cpp b/src/rpc/websocket_api.cpp index 0ff93048f..6342b6f67 100644 --- a/src/rpc/websocket_api.cpp +++ b/src/rpc/websocket_api.cpp @@ -85,7 +85,6 @@ std::string websocket_api_connection::on_message( const std::string& message, bool send_message /* = true */ ) { - wdump((message)); try { auto var = fc::json::from_string(message); diff --git a/src/variant_object.cpp b/src/variant_object.cpp index 38851b07b..6f3b1dcc1 100644 --- a/src/variant_object.cpp +++ b/src/variant_object.cpp @@ -163,7 +163,6 @@ namespace fc return *this; } - void to_variant( const variant_object& var, variant& vo ) { vo = variant(var); From d1faea2bde66a605abf6e514803c3dc61f12d61b Mon Sep 17 00:00:00 2001 From: Vikram Rajkumar Date: Thu, 12 Jan 2017 18:54:00 -0600 Subject: [PATCH 009/260] Revert incorrect start of boost compatibility update --- src/thread/context.hpp | 42 +++++++---------------------------------- src/thread/thread_d.hpp | 36 +++-------------------------------- 2 files changed, 10 insertions(+), 68 deletions(-) diff --git a/src/thread/context.hpp b/src/thread/context.hpp index 31bfbaaa0..f6e8a7749 100644 --- a/src/thread/context.hpp +++ b/src/thread/context.hpp @@ -4,8 +4,6 @@ #include #include -#include - #include #if BOOST_VERSION >= 105400 @@ -45,17 +43,12 @@ namespace fc { struct context { typedef fc::context* ptr; -#if BOOST_VERSION >= 105400 // && BOOST_VERSION <= 106100 +#if BOOST_VERSION >= 105400 bco::stack_context stack_ctx; #endif -#if BOOST_VERSION >= 106100 - typedef bc::detail::transfer_t transfer_t; -#else - typedef intptr_t transfer_t; -#endif - context( void (*sf)(transfer_t), stack_allocator& alloc, fc::thread* t ) + context( void (*sf)(intptr_t), stack_allocator& alloc, fc::thread* t ) : caller_context(0), stack_alloc(&alloc), next_blocked(0), @@ -70,13 +63,7 @@ namespace fc { cur_task(0), context_posted_num(0) { -#if BOOST_VERSION >= 106100 - // std::cerr<< "HERE: "<< BOOST_VERSION <<"\n"; - //my_context = new bc::execution_context( [=]( bc::execution_context sink, intptr_t self ){ std::cerr<<"in ex\n"; sf(self); std::cerr<<"exit ex\n"; return sink; } ); - size_t stack_size = FC_CONTEXT_STACK_SIZE; - alloc.allocate(stack_ctx, stack_size); - my_context = bc::detail::make_fcontext( stack_ctx.sp, stack_ctx.size, sf ); -#elif BOOST_VERSION >= 105600 +#if BOOST_VERSION >= 105600 size_t stack_size = FC_CONTEXT_STACK_SIZE; alloc.allocate(stack_ctx, stack_size); my_context = bc::make_fcontext( stack_ctx.sp, stack_ctx.size, sf); @@ -97,7 +84,7 @@ namespace fc { } context( fc::thread* t) : -#if BOOST_VERSION >= 105600 && BOOST_VERSION <= 106100 +#if BOOST_VERSION >= 105600 my_context(nullptr), #elif BOOST_VERSION >= 105300 my_context(new bc::fcontext_t), @@ -115,21 +102,10 @@ namespace fc { complete(false), cur_task(0), context_posted_num(0) - { - -#if BOOST_VERSION >= 106100 - /* - bc::execution_context tmp( [=]( bc::execution_context sink, intptr_t ) { std::cerr<<"get current\n"; return sink; } ); - auto result = tmp(0); - my_context = new bc::execution_context( std::move( std::get<0>(result) ) ); - */ -#endif - } + {} ~context() { -#if BOOST_VERSION >= 106100 - // delete my_context; -#elif BOOST_VERSION >= 105600 +#if BOOST_VERSION >= 105600 if(stack_alloc) stack_alloc->deallocate( stack_ctx ); #elif BOOST_VERSION >= 105400 @@ -233,11 +209,7 @@ namespace fc { - -#if BOOST_VERSION >= 106100 - //bc::execution_context* my_context; - bc::detail::fcontext_t my_context; -#elif BOOST_VERSION >= 105300 && BOOST_VERSION < 105600 +#if BOOST_VERSION >= 105300 && BOOST_VERSION < 105600 bc::fcontext_t* my_context; #else bc::fcontext_t my_context; diff --git a/src/thread/thread_d.hpp b/src/thread/thread_d.hpp index 940a2801f..941b2fa01 100644 --- a/src/thread/thread_d.hpp +++ b/src/thread/thread_d.hpp @@ -18,8 +18,6 @@ namespace fc { class thread_d { public: - fc::context* prev_ctx = nullptr; - thread_d(fc::thread& s) :self(s), boost_thread(0), task_in_queue(0), @@ -399,12 +397,7 @@ namespace fc { } // slog( "jump to %p from %p", next, prev ); // fc_dlog( logger::get("fc_context"), "from ${from} to ${to}", ( "from", int64_t(prev) )( "to", int64_t(next) ) ); -#if BOOST_VERSION >= 106100 - prev_ctx = prev; - std::cerr<<"start jumping to existing context...\n"; - bc::detail::jump_fcontext( next->my_context, this ); - std::cerr<<"back from jumping to existing context\n"; -#elif BOOST_VERSION >= 105600 +#if BOOST_VERSION >= 105600 bc::jump_fcontext( &prev->my_context, next->my_context, 0 ); #elif BOOST_VERSION >= 105300 bc::jump_fcontext( prev->my_context, next->my_context, 0 ); @@ -446,16 +439,7 @@ namespace fc { // slog( "jump to %p from %p", next, prev ); // fc_dlog( logger::get("fc_context"), "from ${from} to ${to}", ( "from", int64_t(prev) )( "to", int64_t(next) ) ); -#if BOOST_VERSION >= 106100 - //(*next->my_context)( (intptr_t)this ); - //bc::detail::transfer_t tran; tran.data = this; - std::cerr << "start prev->my_context = " << prev->my_context <<"... \n"; - std::cerr << "jumping to next context... \n"; - prev_ctx = prev; - auto result = bc::detail::jump_fcontext( next->my_context, this ); - std::cerr << "end prev->my_context = " << prev->my_context <<"... \n"; - std::cerr << result.fctx <<" <--- result \n"; -#elif BOOST_VERSION >= 105600 +#if BOOST_VERSION >= 105600 bc::jump_fcontext( &prev->my_context, next->my_context, (intptr_t)this ); #elif BOOST_VERSION >= 105300 bc::jump_fcontext( prev->my_context, next->my_context, (intptr_t)this ); @@ -483,22 +467,9 @@ namespace fc { return true; } - static void start_process_tasks( fc::context::transfer_t my ) + static void start_process_tasks( intptr_t my ) { -#if BOOST_VERSION >= 106100 - std::cerr<<"my data: "<prev_ctx ) - { - std::cerr << "setting prev_ctx to " << int64_t(my.fctx) << "\n"; - self->prev_ctx->my_context = my.fctx; - } - std::cerr<<"start process tasks\n" << int64_t(self)<<"\n"; - assert( self != 0 ); -#else thread_d* self = (thread_d*)my; -#endif try { self->process_tasks(); @@ -513,7 +484,6 @@ namespace fc { } self->free_list.push_back(self->current); self->start_next_fiber( false ); - std::cerr << "existing start process tasks \n "; } void run_next_task() From 326140a9315970563c8a78834bad4ca2bb0d1fe2 Mon Sep 17 00:00:00 2001 From: Vikram Rajkumar Date: Thu, 12 Jan 2017 18:24:06 -0600 Subject: [PATCH 010/260] Remove leftover udt code --- .gitignore | 2 - include/fc/exception/exception.hpp | 2 - src/exception.cpp | 1 - tests/udt_client.cpp | 36 ------------- tests/udt_server.cpp | 83 ------------------------------ tests/udtc.cpp | 49 ------------------ tests/udts.cpp | 39 -------------- 7 files changed, 212 deletions(-) delete mode 100644 tests/udt_client.cpp delete mode 100644 tests/udt_server.cpp delete mode 100644 tests/udtc.cpp delete mode 100644 tests/udts.cpp diff --git a/.gitignore b/.gitignore index 42cf923d0..5d3e63319 100644 --- a/.gitignore +++ b/.gitignore @@ -50,5 +50,3 @@ GitSHA3.cpp ntp_test task_cancel_test -udt_client -udt_server diff --git a/include/fc/exception/exception.hpp b/include/fc/exception/exception.hpp index 0b1063236..9fa7b547e 100644 --- a/include/fc/exception/exception.hpp +++ b/include/fc/exception/exception.hpp @@ -32,7 +32,6 @@ namespace fc invalid_operation_exception_code = 14, unknown_host_exception_code = 15, null_optional_code = 16, - udt_error_code = 17, aes_error_code = 18, overflow_code = 19, underflow_code = 20, @@ -294,7 +293,6 @@ namespace fc FC_DECLARE_EXCEPTION( assert_exception, assert_exception_code, "Assert Exception" ); FC_DECLARE_EXCEPTION( eof_exception, eof_exception_code, "End Of File" ); FC_DECLARE_EXCEPTION( null_optional, null_optional_code, "null optional" ); - FC_DECLARE_EXCEPTION( udt_exception, udt_error_code, "UDT error" ); FC_DECLARE_EXCEPTION( aes_exception, aes_error_code, "AES error" ); FC_DECLARE_EXCEPTION( overflow_exception, overflow_code, "Integer Overflow" ); FC_DECLARE_EXCEPTION( underflow_exception, underflow_code, "Integer Underflow" ); diff --git a/src/exception.cpp b/src/exception.cpp index fef482af6..bbf927986 100644 --- a/src/exception.cpp +++ b/src/exception.cpp @@ -21,7 +21,6 @@ namespace fc (eof_exception) (unknown_host_exception) (null_optional) - (udt_exception) (aes_exception) (overflow_exception) (underflow_exception) diff --git a/tests/udt_client.cpp b/tests/udt_client.cpp deleted file mode 100644 index f575b28ec..000000000 --- a/tests/udt_client.cpp +++ /dev/null @@ -1,36 +0,0 @@ -#include -#include -#include - -using namespace std; -using namespace UDT; - -int main() -{ - UDTSOCKET client = UDT::socket(AF_INET, SOCK_STREAM, 0); - - sockaddr_in serv_addr; - serv_addr.sin_family = AF_INET; - serv_addr.sin_port = htons(9000); - inet_pton(AF_INET, "127.0.0.1", &serv_addr.sin_addr); - - memset(&(serv_addr.sin_zero), '\0', 8); - - // connect to the server, implict bind - if (UDT::ERROR == UDT::connect(client, (sockaddr*)&serv_addr, sizeof(serv_addr))) - { - cout << "connect: " << UDT::getlasterror().getErrorMessage(); - return 0; - } - - char* hello = "hello world! 3\n"; - if (UDT::ERROR == UDT::send(client, hello, strlen(hello) + 1, 0)) - { - cout << "send: " << UDT::getlasterror().getErrorMessage(); - return 0; - } - - UDT::close(client); - - return 1; -} diff --git a/tests/udt_server.cpp b/tests/udt_server.cpp deleted file mode 100644 index ff7e2fbcd..000000000 --- a/tests/udt_server.cpp +++ /dev/null @@ -1,83 +0,0 @@ -#include -#include -#include - -using namespace std; - -int main( int argc, char** argv ) -{ - UDTSOCKET serv = UDT::socket(AF_INET, SOCK_STREAM, 0); - bool block = false; - - sockaddr_in my_addr; - my_addr.sin_family = AF_INET; - my_addr.sin_port = htons(9000); - my_addr.sin_addr.s_addr = INADDR_ANY; - memset(&(my_addr.sin_zero), '\0', 8); - - if (UDT::ERROR == UDT::bind(serv, (sockaddr*)&my_addr, sizeof(my_addr))) - { - cout << "bind: " << UDT::getlasterror().getErrorMessage(); - return 0; - } - UDT::listen(serv, 10); - - int namelen; - sockaddr_in their_addr; - - - UDT::setsockopt(serv, 0, UDT_SNDSYN, &block, sizeof(bool)); - UDT::setsockopt(serv, 0, UDT_RCVSYN, &block, sizeof(bool)); - UDTSOCKET recver = UDT::accept(serv, (sockaddr*)&their_addr, &namelen); - if( recver == UDT::INVALID_SOCK ) - { - if( UDT::getlasterror_code() == CUDTException::EASYNCRCV ) - { - std::cout << "nothing yet... better luck next time\n"; - } - } - auto pollid = UDT::epoll_create(); - UDT::epoll_add_usock(pollid, serv, nullptr );// const int* events = NULL); - std::set readready; - std::set writeready; - std::cout << "waiting for 5 seconds\n"; - UDT::epoll_wait( pollid, &readready, &writeready, 10000 ); - - - recver = UDT::accept(serv, (sockaddr*)&their_addr, &namelen); - if( recver == UDT::INVALID_SOCK ) - { - if( UDT::getlasterror_code() == CUDTException::EASYNCRCV ) - { - std::cout << "nothing yet... better luck next time\n"; - } - return 0; - } - UDT::setsockopt(recver, 0, UDT_SNDSYN, &block, sizeof(bool)); - UDT::setsockopt(recver, 0, UDT_RCVSYN, &block, sizeof(bool)); - UDT::epoll_remove_usock(pollid, serv );// const int* events = NULL); - int events = UDT_EPOLL_IN; - - UDT::epoll_add_usock(pollid, recver, &events );// const int* events = NULL); - - readready.clear(); - UDT::epoll_wait( pollid, &readready, &writeready, 5000 ); - - char ip[16]; - cout << "new connection: " << inet_ntoa(their_addr.sin_addr) << ":" << ntohs(their_addr.sin_port) << endl; - - char data[100]; - - while (UDT::ERROR == UDT::recv(recver, data, 100, 0)) - { - cout << "recv:" << UDT::getlasterror().getErrorMessage() << endl; - UDT::epoll_wait( pollid, &readready, &writeready, 5000 ); - } - - cout << data << endl; - - UDT::close(recver); - UDT::close(serv); - - return 1; -} diff --git a/tests/udtc.cpp b/tests/udtc.cpp deleted file mode 100644 index aa48bb33e..000000000 --- a/tests/udtc.cpp +++ /dev/null @@ -1,49 +0,0 @@ -#include -#include -#include -#include -#include -#include - -using namespace fc; - -int main( int argc, char** argv ) -{ - try { - udt_socket sock; - sock.bind( fc::ip::endpoint::from_string( "127.0.0.1:6666" ) ); - ilog( "." ); - sock.connect_to( fc::ip::endpoint::from_string( "127.0.0.1:7777" ) ); - ilog( "after connect to..." ); - - std::cout << "local endpoint: " < response; - response.resize(1024); - int r = sock.readsome( response.data(), response.size() ); - while( r ) - { - std::cout.write( response.data(), r ); - r = sock.readsome( response.data(), response.size() ); - } - */ - // if we exit too quickly, UDT will not have a chance to - // send the graceful close message. - //fc::usleep( fc::seconds(1) ); - } catch ( const fc::exception& e ) - { - elog( "${e}", ("e",e.to_detail_string() ) ); - } - - return 0; -} diff --git a/tests/udts.cpp b/tests/udts.cpp deleted file mode 100644 index 8b8d5750f..000000000 --- a/tests/udts.cpp +++ /dev/null @@ -1,39 +0,0 @@ -#include -#include -#include -#include -#include - -using namespace fc; - -int main( int argc, char** argv ) -{ - try { - udt_server serv; - serv.listen( fc::ip::endpoint::from_string( "127.0.0.1:7777" ) ); - - while( true ) - { - udt_socket sock; - serv.accept( sock ); - - std::vector response; - response.resize(1024); - int r = sock.readsome( response.data(), response.size() ); - while( r ) - { - std::cout.write( response.data(), r ); - r = sock.readsome( response.data(), response.size() ); - //sock.write( response.data(), response.size() ); - } - - std::string goodbye = "goodbye cruel world"; - sock.write( goodbye.c_str(), goodbye.size() ); - } - } catch ( const fc::exception& e ) - { - elog( "${e}", ("e",e.to_detail_string() ) ); - } - - return 0; -} From 2b26a51b6c196409b3a31ac76e33aabee9c0ef9e Mon Sep 17 00:00:00 2001 From: Vikram Rajkumar Date: Fri, 13 Jan 2017 14:29:22 -0600 Subject: [PATCH 011/260] Remove unused ssh code --- include/fc/ssh/client.hpp | 193 ---------- include/fc/ssh/error.hpp | 25 -- include/fc/ssh/process.hpp | 58 --- src/ssh/client.cpp | 717 ------------------------------------- src/ssh/client_impl.hpp | 280 --------------- src/ssh/process.cpp | 334 ----------------- 6 files changed, 1607 deletions(-) delete mode 100644 include/fc/ssh/client.hpp delete mode 100644 include/fc/ssh/error.hpp delete mode 100644 include/fc/ssh/process.hpp delete mode 100644 src/ssh/client.cpp delete mode 100644 src/ssh/client_impl.hpp delete mode 100644 src/ssh/process.cpp diff --git a/include/fc/ssh/client.hpp b/include/fc/ssh/client.hpp deleted file mode 100644 index eb24a8e43..000000000 --- a/include/fc/ssh/client.hpp +++ /dev/null @@ -1,193 +0,0 @@ -#pragma once -#include -#include -#include - -namespace fc { - class path; - class logger; - namespace ssh { - namespace detail { - class client_impl; - class process_impl; - }; - - enum sftp_file_type { - named_pipe = 0010000, - directory = 0040000, - regular = 0100000, - symlink = 0120000 - }; - - - enum sftp_file_mode { - owner_mask = 0000700, /* RWX mask for owner */ - owner_read = 0000400, /* R for owner */ - owner_write = 0000200, /* W for owner */ - owner_exec = 0000100, /* X for owner */ - group_mask = 0000070, /* RWX mask for group */ - group_read = 0000040, /* R for group */ - group_write = 0000020, /* W for group */ - group_exec = 0000010, /* X for group */ - other_mask = 0000007, /* RWX mask for other */ - other_read = 0000004, /* R for other */ - other_write = 0000002, /* W for other */ - other_exec = 0000001 /* X for other */ - }; - - struct file_attrib { - file_attrib(); - - uint64_t size; - uint32_t uid; - uint32_t gid; - uint32_t permissions; - uint32_t atime; - uint32_t mtime; - - bool exists(); - bool is_file(); - bool is_directory(); - }; - - - /** - * @brief Enables communication over ssh using libssh2. - * - * Because the client creates other resources that depend upon - * it, it can only be created as a std::shared_ptr (aka client::ptr) - * via client::create(); - * - */ - class client - { - public: - enum trace_level { - TRACE_NONE = 0, - TRACE_TRANS = (1<<1), - TRACE_KEX = (1<<2), - TRACE_AUTH = (1<<3), - TRACE_CONN = (1<<4), - TRACE_SCP = (1<<5), - TRACE_SFTP = (1<<6), - TRACE_ERROR = (1<<7), - TRACE_PUBLICKEY = (1<<8), - TRACE_SOCKET = (1<<9) - }; - /** - * Everything but TRACE_ERROR will be logged at fc::log_level::debug, while - * TRACE_ERROR will be logged at fc::log_level::error - * - * @param bitmask comprised of values from trace_level - **/ - void set_trace_level( int bitmask ); - int get_trace_level()const; - - /** - * Override the default logger used by fc::ssh::client - */ - void set_logger( const logger& lgr ); - const logger& get_logger()const; - - /** - * Connect, with no password specified. Authentication will try public key, - * (via agent or explicitly-set key), empty password, then keyboard-interactive - */ - void connect( const fc::string& user, const fc::string& host, uint16_t port = 22); - - /** - * Connect, specifying a password to be used for password authentication - */ - void connect( const fc::string& user, const fc::string& pass, const fc::string& host, uint16_t port = 22); - - /** - * @note THIS METHOD IS DEPRECATED and should be replace with: - * - * ssh::client_ptr sshc = std::make_shared(); - * sshc->connect( ... ) - * ssh::process_ptr proc = std::make_shared( sshc ); - * proc->exec( ... ) - * - * - * @brief execute command on remote machine - * @param pty_type - whether or not to request a PTY when executing this process, this is necessary - * for interactive (non-buffered) IO with the remote process, if left empty no pty will be - * requested - * - * @note Processes launched in this manner will fully buffer stdin and stdout regardless of whether - * the process calls flush(). If you need unbuffered (streaming, realtime) access to standard - * out then you must launch the process via a shell. - ssh::process exec( const fc::string& cmd, const fc::string& pty_type = "" ); - */ - - - /** - * @brief upload a file to remote host - * @param progress a callback to report / cancel upload. - * The callback takes two parameters, bytes sent and file size. To continue the - * transfer, the callback should return true. To cancel the callback should return false. - */ - void scp_send( const fc::path& local_path, const fc::path& remote_path, - std::function progress = [](uint64_t,uint64_t){return true;} ); - - /** - * @brief recursively sends the contents of local_dir to the remote_path - * - * If remote_path ends in '/' then a new directory at remote_path/local_dir.filename() will - * be created, otherwise local_dir / * will be copied to remote_path / * - * - * Progress will be reported as total bytes transferred for all files. - */ - void scp_send_dir( const fc::path& local_dir, const fc::path& remote_path, - std::function progress = [](uint64_t,uint64_t){return true;} ); - - /** - * @pre remote_path is not a directory - * @post remote file is removed from the remote filesystem - */ - void rm( const fc::path& remote_path ); - - /** - * @pre remote_path is a directory - * @post remote directory is removed from the remote filesystem - */ - void rmdir( const fc::path& remote_path ); - - void rmdir_recursive( const fc::path& remote_path ); - - file_attrib stat( const fc::path& remote_path ); - - /** - * @pre all parent directories already exist. - * @pre remote_dir is not exist or is already a directory - * @post remote_dir exists. - */ - void mkdir( const fc::path& remote_dir, int mode = owner_read|owner_write|owner_exec ); - - /** - * Create all parent directories for remote_dir if they do not exist. - * - * @post remote_dir exists. - */ - void create_directories( const fc::path& remote_dir, int mode = owner_read|owner_write|owner_exec ); - - /** - * Sets whether the remote system is believed to be a Windows box (by default, it's - * assumed to be running UNIX. This alters how command-line arguments are quoted - * and possibly how filenames are altered when copying files - */ - void set_remote_system_is_windows(bool is_windows = true); - - void close(); - - client(); - ~client(); - - private: - friend class process; - friend class detail::process_impl; - std::unique_ptr my; - }; - typedef std::shared_ptr client_ptr; - -} } // namespace fc::ssh diff --git a/include/fc/ssh/error.hpp b/include/fc/ssh/error.hpp deleted file mode 100644 index 55eba7c4a..000000000 --- a/include/fc/ssh/error.hpp +++ /dev/null @@ -1,25 +0,0 @@ -#ifndef MACE_SSH_ERROR_HPP -#define MACE_SSH_ERROR_HPP -#include -#include - -namespace mace { namespace ssh { -typedef boost::error_info err_msg; - -struct exception : public virtual boost::exception, public virtual std::exception { - const char* what()const throw() { return "exception"; } - virtual void rethrow()const { BOOST_THROW_EXCEPTION(*this); } - const std::string& message()const { return *boost::get_error_info(*this); } -}; - -} } // mace::ssh - -/** - * Helper macro for throwing exceptions with a message: THROW( "Hello World %1%, %2%", %"Hello" %"World" ) - */ -#define MACE_SSH_THROW( MSG, ... ) \ - do { \ - BOOST_THROW_EXCEPTION( mace::ssh::exception() << mace::ssh::err_msg( (boost::format( MSG ) __VA_ARGS__ ).str() ) );\ - } while(0) - -#endif diff --git a/include/fc/ssh/process.hpp b/include/fc/ssh/process.hpp deleted file mode 100644 index 08eb089b5..000000000 --- a/include/fc/ssh/process.hpp +++ /dev/null @@ -1,58 +0,0 @@ -#pragma once -#include - -namespace fc { namespace ssh -{ - - class client; - - namespace detail { - class process_impl; - }; - - /** - * Enables communication with a process executed via - * client::exec(). - * - * Process can only be created by mace::ssh::client. - */ - class process : public iprocess - { - public: - virtual iprocess& exec( const fc::path& exe, std::vector args, - const fc::path& work_dir = fc::path(), exec_opts opts = open_all ); - - /** - * Blocks until the result code of the process has been returned. - */ - virtual int result(); - - - /** - * Not supported. libssh2 does not support sending signals to remote processes. - * closing in_stream() is the best you can do - */ - virtual void kill(); - - - /** - * @brief returns a stream that writes to the process' stdin - */ - virtual fc::buffered_ostream_ptr in_stream(); - - /** - * @brief returns a stream that reads from the process' stdout - */ - virtual fc::buffered_istream_ptr out_stream(); - /** - * @brief returns a stream that reads from the process' stderr - */ - virtual fc::buffered_istream_ptr err_stream(); - - process( fc::ssh::client_ptr c ); - ~process(); - private: - std::unique_ptr my; - }; - -} } // fc::ssh diff --git a/src/ssh/client.cpp b/src/ssh/client.cpp deleted file mode 100644 index 80d878807..000000000 --- a/src/ssh/client.cpp +++ /dev/null @@ -1,717 +0,0 @@ -#define NOMINMAX // prevent windows from defining min and max macros -#include -#include - -#include - -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "client_impl.hpp" - -namespace fc { namespace ssh { - - namespace detail { - static int ssh_init = libssh2_init(0); - } - - client::client():my( new detail::client_impl() ){ (void)detail::ssh_init; /* fix unused warning...*/ } - client::~client() { my->close(); } - - void client::set_trace_level( int bitmask ) { my->_trace_level = bitmask; } - int client::get_trace_level()const { return my->_trace_level; } - const logger& client::get_logger()const { return my->logr; } - void client::set_logger( const logger& l ) { my->logr = l; } - - void client::connect( const fc::string& user, const fc::string& host, uint16_t port ) { - my->hostname = host; - my->uname = user; - my->port = port; - my->connect(); - } - void client::connect( const fc::string& user, const fc::string& pass, - const fc::string& host, uint16_t port ) { - my->hostname = host; - my->uname = user; - my->upass = pass; - my->port = port; - - my->connect(); - } - - void client::close() { my->close(); } - - -// ssh::process client::exec( const fc::string& cmd, const fc::string& pty_type ) { -// return ssh::process( *this, cmd, pty_type ); -// } - - /** - * @todo implement progress reporting. - */ - void client::scp_send_dir( const fc::path& local_dir, const fc::path& remote_path, - std::function progress ) - { - fc::path remote_dir = remote_path; - if( remote_dir.filename() == fc::path(".") ) - remote_dir /= local_dir.filename(); - - fc_dlog( my->logr, "scp -r ${local} ${remote}", ("local",local_dir)("remote",remote_dir) ); - create_directories( remote_dir ); - - directory_iterator ditr(local_dir); - directory_iterator dend; - - while( ditr != dend ) { - if( (*ditr).filename() == "." || - (*ditr).filename() == ".." ) - { } - else if( fc::is_directory(*ditr) ) - { - scp_send_dir( (*ditr), remote_dir / (*ditr).filename() ); - } else if( fc::is_regular_file(*ditr) ) { - scp_send( *ditr, remote_dir / (*ditr).filename() ); - } else { - fc_wlog( my->logr, "Skipping '${path}", ("path",fc::canonical(*ditr)) ); - } - ++ditr; - } - } - - void client::scp_send( const fc::path& local_path, const fc::path& remote_path, - std::function progress ) { - fc_wlog( my->logr, "scp ${local} ${remote}", ("local",local_path)("remote",remote_path ) ); - if( !fc::exists(local_path) ) { - FC_THROW( "Source file '${file}' does not exist", ("file",local_path) ) ; - } - if( is_directory( local_path ) ) { - FC_THROW( "Source file '${file}' is a directory, expected a file", ("file",local_path) ) ; - } - - // memory map the file - uint64_t fsize = file_size(local_path); - if( fsize == 0 ) { - elog( "file size ${file_size}", ("file_size", fsize) ); - // TODO: handle empty file case - if( progress ) progress(0,0); - return; - } - file_mapping fmap( local_path.string().c_str(), read_only ); - - LIBSSH2_CHANNEL* chan = 0; - time_t now; - memset( &now, 0, sizeof(now) ); - - // TODO: preserve creation / modification date - // TODO: perserve permissions / exec bit? - try { - // libssh2_scp_send64 stores state data in the session object, and it calls channel_open which - // stores its own state data, so lock both. - fc::scoped_lock channel_open_lock(my->channel_open_mutex); - fc::scoped_lock scp_send_lock(my->scp_send_mutex); - chan = my->call_ssh2_ptr_function_throw(boost::bind(libssh2_scp_send64, my->session, remote_path.generic_string().c_str(), 0700, fsize, now, now )); - } catch (fc::exception& er) { - FC_RETHROW_EXCEPTION(er, error, "scp ${local_file} to ${remote_file} failed", ("local_file", local_path)("remote_file",remote_path)); - } - uint64_t total_bytes_written = 0; - try { - const size_t max_mapping_size = 1024*1024*1024; // 1GB - for (uint64_t current_offset = 0; current_offset < fsize; current_offset += max_mapping_size) { - uint64_t total_bytes_left_to_send = fsize - current_offset; - size_t bytes_to_send_this_iteration = (size_t)std::min(total_bytes_left_to_send, max_mapping_size); - mapped_region mr( fmap, fc::read_only, current_offset, bytes_to_send_this_iteration); - size_t bytes_written_this_iteration = 0; - char* pos = reinterpret_cast(mr.get_address()); - while( progress(total_bytes_written, fsize) && bytes_written_this_iteration < bytes_to_send_this_iteration) { - int r = my->call_ssh2_function_throw(boost::bind(libssh2_channel_write_ex, chan, 0, pos, - bytes_to_send_this_iteration - bytes_written_this_iteration), - "scp failed ${code} - ${message}"); - bytes_written_this_iteration += r; - total_bytes_written += r; - pos += r; - // fc_wlog( my->logr, "wrote ${bytes} bytes", ("bytes",r) ); - } - } - my->call_ssh2_function(boost::bind(libssh2_channel_send_eof, chan)); - my->call_ssh2_function(boost::bind(libssh2_channel_wait_eof, chan)); - my->call_ssh2_function(boost::bind(libssh2_channel_close, chan)); - } catch ( fc::exception& er ) { - // clean up chan - my->call_ssh2_function(boost::bind(libssh2_channel_free, chan)); - throw er; - } - my->call_ssh2_function_throw(boost::bind(libssh2_channel_free, chan), - "scp failed ${code} - ${message}"); - } - - - void client::rm( const fc::path& remote_path ) { - try { - auto s = stat(remote_path); - if( s.is_directory() ) { - FC_THROW( "sftp cannot remove directory ${path}", ("path",remote_path) ); - } - else if( !s.exists() ) { - return; // nothing to do - } - - { - fc::scoped_lock scp_unlink_lock(my->scp_unlink_mutex); - my->call_ssh2_function_throw(boost::bind(libssh2_sftp_unlink_ex, my->sftp, remote_path.generic_string().c_str(), remote_path.generic_string().size()), - "sftp rm failed ${code}"); - } - } catch ( fc::exception& er ) { - FC_RETHROW_EXCEPTION( er, error, "sftp remove '${remote_path}' failed", ("remote_path",remote_path) ); - } - } - - void client::rmdir( const fc::path& remote_path ) { - try { - auto s = stat(remote_path); - if( !s.is_directory() ) - FC_THROW( "sftp cannot rmdir non-directory ${path}", ("path",remote_path) ); - else if( !s.exists() ) - return; // nothing to do - - { - fc::scoped_lock scp_rmdir_lock(my->scp_rmdir_mutex); - my->call_ssh2_function_throw(boost::bind(libssh2_sftp_rmdir_ex, my->sftp, remote_path.generic_string().c_str(), remote_path.generic_string().size()), - "sftp rmdir failed ${code}"); - } - } catch ( fc::exception& er ) { - FC_RETHROW_EXCEPTION( er, error, "sftp rmdir '${remote_path}' failed", ("remote_path",remote_path) ); - } - } - - void client::rmdir_recursive( const fc::path& remote_path ) { - try { - auto s = stat(remote_path); - if( !s.is_directory() ) - FC_THROW( "sftp cannot rmdir non-directory ${path}", ("path",remote_path) ); - else if( !s.exists() ) - return; // nothing to do - - LIBSSH2_SFTP_HANDLE *dir_handle; - { - fc::scoped_lock scp_open_lock(my->scp_open_mutex); - dir_handle = - my->call_ssh2_ptr_function_throw(boost::bind(libssh2_sftp_open_ex, my->sftp, remote_path.generic_string().c_str(), remote_path.generic_string().size(), 0, 0, LIBSSH2_SFTP_OPENDIR), - "sftp libssh2_sftp_opendir failed ${code}"); - } - do { - char mem[512]; - LIBSSH2_SFTP_ATTRIBUTES attrs; - - int rc; - { - fc::scoped_lock scp_readdir_lock(my->scp_readdir_mutex); - rc = my->call_ssh2_function_throw(boost::bind(libssh2_sftp_readdir_ex, dir_handle, mem, sizeof(mem), (char*)NULL, 0, &attrs), - "sftp readdir failed ${code}"); - } - if (rc > 0) { - fc::string file_or_dir_name(mem, rc); - if (file_or_dir_name == "." || file_or_dir_name == "..") - continue; - fc::path full_remote_path = remote_path / file_or_dir_name; - if (LIBSSH2_SFTP_S_ISDIR(attrs.permissions)) - rmdir_recursive(full_remote_path); - else if (LIBSSH2_SFTP_S_ISREG(attrs.permissions)) { - fc::scoped_lock scp_unlink_lock(my->scp_unlink_mutex); - my->call_ssh2_function_throw(boost::bind(libssh2_sftp_unlink_ex, my->sftp, full_remote_path.generic_string().c_str(), full_remote_path.generic_string().size()), - "sftp rm failed ${code}"); - } - } else - break; - } while (1); - - { - fc::scoped_lock scp_close_lock(my->scp_close_mutex); - my->call_ssh2_function_throw(boost::bind(libssh2_sftp_close_handle, dir_handle), "sftp libssh2_sftp_closedir failed ${code}"); - } - { - fc::scoped_lock scp_rmdir_lock(my->scp_rmdir_mutex); - my->call_ssh2_function_throw(boost::bind(libssh2_sftp_rmdir_ex, my->sftp, remote_path.generic_string().c_str(), remote_path.generic_string().size()), - "sftp rmdir failed ${code}"); - } - } catch ( fc::exception& er ) { - FC_RETHROW_EXCEPTION( er, error, "sftp rmdir recursive '${remote_path}' failed", ("remote_path",remote_path) ); - } - } - - file_attrib client::stat( const fc::path& remote_path ){ - my->init_sftp(); - LIBSSH2_SFTP_ATTRIBUTES att; - int ec; - { - fc::scoped_lock scp_stat_lock(my->scp_stat_mutex); - ec = my->call_ssh2_function(boost::bind(libssh2_sftp_stat_ex, my->sftp, - remote_path.generic_string().c_str(), remote_path.generic_string().size(), - LIBSSH2_SFTP_STAT, &att)); - } - if( ec ) - return file_attrib(); - file_attrib ft; - ft.size = att.filesize; - ft.permissions = att.permissions; - return ft; - } - void client::create_directories( const fc::path& rdir, int mode ) { - boost::filesystem::path dir = rdir; - boost::filesystem::path p; - auto pitr = dir.begin(); - while( pitr != dir.end() ) { - p /= *pitr; - if( !stat( p ).exists() ) { - mkdir(p,mode); - } - ++pitr; - } - } - - void client::mkdir( const fc::path& rdir, int mode ) { - try { - auto s = stat(rdir); - if( s.is_directory() ) - return; - else if( s.exists() ) - FC_THROW( "File already exists at path ${path}", ("path",rdir) ); - - { - fc::scoped_lock scp_mkdir_lock(my->scp_mkdir_mutex); - my->call_ssh2_function_throw(boost::bind(libssh2_sftp_mkdir_ex, my->sftp, - rdir.generic_string().c_str(), rdir.generic_string().size(), mode), - "sftp mkdir error"); - } - } catch ( fc::exception& er ) { - FC_RETHROW_EXCEPTION( er, error, "sftp failed to create directory '${directory}'", ( "directory", rdir ) ); - } - } - - void client::set_remote_system_is_windows(bool is_windows /* = true */) { - my->remote_system_is_windows = is_windows; - } - - - file_attrib::file_attrib() - :size(0),uid(0),gid(0),permissions(0),atime(0),mtime(0) - { } - - bool file_attrib::is_directory() { - return LIBSSH2_SFTP_S_ISDIR(permissions); - } - bool file_attrib::is_file() { - return LIBSSH2_SFTP_S_ISREG(permissions); - } - bool file_attrib::exists() { - return 0 != permissions; - } - - detail::client_impl::client_impl() : - session(nullptr), - knownhosts(nullptr), - sftp(nullptr), - agent(nullptr), - _trace_level(0), // was LIBSSH2_TRACE_ERROR - logr(fc::logger::get( "fc::ssh::client" )), - remote_system_is_windows(false) { - logr.set_parent( fc::logger::get( "default" ) ); - } - - detail::client_impl::~client_impl() { - close(); - } - - /* static */ - void detail::client_impl::kbd_callback(const char *name, int name_len, - const char *instruction, int instruction_len, int num_prompts, - const LIBSSH2_USERAUTH_KBDINT_PROMPT *prompts, - LIBSSH2_USERAUTH_KBDINT_RESPONSE *responses, - void **abstract) { - detail::client_impl* self = (client_impl*)*abstract; - - - for (int i = 0; i < num_prompts; i++) { - fwrite(prompts[i].text, 1, prompts[i].length, stdout); - - if( self->upass.size() == 0 ) { - /** TODO: add keyboard callback here... - fgets(buf, sizeof(buf), stdin); - n = strlen(buf); - while (n > 0 && strchr("\r\n", buf[n - 1])) - n--; - buf[n] = 0; - -#ifdef WIN32 // fix warning -# define strdup _strdup -#endif - responses[i].text = strdup(buf); - responses[i].length = n; - */ - responses[i].text = nullptr; - responses[i].length = 0; - } else { - responses[i].text = strdup(self->upass.c_str()); - responses[i].length = self->upass.size(); - } - } - } - - void detail::client_impl::connect() { - try { - if( libssh2_init(0) < 0 ) - FC_THROW( "Unable to init libssh2" ); - - auto eps = fc::asio::tcp::resolve( hostname, boost::lexical_cast(port) ); - if( eps.size() == 0 ) - FC_THROW( "Unable to resolve host '${host}'", ("host",hostname) ); - - sock.reset( new boost::asio::ip::tcp::socket( fc::asio::default_io_service() ) ); - - bool resolved = false; - for( uint32_t i = 0; i < eps.size(); ++i ) { - std::stringstream ss; ss << eps[i]; - try { - boost::system::error_code ec; - fc_ilog( logr, "Attempting to connect to ${endpoint}", ("endpoint",ss.str().c_str()) ); - fc::asio::tcp::connect( *sock, eps[i] ); - endpt = eps[i]; - resolved = true; - break; - } catch ( fc::exception& er ) { - fc_ilog( logr, "Failed to connect to ${endpoint}\n${error_reprot}", - ("endpoint",ss.str().c_str())("error_report", er.to_detail_string()) ); - sock->close(); - } - } - if( !resolved ) - FC_THROW( "Unable to connect to any resolved endpoint for ${host}:${port}", - ("host", hostname).set("port",port) ); - - session = libssh2_session_init(); - libssh2_trace( session, _trace_level ); - libssh2_trace_sethandler( session, this, client_impl::handle_trace ); - - *libssh2_session_abstract(session) = this; - - libssh2_session_set_blocking( session, 0 ); - try { - call_ssh2_function_throw(boost::bind(libssh2_session_handshake, session, sock->native()), - "SSH Handshake error: ${code} - ${message}"); - } catch (fc::exception& er) { - FC_RETHROW_EXCEPTION( er, error, "Error during SSH handshake" );; - } - //const char* fingerprint = libssh2_hostkey_hash(session, LIBSSH2_HOSTKEY_HASH_SHA1); - //slog( "fingerprint: %s", fingerprint ); - - // try to authenticate, throw on error. - try { - authenticate(); - } catch (fc::exception& er) { - FC_RETHROW_EXCEPTION( er, error, "Error during SSH authentication" );; - } - //slog("."); - } catch ( fc::exception& er ) { - elog( "Unable to connect to ssh server: ${detail}", ("detail", er.to_detail_string().c_str()) ); - close(); - FC_RETHROW_EXCEPTION( er, error, "Unable to connect to ssh server" );; - } catch ( ... ) { - close(); - FC_THROW( "Unable to connect to ssh server", ("exception", fc::except_str() ) ); - } - } - - /* static */ - void detail::client_impl::handle_trace( LIBSSH2_SESSION* session, void* context, const char* data, size_t length ) { - client_impl* my = (client_impl*)context; - fc::string str(data,length); - fc_wlog( my->logr, "${message}", ("message",str) ); - } - - void detail::client_impl::close() { - if( session ) { - if( sftp ) { - try { - call_ssh2_function(boost::bind(libssh2_sftp_shutdown, sftp)); - }catch(...){ - fc_wlog( logr, "caught closing sftp session" ); - } - sftp = 0; - } - - if (agent) { - libssh2_agent_disconnect(agent); - libssh2_agent_free(agent); - agent = nullptr; - } - - try { - call_ssh2_function(boost::bind(libssh2_session_disconnect_ex, session, SSH_DISCONNECT_BY_APPLICATION, "exit cleanly", "")); - call_ssh2_function(boost::bind(libssh2_session_free, session), false); - } catch ( ... ){ - fc_wlog( logr, "caught freeing session" ); - } - session = 0; - try { - if( sock ) - sock->close(); - } catch ( ... ){ - fc_wlog( logr, "caught error closing socket" ); - } - sock.reset(0); - try { - if( read_prom ) - read_prom->wait(); - } catch ( ... ){ - fc_wlog( logr, "caught error waiting on read" ); - } - try { - if( write_prom ) - write_prom->wait(); - } catch ( ... ){ - fc_wlog( logr, "caught error waiting on write" ); - } - } - } - - void detail::client_impl::authenticate() { - try { - char * alist = NULL; - // libssh2_userauth_list has strange enough behavior that we can't use the - // call_blocking_libssh2_function-type functions to wait and retry, so we must - // explicitly lock around the libssh2_userauth_list calls. - // hence, this anonymous scope: - { - fc::unique_lock lock(ssh_session_mutex); - - alist = libssh2_userauth_list(session, uname.c_str(),uname.size()); - - if(alist==NULL) { - char * msg = 0; - int ec = 0; - if(libssh2_userauth_authenticated(session)) - return; // CONNECTED! - ec = libssh2_session_last_error(session,&msg,NULL,0); - - while( !alist && (ec == LIBSSH2_ERROR_EAGAIN) ) { - wait_on_socket(); - alist = libssh2_userauth_list(session, uname.c_str(), uname.size()); - ec = libssh2_session_last_error(session,&msg,NULL,0); - } - if( !alist ) { - FC_THROW( "Error getting authorization list: ${code} - ${message}", - ("code",ec).set("message",msg)); - } - } - } // end anonymous scope - - std::vector split_alist; - bool pubkey = false; - bool pass = false; - bool keybd = false; - boost::split( split_alist, alist, boost::is_any_of(",") ); - std::for_each( split_alist.begin(), split_alist.end(), [&](const std::string& s){ - if( s == "publickey" ) - pubkey = true; - else if( s == "password" ) - pass = true; - else if( s == "keyboard-interactive" ) - keybd = true; - else - fc_dlog( logr, "Unknown/unsupported authentication type '${auth_type}'", ("auth_type",s.c_str())); - }); - - if( pubkey && try_pub_key() ) - return; - if( pass && try_pass() ) - return; - if( keybd && try_keyboard() ) - return; - } catch ( fc::exception& er ) { - FC_RETHROW_EXCEPTION( er, error, "Unable to authenticate ssh connection" ); - } - FC_THROW( "Unable to authenticate ssh connection" ); - } // authenticate() - - bool detail::client_impl::try_pass() { - return !call_ssh2_function(boost::bind(libssh2_userauth_password_ex, session, uname.c_str(), uname.size(), - upass.c_str(), upass.size(), (LIBSSH2_PASSWD_CHANGEREQ_FUNC((*)))NULL)); - } - bool detail::client_impl::try_keyboard() { - return !call_ssh2_function(boost::bind(libssh2_userauth_keyboard_interactive_ex, session, - uname.c_str(), uname.size(), &client_impl::kbd_callback)); - } - bool detail::client_impl::try_pub_key() { - if (privkey.size()) { - if (!call_ssh2_function(boost::bind(libssh2_userauth_publickey_fromfile_ex, - session, - uname.c_str(), uname.size(), - pubkey.c_str(), - privkey.c_str(), - passphrase.c_str()))) - return true; // successful authentication from file - fc_ilog( logr, "failed to authenticate with private key from file '${privkey_filename}'", ("privkey_filename",privkey)); - } else - fc_ilog( logr, "no private key file set, skiping pubkey authorization from file"); - - agent = libssh2_agent_init(session); - if (!agent) { - fc_wlog( logr, "failed to initialize ssh-agent support"); - return false; - } - - if (call_ssh2_function(boost::bind(libssh2_agent_connect, agent))) { - fc_ilog( logr, "failed to connect to ssh-agent"); - return false; - } - - if (call_ssh2_function(boost::bind(libssh2_agent_list_identities, agent))) { - fc_ilog( logr, "failed requesting identities from ssh-agent"); - return false; - } - - struct libssh2_agent_publickey *prev_identity = NULL; - while (1) { - struct libssh2_agent_publickey *identity; - int ec = call_ssh2_function(boost::bind(libssh2_agent_get_identity, agent, &identity, prev_identity)); - if (ec == 1) - break; // done iterating over keys - if (ec < 0) { - fc_ilog( logr, "failed obtaining identity from ssh-agent"); - return false; - } - - if (call_ssh2_function(boost::bind(libssh2_agent_userauth, agent, uname.c_str(), identity))) - fc_ilog( logr, "unable to authenticate with public key '${key_comment}'", ("key_comment",identity->comment)); - else { - fc_ilog( logr, "authenticated with public key '${key_comment}'", ("key_comment",identity->comment)); - return true; - } - prev_identity = identity; - } - return false; - } - - void detail::client_impl::wait_on_socket(int additionalDirections /* = 0 */) { - int dir = libssh2_session_block_directions(session); - dir |= additionalDirections; - if( !dir ) - return; - - fc::promise::ptr rprom, wprom; - if( dir & LIBSSH2_SESSION_BLOCK_INBOUND ) { - fc::scoped_lock lock(this->_spin_lock); - if( !read_prom ) { - read_prom.reset( new fc::promise("read_prom") ); - sock->async_read_some( boost::asio::null_buffers(), - [=]( const boost::system::error_code& e, size_t ) { - fc::scoped_lock lock(this->_spin_lock); - this->read_prom->set_value(e); - this->read_prom.reset(nullptr); - } ); - } - rprom = read_prom; - } - - if( dir & LIBSSH2_SESSION_BLOCK_OUTBOUND ) { - fc::scoped_lock lock(this->_spin_lock); - if( !write_prom ) { - write_prom.reset( new fc::promise("write_prom") ); - sock->async_write_some( boost::asio::null_buffers(), - [=]( const boost::system::error_code& e, size_t ) { - fc::scoped_lock lock(this->_spin_lock); - this->write_prom->set_value(e); - this->write_prom.reset(0); - } ); - } - wprom = write_prom; - } - - boost::system::error_code ec; - if( rprom.get() && wprom.get() ) { - typedef fc::future fprom; - fprom fw(wprom); - fprom fr(rprom); -#if 0 - // EMF: at present there are known bugs in fc::wait_any, and it will fail to wake up - // when one of the futures is ready. - int r = fc::wait_any( fw, fr, fc::seconds(1) ); -#else - int r; - while (1) { - if (fw.ready()) { - r = 0; break; - } - if (fr.ready()) { - r = 1; break; - } - fc::usleep(fc::microseconds(5000)); - } -#endif - switch( r ) { - case 0: - if( wprom->wait() ) { - FC_THROW( "Socket Error ${message}", - ( "message", boost::system::system_error(rprom->wait() ).what() ) ); - } - break; - case 1: - if( rprom->wait() ) { - FC_THROW( "Socket Error ${message}", - ( "message", boost::system::system_error(rprom->wait() ).what() ) ); - } - break; - } - } else if( rprom ) { - if( rprom->wait() ) { - FC_THROW( "Socket Error ${message}", - ( "message", boost::system::system_error(rprom->wait() ).what() ) ); - } - } else if( wprom ) { - if( wprom->wait() ) { - FC_THROW( "Socket Error ${message}", - ( "message", boost::system::system_error(wprom->wait() ).what() ) ); - } - } - } - void detail::client_impl::init_sftp() { - if( !sftp ) - sftp = call_ssh2_ptr_function_throw(boost::bind(libssh2_sftp_init,session), - "init sftp error ${code} - ${message}"); - } - - - LIBSSH2_CHANNEL* detail::client_impl::open_channel( const fc::string& pty_type ) { - LIBSSH2_CHANNEL* chan = 0; - /* anonymous scope */ { - fc::scoped_lock channel_open_lock(channel_open_mutex); - - chan = call_ssh2_ptr_function_throw(boost::bind(libssh2_channel_open_ex, session, - "session", sizeof("session") - 1, - LIBSSH2_CHANNEL_WINDOW_DEFAULT, - LIBSSH2_CHANNEL_PACKET_DEFAULT, - (const char*)NULL, 0), - "libssh2_channel_open_session failed: ${message}"); - } - - if( pty_type.size() ) - call_ssh2_function_throw(boost::bind(libssh2_channel_request_pty_ex, chan, pty_type.c_str(), pty_type.size(), - (char *)NULL, 0, LIBSSH2_TERM_WIDTH, LIBSSH2_TERM_HEIGHT, - LIBSSH2_TERM_WIDTH_PX, LIBSSH2_TERM_HEIGHT_PX), - "libssh2_channel_req_pty failed: ${message}"); - return chan; - } - -} } diff --git a/src/ssh/client_impl.hpp b/src/ssh/client_impl.hpp deleted file mode 100644 index 606bd3648..000000000 --- a/src/ssh/client_impl.hpp +++ /dev/null @@ -1,280 +0,0 @@ -#define NOMINMAX -#include -#include - -#include - -#include -#include -#include -#include -#include -#include - -#include - -// include this to get acess to the details of the LIBSSH2_SESSION structure, so -// we can verify that all data has really been sent when libssh2 says it has. -#include <../src/libssh2_priv.h> - -namespace fc { namespace ssh { - - namespace detail { - - class client_impl { - public: - client_impl(); - ~client_impl(); - - LIBSSH2_SESSION* session; - LIBSSH2_KNOWNHOSTS* knownhosts; - LIBSSH2_SFTP* sftp; - LIBSSH2_AGENT* agent; - - std::unique_ptr sock; - boost::asio::ip::tcp::endpoint endpt; - - fc::mutex ssh_session_mutex; - fc::mutex channel_open_mutex; - fc::mutex process_startup_mutex; - fc::mutex scp_send_mutex; - fc::mutex scp_stat_mutex; - fc::mutex scp_mkdir_mutex; - fc::mutex scp_rmdir_mutex; - fc::mutex scp_unlink_mutex; - fc::mutex scp_close_mutex; - fc::mutex scp_readdir_mutex; - fc::mutex scp_open_mutex; - - fc::string uname; - fc::string upass; - fc::string pubkey; - fc::string privkey; - fc::string passphrase; - fc::string hostname; - uint16_t port; - bool session_connected; - fc::promise::ptr read_prom; - fc::promise::ptr write_prom; - fc::spin_lock _spin_lock; - int _trace_level; - logger logr; - - bool remote_system_is_windows; // true if windows, false if unix, used for command-line quoting and maybe filename translation - - LIBSSH2_CHANNEL* open_channel( const fc::string& pty_type ); - static void kbd_callback(const char *name, int name_len, - const char *instruction, int instruction_len, int num_prompts, - const LIBSSH2_USERAUTH_KBDINT_PROMPT *prompts, - LIBSSH2_USERAUTH_KBDINT_RESPONSE *responses, - void **abstract); - - void connect(); - - static void handle_trace( LIBSSH2_SESSION* session, void* context, const char* data, size_t length ); - - void close(); - void authenticate(); - - bool try_pass(); - bool try_keyboard(); - bool try_pub_key(); - - // don't call this "unlocked" version directly - template - int call_ssh2_function_unlocked(const T& lambda, bool check_for_errors = true); - - // calls into libssh2, waits and retries the function if we get LIBSSH2_ERROR_EAGAIN - template - int call_ssh2_function(const T& lambda, bool check_for_errors = true); - - // calls into libssh2, waits and retries the function if we get LIBSSH2_ERROR_EAGAIN - // if libssh2 returns an error, get extended info and throw a message with ${code} and ${message} - // set appropriately. - template - int call_ssh2_function_throw(const T& lambda, const char* message = "libssh2 call failed ${code} - ${message}", bool check_for_errors = true); - - // this version is a little different, it handles functions like libssh2_sftp_init which return - // a pointer instead of an int. These retry automatically if the result is NULL and the error - // is LIBSSH2_ERROR_EAGAIN - template - return_type call_ssh2_ptr_function_throw(std::function lambda, const char* message = "libssh2 call failed ${code} - ${message}", bool check_for_errors = true); - - void wait_on_socket(int additionalDirections = 0); - - void init_sftp(); - }; - - - // #define OLD_BLOCKING, - // the OLD_BLOCKING version of these functions will ensure that if a libssh2 function returns - // LIBSSH2_ERROR_EAGAIN, no other libssh2 functions will be called until that function has been - // called again and returned some other value. - // - // if you don't define this and use the new version of this, we will release the lock and let - // other libssh2 functions be called *unless* it appears that there was unwritten data. - // - // the OLD_BLOCKING version is too conservative -- if you try to read on a channel that doesn't - // have any data, you're likely to deadlock. The new version is not heavily tested and may be - // too lax, time will tell. -#ifdef OLD_BLOCKING - // don't call this "unlocked" version directly - template - int client_impl::call_ssh2_function_unlocked(const T& lambda, bool check_for_errors /* = true */) { - int ec = lambda(); - while (ec == LIBSSH2_ERROR_EAGAIN ) { - wait_on_socket(); - ec = lambda(); - } - - // this assert catches bugs in libssh2 if libssh2 returns ec != LIBSSH2_ERROR_EAGAIN - // but the internal session data indicates a data write is still in progress - // set check_for_errors to false when closing the connection - assert(!check_for_errors || !session->packet.olen); - - return ec; - } - - // calls into libssh2, waits and retries the function if we get LIBSSH2_ERROR_EAGAIN - template - int client_impl::call_ssh2_function(const T& lambda, bool check_for_errors /* = true */) { - fc::scoped_lock lock(ssh_session_mutex); - return call_ssh2_function_unlocked(lambda, check_for_errors); - } -#else - // calls into libssh2, waits and retries the function if we get LIBSSH2_ERROR_EAGAIN - template - int client_impl::call_ssh2_function(const T& lambda, bool check_for_errors /* = true */) { - fc::unique_lock lock(ssh_session_mutex); - int ec = lambda(); - while (ec == LIBSSH2_ERROR_EAGAIN) { - bool unlock_to_wait = !session->packet.olen; - if (unlock_to_wait) - lock.unlock(); - wait_on_socket(); - if (unlock_to_wait) - lock.lock(); - ec = lambda(); - } - // this assert catches bugs in libssh2 if libssh2 returns ec != LIBSSH2_ERROR_EAGAIN - // but the internal session data indicates a data write is still in progress - // set check_for_errors to false when closing the connection - assert(!check_for_errors || !session->packet.olen); - return ec; - } -#endif - -#ifdef OLD_BLOCKING - // calls into libssh2, waits and retries the function if we get LIBSSH2_ERROR_EAGAIN - // if libssh2 returns an error, get extended info and throw a message with ${code} and ${message} - // set appropriately. - template - int client_impl::call_ssh2_function_throw(const T& lambda, const char* message /* = "libssh2 call failed ${code} - ${message}" */, bool check_for_errors /* = true */) { - fc::scoped_lock lock(ssh_session_mutex); - int ec = call_ssh2_function_unlocked(lambda, check_for_errors); - - if (ec == LIBSSH2_ERROR_SFTP_PROTOCOL && sftp) { - ec = libssh2_sftp_last_error(sftp); - FC_THROW(message, ("code", ec).set("message", "SFTP protocol error")); - } else if( ec < 0 ) { - char* msg = 0; - ec = libssh2_session_last_error( session, &msg, 0, 0 ); - FC_THROW(message, ("code",ec).set("message",msg)); - } - return ec; - } -#else - // calls into libssh2, waits and retries the function if we get LIBSSH2_ERROR_EAGAIN - // if libssh2 returns an error, get extended info and throw a message with ${code} and ${message} - // set appropriately. - template - int client_impl::call_ssh2_function_throw(const T& lambda, const char* message /* = "libssh2 call failed ${code} - ${message}" */, bool check_for_errors /* = true */) { - fc::unique_lock lock(ssh_session_mutex); - int ec = lambda(); - while (ec == LIBSSH2_ERROR_EAGAIN) { - bool unlock_to_wait = !session->packet.olen; - if (unlock_to_wait) - lock.unlock(); - wait_on_socket(); - if (unlock_to_wait) - lock.lock(); - ec = lambda(); - } - // this assert catches bugs in libssh2 if libssh2 returns ec != LIBSSH2_ERROR_EAGAIN - // but the internal session data indicates a data write is still in progress - // set check_for_errors to false when closing the connection - assert(!check_for_errors || !session->packet.olen); - - if (ec == LIBSSH2_ERROR_SFTP_PROTOCOL && sftp) { - ec = libssh2_sftp_last_error(sftp); - FC_THROW(message, ("code", ec).set("message", "SFTP protocol error")); - } else if( ec < 0 ) { - char* msg = 0; - ec = libssh2_session_last_error( session, &msg, 0, 0 ); - FC_THROW(message, ("code",ec).set("message",msg)); - } - return ec; - } -#endif - -#ifdef OLD_BLOCKING - // this version is a little different, it handles functions like libssh2_sftp_init which return - // a pointer instead of an int. These retry automatically if the result is NULL and the error - // is LIBSSH2_ERROR_EAGAIN - template - return_type client_impl::call_ssh2_ptr_function_throw(std::function lambda, const char* message /* = "libssh2 call failed ${code} - ${message}" */, bool check_for_errors /* = true */) { - fc::scoped_lock lock(ssh_session_mutex); - return_type ret = lambda(); - while (!ret) { - char* msg = 0; - int ec = libssh2_session_last_error(session,&msg,NULL,0); - if ( ec == LIBSSH2_ERROR_EAGAIN ) { - wait_on_socket(); - ret = lambda(); - } else if (ec == LIBSSH2_ERROR_SFTP_PROTOCOL && sftp) { - ec = libssh2_sftp_last_error(sftp); - FC_THROW(message, ("code", ec).set("message", "SFTP protocol error")); - } else { - ec = libssh2_session_last_error( session, &msg, 0, 0 ); - FC_THROW(message, ("code",ec).set("message",msg)); - } - } - assert(!check_for_errors || !session->packet.olen); - - return ret; - } -#else - // this version is a little different, it handles functions like libssh2_sftp_init which return - // a pointer instead of an int. These retry automatically if the result is NULL and the error - // is LIBSSH2_ERROR_EAGAIN - template - return_type client_impl::call_ssh2_ptr_function_throw(std::function lambda, const char* message /* = "libssh2 call failed ${code} - ${message}" */, bool check_for_errors /* = true */) { - fc::unique_lock lock(ssh_session_mutex); - return_type ret = lambda(); - while (!ret) { - char* msg = 0; - int ec = libssh2_session_last_error(session,&msg,NULL,0); - if ( ec == LIBSSH2_ERROR_EAGAIN ) { - bool unlock_to_wait = !session->packet.olen; - if (unlock_to_wait) - lock.unlock(); - wait_on_socket(); - if (unlock_to_wait) - lock.lock(); - ret = lambda(); - } else if (ec == LIBSSH2_ERROR_SFTP_PROTOCOL && sftp) { - ec = libssh2_sftp_last_error(sftp); - FC_THROW(message, ("code", ec).set("message", "SFTP protocol error")); - } else { - ec = libssh2_session_last_error( session, &msg, 0, 0 ); - FC_THROW(message, ("code",ec).set("message",msg)); - } - } - assert(!check_for_errors || !session->packet.olen); - - return ret; - } -#endif - } - -} } diff --git a/src/ssh/process.cpp b/src/ssh/process.cpp deleted file mode 100644 index 8794c119a..000000000 --- a/src/ssh/process.cpp +++ /dev/null @@ -1,334 +0,0 @@ -#define NOMINMAX // prevent windows from defining min and max macros -#include -#include - -#include -#include -#include - -#include -#include -#include -#include -#include - -#include "client_impl.hpp" - -#if defined (_MSC_VER) -#pragma warning (disable : 4355) -#endif - -namespace fc { namespace ssh { - - namespace detail { - class process_impl; - class process_istream : public fc::istream { - public: - process_istream( process_impl& p, int c ) - :proc(p),chan(c){} - - virtual size_t readsome( char* buf, size_t len ); - - virtual bool eof() const; - - process_impl& proc; - int chan; - }; - - class process_ostream : public fc::ostream { - public: - process_ostream( process_impl& p ) - :proc(p){} - - virtual size_t writesome( const char* buf, size_t len ); - virtual void close(); - virtual void flush(); - - process_impl& proc; - }; - - class process_impl { - public: - process_impl( client_ptr c ); - ~process_impl(); - //process_impl( const client& c, const fc::string& cmd, const fc::string& pty_type ); - void exec(const fc::path& exe, vector args, - const fc::path& work_dir /* = fc::path() */, fc::iprocess::exec_opts opts /* = open_all */); - - - int read_some( char* data, size_t len, int stream_id ); - int write_some( const char* data, size_t len, int stream_id ); - void flush(); - void send_eof(); - - LIBSSH2_CHANNEL* chan; - client_ptr sshc; - buffered_ostream_ptr buffered_std_in; - buffered_istream_ptr buffered_std_out; - buffered_istream_ptr buffered_std_err; - - fc::string command; - fc::promise::ptr result; - - fc::optional return_code; - fc::ostring return_signal; - fc::ostring return_signal_message; - private: - static fc::string windows_shell_escape(const fc::string& str); - static fc::string unix_shell_escape(const fc::string& str); - static fc::string windows_shell_escape_command(const fc::path& exe, const vector& args); - static fc::string unix_shell_escape_command(const fc::path& exe, const vector& args); - }; - - } // end namespace detail - - - process::process(client_ptr c) : - my(new detail::process_impl(c)) - {} - - process::~process() - {} - - iprocess& process::exec( const fc::path& exe, vector args, - const fc::path& work_dir /* = fc::path() */, exec_opts opts /* = open_all */ ) { - my->exec(exe, args, work_dir, opts); - return *this; - } - - /** - * Blocks until the result code of the process has been returned. - */ - int process::result() { - if (!my->return_code && !my->return_signal) { - // we don't have any cached exit status, so wait and obtain the values now - my->sshc->my->call_ssh2_function(boost::bind(libssh2_channel_wait_eof, my->chan)); - my->sshc->my->call_ssh2_function_throw(boost::bind(libssh2_channel_wait_closed, my->chan), - "Error waiting on socket to close: ${message}"); - - char* exit_signal; - char* error_message; - libssh2_channel_get_exit_signal(my->chan, &exit_signal, NULL, &error_message, NULL, NULL, NULL); - if (exit_signal) { - // process terminated with a signal - my->return_signal = exit_signal; - libssh2_free(my->chan->session, exit_signal); - if (error_message) { - my->return_signal_message = error_message; - libssh2_free(my->chan->session, error_message); - } - } else - my->return_code = libssh2_channel_get_exit_status(my->chan); - } - if (my->return_signal) - FC_THROW("process terminated with signal ${signal}: ${signal_message}", ("signal", *my->return_signal) - ("signal_message", my->return_signal_message ? *my->return_signal_message : "")); - else - return *my->return_code; - } - - void process::kill() { - elog("error: fc::ssh::process::kill() not supported"); - } - - - /** - * @brief returns a stream that writes to the procss' stdin - */ - fc::buffered_ostream_ptr process::in_stream() { - return my->buffered_std_in; - } - - /** - * @brief returns a stream that reads from the process' stdout - */ - fc::buffered_istream_ptr process::out_stream() { - return my->buffered_std_out; - } - - /** - * @brief returns a stream that reads from the process' stderr - */ - fc::buffered_istream_ptr process::err_stream() { - return my->buffered_std_err; - } - - void detail::process_impl::flush() { - if( !chan ) return; - /* channel_flush deleates input buffer, and does not ensure writes go out - * - int ec = libssh2_channel_flush_ex( chan, LIBSSH2_CHANNEL_FLUSH_EXTENDED_DATA); - while( ec == LIBSSH2_ERROR_EAGAIN ) { - sshc.my->wait_on_socket(); - ec = libssh2_channel_flush_ex( chan, LIBSSH2_CHANNEL_FLUSH_EXTENDED_DATA ); - } - ec = libssh2_channel_flush( chan ); - while( ec == LIBSSH2_ERROR_EAGAIN ) { - sshc.my->wait_on_socket(); - ec = libssh2_channel_flush( chan ); - } - if( ec < 0 ) { - FC_THROW( "ssh flush failed", ( "channel_error", ec) ); - } - */ - } - - int detail::process_impl::read_some( char* data, size_t len, int stream_id ){ - if( !sshc->my->session ) { FC_THROW( "Session closed" ); } - int rc; - char* buf = data; - size_t buflen = len; - do { - rc = sshc->my->call_ssh2_function_throw(boost::bind(libssh2_channel_read_ex, chan, stream_id, buf, buflen), - "read failed: ${message}"); - if( rc > 0 ) { - buf += rc; - buflen -= rc; - return buf-data; - } else if( rc == 0 ) { - if( libssh2_channel_eof( chan ) ) - return -1; // eof - sshc->my->wait_on_socket(); - } - } while( rc >= 0 && buflen); - return buf-data; - } - - int detail::process_impl::write_some( const char* data, size_t len, int stream_id ) { - if( !sshc->my->session ) { FC_THROW( "Session closed" ); } - - int rc; - const char* buf = data; - size_t buflen = len; - do { - rc = sshc->my->call_ssh2_function_throw(boost::bind(libssh2_channel_write_ex, chan, stream_id, buf, buflen), - "write failed: ${message}"); - if( rc > 0 ) { - buf += rc; - buflen -= rc; - return buf-data; - } else if( rc == 0 ) { - if( libssh2_channel_eof( chan ) ) { - FC_THROW( "EOF" ); - //return -1; // eof - } - } - } while( rc >= 0 && buflen); - return buf-data; - } - - void detail::process_impl::send_eof() { - if( sshc->my->session ) - sshc->my->call_ssh2_function_throw(boost::bind(libssh2_channel_send_eof, chan), - "send eof failed: ${message}"); - } - - size_t detail::process_istream::readsome( char* buf, size_t len ) { - int bytesRead = proc.read_some(buf, len, chan); - if (bytesRead < 0) - FC_THROW("EOF"); - else - return bytesRead; - } - - bool detail::process_istream::eof()const { - return 0 != libssh2_channel_eof( proc.chan ); - } - - size_t detail::process_ostream::writesome( const char* buf, size_t len ) { - return proc.write_some(buf, len, 0); - } - - void detail::process_ostream::close(){ - proc.send_eof(); - } - - void detail::process_ostream::flush(){ - proc.flush(); - } - - detail::process_impl::process_impl( client_ptr c ) - :chan(nullptr), - sshc(c), - buffered_std_in(new buffered_ostream(ostream_ptr(new process_ostream(*this)))), - buffered_std_out(new buffered_istream(istream_ptr(new process_istream(*this, 0)))), - buffered_std_err(new buffered_istream(istream_ptr(new process_istream(*this, SSH_EXTENDED_DATA_STDERR)))) - { - } - - detail::process_impl::~process_impl() { - if (chan) { - sshc->my->call_ssh2_function(boost::bind(libssh2_channel_free, chan)); - chan = NULL; - } - } - - // these rules work pretty well for a standard bash shell on unix - fc::string detail::process_impl::unix_shell_escape(const fc::string& str) { - if (str.find_first_of(" ;&|><*?`$(){}[]!#'\"") == fc::string::npos) - return str; - fc::string escaped_quotes(str); - for (size_t start = escaped_quotes.find("'"); - start != fc::string::npos; - start = escaped_quotes.find("'", start + 5)) - escaped_quotes.replace(start, 1, "'\"'\"'"); - fc::string escaped_str("\'"); - escaped_str += escaped_quotes; - escaped_str += "\'"; - return escaped_str; - } - fc::string detail::process_impl::unix_shell_escape_command(const fc::path& exe, const vector& args) { - fc::stringstream command_line; - command_line << unix_shell_escape(exe.string()); - for (unsigned i = 0; i < args.size(); ++i) - command_line << " " << unix_shell_escape(args[i]); - return command_line.str(); - } - - // windows command-line escaping rules are a disaster, partly because how the command-line is - // parsed depends on what program you're running. In windows, the command line is passed in - // as a single string, and the process is left to interpret it as it sees fit. The standard - // C runtime uses one set of rules, the function CommandLineToArgvW usually used by - // GUI-mode programs uses a different set. - // Here we try to find a common denominator that works well for simple cases - // it's only minimally tested right now due to time constraints. - fc::string detail::process_impl::windows_shell_escape(const fc::string& str) { - if (str.find_first_of(" \"") == fc::string::npos) - return str; - fc::string escaped_quotes(str); - for (size_t start = escaped_quotes.find("\""); - start != fc::string::npos; - start = escaped_quotes.find("\"", start + 2)) - escaped_quotes.replace(start, 1, "\\\""); - fc::string escaped_str("\""); - escaped_str += escaped_quotes; - escaped_str += "\""; - return escaped_str; - } - fc::string detail::process_impl::windows_shell_escape_command(const fc::path& exe, const vector& args) { - fc::stringstream command_line; - command_line << windows_shell_escape(exe.string()); - for (unsigned i = 0; i < args.size(); ++i) - command_line << " " << windows_shell_escape(args[i]); - return command_line.str(); - } - - void detail::process_impl::exec(const fc::path& exe, vector args, - const fc::path& work_dir /* = fc::path() */, - fc::iprocess::exec_opts opts /* = open_all */) { - chan = sshc->my->open_channel(""); - - sshc->my->call_ssh2_function(boost::bind(libssh2_channel_handle_extended_data2, chan, LIBSSH2_CHANNEL_EXTENDED_DATA_NORMAL)); - - try { - fc::scoped_lock process_startup_lock(sshc->my->process_startup_mutex); - fc::string command_line = sshc->my->remote_system_is_windows ? windows_shell_escape_command(exe, args) : unix_shell_escape_command(exe, args); - sshc->my->call_ssh2_function_throw(boost::bind(libssh2_channel_process_startup, chan, "exec", sizeof("exec") - 1, command_line.c_str(), command_line.size()), - "exec failed: ${message}"); // equiv to libssh2_channel_exec(chan, cmd) macro - } catch (fc::exception& er) { - elog( "error starting process" ); - FC_RETHROW_EXCEPTION(er, error, "error starting process"); - } - } - -} } From b973a4432d902495e1a907d9f7e79ada831e28bc Mon Sep 17 00:00:00 2001 From: Vikram Rajkumar Date: Fri, 13 Jan 2017 15:59:38 -0600 Subject: [PATCH 012/260] Update submodules --- .gitmodules | 10 +++++----- vendor/diff-match-patch-cpp-stl | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.gitmodules b/.gitmodules index 22610c43d..0c2a83388 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,9 +1,9 @@ +[submodule "vendor/diff-match-patch-cpp-stl"] + path = vendor/diff-match-patch-cpp-stl + url = https://github.com/leutloff/diff-match-patch-cpp-stl [submodule "vendor/secp256k1-zkp"] - path = vendor/secp256k1-zkp - url = https://github.com/cryptonomex/secp256k1-zkp.git + path = vendor/secp256k1-zkp + url = https://github.com/bitshares/secp256k1-zkp.git [submodule "vendor/websocketpp"] path = vendor/websocketpp url = https://github.com/zaphoyd/websocketpp.git -[submodule "vendor/diff-match-patch-cpp-stl"] - path = vendor/diff-match-patch-cpp-stl - url = https://github.com/leutloff/diff-match-patch-cpp-stl diff --git a/vendor/diff-match-patch-cpp-stl b/vendor/diff-match-patch-cpp-stl index aee799a31..7f95b37e5 160000 --- a/vendor/diff-match-patch-cpp-stl +++ b/vendor/diff-match-patch-cpp-stl @@ -1 +1 @@ -Subproject commit aee799a31d08977b166fb19cad794730717e3304 +Subproject commit 7f95b37e554453262e2bcda830724fc362614103 From c1361d8cf97de719b6fd0ece244b3ae51d472e3e Mon Sep 17 00:00:00 2001 From: Vikram Rajkumar Date: Fri, 13 Jan 2017 18:36:35 -0600 Subject: [PATCH 013/260] Add fork note to README --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 31b0e44ea..5e7feef1f 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,8 @@ fc == +**NOTE:** This fork reverts upstream commit a421e280488385cab26a42153f7ce3c8d5b6281f to avoid changing the BitShares API. + FC stands for fast-compiling c++ library and provides a set of utility libraries useful for the development of asynchronous libraries. Some of the highlights include: From aed35f5b068c5798e55440348b0d85f9cf9b4f72 Mon Sep 17 00:00:00 2001 From: elmato Date: Mon, 16 Jan 2017 19:55:17 +0000 Subject: [PATCH 014/260] Add access to HTTP request headers in websocket_connection --- include/fc/network/http/websocket.hpp | 2 ++ src/network/http/websocket.cpp | 5 +++++ 2 files changed, 7 insertions(+) diff --git a/include/fc/network/http/websocket.hpp b/include/fc/network/http/websocket.hpp index 210211eb3..f56b4beca 100644 --- a/include/fc/network/http/websocket.hpp +++ b/include/fc/network/http/websocket.hpp @@ -29,6 +29,8 @@ namespace fc { namespace http { void set_session_data( fc::any d ){ _session_data = std::move(d); } fc::any& get_session_data() { return _session_data; } + virtual std::string get_request_header(const std::string& key) = 0; + fc::signal closed; private: fc::any _session_data; diff --git a/src/network/http/websocket.cpp b/src/network/http/websocket.cpp index 1f92f7728..7f26b4d55 100644 --- a/src/network/http/websocket.cpp +++ b/src/network/http/websocket.cpp @@ -168,6 +168,11 @@ namespace fc { namespace http { _ws_connection->close(code,reason); } + virtual std::string get_request_header(const std::string& key)override + { + return _ws_connection->get_request_header(key); + } + T _ws_connection; }; From dd36202e74262b551588e88063e982ecf6bcd4f2 Mon Sep 17 00:00:00 2001 From: elmato Date: Fri, 27 Jan 2017 05:38:16 +0000 Subject: [PATCH 015/260] Replace the call to get_api_by_name with a direct call to the functions that return fc::api<> in the login_api. If the call to any of this functions succeed (because they where previously enabled), the api will auto-register itself in the websocket_api_connection/http_api_connection and will return an api_id_type. --- src/rpc/http_api.cpp | 4 +--- src/rpc/websocket_api.cpp | 4 +--- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/src/rpc/http_api.cpp b/src/rpc/http_api.cpp index 281febd1b..c9571a2ee 100644 --- a/src/rpc/http_api.cpp +++ b/src/rpc/http_api.cpp @@ -17,9 +17,7 @@ http_api_connection::http_api_connection() api_id_type api_id; if( args[0].is_string() ) { - variants subargs; - subargs.push_back( args[0] ); - variant subresult = this->receive_call( 1, "get_api_by_name", subargs ); + variant subresult = this->receive_call( 1, args[0].as_string() ); api_id = subresult.as_uint64(); } else diff --git a/src/rpc/websocket_api.cpp b/src/rpc/websocket_api.cpp index 6342b6f67..3c6efeffa 100644 --- a/src/rpc/websocket_api.cpp +++ b/src/rpc/websocket_api.cpp @@ -16,9 +16,7 @@ websocket_api_connection::websocket_api_connection( fc::http::websocket_connecti api_id_type api_id; if( args[0].is_string() ) { - variants subargs; - subargs.push_back( args[0] ); - variant subresult = this->receive_call( 1, "get_api_by_name", subargs ); + variant subresult = this->receive_call( 1, args[0].as_string() ); api_id = subresult.as_uint64(); } else From fe829980210d68b7878dc01df1ab23b197d759d7 Mon Sep 17 00:00:00 2001 From: Vikram Rajkumar Date: Thu, 16 Mar 2017 12:29:57 -0500 Subject: [PATCH 016/260] Remove NTP --- .gitignore | 1 - CMakeLists.txt | 1 - include/fc/network/ntp.hpp | 27 ---- src/network/ntp.cpp | 272 ------------------------------------- tests/CMakeLists.txt | 4 - tests/network/ntp_test.cpp | 30 ---- 6 files changed, 335 deletions(-) delete mode 100644 include/fc/network/ntp.hpp delete mode 100644 src/network/ntp.cpp delete mode 100644 tests/network/ntp_test.cpp diff --git a/.gitignore b/.gitignore index 5d3e63319..8f529ee45 100644 --- a/.gitignore +++ b/.gitignore @@ -48,5 +48,4 @@ fc_automoc.cpp git_revision.cpp GitSHA3.cpp -ntp_test task_cancel_test diff --git a/CMakeLists.txt b/CMakeLists.txt index fd6d2019f..aabe26a3d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -230,7 +230,6 @@ set( fc_sources src/network/http/http_connection.cpp src/network/http/http_server.cpp src/network/http/websocket.cpp - src/network/ntp.cpp src/network/ip.cpp src/network/rate_limiting.cpp src/network/resolve.cpp diff --git a/include/fc/network/ntp.hpp b/include/fc/network/ntp.hpp deleted file mode 100644 index 6067b3cae..000000000 --- a/include/fc/network/ntp.hpp +++ /dev/null @@ -1,27 +0,0 @@ -#pragma once -#include -#include -#include -#include - - -namespace fc { - - namespace detail { class ntp_impl; } - - class ntp - { - public: - ntp(); - ~ntp(); - - void add_server( const std::string& hostname, uint16_t port = 123 ); - void set_request_interval( uint32_t interval_sec ); - void request_now(); - optional get_time()const; - - private: - std::unique_ptr my; - }; - -} // namespace fc diff --git a/src/network/ntp.cpp b/src/network/ntp.cpp deleted file mode 100644 index 5c0a085be..000000000 --- a/src/network/ntp.cpp +++ /dev/null @@ -1,272 +0,0 @@ -#include -#include -#include -#include -#include - -#include -#include "../byteswap.hpp" - -#include -#include - -namespace fc -{ - namespace detail { - - class ntp_impl - { - public: - /** vector < host, port > */ - fc::thread _ntp_thread; - std::vector< std::pair< std::string, uint16_t> > _ntp_hosts; - fc::future _read_loop_done; - udp_socket _sock; - uint32_t _request_interval_sec; - uint32_t _retry_failed_request_interval_sec; - fc::time_point _last_valid_ntp_reply_received_time; - - std::atomic_bool _last_ntp_delta_initialized; - std::atomic _last_ntp_delta_microseconds; - - - fc::future _request_time_task_done; - - ntp_impl() : - _ntp_thread("ntp"), - _request_interval_sec( 60*60 /* 1 hr */), - _retry_failed_request_interval_sec(60 * 5), - _last_ntp_delta_microseconds(0) - { - _last_ntp_delta_initialized = false; - _ntp_hosts.push_back( std::make_pair( "pool.ntp.org",123 ) ); - } - - ~ntp_impl() - { - } - - fc::time_point ntp_timestamp_to_fc_time_point(uint64_t ntp_timestamp_net_order) - { - uint64_t ntp_timestamp_host = bswap_64(ntp_timestamp_net_order); - uint32_t fractional_seconds = ntp_timestamp_host & 0xffffffff; - uint32_t microseconds = (uint32_t)((((uint64_t)fractional_seconds * 1000000) + (uint64_t(1) << 31)) >> 32); - uint32_t seconds_since_1900 = ntp_timestamp_host >> 32; - uint32_t seconds_since_epoch = seconds_since_1900 - 2208988800; - return fc::time_point() + fc::seconds(seconds_since_epoch) + fc::microseconds(microseconds); - } - - uint64_t fc_time_point_to_ntp_timestamp(const fc::time_point& fc_timestamp) - { - uint64_t microseconds_since_epoch = (uint64_t)fc_timestamp.time_since_epoch().count(); - uint32_t seconds_since_epoch = (uint32_t)(microseconds_since_epoch / 1000000); - uint32_t seconds_since_1900 = seconds_since_epoch + 2208988800; - uint32_t microseconds = microseconds_since_epoch % 1000000; - uint32_t fractional_seconds = (uint32_t)((((uint64_t)microseconds << 32) + (uint64_t(1) << 31)) / 1000000); - uint64_t ntp_timestamp_net_order = ((uint64_t)seconds_since_1900 << 32) + fractional_seconds; - return bswap_64(ntp_timestamp_net_order); - } - - void request_now() - { - assert(_ntp_thread.is_current()); - for( auto item : _ntp_hosts ) - { - try - { - //wlog( "resolving... ${r}", ("r", item) ); - auto eps = resolve( item.first, item.second ); - for( auto ep : eps ) - { - // wlog( "sending request to ${ep}", ("ep",ep) ); - std::shared_ptr send_buffer(new char[48], [](char* p){ delete[] p; }); - std::array packet_to_send { {010,0,0,0,0,0,0,0,0} }; - memcpy(send_buffer.get(), packet_to_send.data(), packet_to_send.size()); - uint64_t* send_buf_as_64_array = (uint64_t*)send_buffer.get(); - send_buf_as_64_array[5] = fc_time_point_to_ntp_timestamp(fc::time_point::now()); // 5 = Transmit Timestamp - _sock.send_to(send_buffer, packet_to_send.size(), ep); - break; - } - } - catch (const fc::canceled_exception&) - { - throw; - } - // this could fail to resolve but we want to go on to other hosts.. - catch ( const fc::exception& e ) - { - elog( "${e}", ("e",e.to_detail_string() ) ); - } - } - } // request_now - - // started for first time in ntp() constructor, canceled in ~ntp() destructor - // this task gets invoked every _retry_failed_request_interval_sec (currently 5 min), and if - // _request_interval_sec (currently 1 hour) has passed since the last successful update, - // it sends a new request - void request_time_task() - { - assert(_ntp_thread.is_current()); - if (_last_valid_ntp_reply_received_time <= fc::time_point::now() - fc::seconds(_request_interval_sec - 5)) - request_now(); - if (!_request_time_task_done.valid() || !_request_time_task_done.canceled()) - _request_time_task_done = schedule( [=](){ request_time_task(); }, - fc::time_point::now() + fc::seconds(_retry_failed_request_interval_sec), - "request_time_task" ); - } // request_loop - - void start_read_loop() - { - _read_loop_done = _ntp_thread.async( [this](){ read_loop(); }, "ntp_read_loop" ); - } - - void read_loop() - { - assert(_ntp_thread.is_current()); - - uint32_t receive_buffer_size = sizeof(uint64_t) * 1024; - std::shared_ptr receive_buffer(new char[receive_buffer_size], [](char* p){ delete[] p; }); - uint64_t* recv_buf = (uint64_t*)receive_buffer.get(); - - //outer while to restart read-loop if exception is thrown while waiting to receive on socket. - while( !_read_loop_done.canceled() ) - { - // if you start the read while loop here, the recieve_from call will throw "invalid argument" on win32, - // so instead we start the loop after making our first request - try - { - _sock.open(); - request_time_task(); //this will re-send a time request - - while( !_read_loop_done.canceled() ) - { - fc::ip::endpoint from; - try - { - _sock.receive_from( receive_buffer, receive_buffer_size, from ); - // wlog("received ntp reply from ${from}",("from",from) ); - } FC_RETHROW_EXCEPTIONS(error, "Error reading from NTP socket"); - - fc::time_point receive_time = fc::time_point::now(); - fc::time_point origin_time = ntp_timestamp_to_fc_time_point(recv_buf[3]); - fc::time_point server_receive_time = ntp_timestamp_to_fc_time_point(recv_buf[4]); - fc::time_point server_transmit_time = ntp_timestamp_to_fc_time_point(recv_buf[5]); - - fc::microseconds offset(((server_receive_time - origin_time) + - (server_transmit_time - receive_time)).count() / 2); - fc::microseconds round_trip_delay((receive_time - origin_time) - - (server_transmit_time - server_receive_time)); - //wlog("origin_time = ${origin_time}, server_receive_time = ${server_receive_time}, server_transmit_time = ${server_transmit_time}, receive_time = ${receive_time}", - // ("origin_time", origin_time)("server_receive_time", server_receive_time)("server_transmit_time", server_transmit_time)("receive_time", receive_time)); - // wlog("ntp offset: ${offset}, round_trip_delay ${delay}", ("offset", offset)("delay", round_trip_delay)); - - //if the reply we just received has occurred more than a second after our last time request (it was more than a second ago since our last request) - if( round_trip_delay > fc::microseconds(300000) ) - { - wlog("received stale ntp reply requested at ${request_time}, send a new time request", ("request_time", origin_time)); - request_now(); //request another reply and ignore this one - } - else //we think we have a timely reply, process it - { - if( offset < fc::seconds(60*60*24) && offset > fc::seconds(-60*60*24) ) - { - _last_ntp_delta_microseconds = offset.count(); - _last_ntp_delta_initialized = true; - fc::microseconds ntp_delta_time = fc::microseconds(_last_ntp_delta_microseconds); - _last_valid_ntp_reply_received_time = receive_time; - wlog("ntp_delta_time updated to ${delta_time} us", ("delta_time",ntp_delta_time) ); - } - else - elog( "NTP time and local time vary by more than a day! ntp:${ntp_time} local:${local}", - ("ntp_time", receive_time + offset)("local", fc::time_point::now()) ); - } - } - } // try - catch (fc::canceled_exception) - { - throw; - } - catch (const fc::exception& e) - { - //swallow any other exception and restart loop - elog("exception in read_loop, going to restart it. ${e}",("e",e)); - } - catch (...) - { - //swallow any other exception and restart loop - elog("unknown exception in read_loop, going to restart it."); - } - _sock.close(); - fc::usleep(fc::seconds(_retry_failed_request_interval_sec)); - } //outer while loop - wlog("exiting ntp read_loop"); - } //end read_loop() - }; //ntp_impl - - } // namespace detail - - - - ntp::ntp() - :my( new detail::ntp_impl() ) - { - my->start_read_loop(); - } - - ntp::~ntp() - { - my->_ntp_thread.async([=](){ - try - { - my->_request_time_task_done.cancel_and_wait("ntp object is destructing"); - } - catch ( const fc::exception& e ) - { - wlog( "Exception thrown while shutting down NTP's request_time_task, ignoring: ${e}", ("e",e) ); - } - catch (...) - { - wlog( "Exception thrown while shutting down NTP's request_time_task, ignoring" ); - } - - try - { - my->_read_loop_done.cancel_and_wait("ntp object is destructing"); - } - catch ( const fc::exception& e ) - { - wlog( "Exception thrown while shutting down NTP's read_loop, ignoring: ${e}", ("e",e) ); - } - catch (...) - { - wlog( "Exception thrown while shutting down NTP's read_loop, ignoring" ); - } - - }, "ntp_shutdown_task").wait(); - } - - - void ntp::add_server( const std::string& hostname, uint16_t port) - { - my->_ntp_thread.async( [=](){ my->_ntp_hosts.push_back( std::make_pair(hostname,port) ); }, "add_server" ).wait(); - } - - void ntp::set_request_interval( uint32_t interval_sec ) - { - my->_request_interval_sec = interval_sec; - my->_retry_failed_request_interval_sec = std::min(my->_retry_failed_request_interval_sec, interval_sec); - } - - void ntp::request_now() - { - my->_ntp_thread.async( [=](){ my->request_now(); }, "request_now" ).wait(); - } - - optional ntp::get_time()const - { - if( my->_last_ntp_delta_initialized ) - return fc::time_point::now() + fc::microseconds(my->_last_ntp_delta_microseconds); - return optional(); - } - -} //namespace fc diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index a1c9fef0c..1043e505c 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -10,9 +10,6 @@ if( ECC_IMPL STREQUAL secp256k1 ) target_link_libraries( blind fc ) endif() -add_executable( ntp_test all_tests.cpp network/ntp_test.cpp ) -target_link_libraries( ntp_test fc ) - add_executable( task_cancel_test all_tests.cpp thread/task_cancel.cpp ) target_link_libraries( task_cancel_test fc ) @@ -52,7 +49,6 @@ add_executable( all_tests all_tests.cpp crypto/dh_test.cpp crypto/rand_test.cpp crypto/sha_tests.cpp - network/ntp_test.cpp network/http/websocket_test.cpp thread/task_cancel.cpp bloom_test.cpp diff --git a/tests/network/ntp_test.cpp b/tests/network/ntp_test.cpp deleted file mode 100644 index 957d1e413..000000000 --- a/tests/network/ntp_test.cpp +++ /dev/null @@ -1,30 +0,0 @@ -#include - -#include -#include -#include - -BOOST_AUTO_TEST_SUITE(fc_network) - -BOOST_AUTO_TEST_CASE( ntp_test ) -{ - ilog("start ntp test"); - fc::usleep( fc::seconds(1) ); - ilog("done ntp test"); - /* - fc::ntp ntp_service; - ntp_service.set_request_interval(5); - fc::usleep(fc::seconds(4) ); - auto time = ntp_service.get_time(); - BOOST_CHECK( time ); - auto ntp_time = *time; - auto delta = ntp_time - fc::time_point::now(); -// auto minutes = delta.count() / 1000000 / 60; -// auto hours = delta.count() / 1000000 / 60 / 60; -// auto seconds = delta.count() / 1000000; - auto msec= delta.count() / 1000; - BOOST_CHECK( msec < 100 ); - */ -} - -BOOST_AUTO_TEST_SUITE_END() From 0d0b485f3ab76d46da1bbe5d85c60a6d95e06bd4 Mon Sep 17 00:00:00 2001 From: Vikram Rajkumar Date: Thu, 16 Mar 2017 12:33:30 -0500 Subject: [PATCH 017/260] Remove GNTP (unrelated to NTP) --- CMakeLists.txt | 1 - include/fc/network/gntp.hpp | 57 ------- src/network/gntp.cpp | 291 ------------------------------------ 3 files changed, 349 deletions(-) delete mode 100644 include/fc/network/gntp.hpp delete mode 100644 src/network/gntp.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index aabe26a3d..e2ff40de4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -234,7 +234,6 @@ set( fc_sources src/network/rate_limiting.cpp src/network/resolve.cpp src/network/url.cpp - src/network/gntp.cpp src/compress/smaz.cpp src/compress/zlib.cpp vendor/cyoencode-1.0.2/src/CyoDecode.c diff --git a/include/fc/network/gntp.hpp b/include/fc/network/gntp.hpp deleted file mode 100644 index fcfa6563c..000000000 --- a/include/fc/network/gntp.hpp +++ /dev/null @@ -1,57 +0,0 @@ -#pragma once -#include -#include -#include -#include - -#include -#include - -namespace fc -{ - namespace detail { - class gntp_icon_impl; - } - class gntp_notifier; - - class gntp_icon { - public: - gntp_icon(const char* buffer, size_t length); - ~gntp_icon(); - private: - std::unique_ptr my; - friend class gntp_notifier; - }; - typedef std::shared_ptr gntp_icon_ptr; - - class gntp_notification_type { - public: - std::string name; - std::string display_name; - bool enabled; - gntp_icon_ptr icon; - }; - typedef std::vector gntp_notification_type_list; - - namespace detail { - class gntp_notifier_impl; - } - - typedef uint160_t gntp_guid; - - class gntp_notifier { - public: - gntp_notifier(const std::string& host_to_notify = "127.0.0.1", uint16_t port = 23053, - const optional& password = optional()); - ~gntp_notifier(); - void set_application_name(std::string application_name); - void set_application_icon(const gntp_icon_ptr& icon); - void register_notifications(); - gntp_guid send_notification(std::string name, std::string title, std::string text, const gntp_icon_ptr& icon = gntp_icon_ptr(), optional coalescingId = optional()); - void add_notification_type(const gntp_notification_type& notificationType); - private: - std::unique_ptr my; - }; - - -} // namespace fc diff --git a/src/network/gntp.cpp b/src/network/gntp.cpp deleted file mode 100644 index 89c17354f..000000000 --- a/src/network/gntp.cpp +++ /dev/null @@ -1,291 +0,0 @@ -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -namespace fc -{ - namespace detail - { - static std::string calc_sha1_base32_of_buffer(const std::string& buffer) - { - sha1::encoder sha1_encoder; - sha1_encoder.write(buffer.c_str(), buffer.size()); - sha1 sha1_result = sha1_encoder.result(); - string sha1_result_base32 = to_base32((char*)&sha1_result, sizeof(sha1_result)); - return sha1_result_base32.c_str(); - } - - - class gntp_icon_impl - { - public: - std::string _icon_bytes; - std::string _sha1_hash; - - gntp_icon_impl(const char* buffer, size_t length) : - _icon_bytes(buffer, length), - _sha1_hash(calc_sha1_base32_of_buffer(_icon_bytes)) - { - } - }; - - class gntp_notifier_impl - { - public: - gntp_notifier_impl(const std::string& host_to_notify = "127.0.0.1", uint16_t port = 23053, const optional& password = optional()); - - // there's no API to change these right now, it will always notify localhost at the default GNTP port - std::string hostname; - uint16_t port; - optional password; - - std::string application_name; - gntp_icon_ptr application_icon; - - gntp_notification_type_list notification_types; // list of all notification types we're registered to send - - optional endpoint; // cache the last endpoint we've connected to - - bool connection_failed; // true after we've tried to connect and failed - bool is_registered; // true after we've registered - - void send_gntp_message(const std::string& message); - }; - - gntp_notifier_impl::gntp_notifier_impl(const std::string& host_to_notify /* = "127.0.0.1" */, uint16_t port /* = 23053 */, - const optional& password /* = optional() */) : - hostname(host_to_notify), - port(port), - password(password), - connection_failed(false), - is_registered(false) - { - } - - void gntp_notifier_impl::send_gntp_message(const std::string& message) - { - std::shared_ptr sock(new boost::asio::ip::tcp::socket(asio::default_io_service())); - - bool connected = false; - if (endpoint) - { - // we've successfully connected before, connect to the same endpoint that worked last time - try - { - asio::tcp::connect(*sock, *endpoint); - connected = true; - } - catch (exception& er) - { - ilog("Failed to connect to GNTP service using an endpoint that previously worked: ${error_report}", - ("error_report", er.to_detail_string())); - sock->close(); - // clear the cached endpoint and fall through to the full connection procedure - endpoint = optional(); - } - catch (...) - { - ilog("Failed to connect to GNTP service using an endpoint that previously worked"); - sock->close(); - // clear the cached endpoint and fall through to the full connection procedure - endpoint = optional(); - } - } - if (!connected) - { - // do the full connection procedure - auto eps = asio::tcp::resolve(hostname, boost::lexical_cast(port)); - if (eps.size() == 0) - FC_THROW("Unable to resolve host '${host}'", ("host", hostname)); - - for (uint32_t i = 0; i < eps.size(); ++i) - { - try - { - boost::system::error_code ec; - ilog("Attempting to connect to GNTP srvice"); - asio::tcp::connect(*sock, eps[i]); - endpoint = eps[i]; - connected = true; - break; - } - catch (const exception& er) - { - ilog("Failed to connect to GNTP service: ${error_reprot}", - ("error_report", er.to_detail_string()) ); - sock->close(); - } - catch (...) - { - ilog("Failed to connect to GNTP service"); - sock->close(); - } - } - } - if (!connected) - FC_THROW("Unable to connect to any resolved endpoint for ${host}:${port}", - ("host", hostname)("port", port)); - try - { - asio::ostream write_stream(sock); - write_stream.write(message.c_str(), message.size()); - write_stream.flush(); - write_stream.close(); - } - catch (exception& er) - { - FC_RETHROW_EXCEPTION(er, warn, "Caught an exception while sending data to GNTP service"); - } - catch (...) - { - FC_THROW("Caught an exception while sending data to GNTP service"); - } - } - } // end namespace detail - - gntp_icon::gntp_icon(const char* buffer, size_t length) : - my(new detail::gntp_icon_impl(buffer, length)) - { - } - gntp_icon::~gntp_icon() - { - } - - gntp_notifier::gntp_notifier(const std::string& host_to_notify /* = "127.0.0.1" */, uint16_t port /* = 23053 */, - const optional& password /* = optional() */) : - my(new detail::gntp_notifier_impl(host_to_notify, port, password)) - { - } - - gntp_notifier::~gntp_notifier() - { - } - - void gntp_notifier::set_application_name(std::string appName) - { - my->application_name = appName; - } - void gntp_notifier::set_application_icon(const gntp_icon_ptr& icon) - { - my->application_icon = icon; - } - void gntp_notifier::add_notification_type(const gntp_notification_type& notification_type) - { - my->notification_types.push_back(notification_type); - } - - void gntp_notifier::register_notifications() - { - // this call will reset any errors - my->connection_failed = false; - my->is_registered = false; - - std::ostringstream message; - std::set icons_used; - - message << "GNTP/1.0 REGISTER NONE\r\n"; - message << "Application-Name: " << my->application_name << "\r\n"; - if (my->application_icon) - { - message << "Application-Icon: x-growl-resource://" << my->application_icon->my->_sha1_hash << "\r\n"; - icons_used.insert(my->application_icon); - } - - message << "Notifications-Count: " << my->notification_types.size() << "\r\n"; - for (const gntp_notification_type& notification_type : my->notification_types) - { - message << "\r\n"; - message << "Notification-Name: " << notification_type.name << "\r\n"; - if (!notification_type.display_name.empty()) - message << "Notification-Display-Name: " << notification_type.display_name << "\r\n"; - if (notification_type.icon) - { - message << "Notification-Icon: x-growl-resource://" << notification_type.icon->my->_sha1_hash << "\r\n"; - icons_used.insert(notification_type.icon); - } - message << "Notification-Enabled: " << (notification_type.enabled ? "True" : "False") << "\r\n"; - } - if (!icons_used.empty()) - { - message << "\r\n"; - for (const gntp_icon_ptr& icon : icons_used) - { - message << "Identifier: " << icon->my->_sha1_hash << "\r\n"; - message << "Length: " << icon->my->_icon_bytes.size() << "\r\n"; - message << "\r\n"; - message << icon->my->_icon_bytes; - message << "\r\n"; - } - } - - message << "\r\n\r\n"; - try - { - my->send_gntp_message(message.str()); - my->is_registered = true; - } - catch (const exception&) - { - my->connection_failed = true; - } - } - gntp_guid gntp_notifier::send_notification(std::string name, std::string title, std::string text, - const gntp_icon_ptr& icon, optional coalescingId /* = optional() */) - { - if (my->connection_failed) - return gntp_guid(); - if (!my->is_registered) - return gntp_guid(); - - gntp_guid notification_id; - rand_pseudo_bytes(notification_id.data(), 20); - - std::ostringstream message; - message << "GNTP/1.0 NOTIFY NONE"; - if (my->password) - { - char salt[16]; - rand_pseudo_bytes(salt, sizeof(salt)); - std::string salted_password = *my->password + std::string(salt, 16); - sha256 key = sha256::hash(salted_password); - sha256 keyhash = sha256::hash(key.data(), 32); - message << " SHA256:" << boost::to_upper_copy(to_hex(keyhash.data(), 32)) << "." << boost::to_upper_copy(to_hex(salt, sizeof(salt))); - } - message << "\r\n"; - message << "Application-Name: " << my->application_name << "\r\n"; - message << "Notification-Name: " << name << "\r\n"; - message << "Notification-ID: " << notification_id.str() << "\r\n"; - message << "Notification-Coalescing-ID: " << (coalescingId ? coalescingId->str() : notification_id.str()) << "\r\n"; - message << "Notification-Title: " << title << "\r\n"; - message << "Notification-Text: " << text << "\r\n"; - if (icon) - message << "Notification-Icon: x-growl-resource://" << icon->my->_sha1_hash << "\r\n"; - - if (icon) - { - message << "\r\n"; - message << "Identifier: " << icon->my->_sha1_hash << "\r\n"; - message << "Length: " << icon->my->_icon_bytes.size() << "\r\n"; - message << "\r\n"; - message << icon->my->_icon_bytes; - message << "\r\n"; - } - message << "\r\n\r\n"; - my->send_gntp_message(message.str()); - return notification_id; - } - -} // namespace fc \ No newline at end of file From 25d7b3055f9cec988632ea920ef0cdf103ee37b0 Mon Sep 17 00:00:00 2001 From: oxarbitrage Date: Fri, 17 Mar 2017 18:31:45 -0300 Subject: [PATCH 018/260] struct range_proof_info change int to int64_t https://github.com/bitshares/bitshares-core/issues/160 --- include/fc/crypto/elliptic.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/fc/crypto/elliptic.hpp b/include/fc/crypto/elliptic.hpp index dd60da736..7d3046f25 100644 --- a/include/fc/crypto/elliptic.hpp +++ b/include/fc/crypto/elliptic.hpp @@ -218,8 +218,8 @@ namespace fc { struct range_proof_info { - int exp; - int mantissa; + int64_t exp; + int64_t mantissa; uint64_t min_value; uint64_t max_value; }; From fa63cd799f9c33828f89e862fc34e02a545b26c6 Mon Sep 17 00:00:00 2001 From: Michael Vandeberg Date: Mon, 10 Apr 2017 11:12:24 -0400 Subject: [PATCH 019/260] Responses contain jsonrpc field and increased readability of errors #13 --- include/fc/rpc/state.hpp | 5 ++++- src/exception.cpp | 9 +++++---- src/rpc/websocket_api.cpp | 5 +++-- 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/include/fc/rpc/state.hpp b/include/fc/rpc/state.hpp index 3c36bcf9f..e031530b6 100644 --- a/include/fc/rpc/state.hpp +++ b/include/fc/rpc/state.hpp @@ -23,7 +23,10 @@ namespace fc { namespace rpc { response(){} response( int64_t i, fc::variant r ):id(i),result(r){} response( int64_t i, error_object r ):id(i),error(r){} + response( int64_t i, fc::variant r, string j ):id(i),jsonrpc(j),result(r){} + response( int64_t i, error_object r, string j ):id(i),jsonrpc(j),error(r){} int64_t id = 0; + optional jsonrpc; optional result; optional error; }; @@ -57,4 +60,4 @@ namespace fc { namespace rpc { FC_REFLECT( fc::rpc::request, (id)(method)(params) ); FC_REFLECT( fc::rpc::error_object, (code)(message)(data) ) -FC_REFLECT( fc::rpc::response, (id)(result)(error) ) +FC_REFLECT( fc::rpc::response, (id)(jsonrpc)(result)(error) ) diff --git a/src/exception.cpp b/src/exception.cpp index fef482af6..7da6bea0b 100644 --- a/src/exception.cpp +++ b/src/exception.cpp @@ -156,7 +156,7 @@ namespace fc * and other information that is generally only useful for * developers. */ - string exception::to_detail_string( log_level ll )const + string exception::to_detail_string( log_level ll )const { fc::stringstream ss; ss << variant(my->_code).as_string() <<" " << my->_name << ": " <_what<<"\n"; @@ -174,13 +174,14 @@ namespace fc /** * Generates a user-friendly error report. */ - string exception::to_string( log_level ll )const + string exception::to_string( log_level ll )const { fc::stringstream ss; - ss << what() << " (" << variant(my->_code).as_string() <<")\n"; + ss << what() << ":"; for( auto itr = my->_elog.begin(); itr != my->_elog.end(); ++itr ) { - ss << fc::format_string( itr->get_format(), itr->get_data() ) <<"\n"; + if( itr->get_format().size() ) + ss << " " << fc::format_string( itr->get_format(), itr->get_data() ); // ss << " " << itr->get_context().to_string() <<"\n"; } return ss.str(); diff --git a/src/rpc/websocket_api.cpp b/src/rpc/websocket_api.cpp index 5f86474bb..fe95d8c81 100644 --- a/src/rpc/websocket_api.cpp +++ b/src/rpc/websocket_api.cpp @@ -90,6 +90,7 @@ std::string websocket_api_connection::on_message( { auto var = fc::json::from_string(message); const auto& var_obj = var.get_object(); + if( var_obj.contains( "method" ) ) { auto call = var.as(); @@ -115,7 +116,7 @@ std::string websocket_api_connection::on_message( if( call.id ) { - auto reply = fc::json::to_string( response( *call.id, result ) ); + auto reply = fc::json::to_string( response( *call.id, result, "2.0" ) ); if( send_message ) _connection.send_message( reply ); return reply; @@ -132,7 +133,7 @@ std::string websocket_api_connection::on_message( } if( optexcept ) { - auto reply = fc::json::to_string( response( *call.id, error_object{ 1, optexcept->to_detail_string(), fc::variant(*optexcept)} ) ); + auto reply = fc::json::to_string( response( *call.id, error_object{ 1, optexcept->to_string(), fc::variant(*optexcept)}, "2.0" ) ); if( send_message ) _connection.send_message( reply ); From 908762d687eccab019403189fd1d95502fb75c89 Mon Sep 17 00:00:00 2001 From: Nathan Hourt Date: Tue, 25 Apr 2017 15:39:42 -0500 Subject: [PATCH 020/260] ...Fix build? --- include/fc/static_variant.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/fc/static_variant.hpp b/include/fc/static_variant.hpp index 9aab79037..228eb658b 100644 --- a/include/fc/static_variant.hpp +++ b/include/fc/static_variant.hpp @@ -382,5 +382,5 @@ struct visitor { s.visit( to_static_variant(ar[1]) ); } - template struct get_typename { static const char* name() { return typeid(static_variant).name(); } }; + template struct get_typename> { static const char* name() { return typeid(static_variant).name(); } }; } // namespace fc From fee06a4c75d3215f9b502f8145383005bdda2c80 Mon Sep 17 00:00:00 2001 From: Nathan Hourt Date: Tue, 25 Apr 2017 15:50:56 -0500 Subject: [PATCH 021/260] Add OpenSSL 1.1.0 support These changes should add support for openssl 1.1.0 while maintaining compatibility with 1.0.2 --- src/crypto/base58.cpp | 142 ++++++++++++++++++++++-------------------- src/crypto/dh.cpp | 47 +++++++++++++- 2 files changed, 119 insertions(+), 70 deletions(-) diff --git a/src/crypto/base58.cpp b/src/crypto/base58.cpp index e1d5d333e..46c9adcdd 100644 --- a/src/crypto/base58.cpp +++ b/src/crypto/base58.cpp @@ -66,74 +66,71 @@ class CAutoBN_CTX /** C++ wrapper for BIGNUM (OpenSSL bignum) */ -class CBigNum : public BIGNUM +class CBigNum { + BIGNUM* bn; public: CBigNum() - { - BN_init(this); - } + : bn(BN_new()) {} CBigNum(const CBigNum& b) + : CBigNum() { - BN_init(this); - if (!BN_copy(this, &b)) + if (!BN_copy(bn, b.bn)) { - BN_clear_free(this); + BN_clear_free(bn); throw bignum_error("CBigNum::CBigNum(const CBigNum&) : BN_copy failed"); } } CBigNum& operator=(const CBigNum& b) { - if (!BN_copy(this, &b)) + if (!BN_copy(bn, b.bn)) throw bignum_error("CBigNum::operator= : BN_copy failed"); return (*this); } ~CBigNum() { - BN_clear_free(this); + BN_clear_free(bn); } //CBigNum(char n) is not portable. Use 'signed char' or 'unsigned char'. - CBigNum(signed char n) { BN_init(this); if (n >= 0) setulong(n); else setint64(n); } - CBigNum(short n) { BN_init(this); if (n >= 0) setulong(n); else setint64(n); } - CBigNum(int n) { BN_init(this); if (n >= 0) setulong(n); else setint64(n); } - //CBigNum(long n) { BN_init(this); if (n >= 0) setulong(n); else setint64(n); } - CBigNum(int64_t n) { BN_init(this); setint64(n); } - CBigNum(unsigned char n) { BN_init(this); setulong(n); } - CBigNum(unsigned short n) { BN_init(this); setulong(n); } - CBigNum(unsigned int n) { BN_init(this); setulong(n); } - //CBigNum(unsigned long n) { BN_init(this); setulong(n); } - CBigNum(uint64_t n) { BN_init(this); setuint64(n); } + CBigNum(signed char n) :CBigNum() { if (n >= 0) setulong(n); else setint64(n); } + CBigNum(short n) :CBigNum() { if (n >= 0) setulong(n); else setint64(n); } + CBigNum(int n) :CBigNum() { if (n >= 0) setulong(n); else setint64(n); } + CBigNum(int64_t n) :CBigNum() { setint64(n); } + CBigNum(unsigned char n) :CBigNum() { setulong(n); } + CBigNum(unsigned short n) :CBigNum() { setulong(n); } + CBigNum(unsigned int n) :CBigNum() { setulong(n); } + CBigNum(uint64_t n) :CBigNum() { setuint64(n); } explicit CBigNum(const std::vector& vch) + : CBigNum() { - BN_init(this); setvch(vch); } void setulong(unsigned long n) { - if (!BN_set_word(this, n)) + if (!BN_set_word(bn, n)) throw bignum_error("CBigNum conversion from unsigned long : BN_set_word failed"); } unsigned long getulong() const { - return BN_get_word(this); + return BN_get_word(bn); } unsigned int getuint() const { - return BN_get_word(this); + return BN_get_word(bn); } int getint() const { - unsigned long n = BN_get_word(this); - if (!BN_is_negative(this)) + unsigned long n = BN_get_word(bn); + if (!BN_is_negative(bn)) return (n > (unsigned long)std::numeric_limits::max() ? std::numeric_limits::max() : n); else return (n > (unsigned long)std::numeric_limits::max() ? std::numeric_limits::min() : -(int)n); @@ -171,7 +168,7 @@ class CBigNum : public BIGNUM pch[1] = (nSize >> 16) & 0xff; pch[2] = (nSize >> 8) & 0xff; pch[3] = (nSize) & 0xff; - BN_mpi2bn(pch, p - pch, this); + BN_mpi2bn(pch, p - pch, bn); } void setuint64(uint64_t n) @@ -198,7 +195,7 @@ class CBigNum : public BIGNUM pch[1] = (nSize >> 16) & 0xff; pch[2] = (nSize >> 8) & 0xff; pch[3] = (nSize) & 0xff; - BN_mpi2bn(pch, p - pch, this); + BN_mpi2bn(pch, p - pch, bn); } @@ -214,16 +211,16 @@ class CBigNum : public BIGNUM vch2[3] = (nSize >> 0) & 0xff; // swap data to big endian reverse_copy(vch.begin(), vch.end(), vch2.begin() + 4); - BN_mpi2bn(&vch2[0], vch2.size(), this); + BN_mpi2bn(&vch2[0], vch2.size(), bn); } std::vector getvch() const { - unsigned int nSize = BN_bn2mpi(this, NULL); + unsigned int nSize = BN_bn2mpi(bn, NULL); if (nSize <= 4) return std::vector(); std::vector vch(nSize); - BN_bn2mpi(this, &vch[0]); + BN_bn2mpi(bn, &vch[0]); vch.erase(vch.begin(), vch.begin() + 4); reverse(vch.begin(), vch.end()); return vch; @@ -237,16 +234,16 @@ class CBigNum : public BIGNUM if (nSize >= 1) vch[4] = (nCompact >> 16) & 0xff; if (nSize >= 2) vch[5] = (nCompact >> 8) & 0xff; if (nSize >= 3) vch[6] = (nCompact >> 0) & 0xff; - BN_mpi2bn(&vch[0], vch.size(), this); + BN_mpi2bn(&vch[0], vch.size(), bn); return *this; } unsigned int GetCompact() const { - unsigned int nSize = BN_bn2mpi(this, NULL); + unsigned int nSize = BN_bn2mpi(bn, NULL); std::vector vch(nSize); nSize -= 4; - BN_bn2mpi(this, &vch[0]); + BN_bn2mpi(bn, &vch[0]); unsigned int nCompact = nSize << 24; if (nSize >= 1) nCompact |= (vch[4] << 16); if (nSize >= 2) nCompact |= (vch[5] << 8); @@ -281,7 +278,7 @@ class CBigNum : public BIGNUM *this += n; } if (fNegative) - *this = 0 - *this; + BN_set_negative(bn, 1); } std::string ToString(int nBase=10) const @@ -291,20 +288,20 @@ class CBigNum : public BIGNUM CBigNum bn0 = 0; std::string str; CBigNum bn = *this; - BN_set_negative(&bn, false); + BN_set_negative(bn.bn, false); CBigNum dv; CBigNum rem; - if (BN_cmp(&bn, &bn0) == 0) + if (BN_cmp(bn.bn, bn0.bn) == 0) return "0"; - while (BN_cmp(&bn, &bn0) > 0) + while (BN_cmp(bn.bn, bn0.bn) > 0) { - if (!BN_div(&dv, &rem, &bn, &bnBase, pctx)) + if (!BN_div(dv.bn, rem.bn, bn.bn, bnBase.bn, pctx)) throw bignum_error("CBigNum::ToString() : BN_div failed"); bn = dv; unsigned int c = rem.getulong(); str += "0123456789abcdef"[c]; } - if (BN_is_negative(this)) + if (BN_is_negative(this->bn)) str += "-"; reverse(str.begin(), str.end()); return str; @@ -319,45 +316,50 @@ class CBigNum : public BIGNUM bool operator!() const { - return BN_is_zero(this); + return BN_is_zero(bn); } CBigNum& operator+=(const CBigNum& b) { - if (!BN_add(this, this, &b)) + if (!BN_add(bn, bn, b.bn)) throw bignum_error("CBigNum::operator+= : BN_add failed"); return *this; } CBigNum& operator-=(const CBigNum& b) { - *this = *this - b; + if (!BN_sub(bn, bn, b.bn)) + throw bignum_error("CBigNum::operator-= : BN_sub failed"); return *this; } CBigNum& operator*=(const CBigNum& b) { CAutoBN_CTX pctx; - if (!BN_mul(this, this, &b, pctx)) + if (!BN_mul(bn, bn, b.bn, pctx)) throw bignum_error("CBigNum::operator*= : BN_mul failed"); return *this; } CBigNum& operator/=(const CBigNum& b) { - *this = *this / b; + CAutoBN_CTX pctx; + if (!BN_div(bn, NULL, bn, b.bn, pctx)) + throw bignum_error("CBigNum::operator/= : BN_div failed"); return *this; } CBigNum& operator%=(const CBigNum& b) { - *this = *this % b; + CAutoBN_CTX pctx; + if (!BN_div(NULL, bn, bn, b.bn, pctx)) + throw bignum_error("CBigNum::operator%= : BN_div failed"); return *this; } CBigNum& operator<<=(unsigned int shift) { - if (!BN_lshift(this, this, shift)) + if (!BN_lshift(bn, bn, shift)) throw bignum_error("CBigNum:operator<<= : BN_lshift failed"); return *this; } @@ -368,13 +370,13 @@ class CBigNum : public BIGNUM // if built on ubuntu 9.04 or 9.10, probably depends on version of openssl CBigNum a = 1; a <<= shift; - if (BN_cmp(&a, this) > 0) + if (BN_cmp(a.bn, bn) > 0) { *this = 0; return *this; } - if (!BN_rshift(this, this, shift)) + if (!BN_rshift(bn, bn, shift)) throw bignum_error("CBigNum:operator>>= : BN_rshift failed"); return *this; } @@ -383,7 +385,7 @@ class CBigNum : public BIGNUM CBigNum& operator++() { // prefix operator - if (!BN_add(this, this, BN_value_one())) + if (!BN_add(bn, bn, BN_value_one())) throw bignum_error("CBigNum::operator++ : BN_add failed"); return *this; } @@ -400,7 +402,7 @@ class CBigNum : public BIGNUM { // prefix operator CBigNum r; - if (!BN_sub(&r, this, BN_value_one())) + if (!BN_sub(r.bn, bn, BN_value_one())) throw bignum_error("CBigNum::operator-- : BN_sub failed"); *this = r; return *this; @@ -414,10 +416,12 @@ class CBigNum : public BIGNUM return ret; } - - friend inline const CBigNum operator-(const CBigNum& a, const CBigNum& b); - friend inline const CBigNum operator/(const CBigNum& a, const CBigNum& b); - friend inline const CBigNum operator%(const CBigNum& a, const CBigNum& b); + const BIGNUM* to_bignum() const { + return bn; + } + BIGNUM* to_bignum() { + return bn; + } }; @@ -425,7 +429,7 @@ class CBigNum : public BIGNUM inline const CBigNum operator+(const CBigNum& a, const CBigNum& b) { CBigNum r; - if (!BN_add(&r, &a, &b)) + if (!BN_add(r.to_bignum(), a.to_bignum(), b.to_bignum())) throw bignum_error("CBigNum::operator+ : BN_add failed"); return r; } @@ -433,7 +437,7 @@ inline const CBigNum operator+(const CBigNum& a, const CBigNum& b) inline const CBigNum operator-(const CBigNum& a, const CBigNum& b) { CBigNum r; - if (!BN_sub(&r, &a, &b)) + if (!BN_sub(r.to_bignum(), a.to_bignum(), b.to_bignum())) throw bignum_error("CBigNum::operator- : BN_sub failed"); return r; } @@ -441,7 +445,7 @@ inline const CBigNum operator-(const CBigNum& a, const CBigNum& b) inline const CBigNum operator-(const CBigNum& a) { CBigNum r(a); - BN_set_negative(&r, !BN_is_negative(&r)); + BN_set_negative(r.to_bignum(), !BN_is_negative(r.to_bignum())); return r; } @@ -449,7 +453,7 @@ inline const CBigNum operator*(const CBigNum& a, const CBigNum& b) { CAutoBN_CTX pctx; CBigNum r; - if (!BN_mul(&r, &a, &b, pctx)) + if (!BN_mul(r.to_bignum(), a.to_bignum(), b.to_bignum(), pctx)) throw bignum_error("CBigNum::operator* : BN_mul failed"); return r; } @@ -458,7 +462,7 @@ inline const CBigNum operator/(const CBigNum& a, const CBigNum& b) { CAutoBN_CTX pctx; CBigNum r; - if (!BN_div(&r, NULL, &a, &b, pctx)) + if (!BN_div(r.to_bignum(), NULL, a.to_bignum(), b.to_bignum(), pctx)) throw bignum_error("CBigNum::operator/ : BN_div failed"); return r; } @@ -467,7 +471,7 @@ inline const CBigNum operator%(const CBigNum& a, const CBigNum& b) { CAutoBN_CTX pctx; CBigNum r; - if (!BN_mod(&r, &a, &b, pctx)) + if (!BN_mod(r.to_bignum(), a.to_bignum(), b.to_bignum(), pctx)) throw bignum_error("CBigNum::operator% : BN_div failed"); return r; } @@ -475,7 +479,7 @@ inline const CBigNum operator%(const CBigNum& a, const CBigNum& b) inline const CBigNum operator<<(const CBigNum& a, unsigned int shift) { CBigNum r; - if (!BN_lshift(&r, &a, shift)) + if (!BN_lshift(r.to_bignum(), a.to_bignum(), shift)) throw bignum_error("CBigNum:operator<< : BN_lshift failed"); return r; } @@ -487,12 +491,12 @@ inline const CBigNum operator>>(const CBigNum& a, unsigned int shift) return r; } -inline bool operator==(const CBigNum& a, const CBigNum& b) { return (BN_cmp(&a, &b) == 0); } -inline bool operator!=(const CBigNum& a, const CBigNum& b) { return (BN_cmp(&a, &b) != 0); } -inline bool operator<=(const CBigNum& a, const CBigNum& b) { return (BN_cmp(&a, &b) <= 0); } -inline bool operator>=(const CBigNum& a, const CBigNum& b) { return (BN_cmp(&a, &b) >= 0); } -inline bool operator<(const CBigNum& a, const CBigNum& b) { return (BN_cmp(&a, &b) < 0); } -inline bool operator>(const CBigNum& a, const CBigNum& b) { return (BN_cmp(&a, &b) > 0); } +inline bool operator==(const CBigNum& a, const CBigNum& b) { return (BN_cmp(a.to_bignum(), b.to_bignum()) == 0); } +inline bool operator!=(const CBigNum& a, const CBigNum& b) { return (BN_cmp(a.to_bignum(), b.to_bignum()) != 0); } +inline bool operator<=(const CBigNum& a, const CBigNum& b) { return (BN_cmp(a.to_bignum(), b.to_bignum()) <= 0); } +inline bool operator>=(const CBigNum& a, const CBigNum& b) { return (BN_cmp(a.to_bignum(), b.to_bignum()) >= 0); } +inline bool operator<(const CBigNum& a, const CBigNum& b) { return (BN_cmp(a.to_bignum(), b.to_bignum()) < 0); } +inline bool operator>(const CBigNum& a, const CBigNum& b) { return (BN_cmp(a.to_bignum(), b.to_bignum()) > 0); } static const char* pszBase58 = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"; @@ -522,7 +526,7 @@ inline std::string EncodeBase58(const unsigned char* pbegin, const unsigned char CBigNum rem; while (bn > bn0) { - if (!BN_div(&dv, &rem, &bn, &bn58, pctx)) + if (!BN_div(dv.to_bignum(), rem.to_bignum(), bn.to_bignum(), bn58.to_bignum(), pctx)) throw bignum_error("EncodeBase58 : BN_div failed"); bn = dv; unsigned int c = rem.getulong(); @@ -572,7 +576,7 @@ inline bool DecodeBase58(const char* psz, std::vector& vchRet) break; } bnChar.setulong(p1 - pszBase58); - if (!BN_mul(&bn, &bn, &bn58, pctx)) + if (!BN_mul(bn.to_bignum(), bn.to_bignum(), bn58.to_bignum(), pctx)) throw bignum_error("DecodeBase58 : BN_mul failed"); bn += bnChar; } diff --git a/src/crypto/dh.cpp b/src/crypto/dh.cpp index cbd7dcc25..e7f6c59d3 100644 --- a/src/crypto/dh.cpp +++ b/src/crypto/dh.cpp @@ -1,6 +1,9 @@ #include #include +#if OPENSSL_VERSION_NUMBER >= 0x10100000L +#endif + namespace fc { SSL_TYPE(ssl_dh, DH, DH_free) @@ -12,10 +15,19 @@ namespace fc { bool diffie_hellman::generate_params( int s, uint8_t g ) { - ssl_dh dh = DH_generate_parameters( s, g, NULL, NULL ); + ssl_dh dh; + DH_generate_parameters_ex(dh.obj, s, g, NULL); +#if OPENSSL_VERSION_NUMBER >= 0x10100000L + ssl_bignum bn_p; + DH_get0_pqg(dh.obj, (const BIGNUM**)&bn_p.obj, NULL, NULL); + p.resize( BN_num_bytes( bn_p ) ); + if( p.size() ) + BN_bn2bin( bn_p, (unsigned char*)&p.front() ); +#else p.resize( BN_num_bytes( dh->p ) ); if( p.size() ) BN_bn2bin( dh->p, (unsigned char*)&p.front() ); +#endif this->g = g; return fc::validate( dh, valid ); } @@ -25,8 +37,14 @@ namespace fc { if( !p.size() ) return valid = false; ssl_dh dh = DH_new(); +#if OPENSSL_VERSION_NUMBER >= 0x10100000L + const auto bn_p = BN_bin2bn( (unsigned char*)&p.front(), p.size(), NULL ); + const auto bn_g = BN_bin2bn( (unsigned char*)&g, 1, NULL ); + DH_set0_pqg(dh.obj, bn_p, NULL, bn_g); +#else dh->p = BN_bin2bn( (unsigned char*)&p.front(), p.size(), NULL ); dh->g = BN_bin2bn( (unsigned char*)&g, 1, NULL ); +#endif return fc::validate( dh, valid ); } @@ -35,8 +53,14 @@ namespace fc { if( !p.size() ) return valid = false; ssl_dh dh = DH_new(); +#if OPENSSL_VERSION_NUMBER >= 0x10100000L + const auto bn_p = BN_bin2bn( (unsigned char*)&p.front(), p.size(), NULL ); + const auto bn_g = BN_bin2bn( (unsigned char*)&g, 1, NULL ); + DH_set0_pqg(dh.obj, bn_p, NULL, bn_g); +#else dh->p = BN_bin2bn( (unsigned char*)&p.front(), p.size(), NULL ); dh->g = BN_bin2bn( (unsigned char*)&g, 1, NULL ); +#endif if( !fc::validate( dh, valid ) ) { @@ -44,21 +68,42 @@ namespace fc { } DH_generate_key(dh); +#if OPENSSL_VERSION_NUMBER >= 0x10100000L + ssl_bignum bn_pub_key; + ssl_bignum bn_priv_key; + DH_get0_key(dh.obj, (const BIGNUM**)&bn_pub_key.obj, (const BIGNUM**)&bn_priv_key.obj); + pub_key.resize( BN_num_bytes( bn_pub_key ) ); + priv_key.resize( BN_num_bytes( bn_priv_key ) ); + if( pub_key.size() ) + BN_bn2bin( bn_pub_key.obj, (unsigned char*)&pub_key.front() ); + if( priv_key.size() ) + BN_bn2bin( bn_priv_key.obj, (unsigned char*)&priv_key.front() ); +#else pub_key.resize( BN_num_bytes( dh->pub_key ) ); priv_key.resize( BN_num_bytes( dh->priv_key ) ); if( pub_key.size() ) BN_bn2bin( dh->pub_key, (unsigned char*)&pub_key.front() ); if( priv_key.size() ) BN_bn2bin( dh->priv_key, (unsigned char*)&priv_key.front() ); +#endif return true; } bool diffie_hellman::compute_shared_key( const char* buf, uint32_t s ) { ssl_dh dh = DH_new(); +#if OPENSSL_VERSION_NUMBER >= 0x10100000L + auto bn_p = BN_bin2bn( (unsigned char*)&p.front(), p.size(), NULL ); + auto bn_pub_key = BN_bin2bn( (unsigned char*)&pub_key.front(), pub_key.size(), NULL ); + auto bn_priv_key = BN_bin2bn( (unsigned char*)&priv_key.front(), priv_key.size(), NULL ); + auto bn_g = BN_bin2bn( (unsigned char*)&g, 1, NULL ); + DH_set0_pqg(dh.obj, bn_p, NULL, bn_g); + DH_set0_key(dh.obj, bn_pub_key, bn_priv_key); +#else dh->p = BN_bin2bn( (unsigned char*)&p.front(), p.size(), NULL ); dh->pub_key = BN_bin2bn( (unsigned char*)&pub_key.front(), pub_key.size(), NULL ); dh->priv_key = BN_bin2bn( (unsigned char*)&priv_key.front(), priv_key.size(), NULL ); dh->g = BN_bin2bn( (unsigned char*)&g, 1, NULL ); +#endif int check; DH_check(dh,&check); From 6d386e442b57f4da6099ebd934e071a73d46f398 Mon Sep 17 00:00:00 2001 From: Vikram Rajkumar Date: Tue, 25 Apr 2017 20:22:31 -0500 Subject: [PATCH 022/260] Revert "...Fix build?" This reverts commit 908762d687eccab019403189fd1d95502fb75c89. --- include/fc/static_variant.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/fc/static_variant.hpp b/include/fc/static_variant.hpp index 228eb658b..9aab79037 100644 --- a/include/fc/static_variant.hpp +++ b/include/fc/static_variant.hpp @@ -382,5 +382,5 @@ struct visitor { s.visit( to_static_variant(ar[1]) ); } - template struct get_typename> { static const char* name() { return typeid(static_variant).name(); } }; + template struct get_typename { static const char* name() { return typeid(static_variant).name(); } }; } // namespace fc From 91af0e7edbec0e37d38efff78c5644f9ba8aedd7 Mon Sep 17 00:00:00 2001 From: Vikram Rajkumar Date: Wed, 26 Apr 2017 11:58:32 -0500 Subject: [PATCH 023/260] Fix compilation on Clang 4+ --- CMakeLists.txt | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index ebca16e56..41da2d4b3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -306,6 +306,12 @@ ELSE() target_compile_options(fc PUBLIC ${CPP_STANDARD} -Wall -fnon-call-exceptions) endif() SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CPP_STANDARD} -Wall -fnon-call-exceptions") + + if( "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" ) + if( CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 3 ) + set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-invalid-partial-specialization" ) + endif() + endif() ENDIF() ENDIF() From 453b3de77efeed3d159c67b9eaa9e0595e0f9091 Mon Sep 17 00:00:00 2001 From: Vikram Rajkumar Date: Wed, 26 Apr 2017 12:20:58 -0500 Subject: [PATCH 024/260] Better fix for Clang 4+ --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 41da2d4b3..cd537ebf6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -308,7 +308,7 @@ ELSE() SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CPP_STANDARD} -Wall -fnon-call-exceptions") if( "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" ) - if( CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 3 ) + if( CMAKE_CXX_COMPILER_VERSION VERSION_EQUAL 4.0.0 OR CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 4.0.0 ) set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-invalid-partial-specialization" ) endif() endif() From 0c25cb568fcc22908bd5fc194f9c0666c7aecccb Mon Sep 17 00:00:00 2001 From: kinglaw <58291@qq.com> Date: Thu, 1 Jun 2017 13:03:02 +0800 Subject: [PATCH 025/260] In order to pass compile in vs2013, fixed: removed equihash from the cmakelists.txt. Fix the inconsistencies of the template functions "from_variant" ,"unpack" and definitions that processes flat_map. Signed-off-by: kinglaw <58291@qq.com> --- CMakeLists.txt | 6 +----- include/fc/container/flat_fwd.hpp | 4 ++-- include/fc/variant.hpp | 4 ++-- 3 files changed, 5 insertions(+), 9 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index cd537ebf6..62b579d47 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -221,7 +221,6 @@ set( fc_sources src/crypto/dh.cpp src/crypto/blowfish.cpp src/crypto/elliptic_common.cpp - src/crypto/equihash.cpp ${ECC_REST} src/crypto/elliptic_${ECC_IMPL}.cpp src/crypto/rand.cpp @@ -251,7 +250,6 @@ list(APPEND sources "${CMAKE_CURRENT_BINARY_DIR}/git_revision.cpp") list(APPEND sources ${fc_headers}) add_subdirectory( vendor/websocketpp EXCLUDE_FROM_ALL ) -add_subdirectory( vendor/equihash ) setup_library( fc SOURCES ${sources} LIBRARY_TYPE STATIC ) install( DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/include/" DESTINATION include ) @@ -373,14 +371,13 @@ target_include_directories(fc ${CMAKE_CURRENT_SOURCE_DIR}/vendor/boost_1.51/include ${CMAKE_CURRENT_SOURCE_DIR}/vendor/cyoencode-1.0.2/src ${CMAKE_CURRENT_SOURCE_DIR}/vendor/secp256k1-zkp - ${CMAKE_CURRENT_SOURCE_DIR}/vendor/equihash ) #target_link_libraries( fc PUBLIC ${Boost_LIBRARIES} ${OPENSSL_LIBRARIES} ${ZLIB_LIBRARIES} ${BZIP2_LIBRARIES} ${PLATFORM_SPECIFIC_LIBS} ${RPCRT4} ${CMAKE_DL_LIBS} ${rt_library} ${ECC_LIB} ) IF(NOT WIN32) set(LINK_USR_LOCAL_LIB -L/usr/local/lib) ENDIF() -target_link_libraries( fc PUBLIC ${LINK_USR_LOCAL_LIB} equihash ${Boost_LIBRARIES} ${OPENSSL_LIBRARIES} ${ZLIB_LIBRARIES} ${BZIP2_LIBRARIES} ${PLATFORM_SPECIFIC_LIBS} ${RPCRT4} ${CMAKE_DL_LIBS} ${rt_library} ${readline_libraries} ${ECC_LIB} ) +target_link_libraries( fc PUBLIC ${LINK_USR_LOCAL_LIB} ${Boost_LIBRARIES} ${OPENSSL_LIBRARIES} ${ZLIB_LIBRARIES} ${BZIP2_LIBRARIES} ${PLATFORM_SPECIFIC_LIBS} ${RPCRT4} ${CMAKE_DL_LIBS} ${rt_library} ${readline_libraries} ${ECC_LIB} ) if(MSVC) set_source_files_properties( src/network/http/websocket.cpp PROPERTIES COMPILE_FLAGS "/bigobj" ) @@ -396,7 +393,6 @@ ENDIF(MSVC) ENDIF() include_directories( vendor/websocketpp ) -include_directories( vendor/equihash ) add_subdirectory(tests) diff --git a/include/fc/container/flat_fwd.hpp b/include/fc/container/flat_fwd.hpp index 98dd9547b..d56323a8f 100644 --- a/include/fc/container/flat_fwd.hpp +++ b/include/fc/container/flat_fwd.hpp @@ -16,8 +16,8 @@ namespace fc { void unpack( Stream& s, flat_set& value ); template void pack( Stream& s, const flat_map& value ); - template - void unpack( Stream& s, flat_map& value ) ; + template + void unpack(Stream& s, flat_map& value); template diff --git a/include/fc/variant.hpp b/include/fc/variant.hpp index 092de0aa7..c5ddf0d7f 100644 --- a/include/fc/variant.hpp +++ b/include/fc/variant.hpp @@ -90,8 +90,8 @@ namespace fc template void to_variant( const fc::flat_map& var, variant& vo ); - template - void from_variant( const variant& var, fc::flat_map& vo ); + template + void from_variant(const variant& var, flat_map& vo); template void to_variant( const std::map& var, variant& vo ); From 680731ef1b8cf11b0749b739442363224a749eac Mon Sep 17 00:00:00 2001 From: Vikram Rajkumar Date: Thu, 1 Jun 2017 16:11:35 -0500 Subject: [PATCH 026/260] Remove equihash --- CMakeLists.txt | 6 +- include/fc/crypto/equihash.hpp | 22 - src/crypto/equihash.cpp | 57 --- vendor/equihash/CMakeLists.txt | 19 - .../equihash/include/equihash/blake2-config.h | 72 --- .../equihash/include/equihash/blake2-impl.h | 136 ----- vendor/equihash/include/equihash/blake2.h | 157 ------ .../include/equihash/blake2b-load-sse2.h | 68 --- .../include/equihash/blake2b-load-sse41.h | 402 --------------- .../equihash/include/equihash/blake2b-round.h | 170 ------- vendor/equihash/include/equihash/pow.hpp | 120 ----- vendor/equihash/src/blake2b.c | 469 ------------------ vendor/equihash/src/pow.cpp | 415 ---------------- 13 files changed, 1 insertion(+), 2112 deletions(-) delete mode 100644 include/fc/crypto/equihash.hpp delete mode 100644 src/crypto/equihash.cpp delete mode 100644 vendor/equihash/CMakeLists.txt delete mode 100644 vendor/equihash/include/equihash/blake2-config.h delete mode 100644 vendor/equihash/include/equihash/blake2-impl.h delete mode 100644 vendor/equihash/include/equihash/blake2.h delete mode 100644 vendor/equihash/include/equihash/blake2b-load-sse2.h delete mode 100644 vendor/equihash/include/equihash/blake2b-load-sse41.h delete mode 100644 vendor/equihash/include/equihash/blake2b-round.h delete mode 100644 vendor/equihash/include/equihash/pow.hpp delete mode 100644 vendor/equihash/src/blake2b.c delete mode 100644 vendor/equihash/src/pow.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index cd537ebf6..62b579d47 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -221,7 +221,6 @@ set( fc_sources src/crypto/dh.cpp src/crypto/blowfish.cpp src/crypto/elliptic_common.cpp - src/crypto/equihash.cpp ${ECC_REST} src/crypto/elliptic_${ECC_IMPL}.cpp src/crypto/rand.cpp @@ -251,7 +250,6 @@ list(APPEND sources "${CMAKE_CURRENT_BINARY_DIR}/git_revision.cpp") list(APPEND sources ${fc_headers}) add_subdirectory( vendor/websocketpp EXCLUDE_FROM_ALL ) -add_subdirectory( vendor/equihash ) setup_library( fc SOURCES ${sources} LIBRARY_TYPE STATIC ) install( DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/include/" DESTINATION include ) @@ -373,14 +371,13 @@ target_include_directories(fc ${CMAKE_CURRENT_SOURCE_DIR}/vendor/boost_1.51/include ${CMAKE_CURRENT_SOURCE_DIR}/vendor/cyoencode-1.0.2/src ${CMAKE_CURRENT_SOURCE_DIR}/vendor/secp256k1-zkp - ${CMAKE_CURRENT_SOURCE_DIR}/vendor/equihash ) #target_link_libraries( fc PUBLIC ${Boost_LIBRARIES} ${OPENSSL_LIBRARIES} ${ZLIB_LIBRARIES} ${BZIP2_LIBRARIES} ${PLATFORM_SPECIFIC_LIBS} ${RPCRT4} ${CMAKE_DL_LIBS} ${rt_library} ${ECC_LIB} ) IF(NOT WIN32) set(LINK_USR_LOCAL_LIB -L/usr/local/lib) ENDIF() -target_link_libraries( fc PUBLIC ${LINK_USR_LOCAL_LIB} equihash ${Boost_LIBRARIES} ${OPENSSL_LIBRARIES} ${ZLIB_LIBRARIES} ${BZIP2_LIBRARIES} ${PLATFORM_SPECIFIC_LIBS} ${RPCRT4} ${CMAKE_DL_LIBS} ${rt_library} ${readline_libraries} ${ECC_LIB} ) +target_link_libraries( fc PUBLIC ${LINK_USR_LOCAL_LIB} ${Boost_LIBRARIES} ${OPENSSL_LIBRARIES} ${ZLIB_LIBRARIES} ${BZIP2_LIBRARIES} ${PLATFORM_SPECIFIC_LIBS} ${RPCRT4} ${CMAKE_DL_LIBS} ${rt_library} ${readline_libraries} ${ECC_LIB} ) if(MSVC) set_source_files_properties( src/network/http/websocket.cpp PROPERTIES COMPILE_FLAGS "/bigobj" ) @@ -396,7 +393,6 @@ ENDIF(MSVC) ENDIF() include_directories( vendor/websocketpp ) -include_directories( vendor/equihash ) add_subdirectory(tests) diff --git a/include/fc/crypto/equihash.hpp b/include/fc/crypto/equihash.hpp deleted file mode 100644 index d37269e94..000000000 --- a/include/fc/crypto/equihash.hpp +++ /dev/null @@ -1,22 +0,0 @@ -#pragma once -#include -#include - -namespace fc { namespace equihash { - - struct proof - { - uint32_t n; - uint32_t k; - sha256 seed; - std::vector< uint32_t > inputs; - - bool is_valid( bool test_canonical_order = false, bool test_intermediate_zeros = false ) const; - void canonize_indexes(); - - static proof hash( uint32_t n, uint32_t k, sha256 seed ); - }; - -} } // fc - -FC_REFLECT( fc::equihash::proof, (n)(k)(seed)(inputs) ) diff --git a/src/crypto/equihash.cpp b/src/crypto/equihash.cpp deleted file mode 100644 index d6f40bf29..000000000 --- a/src/crypto/equihash.cpp +++ /dev/null @@ -1,57 +0,0 @@ -#include - -#include - -#define EQUIHASH_NONCE 2 - -namespace fc { namespace equihash { - - _POW::Seed sha_to_seed( sha256 seed ) - { - _POW::Seed new_seed; - - // Seed is 128 bits. Half of sha256 to create seed. Should still have enough randomness - new_seed.v[0] = (unsigned int) seed._hash[0]; - new_seed.v[0] ^= (unsigned int) seed._hash[2]; - new_seed.v[1] = (unsigned int)( seed._hash[0] >> 32 ); - new_seed.v[1] ^= (unsigned int)( seed._hash[2] >> 32 ); - new_seed.v[2] = (unsigned int) seed._hash[1]; - new_seed.v[2] ^= (unsigned int) seed._hash[3]; - new_seed.v[3] = (unsigned int)( seed._hash[1] >> 32 ); - new_seed.v[3] ^= (unsigned int)( seed._hash[3] >> 32 ); - - return new_seed; - } - - bool proof::is_valid( bool test_canonical_order, bool test_intermediate_zeros ) const - { - _POW::Proof test( n, k, sha_to_seed( seed ), EQUIHASH_NONCE, inputs ); - if( test_canonical_order && !test.CheckIndexesCanon() ) - return false; - if( test_intermediate_zeros ) - return test.FullTest(); - return test.Test(); - } - - void proof::canonize_indexes() - { - _POW::Proof p( n, k, sha_to_seed( seed ), EQUIHASH_NONCE, inputs ); - _POW::Proof p_canon = p.CanonizeIndexes(); - inputs = p_canon.inputs; - } - - proof proof::hash( uint32_t n, uint32_t k, sha256 seed ) - { - auto hash = _POW::Equihash( n, k, sha_to_seed( seed ) ); - auto result = hash.FindProof( EQUIHASH_NONCE ); - - proof p; - p.n = n; - p.k = k; - p.seed = seed; - p.inputs = result.inputs; - - return p; - } - -} } // fc::equihash diff --git a/vendor/equihash/CMakeLists.txt b/vendor/equihash/CMakeLists.txt deleted file mode 100644 index a90d30273..000000000 --- a/vendor/equihash/CMakeLists.txt +++ /dev/null @@ -1,19 +0,0 @@ -file(GLOB HEADERS "include/equihash/*.hpp" ) - -set( CMAKE_C_FLAGS "-std=c99" ) - -add_library( equihash - src/pow.cpp - src/blake2b.c - ) - -target_link_libraries( equihash ) -target_include_directories( equihash PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include" ) - -install( TARGETS - equihash - - RUNTIME DESTINATION bin - LIBRARY DESTINATION lib - ARCHIVE DESTINATION lib -) diff --git a/vendor/equihash/include/equihash/blake2-config.h b/vendor/equihash/include/equihash/blake2-config.h deleted file mode 100644 index 70d61f109..000000000 --- a/vendor/equihash/include/equihash/blake2-config.h +++ /dev/null @@ -1,72 +0,0 @@ -/* - BLAKE2 reference source code package - optimized C implementations - - Written in 2012 by Samuel Neves - - To the extent possible under law, the author(s) have dedicated all copyright - and related and neighboring rights to this software to the public domain - worldwide. This software is distributed without any warranty. - - You should have received a copy of the CC0 Public Domain Dedication along with - this software. If not, see . -*/ -#pragma once -#ifndef __BLAKE2_CONFIG_H__ -#define __BLAKE2_CONFIG_H__ - -// These don't work everywhere -#if defined(__SSE2__) -#define HAVE_SSE2 -#endif - -#if defined(__SSSE3__) -#define HAVE_SSSE3 -#endif - -#if defined(__SSE4_1__) -#define HAVE_SSE41 -#endif - -#if defined(__AVX__) -#define HAVE_AVX -#endif - -#if defined(__XOP__) -#define HAVE_XOP -#endif - - -#ifdef HAVE_AVX2 -#ifndef HAVE_AVX -#define HAVE_AVX -#endif -#endif - -#ifdef HAVE_XOP -#ifndef HAVE_AVX -#define HAVE_AVX -#endif -#endif - -#ifdef HAVE_AVX -#ifndef HAVE_SSE41 -#define HAVE_SSE41 -#endif -#endif - -#ifdef HAVE_SSE41 -#ifndef HAVE_SSSE3 -#define HAVE_SSSE3 -#endif -#endif - -#ifdef HAVE_SSSE3 -#define HAVE_SSE2 -#endif - -#if !defined(HAVE_SSE2) -#error "This code requires at least SSE2." -#endif - -#endif - diff --git a/vendor/equihash/include/equihash/blake2-impl.h b/vendor/equihash/include/equihash/blake2-impl.h deleted file mode 100644 index 16219dbcb..000000000 --- a/vendor/equihash/include/equihash/blake2-impl.h +++ /dev/null @@ -1,136 +0,0 @@ -/* - BLAKE2 reference source code package - optimized C implementations - - Written in 2012 by Samuel Neves - - To the extent possible under law, the author(s) have dedicated all copyright - and related and neighboring rights to this software to the public domain - worldwide. This software is distributed without any warranty. - - You should have received a copy of the CC0 Public Domain Dedication along with - this software. If not, see . -*/ -#pragma once -#ifndef __BLAKE2_IMPL_H__ -#define __BLAKE2_IMPL_H__ - -#include - -static inline uint32_t load32( const void *src ) -{ -#if defined(NATIVE_LITTLE_ENDIAN) - uint32_t w; - memcpy(&w, src, sizeof w); - return w; -#else - const uint8_t *p = ( const uint8_t * )src; - uint32_t w = *p++; - w |= ( uint32_t )( *p++ ) << 8; - w |= ( uint32_t )( *p++ ) << 16; - w |= ( uint32_t )( *p++ ) << 24; - return w; -#endif -} - -static inline uint64_t load64( const void *src ) -{ -#if defined(NATIVE_LITTLE_ENDIAN) - uint64_t w; - memcpy(&w, src, sizeof w); - return w; -#else - const uint8_t *p = ( const uint8_t * )src; - uint64_t w = *p++; - w |= ( uint64_t )( *p++ ) << 8; - w |= ( uint64_t )( *p++ ) << 16; - w |= ( uint64_t )( *p++ ) << 24; - w |= ( uint64_t )( *p++ ) << 32; - w |= ( uint64_t )( *p++ ) << 40; - w |= ( uint64_t )( *p++ ) << 48; - w |= ( uint64_t )( *p++ ) << 56; - return w; -#endif -} - -static inline void store32( void *dst, uint32_t w ) -{ -#if defined(NATIVE_LITTLE_ENDIAN) - memcpy(dst, &w, sizeof w); -#else - uint8_t *p = ( uint8_t * )dst; - *p++ = ( uint8_t )w; w >>= 8; - *p++ = ( uint8_t )w; w >>= 8; - *p++ = ( uint8_t )w; w >>= 8; - *p++ = ( uint8_t )w; -#endif -} - -static inline void store64( void *dst, uint64_t w ) -{ -#if defined(NATIVE_LITTLE_ENDIAN) - memcpy(dst, &w, sizeof w); -#else - uint8_t *p = ( uint8_t * )dst; - *p++ = ( uint8_t )w; w >>= 8; - *p++ = ( uint8_t )w; w >>= 8; - *p++ = ( uint8_t )w; w >>= 8; - *p++ = ( uint8_t )w; w >>= 8; - *p++ = ( uint8_t )w; w >>= 8; - *p++ = ( uint8_t )w; w >>= 8; - *p++ = ( uint8_t )w; w >>= 8; - *p++ = ( uint8_t )w; -#endif -} - -static inline uint64_t load48( const void *src ) -{ - const uint8_t *p = ( const uint8_t * )src; - uint64_t w = *p++; - w |= ( uint64_t )( *p++ ) << 8; - w |= ( uint64_t )( *p++ ) << 16; - w |= ( uint64_t )( *p++ ) << 24; - w |= ( uint64_t )( *p++ ) << 32; - w |= ( uint64_t )( *p++ ) << 40; - return w; -} - -static inline void store48( void *dst, uint64_t w ) -{ - uint8_t *p = ( uint8_t * )dst; - *p++ = ( uint8_t )w; w >>= 8; - *p++ = ( uint8_t )w; w >>= 8; - *p++ = ( uint8_t )w; w >>= 8; - *p++ = ( uint8_t )w; w >>= 8; - *p++ = ( uint8_t )w; w >>= 8; - *p++ = ( uint8_t )w; -} - -static inline uint32_t rotl32( const uint32_t w, const unsigned c ) -{ - return ( w << c ) | ( w >> ( 32 - c ) ); -} - -static inline uint64_t rotl64( const uint64_t w, const unsigned c ) -{ - return ( w << c ) | ( w >> ( 64 - c ) ); -} - -static inline uint32_t rotr32( const uint32_t w, const unsigned c ) -{ - return ( w >> c ) | ( w << ( 32 - c ) ); -} - -static inline uint64_t rotr64( const uint64_t w, const unsigned c ) -{ - return ( w >> c ) | ( w << ( 64 - c ) ); -} - -/* prevents compiler optimizing out memset() */ -static inline void secure_zero_memory( void *v, size_t n ) -{ - volatile uint8_t *p = ( volatile uint8_t * )v; - while( n-- ) *p++ = 0; -} - -#endif - diff --git a/vendor/equihash/include/equihash/blake2.h b/vendor/equihash/include/equihash/blake2.h deleted file mode 100644 index 424e14555..000000000 --- a/vendor/equihash/include/equihash/blake2.h +++ /dev/null @@ -1,157 +0,0 @@ -/* - BLAKE2 reference source code package - optimized C implementations - - Written in 2012 by Samuel Neves - - To the extent possible under law, the author(s) have dedicated all copyright - and related and neighboring rights to this software to the public domain - worldwide. This software is distributed without any warranty. - - You should have received a copy of the CC0 Public Domain Dedication along with - this software. If not, see . -*/ -#pragma once -#ifndef __BLAKE2_H__ -#define __BLAKE2_H__ - -#include -#include - -#if defined(_MSC_VER) -#define ALIGN(x) __declspec(align(x)) -#else -#define ALIGN(x) __attribute__ ((__aligned__(x))) -#endif - -#if defined(__cplusplus) -extern "C" { -#endif - - enum blake2s_constant - { - BLAKE2S_BLOCKBYTES = 64, - BLAKE2S_OUTBYTES = 32, - BLAKE2S_KEYBYTES = 32, - BLAKE2S_SALTBYTES = 8, - BLAKE2S_PERSONALBYTES = 8 - }; - - enum blake2b_constant - { - BLAKE2B_BLOCKBYTES = 128, - BLAKE2B_OUTBYTES = 64, - BLAKE2B_KEYBYTES = 64, - BLAKE2B_SALTBYTES = 16, - BLAKE2B_PERSONALBYTES = 16 - }; - -#pragma pack(push, 1) - typedef struct __blake2s_param - { - uint8_t digest_length; // 1 - uint8_t key_length; // 2 - uint8_t fanout; // 3 - uint8_t depth; // 4 - uint32_t leaf_length; // 8 - uint8_t node_offset[6];// 14 - uint8_t node_depth; // 15 - uint8_t inner_length; // 16 - // uint8_t reserved[0]; - uint8_t salt[BLAKE2S_SALTBYTES]; // 24 - uint8_t personal[BLAKE2S_PERSONALBYTES]; // 32 - } blake2s_param; - - ALIGN( 64 ) typedef struct __blake2s_state - { - uint32_t h[8]; - uint32_t t[2]; - uint32_t f[2]; - uint8_t buf[2 * BLAKE2S_BLOCKBYTES]; - size_t buflen; - uint8_t last_node; - } blake2s_state; - - typedef struct __blake2b_param - { - uint8_t digest_length; // 1 - uint8_t key_length; // 2 - uint8_t fanout; // 3 - uint8_t depth; // 4 - uint32_t leaf_length; // 8 - uint64_t node_offset; // 16 - uint8_t node_depth; // 17 - uint8_t inner_length; // 18 - uint8_t reserved[14]; // 32 - uint8_t salt[BLAKE2B_SALTBYTES]; // 48 - uint8_t personal[BLAKE2B_PERSONALBYTES]; // 64 - } blake2b_param; - - ALIGN( 64 ) typedef struct __blake2b_state - { - uint64_t h[8]; - uint64_t t[2]; - uint64_t f[2]; - uint8_t buf[2 * BLAKE2B_BLOCKBYTES]; - size_t buflen; - uint8_t last_node; - } blake2b_state; - - ALIGN( 64 ) typedef struct __blake2sp_state - { - blake2s_state S[8][1]; - blake2s_state R[1]; - uint8_t buf[8 * BLAKE2S_BLOCKBYTES]; - size_t buflen; - } blake2sp_state; - - ALIGN( 64 ) typedef struct __blake2bp_state - { - blake2b_state S[4][1]; - blake2b_state R[1]; - uint8_t buf[4 * BLAKE2B_BLOCKBYTES]; - size_t buflen; - } blake2bp_state; -#pragma pack(pop) - - // Streaming API - int blake2s_init( blake2s_state *S, const uint8_t outlen ); - int blake2s_init_key( blake2s_state *S, const uint8_t outlen, const void *key, const uint8_t keylen ); - int blake2s_init_param( blake2s_state *S, const blake2s_param *P ); - int blake2s_update( blake2s_state *S, const uint8_t *in, uint64_t inlen ); - int blake2s_final( blake2s_state *S, uint8_t *out, uint8_t outlen ); - - int blake2b_init( blake2b_state *S, const uint8_t outlen ); - int blake2b_init_key( blake2b_state *S, const uint8_t outlen, const void *key, const uint8_t keylen ); - int blake2b_init_param( blake2b_state *S, const blake2b_param *P ); - int blake2b_update( blake2b_state *S, const uint8_t *in, uint64_t inlen ); - int blake2b_final( blake2b_state *S, uint8_t *out, uint8_t outlen ); - - int blake2sp_init( blake2sp_state *S, const uint8_t outlen ); - int blake2sp_init_key( blake2sp_state *S, const uint8_t outlen, const void *key, const uint8_t keylen ); - int blake2sp_update( blake2sp_state *S, const uint8_t *in, uint64_t inlen ); - int blake2sp_final( blake2sp_state *S, uint8_t *out, uint8_t outlen ); - - int blake2bp_init( blake2bp_state *S, const uint8_t outlen ); - int blake2bp_init_key( blake2bp_state *S, const uint8_t outlen, const void *key, const uint8_t keylen ); - int blake2bp_update( blake2bp_state *S, const uint8_t *in, uint64_t inlen ); - int blake2bp_final( blake2bp_state *S, uint8_t *out, uint8_t outlen ); - - // Simple API - int blake2s( uint8_t *out, const void *in, const void *key, const uint8_t outlen, const uint64_t inlen, uint8_t keylen ); - int blake2b( uint8_t *out, const void *in, const void *key, const uint8_t outlen, const uint64_t inlen, uint8_t keylen ); - int blake2b_long(uint8_t *out, const void *in, const uint32_t outlen, const uint64_t inlen); - - int blake2sp( uint8_t *out, const void *in, const void *key, const uint8_t outlen, const uint64_t inlen, uint8_t keylen ); - int blake2bp( uint8_t *out, const void *in, const void *key, const uint8_t outlen, const uint64_t inlen, uint8_t keylen ); - - static inline int blake2( uint8_t *out, const void *in, const void *key, const uint8_t outlen, const uint64_t inlen, uint8_t keylen ) - { - return blake2b( out, in, key, outlen, inlen, keylen ); - } - -#if defined(__cplusplus) -} -#endif - -#endif - diff --git a/vendor/equihash/include/equihash/blake2b-load-sse2.h b/vendor/equihash/include/equihash/blake2b-load-sse2.h deleted file mode 100644 index 1ba153c87..000000000 --- a/vendor/equihash/include/equihash/blake2b-load-sse2.h +++ /dev/null @@ -1,68 +0,0 @@ -/* - BLAKE2 reference source code package - optimized C implementations - - Written in 2012 by Samuel Neves - - To the extent possible under law, the author(s) have dedicated all copyright - and related and neighboring rights to this software to the public domain - worldwide. This software is distributed without any warranty. - - You should have received a copy of the CC0 Public Domain Dedication along with - this software. If not, see . -*/ -#pragma once -#ifndef __BLAKE2B_LOAD_SSE2_H__ -#define __BLAKE2B_LOAD_SSE2_H__ - -#define LOAD_MSG_0_1(b0, b1) b0 = _mm_set_epi64x(m2, m0); b1 = _mm_set_epi64x(m6, m4) -#define LOAD_MSG_0_2(b0, b1) b0 = _mm_set_epi64x(m3, m1); b1 = _mm_set_epi64x(m7, m5) -#define LOAD_MSG_0_3(b0, b1) b0 = _mm_set_epi64x(m10, m8); b1 = _mm_set_epi64x(m14, m12) -#define LOAD_MSG_0_4(b0, b1) b0 = _mm_set_epi64x(m11, m9); b1 = _mm_set_epi64x(m15, m13) -#define LOAD_MSG_1_1(b0, b1) b0 = _mm_set_epi64x(m4, m14); b1 = _mm_set_epi64x(m13, m9) -#define LOAD_MSG_1_2(b0, b1) b0 = _mm_set_epi64x(m8, m10); b1 = _mm_set_epi64x(m6, m15) -#define LOAD_MSG_1_3(b0, b1) b0 = _mm_set_epi64x(m0, m1); b1 = _mm_set_epi64x(m5, m11) -#define LOAD_MSG_1_4(b0, b1) b0 = _mm_set_epi64x(m2, m12); b1 = _mm_set_epi64x(m3, m7) -#define LOAD_MSG_2_1(b0, b1) b0 = _mm_set_epi64x(m12, m11); b1 = _mm_set_epi64x(m15, m5) -#define LOAD_MSG_2_2(b0, b1) b0 = _mm_set_epi64x(m0, m8); b1 = _mm_set_epi64x(m13, m2) -#define LOAD_MSG_2_3(b0, b1) b0 = _mm_set_epi64x(m3, m10); b1 = _mm_set_epi64x(m9, m7) -#define LOAD_MSG_2_4(b0, b1) b0 = _mm_set_epi64x(m6, m14); b1 = _mm_set_epi64x(m4, m1) -#define LOAD_MSG_3_1(b0, b1) b0 = _mm_set_epi64x(m3, m7); b1 = _mm_set_epi64x(m11, m13) -#define LOAD_MSG_3_2(b0, b1) b0 = _mm_set_epi64x(m1, m9); b1 = _mm_set_epi64x(m14, m12) -#define LOAD_MSG_3_3(b0, b1) b0 = _mm_set_epi64x(m5, m2); b1 = _mm_set_epi64x(m15, m4) -#define LOAD_MSG_3_4(b0, b1) b0 = _mm_set_epi64x(m10, m6); b1 = _mm_set_epi64x(m8, m0) -#define LOAD_MSG_4_1(b0, b1) b0 = _mm_set_epi64x(m5, m9); b1 = _mm_set_epi64x(m10, m2) -#define LOAD_MSG_4_2(b0, b1) b0 = _mm_set_epi64x(m7, m0); b1 = _mm_set_epi64x(m15, m4) -#define LOAD_MSG_4_3(b0, b1) b0 = _mm_set_epi64x(m11, m14); b1 = _mm_set_epi64x(m3, m6) -#define LOAD_MSG_4_4(b0, b1) b0 = _mm_set_epi64x(m12, m1); b1 = _mm_set_epi64x(m13, m8) -#define LOAD_MSG_5_1(b0, b1) b0 = _mm_set_epi64x(m6, m2); b1 = _mm_set_epi64x(m8, m0) -#define LOAD_MSG_5_2(b0, b1) b0 = _mm_set_epi64x(m10, m12); b1 = _mm_set_epi64x(m3, m11) -#define LOAD_MSG_5_3(b0, b1) b0 = _mm_set_epi64x(m7, m4); b1 = _mm_set_epi64x(m1, m15) -#define LOAD_MSG_5_4(b0, b1) b0 = _mm_set_epi64x(m5, m13); b1 = _mm_set_epi64x(m9, m14) -#define LOAD_MSG_6_1(b0, b1) b0 = _mm_set_epi64x(m1, m12); b1 = _mm_set_epi64x(m4, m14) -#define LOAD_MSG_6_2(b0, b1) b0 = _mm_set_epi64x(m15, m5); b1 = _mm_set_epi64x(m10, m13) -#define LOAD_MSG_6_3(b0, b1) b0 = _mm_set_epi64x(m6, m0); b1 = _mm_set_epi64x(m8, m9) -#define LOAD_MSG_6_4(b0, b1) b0 = _mm_set_epi64x(m3, m7); b1 = _mm_set_epi64x(m11, m2) -#define LOAD_MSG_7_1(b0, b1) b0 = _mm_set_epi64x(m7, m13); b1 = _mm_set_epi64x(m3, m12) -#define LOAD_MSG_7_2(b0, b1) b0 = _mm_set_epi64x(m14, m11); b1 = _mm_set_epi64x(m9, m1) -#define LOAD_MSG_7_3(b0, b1) b0 = _mm_set_epi64x(m15, m5); b1 = _mm_set_epi64x(m2, m8) -#define LOAD_MSG_7_4(b0, b1) b0 = _mm_set_epi64x(m4, m0); b1 = _mm_set_epi64x(m10, m6) -#define LOAD_MSG_8_1(b0, b1) b0 = _mm_set_epi64x(m14, m6); b1 = _mm_set_epi64x(m0, m11) -#define LOAD_MSG_8_2(b0, b1) b0 = _mm_set_epi64x(m9, m15); b1 = _mm_set_epi64x(m8, m3) -#define LOAD_MSG_8_3(b0, b1) b0 = _mm_set_epi64x(m13, m12); b1 = _mm_set_epi64x(m10, m1) -#define LOAD_MSG_8_4(b0, b1) b0 = _mm_set_epi64x(m7, m2); b1 = _mm_set_epi64x(m5, m4) -#define LOAD_MSG_9_1(b0, b1) b0 = _mm_set_epi64x(m8, m10); b1 = _mm_set_epi64x(m1, m7) -#define LOAD_MSG_9_2(b0, b1) b0 = _mm_set_epi64x(m4, m2); b1 = _mm_set_epi64x(m5, m6) -#define LOAD_MSG_9_3(b0, b1) b0 = _mm_set_epi64x(m9, m15); b1 = _mm_set_epi64x(m13, m3) -#define LOAD_MSG_9_4(b0, b1) b0 = _mm_set_epi64x(m14, m11); b1 = _mm_set_epi64x(m0, m12) -#define LOAD_MSG_10_1(b0, b1) b0 = _mm_set_epi64x(m2, m0); b1 = _mm_set_epi64x(m6, m4) -#define LOAD_MSG_10_2(b0, b1) b0 = _mm_set_epi64x(m3, m1); b1 = _mm_set_epi64x(m7, m5) -#define LOAD_MSG_10_3(b0, b1) b0 = _mm_set_epi64x(m10, m8); b1 = _mm_set_epi64x(m14, m12) -#define LOAD_MSG_10_4(b0, b1) b0 = _mm_set_epi64x(m11, m9); b1 = _mm_set_epi64x(m15, m13) -#define LOAD_MSG_11_1(b0, b1) b0 = _mm_set_epi64x(m4, m14); b1 = _mm_set_epi64x(m13, m9) -#define LOAD_MSG_11_2(b0, b1) b0 = _mm_set_epi64x(m8, m10); b1 = _mm_set_epi64x(m6, m15) -#define LOAD_MSG_11_3(b0, b1) b0 = _mm_set_epi64x(m0, m1); b1 = _mm_set_epi64x(m5, m11) -#define LOAD_MSG_11_4(b0, b1) b0 = _mm_set_epi64x(m2, m12); b1 = _mm_set_epi64x(m3, m7) - - -#endif - diff --git a/vendor/equihash/include/equihash/blake2b-load-sse41.h b/vendor/equihash/include/equihash/blake2b-load-sse41.h deleted file mode 100644 index f6c1bc839..000000000 --- a/vendor/equihash/include/equihash/blake2b-load-sse41.h +++ /dev/null @@ -1,402 +0,0 @@ -/* - BLAKE2 reference source code package - optimized C implementations - - Written in 2012 by Samuel Neves - - To the extent possible under law, the author(s) have dedicated all copyright - and related and neighboring rights to this software to the public domain - worldwide. This software is distributed without any warranty. - - You should have received a copy of the CC0 Public Domain Dedication along with - this software. If not, see . -*/ -#pragma once -#ifndef __BLAKE2B_LOAD_SSE41_H__ -#define __BLAKE2B_LOAD_SSE41_H__ - -#define LOAD_MSG_0_1(b0, b1) \ -do \ -{ \ -b0 = _mm_unpacklo_epi64(m0, m1); \ -b1 = _mm_unpacklo_epi64(m2, m3); \ -} while(0) - - -#define LOAD_MSG_0_2(b0, b1) \ -do \ -{ \ -b0 = _mm_unpackhi_epi64(m0, m1); \ -b1 = _mm_unpackhi_epi64(m2, m3); \ -} while(0) - - -#define LOAD_MSG_0_3(b0, b1) \ -do \ -{ \ -b0 = _mm_unpacklo_epi64(m4, m5); \ -b1 = _mm_unpacklo_epi64(m6, m7); \ -} while(0) - - -#define LOAD_MSG_0_4(b0, b1) \ -do \ -{ \ -b0 = _mm_unpackhi_epi64(m4, m5); \ -b1 = _mm_unpackhi_epi64(m6, m7); \ -} while(0) - - -#define LOAD_MSG_1_1(b0, b1) \ -do \ -{ \ -b0 = _mm_unpacklo_epi64(m7, m2); \ -b1 = _mm_unpackhi_epi64(m4, m6); \ -} while(0) - - -#define LOAD_MSG_1_2(b0, b1) \ -do \ -{ \ -b0 = _mm_unpacklo_epi64(m5, m4); \ -b1 = _mm_alignr_epi8(m3, m7, 8); \ -} while(0) - - -#define LOAD_MSG_1_3(b0, b1) \ -do \ -{ \ -b0 = _mm_shuffle_epi32(m0, _MM_SHUFFLE(1,0,3,2)); \ -b1 = _mm_unpackhi_epi64(m5, m2); \ -} while(0) - - -#define LOAD_MSG_1_4(b0, b1) \ -do \ -{ \ -b0 = _mm_unpacklo_epi64(m6, m1); \ -b1 = _mm_unpackhi_epi64(m3, m1); \ -} while(0) - - -#define LOAD_MSG_2_1(b0, b1) \ -do \ -{ \ -b0 = _mm_alignr_epi8(m6, m5, 8); \ -b1 = _mm_unpackhi_epi64(m2, m7); \ -} while(0) - - -#define LOAD_MSG_2_2(b0, b1) \ -do \ -{ \ -b0 = _mm_unpacklo_epi64(m4, m0); \ -b1 = _mm_blend_epi16(m1, m6, 0xF0); \ -} while(0) - - -#define LOAD_MSG_2_3(b0, b1) \ -do \ -{ \ -b0 = _mm_blend_epi16(m5, m1, 0xF0); \ -b1 = _mm_unpackhi_epi64(m3, m4); \ -} while(0) - - -#define LOAD_MSG_2_4(b0, b1) \ -do \ -{ \ -b0 = _mm_unpacklo_epi64(m7, m3); \ -b1 = _mm_alignr_epi8(m2, m0, 8); \ -} while(0) - - -#define LOAD_MSG_3_1(b0, b1) \ -do \ -{ \ -b0 = _mm_unpackhi_epi64(m3, m1); \ -b1 = _mm_unpackhi_epi64(m6, m5); \ -} while(0) - - -#define LOAD_MSG_3_2(b0, b1) \ -do \ -{ \ -b0 = _mm_unpackhi_epi64(m4, m0); \ -b1 = _mm_unpacklo_epi64(m6, m7); \ -} while(0) - - -#define LOAD_MSG_3_3(b0, b1) \ -do \ -{ \ -b0 = _mm_blend_epi16(m1, m2, 0xF0); \ -b1 = _mm_blend_epi16(m2, m7, 0xF0); \ -} while(0) - - -#define LOAD_MSG_3_4(b0, b1) \ -do \ -{ \ -b0 = _mm_unpacklo_epi64(m3, m5); \ -b1 = _mm_unpacklo_epi64(m0, m4); \ -} while(0) - - -#define LOAD_MSG_4_1(b0, b1) \ -do \ -{ \ -b0 = _mm_unpackhi_epi64(m4, m2); \ -b1 = _mm_unpacklo_epi64(m1, m5); \ -} while(0) - - -#define LOAD_MSG_4_2(b0, b1) \ -do \ -{ \ -b0 = _mm_blend_epi16(m0, m3, 0xF0); \ -b1 = _mm_blend_epi16(m2, m7, 0xF0); \ -} while(0) - - -#define LOAD_MSG_4_3(b0, b1) \ -do \ -{ \ -b0 = _mm_blend_epi16(m7, m5, 0xF0); \ -b1 = _mm_blend_epi16(m3, m1, 0xF0); \ -} while(0) - - -#define LOAD_MSG_4_4(b0, b1) \ -do \ -{ \ -b0 = _mm_alignr_epi8(m6, m0, 8); \ -b1 = _mm_blend_epi16(m4, m6, 0xF0); \ -} while(0) - - -#define LOAD_MSG_5_1(b0, b1) \ -do \ -{ \ -b0 = _mm_unpacklo_epi64(m1, m3); \ -b1 = _mm_unpacklo_epi64(m0, m4); \ -} while(0) - - -#define LOAD_MSG_5_2(b0, b1) \ -do \ -{ \ -b0 = _mm_unpacklo_epi64(m6, m5); \ -b1 = _mm_unpackhi_epi64(m5, m1); \ -} while(0) - - -#define LOAD_MSG_5_3(b0, b1) \ -do \ -{ \ -b0 = _mm_blend_epi16(m2, m3, 0xF0); \ -b1 = _mm_unpackhi_epi64(m7, m0); \ -} while(0) - - -#define LOAD_MSG_5_4(b0, b1) \ -do \ -{ \ -b0 = _mm_unpackhi_epi64(m6, m2); \ -b1 = _mm_blend_epi16(m7, m4, 0xF0); \ -} while(0) - - -#define LOAD_MSG_6_1(b0, b1) \ -do \ -{ \ -b0 = _mm_blend_epi16(m6, m0, 0xF0); \ -b1 = _mm_unpacklo_epi64(m7, m2); \ -} while(0) - - -#define LOAD_MSG_6_2(b0, b1) \ -do \ -{ \ -b0 = _mm_unpackhi_epi64(m2, m7); \ -b1 = _mm_alignr_epi8(m5, m6, 8); \ -} while(0) - - -#define LOAD_MSG_6_3(b0, b1) \ -do \ -{ \ -b0 = _mm_unpacklo_epi64(m0, m3); \ -b1 = _mm_shuffle_epi32(m4, _MM_SHUFFLE(1,0,3,2)); \ -} while(0) - - -#define LOAD_MSG_6_4(b0, b1) \ -do \ -{ \ -b0 = _mm_unpackhi_epi64(m3, m1); \ -b1 = _mm_blend_epi16(m1, m5, 0xF0); \ -} while(0) - - -#define LOAD_MSG_7_1(b0, b1) \ -do \ -{ \ -b0 = _mm_unpackhi_epi64(m6, m3); \ -b1 = _mm_blend_epi16(m6, m1, 0xF0); \ -} while(0) - - -#define LOAD_MSG_7_2(b0, b1) \ -do \ -{ \ -b0 = _mm_alignr_epi8(m7, m5, 8); \ -b1 = _mm_unpackhi_epi64(m0, m4); \ -} while(0) - - -#define LOAD_MSG_7_3(b0, b1) \ -do \ -{ \ -b0 = _mm_unpackhi_epi64(m2, m7); \ -b1 = _mm_unpacklo_epi64(m4, m1); \ -} while(0) - - -#define LOAD_MSG_7_4(b0, b1) \ -do \ -{ \ -b0 = _mm_unpacklo_epi64(m0, m2); \ -b1 = _mm_unpacklo_epi64(m3, m5); \ -} while(0) - - -#define LOAD_MSG_8_1(b0, b1) \ -do \ -{ \ -b0 = _mm_unpacklo_epi64(m3, m7); \ -b1 = _mm_alignr_epi8(m0, m5, 8); \ -} while(0) - - -#define LOAD_MSG_8_2(b0, b1) \ -do \ -{ \ -b0 = _mm_unpackhi_epi64(m7, m4); \ -b1 = _mm_alignr_epi8(m4, m1, 8); \ -} while(0) - - -#define LOAD_MSG_8_3(b0, b1) \ -do \ -{ \ -b0 = m6; \ -b1 = _mm_alignr_epi8(m5, m0, 8); \ -} while(0) - - -#define LOAD_MSG_8_4(b0, b1) \ -do \ -{ \ -b0 = _mm_blend_epi16(m1, m3, 0xF0); \ -b1 = m2; \ -} while(0) - - -#define LOAD_MSG_9_1(b0, b1) \ -do \ -{ \ -b0 = _mm_unpacklo_epi64(m5, m4); \ -b1 = _mm_unpackhi_epi64(m3, m0); \ -} while(0) - - -#define LOAD_MSG_9_2(b0, b1) \ -do \ -{ \ -b0 = _mm_unpacklo_epi64(m1, m2); \ -b1 = _mm_blend_epi16(m3, m2, 0xF0); \ -} while(0) - - -#define LOAD_MSG_9_3(b0, b1) \ -do \ -{ \ -b0 = _mm_unpackhi_epi64(m7, m4); \ -b1 = _mm_unpackhi_epi64(m1, m6); \ -} while(0) - - -#define LOAD_MSG_9_4(b0, b1) \ -do \ -{ \ -b0 = _mm_alignr_epi8(m7, m5, 8); \ -b1 = _mm_unpacklo_epi64(m6, m0); \ -} while(0) - - -#define LOAD_MSG_10_1(b0, b1) \ -do \ -{ \ -b0 = _mm_unpacklo_epi64(m0, m1); \ -b1 = _mm_unpacklo_epi64(m2, m3); \ -} while(0) - - -#define LOAD_MSG_10_2(b0, b1) \ -do \ -{ \ -b0 = _mm_unpackhi_epi64(m0, m1); \ -b1 = _mm_unpackhi_epi64(m2, m3); \ -} while(0) - - -#define LOAD_MSG_10_3(b0, b1) \ -do \ -{ \ -b0 = _mm_unpacklo_epi64(m4, m5); \ -b1 = _mm_unpacklo_epi64(m6, m7); \ -} while(0) - - -#define LOAD_MSG_10_4(b0, b1) \ -do \ -{ \ -b0 = _mm_unpackhi_epi64(m4, m5); \ -b1 = _mm_unpackhi_epi64(m6, m7); \ -} while(0) - - -#define LOAD_MSG_11_1(b0, b1) \ -do \ -{ \ -b0 = _mm_unpacklo_epi64(m7, m2); \ -b1 = _mm_unpackhi_epi64(m4, m6); \ -} while(0) - - -#define LOAD_MSG_11_2(b0, b1) \ -do \ -{ \ -b0 = _mm_unpacklo_epi64(m5, m4); \ -b1 = _mm_alignr_epi8(m3, m7, 8); \ -} while(0) - - -#define LOAD_MSG_11_3(b0, b1) \ -do \ -{ \ -b0 = _mm_shuffle_epi32(m0, _MM_SHUFFLE(1,0,3,2)); \ -b1 = _mm_unpackhi_epi64(m5, m2); \ -} while(0) - - -#define LOAD_MSG_11_4(b0, b1) \ -do \ -{ \ -b0 = _mm_unpacklo_epi64(m6, m1); \ -b1 = _mm_unpackhi_epi64(m3, m1); \ -} while(0) - - -#endif - diff --git a/vendor/equihash/include/equihash/blake2b-round.h b/vendor/equihash/include/equihash/blake2b-round.h deleted file mode 100644 index 75aad89e8..000000000 --- a/vendor/equihash/include/equihash/blake2b-round.h +++ /dev/null @@ -1,170 +0,0 @@ -/* - BLAKE2 reference source code package - optimized C implementations - - Written in 2012 by Samuel Neves - - To the extent possible under law, the author(s) have dedicated all copyright - and related and neighboring rights to this software to the public domain - worldwide. This software is distributed without any warranty. - - You should have received a copy of the CC0 Public Domain Dedication along with - this software. If not, see . -*/ -#pragma once -#ifndef __BLAKE2B_ROUND_H__ -#define __BLAKE2B_ROUND_H__ - -#define LOAD(p) _mm_load_si128( (const __m128i *)(p) ) -#define STORE(p,r) _mm_store_si128((__m128i *)(p), r) - -#define LOADU(p) _mm_loadu_si128( (const __m128i *)(p) ) -#define STOREU(p,r) _mm_storeu_si128((__m128i *)(p), r) - -#define TOF(reg) _mm_castsi128_ps((reg)) -#define TOI(reg) _mm_castps_si128((reg)) - -#define LIKELY(x) __builtin_expect((x),1) - - -/* Microarchitecture-specific macros */ -#ifndef HAVE_XOP -#ifdef HAVE_SSSE3 -#define _mm_roti_epi64(x, c) \ - (-(c) == 32) ? _mm_shuffle_epi32((x), _MM_SHUFFLE(2,3,0,1)) \ - : (-(c) == 24) ? _mm_shuffle_epi8((x), r24) \ - : (-(c) == 16) ? _mm_shuffle_epi8((x), r16) \ - : (-(c) == 63) ? _mm_xor_si128(_mm_srli_epi64((x), -(c)), _mm_add_epi64((x), (x))) \ - : _mm_xor_si128(_mm_srli_epi64((x), -(c)), _mm_slli_epi64((x), 64-(-(c)))) -#else -#define _mm_roti_epi64(r, c) _mm_xor_si128(_mm_srli_epi64( (r), -(c) ),_mm_slli_epi64( (r), 64-(-c) )) -#endif -#else -/* ... */ -#endif - - - -#define G1(row1l,row2l,row3l,row4l,row1h,row2h,row3h,row4h,b0,b1) \ - row1l = _mm_add_epi64(_mm_add_epi64(row1l, b0), row2l); \ - row1h = _mm_add_epi64(_mm_add_epi64(row1h, b1), row2h); \ - \ - row4l = _mm_xor_si128(row4l, row1l); \ - row4h = _mm_xor_si128(row4h, row1h); \ - \ - row4l = _mm_roti_epi64(row4l, -32); \ - row4h = _mm_roti_epi64(row4h, -32); \ - \ - row3l = _mm_add_epi64(row3l, row4l); \ - row3h = _mm_add_epi64(row3h, row4h); \ - \ - row2l = _mm_xor_si128(row2l, row3l); \ - row2h = _mm_xor_si128(row2h, row3h); \ - \ - row2l = _mm_roti_epi64(row2l, -24); \ - row2h = _mm_roti_epi64(row2h, -24); \ - -#define G2(row1l,row2l,row3l,row4l,row1h,row2h,row3h,row4h,b0,b1) \ - row1l = _mm_add_epi64(_mm_add_epi64(row1l, b0), row2l); \ - row1h = _mm_add_epi64(_mm_add_epi64(row1h, b1), row2h); \ - \ - row4l = _mm_xor_si128(row4l, row1l); \ - row4h = _mm_xor_si128(row4h, row1h); \ - \ - row4l = _mm_roti_epi64(row4l, -16); \ - row4h = _mm_roti_epi64(row4h, -16); \ - \ - row3l = _mm_add_epi64(row3l, row4l); \ - row3h = _mm_add_epi64(row3h, row4h); \ - \ - row2l = _mm_xor_si128(row2l, row3l); \ - row2h = _mm_xor_si128(row2h, row3h); \ - \ - row2l = _mm_roti_epi64(row2l, -63); \ - row2h = _mm_roti_epi64(row2h, -63); \ - -#if defined(HAVE_SSSE3) -#define DIAGONALIZE(row1l,row2l,row3l,row4l,row1h,row2h,row3h,row4h) \ - t0 = _mm_alignr_epi8(row2h, row2l, 8); \ - t1 = _mm_alignr_epi8(row2l, row2h, 8); \ - row2l = t0; \ - row2h = t1; \ - \ - t0 = row3l; \ - row3l = row3h; \ - row3h = t0; \ - \ - t0 = _mm_alignr_epi8(row4h, row4l, 8); \ - t1 = _mm_alignr_epi8(row4l, row4h, 8); \ - row4l = t1; \ - row4h = t0; - -#define UNDIAGONALIZE(row1l,row2l,row3l,row4l,row1h,row2h,row3h,row4h) \ - t0 = _mm_alignr_epi8(row2l, row2h, 8); \ - t1 = _mm_alignr_epi8(row2h, row2l, 8); \ - row2l = t0; \ - row2h = t1; \ - \ - t0 = row3l; \ - row3l = row3h; \ - row3h = t0; \ - \ - t0 = _mm_alignr_epi8(row4l, row4h, 8); \ - t1 = _mm_alignr_epi8(row4h, row4l, 8); \ - row4l = t1; \ - row4h = t0; -#else - -#define DIAGONALIZE(row1l,row2l,row3l,row4l,row1h,row2h,row3h,row4h) \ - t0 = row4l;\ - t1 = row2l;\ - row4l = row3l;\ - row3l = row3h;\ - row3h = row4l;\ - row4l = _mm_unpackhi_epi64(row4h, _mm_unpacklo_epi64(t0, t0)); \ - row4h = _mm_unpackhi_epi64(t0, _mm_unpacklo_epi64(row4h, row4h)); \ - row2l = _mm_unpackhi_epi64(row2l, _mm_unpacklo_epi64(row2h, row2h)); \ - row2h = _mm_unpackhi_epi64(row2h, _mm_unpacklo_epi64(t1, t1)) - -#define UNDIAGONALIZE(row1l,row2l,row3l,row4l,row1h,row2h,row3h,row4h) \ - t0 = row3l;\ - row3l = row3h;\ - row3h = t0;\ - t0 = row2l;\ - t1 = row4l;\ - row2l = _mm_unpackhi_epi64(row2h, _mm_unpacklo_epi64(row2l, row2l)); \ - row2h = _mm_unpackhi_epi64(t0, _mm_unpacklo_epi64(row2h, row2h)); \ - row4l = _mm_unpackhi_epi64(row4l, _mm_unpacklo_epi64(row4h, row4h)); \ - row4h = _mm_unpackhi_epi64(row4h, _mm_unpacklo_epi64(t1, t1)) - -#endif - -#if defined(HAVE_SSE41) -#include -#else -#include -#endif - -#define ROUND(r) \ - LOAD_MSG_ ##r ##_1(b0, b1); \ - G1(row1l,row2l,row3l,row4l,row1h,row2h,row3h,row4h,b0,b1); \ - LOAD_MSG_ ##r ##_2(b0, b1); \ - G2(row1l,row2l,row3l,row4l,row1h,row2h,row3h,row4h,b0,b1); \ - DIAGONALIZE(row1l,row2l,row3l,row4l,row1h,row2h,row3h,row4h); \ - LOAD_MSG_ ##r ##_3(b0, b1); \ - G1(row1l,row2l,row3l,row4l,row1h,row2h,row3h,row4h,b0,b1); \ - LOAD_MSG_ ##r ##_4(b0, b1); \ - G2(row1l,row2l,row3l,row4l,row1h,row2h,row3h,row4h,b0,b1); \ - UNDIAGONALIZE(row1l,row2l,row3l,row4l,row1h,row2h,row3h,row4h); - -#endif - -#define BLAKE2_ROUND(row1l,row1h,row2l,row2h,row3l,row3h,row4l,row4h) \ - G1(row1l, row2l, row3l, row4l, row1h, row2h, row3h, row4h); \ - G2(row1l, row2l, row3l, row4l, row1h, row2h, row3h, row4h); \ - \ - DIAGONALIZE(row1l, row2l, row3l, row4l, row1h, row2h, row3h, row4h); \ - \ - G1(row1l, row2l, row3l, row4l, row1h, row2h, row3h, row4h); \ - G2(row1l, row2l, row3l, row4l, row1h, row2h, row3h, row4h); \ - \ - UNDIAGONALIZE(row1l, row2l, row3l, row4l, row1h, row2h, row3h, row4h); diff --git a/vendor/equihash/include/equihash/pow.hpp b/vendor/equihash/include/equihash/pow.hpp deleted file mode 100644 index 297194dda..000000000 --- a/vendor/equihash/include/equihash/pow.hpp +++ /dev/null @@ -1,120 +0,0 @@ -/*Code by Dmitry Khovratovich, 2016 -CC0 license -*/ - -#ifndef __POW -#define __POW - -#include - -#include -#include - - -const int SEED_LENGTH=4; //Length of seed in dwords ; -const int NONCE_LENGTH=24; //Length of nonce in bytes; -const int MAX_NONCE = 0xFFFFF; -const int MAX_N = 32; //Max length of n in bytes, should not exceed 32 -const int LIST_LENGTH = 5; -const unsigned FORK_MULTIPLIER=3; //Maximum collision factor - -/* The block used to initialize the PoW search - @v actual values -*/ -namespace _POW{ - - struct Seed{ - std::vector v; - - Seed(){ - v.resize(SEED_LENGTH,0); - } - explicit Seed(uint32_t x){ - v.resize(SEED_LENGTH, x); - } - Seed(const Seed&r){ - v= r.v; - } - Seed& operator=(const Seed&r){ - v = r.v; - return *this; - } - const uint32_t& operator[](unsigned i) const{ return v[i]; } - }; - - /* Different nonces for PoW search - @v actual values - */ - typedef uint32_t Nonce; - typedef uint32_t Input; - - /*Actual proof of work - * - * - * - */ - struct Proof{ - const unsigned n; - const unsigned k; - const Seed seed; - const Nonce nonce; - const std::vector inputs; - Proof(unsigned n_v, unsigned k_v, Seed I_v, Nonce V_v, std::vector inputs_v): - n(n_v), k(k_v), seed(I_v), nonce(V_v), inputs(inputs_v){}; - Proof():n(0),k(1),seed(0),nonce(0),inputs(std::vector()) {}; - - bool Test(); - bool FullTest()const; - bool CheckIndexesCanon()const; - Proof CanonizeIndexes()const; - }; - - class Tuple { - public: - std::vector blocks; - Input reference; - Tuple(unsigned i) { blocks.resize(i); } - Tuple& operator=(const Tuple &r) { - blocks = r.blocks; - reference = r.reference; - return *this; - } - }; - - class Fork { - public: - Input ref1, ref2; - Fork() {}; - Fork(Input r1, Input r2) : ref1(r1), ref2(r2) {}; - }; - - /*Algorithm class for creating proof - Assumes that n/(k+1) <=32 - * - */ - class Equihash{ - std::vector> tupleList; - std::vector filledList; - std::vector solutions; - std::vector> forks; - unsigned n; - unsigned k; - Seed seed; - Nonce nonce; - public: - /* - Initializes memory. - */ - Equihash(unsigned n_in, unsigned k_in, Seed s) :n(n_in), k(k_in), seed(s) {}; - ~Equihash() {}; - Proof FindProof(); - Proof FindProof( Nonce n ); - void FillMemory(uint32_t length); //fill with hash - void InitializeMemory(); //allocate memory - void ResolveCollisions(bool store); - std::vector ResolveTree(Fork fork); - std::vector ResolveTreeByLevel(Fork fork, unsigned level); - }; -} - -#endif //define __POW diff --git a/vendor/equihash/src/blake2b.c b/vendor/equihash/src/blake2b.c deleted file mode 100644 index e08562e4b..000000000 --- a/vendor/equihash/src/blake2b.c +++ /dev/null @@ -1,469 +0,0 @@ -/* - BLAKE2 reference source code package - optimized C implementations - - Written in 2012 by Samuel Neves - - To the extent possible under law, the author(s) have dedicated all copyright - and related and neighboring rights to this software to the public domain - worldwide. This software is distributed without any warranty. - - You should have received a copy of the CC0 Public Domain Dedication along with - this software. If not, see . -*/ - -#include -#include -#include - -#include -#include - -#include - - -#include -#if defined(HAVE_SSSE3) -#include -#endif -#if defined(HAVE_SSE41) -#include -#endif -#if defined(HAVE_AVX) -#include -#endif -#if defined(HAVE_XOP) -#include -#endif - -#include - -ALIGN( 64 ) static const uint64_t blake2b_IV[8] = -{ - 0x6a09e667f3bcc908ULL, 0xbb67ae8584caa73bULL, - 0x3c6ef372fe94f82bULL, 0xa54ff53a5f1d36f1ULL, - 0x510e527fade682d1ULL, 0x9b05688c2b3e6c1fULL, - 0x1f83d9abfb41bd6bULL, 0x5be0cd19137e2179ULL -}; - -static const uint8_t blake2b_sigma[12][16] = -{ - { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 } , - { 14, 10, 4, 8, 9, 15, 13, 6, 1, 12, 0, 2, 11, 7, 5, 3 } , - { 11, 8, 12, 0, 5, 2, 15, 13, 10, 14, 3, 6, 7, 1, 9, 4 } , - { 7, 9, 3, 1, 13, 12, 11, 14, 2, 6, 5, 10, 4, 0, 15, 8 } , - { 9, 0, 5, 7, 2, 4, 10, 15, 14, 1, 11, 12, 6, 8, 3, 13 } , - { 2, 12, 6, 10, 0, 11, 8, 3, 4, 13, 7, 5, 15, 14, 1, 9 } , - { 12, 5, 1, 15, 14, 13, 4, 10, 0, 7, 6, 3, 9, 2, 8, 11 } , - { 13, 11, 7, 14, 12, 1, 3, 9, 5, 0, 15, 4, 8, 6, 2, 10 } , - { 6, 15, 14, 9, 11, 3, 0, 8, 12, 2, 13, 7, 1, 4, 10, 5 } , - { 10, 2, 8, 4, 7, 6, 1, 5, 15, 11, 9, 14, 3, 12, 13 , 0 } , - { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 } , - { 14, 10, 4, 8, 9, 15, 13, 6, 1, 12, 0, 2, 11, 7, 5, 3 } -}; - - -/* Some helper functions, not necessarily useful */ -static inline int blake2b_set_lastnode( blake2b_state *S ) -{ - S->f[1] = ~0ULL; - return 0; -} - -static inline int blake2b_clear_lastnode( blake2b_state *S ) -{ - S->f[1] = 0ULL; - return 0; -} - -static inline int blake2b_set_lastblock( blake2b_state *S ) -{ - if( S->last_node ) blake2b_set_lastnode( S ); - - S->f[0] = ~0ULL; - return 0; -} - -static inline int blake2b_clear_lastblock( blake2b_state *S ) -{ - if( S->last_node ) blake2b_clear_lastnode( S ); - - S->f[0] = 0ULL; - return 0; -} - - -static inline int blake2b_increment_counter( blake2b_state *S, const uint64_t inc ) -{ -#if __x86_64__ - // ADD/ADC chain - __uint128_t t = ( ( __uint128_t )S->t[1] << 64 ) | S->t[0]; - t += inc; - S->t[0] = ( uint64_t )( t >> 0 ); - S->t[1] = ( uint64_t )( t >> 64 ); -#else - S->t[0] += inc; - S->t[1] += ( S->t[0] < inc ); -#endif - return 0; -} - - -// Parameter-related functions -static inline int blake2b_param_set_digest_length( blake2b_param *P, const uint8_t digest_length ) -{ - P->digest_length = digest_length; - return 0; -} - -static inline int blake2b_param_set_fanout( blake2b_param *P, const uint8_t fanout ) -{ - P->fanout = fanout; - return 0; -} - -static inline int blake2b_param_set_max_depth( blake2b_param *P, const uint8_t depth ) -{ - P->depth = depth; - return 0; -} - -static inline int blake2b_param_set_leaf_length( blake2b_param *P, const uint32_t leaf_length ) -{ - P->leaf_length = leaf_length; - return 0; -} - -static inline int blake2b_param_set_node_offset( blake2b_param *P, const uint64_t node_offset ) -{ - P->node_offset = node_offset; - return 0; -} - -static inline int blake2b_param_set_node_depth( blake2b_param *P, const uint8_t node_depth ) -{ - P->node_depth = node_depth; - return 0; -} - -static inline int blake2b_param_set_inner_length( blake2b_param *P, const uint8_t inner_length ) -{ - P->inner_length = inner_length; - return 0; -} - -static inline int blake2b_param_set_salt( blake2b_param *P, const uint8_t salt[BLAKE2B_SALTBYTES] ) -{ - memcpy( P->salt, salt, BLAKE2B_SALTBYTES ); - return 0; -} - -static inline int blake2b_param_set_personal( blake2b_param *P, const uint8_t personal[BLAKE2B_PERSONALBYTES] ) -{ - memcpy( P->personal, personal, BLAKE2B_PERSONALBYTES ); - return 0; -} - -static inline int blake2b_init0( blake2b_state *S ) -{ - memset( S, 0, sizeof( blake2b_state ) ); - - for( int i = 0; i < 8; ++i ) S->h[i] = blake2b_IV[i]; - - return 0; -} - -/* init xors IV with input parameter block */ -int blake2b_init_param( blake2b_state *S, const blake2b_param *P ) -{ - //blake2b_init0( S ); - const uint8_t * v = ( const uint8_t * )( blake2b_IV ); - const uint8_t * p = ( const uint8_t * )( P ); - uint8_t * h = ( uint8_t * )( S->h ); - /* IV XOR ParamBlock */ - memset( S, 0, sizeof( blake2b_state ) ); - - for( int i = 0; i < BLAKE2B_OUTBYTES; ++i ) h[i] = v[i] ^ p[i]; - - return 0; -} - - -/* Some sort of default parameter block initialization, for sequential blake2b */ -int blake2b_init( blake2b_state *S, const uint8_t outlen ) -{ - if ( ( !outlen ) || ( outlen > BLAKE2B_OUTBYTES ) ) return -1; - - const blake2b_param P = - { - outlen, - 0, - 1, - 1, - 0, - 0, - 0, - 0, - {0}, - {0}, - {0} - }; - return blake2b_init_param( S, &P ); -} - -int blake2b_init_key( blake2b_state *S, const uint8_t outlen, const void *key, const uint8_t keylen ) -{ - if ( ( !outlen ) || ( outlen > BLAKE2B_OUTBYTES ) ) return -1; - - if ( ( !keylen ) || keylen > BLAKE2B_KEYBYTES ) return -1; - - const blake2b_param P = - { - outlen, - keylen, - 1, - 1, - 0, - 0, - 0, - 0, - {0}, - {0}, - {0} - }; - - if( blake2b_init_param( S, &P ) < 0 ) - return 0; - - { - uint8_t block[BLAKE2B_BLOCKBYTES]; - memset( block, 0, BLAKE2B_BLOCKBYTES ); - memcpy( block, key, keylen ); - blake2b_update( S, block, BLAKE2B_BLOCKBYTES ); - secure_zero_memory( block, BLAKE2B_BLOCKBYTES ); /* Burn the key from stack */ - } - return 0; -} - -static inline int blake2b_compress( blake2b_state *S, const uint8_t block[BLAKE2B_BLOCKBYTES] ) -{ - __m128i row1l, row1h; - __m128i row2l, row2h; - __m128i row3l, row3h; - __m128i row4l, row4h; - __m128i b0, b1; - __m128i t0, t1; -#if defined(HAVE_SSSE3) && !defined(HAVE_XOP) - const __m128i r16 = _mm_setr_epi8( 2, 3, 4, 5, 6, 7, 0, 1, 10, 11, 12, 13, 14, 15, 8, 9 ); - const __m128i r24 = _mm_setr_epi8( 3, 4, 5, 6, 7, 0, 1, 2, 11, 12, 13, 14, 15, 8, 9, 10 ); -#endif -#if defined(HAVE_SSE41) - const __m128i m0 = LOADU( block + 00 ); - const __m128i m1 = LOADU( block + 16 ); - const __m128i m2 = LOADU( block + 32 ); - const __m128i m3 = LOADU( block + 48 ); - const __m128i m4 = LOADU( block + 64 ); - const __m128i m5 = LOADU( block + 80 ); - const __m128i m6 = LOADU( block + 96 ); - const __m128i m7 = LOADU( block + 112 ); -#else - const uint64_t m0 = ( ( uint64_t * )block )[ 0]; - const uint64_t m1 = ( ( uint64_t * )block )[ 1]; - const uint64_t m2 = ( ( uint64_t * )block )[ 2]; - const uint64_t m3 = ( ( uint64_t * )block )[ 3]; - const uint64_t m4 = ( ( uint64_t * )block )[ 4]; - const uint64_t m5 = ( ( uint64_t * )block )[ 5]; - const uint64_t m6 = ( ( uint64_t * )block )[ 6]; - const uint64_t m7 = ( ( uint64_t * )block )[ 7]; - const uint64_t m8 = ( ( uint64_t * )block )[ 8]; - const uint64_t m9 = ( ( uint64_t * )block )[ 9]; - const uint64_t m10 = ( ( uint64_t * )block )[10]; - const uint64_t m11 = ( ( uint64_t * )block )[11]; - const uint64_t m12 = ( ( uint64_t * )block )[12]; - const uint64_t m13 = ( ( uint64_t * )block )[13]; - const uint64_t m14 = ( ( uint64_t * )block )[14]; - const uint64_t m15 = ( ( uint64_t * )block )[15]; -#endif - row1l = LOADU( &S->h[0] ); - row1h = LOADU( &S->h[2] ); - row2l = LOADU( &S->h[4] ); - row2h = LOADU( &S->h[6] ); - row3l = LOADU( &blake2b_IV[0] ); - row3h = LOADU( &blake2b_IV[2] ); - row4l = _mm_xor_si128( LOADU( &blake2b_IV[4] ), LOADU( &S->t[0] ) ); - row4h = _mm_xor_si128( LOADU( &blake2b_IV[6] ), LOADU( &S->f[0] ) ); - ROUND( 0 ); - ROUND( 1 ); - ROUND( 2 ); - ROUND( 3 ); - ROUND( 4 ); - ROUND( 5 ); - ROUND( 6 ); - ROUND( 7 ); - ROUND( 8 ); - ROUND( 9 ); - ROUND( 10 ); - ROUND( 11 ); - row1l = _mm_xor_si128( row3l, row1l ); - row1h = _mm_xor_si128( row3h, row1h ); - STOREU( &S->h[0], _mm_xor_si128( LOADU( &S->h[0] ), row1l ) ); - STOREU( &S->h[2], _mm_xor_si128( LOADU( &S->h[2] ), row1h ) ); - row2l = _mm_xor_si128( row4l, row2l ); - row2h = _mm_xor_si128( row4h, row2h ); - STOREU( &S->h[4], _mm_xor_si128( LOADU( &S->h[4] ), row2l ) ); - STOREU( &S->h[6], _mm_xor_si128( LOADU( &S->h[6] ), row2h ) ); - return 0; -} - - -int blake2b_update( blake2b_state *S, const uint8_t *in, uint64_t inlen ) -{ - while( inlen > 0 ) - { - size_t left = S->buflen; - size_t fill = 2 * BLAKE2B_BLOCKBYTES - left; - - if( inlen > fill ) - { - memcpy( S->buf + left, in, fill ); // Fill buffer - S->buflen += fill; - blake2b_increment_counter( S, BLAKE2B_BLOCKBYTES ); - blake2b_compress( S, S->buf ); // Compress - memcpy( S->buf, S->buf + BLAKE2B_BLOCKBYTES, BLAKE2B_BLOCKBYTES ); // Shift buffer left - S->buflen -= BLAKE2B_BLOCKBYTES; - in += fill; - inlen -= fill; - } - else // inlen <= fill - { - memcpy( S->buf + left, in, inlen ); - S->buflen += inlen; // Be lazy, do not compress - in += inlen; - inlen -= inlen; - } - } - - return 0; -} - - -int blake2b_final( blake2b_state *S, uint8_t *out, uint8_t outlen ) -{ - if( outlen > BLAKE2B_OUTBYTES ) - return -1; - - if( S->buflen > BLAKE2B_BLOCKBYTES ) - { - blake2b_increment_counter( S, BLAKE2B_BLOCKBYTES ); - blake2b_compress( S, S->buf ); - S->buflen -= BLAKE2B_BLOCKBYTES; - memcpy( S->buf, S->buf + BLAKE2B_BLOCKBYTES, S->buflen ); - } - - blake2b_increment_counter( S, S->buflen ); - blake2b_set_lastblock( S ); - memset( S->buf + S->buflen, 0, 2 * BLAKE2B_BLOCKBYTES - S->buflen ); /* Padding */ - blake2b_compress( S, S->buf ); - memcpy( out, &S->h[0], outlen ); - return 0; -} - - -int blake2b( uint8_t *out, const void *in, const void *key, const uint8_t outlen, const uint64_t inlen, uint8_t keylen ) -{ - blake2b_state S[1]; - - /* Verify parameters */ - if ( NULL == in ) return -1; - - if ( NULL == out ) return -1; - - if( NULL == key ) keylen = 0; - - if( keylen ) - { - if( blake2b_init_key( S, outlen, key, keylen ) < 0 ) return -1; - } - else - { - if( blake2b_init( S, outlen ) < 0 ) return -1; - } - - blake2b_update( S, ( const uint8_t * )in, inlen ); - blake2b_final( S, out, outlen ); - return 0; -} - -#if defined(SUPERCOP) -int crypto_hash( unsigned char *out, unsigned char *in, unsigned long long inlen ) -{ - return blake2b( out, in, NULL, BLAKE2B_OUTBYTES, inlen, 0 ); -} -#endif - -#if defined(BLAKE2B_SELFTEST) -#include -#include "blake2-kat.h" -int main( int argc, char **argv ) -{ - uint8_t key[BLAKE2B_KEYBYTES]; - uint8_t buf[KAT_LENGTH]; - - for( size_t i = 0; i < BLAKE2B_KEYBYTES; ++i ) - key[i] = ( uint8_t )i; - - for( size_t i = 0; i < KAT_LENGTH; ++i ) - buf[i] = ( uint8_t )i; - - for( size_t i = 0; i < KAT_LENGTH; ++i ) - { - uint8_t hash[BLAKE2B_OUTBYTES]; - blake2b( hash, buf, key, BLAKE2B_OUTBYTES, i, BLAKE2B_KEYBYTES ); - - if( 0 != memcmp( hash, blake2b_keyed_kat[i], BLAKE2B_OUTBYTES ) ) - { - puts( "error" ); - return -1; - } - } - - puts( "ok" ); - return 0; -} -#endif - -int blake2b_long(uint8_t *out, const void *in, const uint32_t outlen, const uint64_t inlen) -{ - blake2b_state blake_state; - if (outlen <= BLAKE2B_OUTBYTES) - { - blake2b_init(&blake_state, outlen); - blake2b_update(&blake_state, (const uint8_t*)&outlen, sizeof(uint32_t)); - blake2b_update(&blake_state, (const uint8_t *)in, inlen); - blake2b_final(&blake_state, out, outlen); - } - else - { - uint8_t out_buffer[BLAKE2B_OUTBYTES]; - uint8_t in_buffer[BLAKE2B_OUTBYTES]; - blake2b_init(&blake_state, BLAKE2B_OUTBYTES); - blake2b_update(&blake_state, (const uint8_t*)&outlen, sizeof(uint32_t)); - blake2b_update(&blake_state, (const uint8_t *)in, inlen); - blake2b_final(&blake_state, out_buffer, BLAKE2B_OUTBYTES); - memcpy(out, out_buffer, BLAKE2B_OUTBYTES / 2); - out += BLAKE2B_OUTBYTES / 2; - uint32_t toproduce = outlen - BLAKE2B_OUTBYTES / 2; - while (toproduce > BLAKE2B_OUTBYTES) - { - memcpy(in_buffer, out_buffer, BLAKE2B_OUTBYTES); - blake2b(out_buffer, in_buffer, NULL, BLAKE2B_OUTBYTES, BLAKE2B_OUTBYTES, 0); - memcpy(out, out_buffer, BLAKE2B_OUTBYTES / 2); - out += BLAKE2B_OUTBYTES / 2; - toproduce -= BLAKE2B_OUTBYTES / 2; - } - memcpy(in_buffer, out_buffer, BLAKE2B_OUTBYTES); - blake2b(out_buffer, in_buffer, NULL, toproduce, BLAKE2B_OUTBYTES, 0); - memcpy(out, out_buffer, toproduce); - - } - return 0; -} \ No newline at end of file diff --git a/vendor/equihash/src/pow.cpp b/vendor/equihash/src/pow.cpp deleted file mode 100644 index 95d6bfb06..000000000 --- a/vendor/equihash/src/pow.cpp +++ /dev/null @@ -1,415 +0,0 @@ -/*Code by Dmitry Khovratovich, 2016 -CC0 license - -Modifications by Steemit, Inc. 2016 -*/ - -#include -#include -#include - -#ifdef EQUIHASH_POW_VERBOSE -#include -#include - -#define EQUIHASH_LOG(s) \ - std::cerr << s << std::endl; -#else -#define EQUIHASH_LOG(s) -#endif - -static uint64_t rdtsc(void) { -#ifdef _MSC_VER - return __rdtsc(); -#else -#if defined(__amd64__) || defined(__x86_64__) - uint64_t rax, rdx; - __asm__ __volatile__("rdtsc" : "=a"(rax), "=d"(rdx) : : ); - return (rdx << 32) | rax; -#elif defined(__i386__) || defined(__i386) || defined(__X86__) - uint64_t rax; - __asm__ __volatile__("rdtsc" : "=A"(rax) : : ); - return rax; -#else -#error "Not implemented!" -#endif -#endif -} - - -using namespace _POW; -using namespace std; - -void Equihash::InitializeMemory() -{ - uint32_t tuple_n = ((uint32_t)1) << (n / (k + 1)); - Tuple default_tuple(k); // k blocks to store (one left for index) - std::vector def_tuples(LIST_LENGTH, default_tuple); - tupleList = std::vector>(tuple_n, def_tuples); - filledList= std::vector(tuple_n, 0); - solutions.resize(0); - forks.resize(0); -} - -void Equihash::FillMemory(uint32_t length) //works for k<=7 -{ - uint32_t input[SEED_LENGTH + 2]; - for (unsigned i = 0; i < SEED_LENGTH; ++i) - input[i] = seed[i]; - input[SEED_LENGTH] = nonce; - input[SEED_LENGTH + 1] = 0; - uint32_t buf[MAX_N / 4]; - for (unsigned i = 0; i < length; ++i, ++input[SEED_LENGTH + 1]) { - blake2b((uint8_t*)buf, &input, NULL, sizeof(buf), sizeof(input), 0); - uint32_t index = buf[0] >> (32 - n / (k + 1)); - unsigned count = filledList[index]; - if (count < LIST_LENGTH) { - for (unsigned j = 1; j < (k + 1); ++j) { - //select j-th block of n/(k+1) bits - tupleList[index][count].blocks[j - 1] = buf[j] >> (32 - n / (k + 1)); - } - tupleList[index][count].reference = i; - filledList[index]++; - } - } -} - -std::vector Equihash::ResolveTreeByLevel(Fork fork, unsigned level) { - if (level == 0) - return std::vector{fork.ref1, fork.ref2}; - auto v1 = ResolveTreeByLevel(forks[level - 1][fork.ref1], level - 1); - auto v2 = ResolveTreeByLevel(forks[level - 1][fork.ref2], level - 1); - v1.insert(v1.end(), v2.begin(), v2.end()); - return v1; -} - -std::vector Equihash::ResolveTree(Fork fork) { - return ResolveTreeByLevel(fork, forks.size()); -} - - -void Equihash::ResolveCollisions(bool store) { - const unsigned tableLength = tupleList.size(); //number of rows in the hashtable - const unsigned maxNewCollisions = tupleList.size()*FORK_MULTIPLIER; //max number of collisions to be found - const unsigned newBlocks = tupleList[0][0].blocks.size() - 1;// number of blocks in the future collisions - std::vector newForks(maxNewCollisions); //list of forks created at this step - auto tableRow = vector(LIST_LENGTH, Tuple(newBlocks)); //Row in the hash table - vector> collisionList(tableLength,tableRow); - std::vector newFilledList(tableLength,0); //number of entries in rows - uint32_t newColls = 0; //collision counter - for (unsigned i = 0; i < tableLength; ++i) { - for (unsigned j = 0; j < filledList[i]; ++j) { - for (unsigned m = j + 1; m < filledList[i]; ++m) { //Collision - //New index - uint32_t newIndex = tupleList[i][j].blocks[0] ^ tupleList[i][m].blocks[0]; - Fork newFork = Fork(tupleList[i][j].reference, tupleList[i][m].reference); - //Check if we get a solution - if (store) { //last step - if (newIndex == 0) {//Solution - std::vector solution_inputs = ResolveTree(newFork); - solutions.push_back(Proof(n, k, seed, nonce, solution_inputs)); - } - } - else { //Resolve - if (newFilledList[newIndex] < LIST_LENGTH && newColls < maxNewCollisions) { - for (unsigned l = 0; l < newBlocks; ++l) { - collisionList[newIndex][newFilledList[newIndex]].blocks[l] - = tupleList[i][j].blocks[l+1] ^ tupleList[i][m].blocks[l+1]; - } - newForks[newColls] = newFork; - collisionList[newIndex][newFilledList[newIndex]].reference = newColls; - newFilledList[newIndex]++; - newColls++; - }//end of adding collision - } - } - }//end of collision for i - } - forks.push_back(newForks); - std::swap(tupleList, collisionList); - std::swap(filledList, newFilledList); -} - -Proof Equihash::FindProof(){ - this->nonce = 1; - while (nonce < MAX_NONCE) { - nonce++; - uint64_t start_cycles = rdtsc(); - InitializeMemory(); //allocate - FillMemory(4UL << (n / (k + 1)-1)); //fill with hashes - uint64_t fill_end = rdtsc(); - /*fp = fopen("proof.log", "a+"); - fprintf(fp, "\n===MEMORY FILLED:\n"); - PrintTuples(fp); - fclose(fp);*/ - for (unsigned i = 1; i <= k; ++i) { - uint64_t resolve_start = rdtsc(); - bool to_store = (i == k); - ResolveCollisions(to_store); //XOR collisions, concatenate indices and shift - uint64_t resolve_end = rdtsc(); - /* fp = fopen("proof.log", "a+"); - fprintf(fp, "\n===RESOLVED AFTER STEP %d:\n", i); - PrintTuples(fp); - fclose(fp);*/ - } - uint64_t stop_cycles = rdtsc(); - - double mcycles_d = (double)(stop_cycles - start_cycles) / (1UL << 20); - uint32_t kbytes = (tupleList.size()*LIST_LENGTH*k*sizeof(uint32_t)) / (1UL << 10); - - //Duplicate check - for (unsigned i = 0; i < solutions.size(); ++i) { - auto vec = solutions[i].inputs; - std::sort(vec.begin(), vec.end()); - bool dup = false; - for (unsigned k = 0; k < vec.size() - 1; ++k) { - if (vec[k] == vec[k + 1]) - dup = true; - } - if (!dup) - { - return solutions[i].CanonizeIndexes(); - } - } - } - return Proof(n, k, seed, nonce, std::vector()); -} - -/** - * Added by Steemit, Inc. for single iteration - */ -Proof Equihash::FindProof( Nonce _nonce ) -{ - this->nonce = _nonce; - InitializeMemory(); //allocate - FillMemory(4UL << (n / (k + 1)-1)); //fill with hashes - - for (unsigned i = 1; i <= k; ++i) { - bool to_store = (i == k); - ResolveCollisions(to_store); //XOR collisions, concatenate indices and shift - } - - //Duplicate check - for (unsigned i = 0; i < solutions.size(); ++i) { - auto vec = solutions[i].inputs; - std::sort(vec.begin(), vec.end()); - bool dup = false; - for (unsigned k = 0; k < vec.size() - 1; ++k) { - if (vec[k] == vec[k + 1]) - dup = true; - } - if (!dup) - { - return solutions[i].CanonizeIndexes(); - } - } - - return Proof(n, k, seed, nonce, std::vector()); -} - -Proof Proof::CanonizeIndexes()const -{ - // We consider the index values in the inputs array to be the leaf nodes of a binary - // tree, and the inner nodes to be labelled with the XOR of the corresponding vector - // elements. - // - // Define a binary tree to be canonically sorted if, for each inner node, the least - // leaf descendant of the left child is less than the least leaf descendant of the - // right child. - // - // This method puts the inputs into canonical order without altering the inner node - // labels. Thus canonization preserves the validity of the proof and the - // footprint of Wagner's algorithm. - // - // We use a bottom-up traversal, dividing the input into successively larger power-of-2 - // blocks and swapping the two half-blocks if non-canonical. - // - // Say a block is least-first if the least element is the first element. - // - // If each half-block is least-first, the conditional swap ensures the full block will also - // be least-first. The half-blocks in the initial iteration are obviously least-first - // (they only have a single element!). So by induction, at each later iteration the half-blocks - // of that iteration are least-first (since they were the full blocks of the previous iteration, - // which were made least-first by the previous iteration's conditional swap). - // - // As a consequence, no search is necessary to find the least element in each half-block, - // it is always the first element in the half-block. - - std::vector< uint32_t > new_inputs = inputs; - - size_t input_size = inputs.size(); - size_t half_size = 1; - size_t block_size = 2; - while( block_size <= input_size ) - { - for( size_t i=0; i+block_size<=input_size; i+=block_size ) - { - auto ita = new_inputs.begin()+i, itb = ita+half_size; - if( (*ita) >= (*itb) ) - { - std::swap_ranges( ita, itb, itb ); - } - } - half_size = block_size; - block_size += block_size; - } - return Proof(n, k, seed, nonce, new_inputs); -} - -bool Proof::CheckIndexesCanon()const -{ - // This method is logically identical to CanonizeIndexes() but will return false - // instead of swapping elements. - - size_t input_size = inputs.size(); - size_t half_size = 1; - size_t block_size = 2; - while( block_size <= input_size ) - { - for( size_t i=0; i+block_size<=input_size; i+=block_size ) - { - auto ita = inputs.begin()+i, itb = ita+half_size; - if( (*ita) >= (*itb) ) - return false; - } - half_size = block_size; - block_size += block_size; - } - return true; -} - -bool Proof::Test() -{ - uint32_t input[SEED_LENGTH + 2]; - for (unsigned i = 0; i < SEED_LENGTH; ++i) - input[i] = seed[i]; - input[SEED_LENGTH] = nonce; - input[SEED_LENGTH + 1] = 0; - uint32_t buf[MAX_N / 4]; - std::vector blocks(k+1,0); - for (unsigned i = 0; i < inputs.size(); ++i) { - input[SEED_LENGTH + 1] = inputs[i]; - blake2b((uint8_t*)buf, &input, NULL, sizeof(buf), sizeof(input), 0); - for (unsigned j = 0; j < (k + 1); ++j) { - //select j-th block of n/(k+1) bits - blocks[j] ^= buf[j] >> (32 - n / (k + 1)); - } - } - bool b = inputs.size() != 0; - for (unsigned j = 0; j < (k + 1); ++j) { - b &= (blocks[j] == 0); - } - - return b; -} - -bool Proof::FullTest()const -{ - // Length must be 2**k - if( inputs.size() != size_t(1 << k) ) - { - EQUIHASH_LOG( "PoW failed length test" ); - return false; - } - - // Ensure all values are distinct - std::vector sorted_inputs = inputs; - std::sort( sorted_inputs.begin(), sorted_inputs.end() ); - for( size_t i=1; i= sorted_inputs[i] ) - { - EQUIHASH_LOG( "PoW failed distinct test" ); - return false; - } - } - - // Ensure all values are canonically indexed - /* - if( !CheckIndexesCanon() ) - return false; - */ - - // Initialize blocks array - uint32_t input[SEED_LENGTH + 2]; - for( size_t i=0; i > blocks; - - const uint32_t max_input = uint32_t(1) << (n / (k + 1) + 1); - - for( size_t i=0; i= max_input ) - { - EQUIHASH_LOG( "PoW failed max_input test" ); - return false; - } - - blake2b((uint8_t*)buf, &input, NULL, sizeof(buf), sizeof(input), 0); - blocks.emplace_back(); - std::vector& x = blocks.back(); - x.resize(k+1); - for( size_t j=0; j<(k+1); j++ ) - { - //select j-th block of n/(k+1) bits - x[j] = buf[j] >> (32 - n / (k + 1)); - } - } - - while( true ) - { -#ifdef EQUIHASH_POW_VERBOSE - std::cerr << "\n\nBegin loop iteration\n"; - for( const std::vector< uint32_t >& x : blocks ) - { - for( const uint32_t& e : x ) - std::cerr << std::hex << std::setw(5) << e << " "; - std::cerr << std::endl; - } -#endif - - size_t count = blocks.size(); - if( count == 0 ) - { - EQUIHASH_LOG( "PoW failed with count == 0" ); - return false; - } - if( count == 1 ) - { - if( blocks[0].size() != 1 ) - { - EQUIHASH_LOG( "PoW failed due to vector size" ); - return false; - } - if( blocks[0][0] != 0 ) - { - EQUIHASH_LOG( "PoW failed because final bits are not zero" ); - return false; - } - return true; - } - if( (count&1) != 0 ) - { - EQUIHASH_LOG( "PoW failed with odd count" ); - return false; - } - for( size_t i=0,new_i=0; i> 1); - } -} From 895e833edc8b282c82b992d3460490b8013f6c2a Mon Sep 17 00:00:00 2001 From: Vikram Rajkumar Date: Thu, 1 Jun 2017 16:47:58 -0500 Subject: [PATCH 027/260] Remove unused FindWt https://github.com/EOSIO/eos/commit/c2f9a372184b368937adfe4fa286b7842d3d4ca9 --- CMakeModules/FindWt.cmake | 127 -------------------------------------- 1 file changed, 127 deletions(-) delete mode 100755 CMakeModules/FindWt.cmake diff --git a/CMakeModules/FindWt.cmake b/CMakeModules/FindWt.cmake deleted file mode 100755 index 094e37842..000000000 --- a/CMakeModules/FindWt.cmake +++ /dev/null @@ -1,127 +0,0 @@ -# Find Wt includes and libraries -# -# This script sets the following variables: -# -# Wt_INCLUDE_DIR -# Wt_LIBRARIES - Release libraries -# Wt_FOUND - True if release libraries found -# Wt_DEBUG_LIBRARIES - Debug libraries -# Wt_DEBUG_FOUND - True if debug libraries found -# -# To direct the script to a particular Wt installation, use the -# standard cmake variables CMAKE_INCLUDE_PATH and CMAKE_LIBRARY_PATH -# -# To use this script to find Wt, when using the new style for include files: -# #include -# #include -# #include -# -# include the following CMake snippet in your project: -# -# FIND_PACKAGE( Wt REQUIRED ) -# INCLUDE_DIRECTORIES( ${Wt_INCLUDE_DIR} ) -# TARGET_LINK_LIBRARIES( yourexe -# ${Wt_DEBUG_LIBRARY} # or {Wt_LIBRARY} -# ${Wt_HTTP_DEBUG_LIBRARY} # or {Wt_HTTP_LIBRARY} -# ${Wt_EXT_DEBUG_LIBRARY} # or {Wt_EXT_LIBRARY} -# ) -# -# To use this script to find Wt, when using the old include style: -# #include -# #include -# #include -# style of include files, change the INCLUDE_DIRECTORIES statement to: -# INCLUDE_DIRECTORIES( ${Wt_INCLUDE_DIR} ${Wt_INCLUDE_DIR}/Wt ) -# -# -# -# -# Copyright (c) 2007, Pau Garcia i Quiles, -# -# Redistribution and use is allowed according to the terms of the BSD license. -# For details see the accompanying COPYING-CMAKE-SCRIPTS file. - -FIND_PATH( Wt_INCLUDE_DIR NAMES Wt/WObject PATHS ENV PATH PATH_SUFFIXES include wt ) - -SET( Wt_FIND_COMPONENTS Release Debug ) - -IF( Wt_INCLUDE_DIR ) - FIND_LIBRARY( Wt_LIBRARY NAMES wt PATHS PATH PATH_SUFFIXES lib lib-release lib_release ) - FIND_LIBRARY( Wt_EXT_LIBRARY NAMES wtext PATHS PATH PATH_SUFFIXES lib lib-release lib_release ) - FIND_LIBRARY( Wt_HTTP_LIBRARY NAMES wthttp PATHS PATH PATH_SUFFIXES lib lib-release lib_release ) - FIND_LIBRARY( Wt_FCGI_LIBRARY NAMES wtfcgi PATHS PATH PATH_SUFFIXES lib lib-release lib_release ) - FIND_LIBRARY( Wt_DBO_LIBRARY NAMES wtdbo PATHS PATH PATH_SUFFIXES lib lib-release lib_release ) - FIND_LIBRARY( Wt_DBOSQLITE3_LIBRARY NAMES wtdbosqlite3 PATHS PATH PATH_SUFFIXES lib lib-release lib_release ) - FIND_LIBRARY( Wt_DBOPOSTGRES_LIBRARY NAMES wtdbopostgres PATHS PATH PATH_SUFFIXES lib lib-release lib_release ) - - FIND_LIBRARY( Wt_DEBUG_LIBRARY NAMES wtd wt PATHS PATH PATH_SUFFIXES lib libd lib-debug lib_debug HINTS /usr/lib/debug/usr/lib) - FIND_LIBRARY( Wt_EXT_DEBUG_LIBRARY NAMES wtextd wtext PATHS PATH PATH_SUFFIXES lib libd lib-debug lib_debug HINTS /usr/lib/debug/usr/lib) - FIND_LIBRARY( Wt_HTTP_DEBUG_LIBRARY NAMES wthttpd wthttp PATHS PATH PATH_SUFFIXES lib libd lib-debug lib_debug HINTS /usr/lib/debug/usr/lib) - FIND_LIBRARY( Wt_FCGI_DEBUG_LIBRARY NAMES wtfcgid wtfcgi PATHS PATH PATH_SUFFIXES lib libd lib-debug lib_debug HINTS /usr/lib/debug/usr/lib) - FIND_LIBRARY( Wt_DBO_DEBUG_LIBRARY NAMES wtdbod wtdbo PATHS PATH PATH_SUFFIXES lib lib-debug lib_debug HINTS /usr/lib/debug/usr/lib) - FIND_LIBRARY( Wt_DBOSQLITE3_DEBUG_LIBRARY NAMES wtdbosqlite3d wtdbosqlite3 PATHS PATH PATH_SUFFIXES lib lib-debug lib_debug HINTS /usr/lib/debug/usr/lib) - FIND_LIBRARY( Wt_DBOPOSTGRES_DEBUG_LIBRARY NAMES wtdbopostgresd wtdbopostgres PATHS PATH PATH_SUFFIXES lib lib-debug lib_debug HINTS /usr/lib/debug/usr/lib) - - IF( Wt_LIBRARY AND Wt_EXT_LIBRARY AND Wt_HTTP_LIBRARY) - SET( Wt_FOUND TRUE ) - SET( Wt_FIND_REQUIRED_Release TRUE ) - SET( Wt_LIBRARIES ${Wt_HTTP_LIBRARY} ${Wt_EXT_LIBRARY} ${Wt_LIBRARY} ) - ENDIF( Wt_LIBRARY AND Wt_EXT_LIBRARY AND Wt_HTTP_LIBRARY) - - IF( Wt_DBO_LIBRARY ) - SET( Wt_LIBRARIES ${Wt_LIBRARIES} ${Wt_DBO_LIBRARY} ) - IF( Wt_DBOSQLITE3_LIBRARY ) - SET( Wt_LIBRARIES ${Wt_LIBRARIES} ${Wt_DBOSQLITE3_LIBRARY} ) - ENDIF( Wt_DBOSQLITE3_LIBRARY ) - IF( Wt_DBOPOSTGRES_LIBRARY ) - SET( Wt_LIBRARIES ${Wt_LIBRARIES} ${Wt_DBOPOSTGRES_LIBRARY} ) - ENDIF( Wt_DBOPOSTGRES_LIBRARY ) - ENDIF( Wt_DBO_LIBRARY ) - - IF( Wt_FCGI_LIBRARY ) - SET( Wt_LIBRARIES ${Wt_LIBRARIES} ${Wt_FCGI_LIBRARY} ) - ENDIF( Wt_FCGI_LIBRARY ) - - IF( Wt_DEBUG_LIBRARY AND Wt_EXT_DEBUG_LIBRARY AND Wt_HTTP_DEBUG_LIBRARY) - SET( Wt_DEBUG_FOUND TRUE ) - SET( Wt_FIND_REQUIRED_Debug TRUE ) - SET( Wt_DEBUG_LIBRARIES ${Wt_HTTP_DEBUG_LIBRARY} ${Wt_EXT_DEBUG_LIBRARY} ${Wt_DEBUG_LIBRARY} ) - ENDIF( Wt_DEBUG_LIBRARY AND Wt_EXT_DEBUG_LIBRARY AND Wt_HTTP_DEBUG_LIBRARY) - - IF( Wt_DBO_DEBUG_LIBRARY ) - SET( Wt_DEBUG_LIBRARIES ${Wt_DEBUG_LIBRARIES} ${Wt_DBO_DEBUG_LIBRARY} ) - IF( Wt_DBOSQLITE3_DEBUG_LIBRARY ) - SET( Wt_DEBUG_LIBRARIES ${Wt_DEBUG_LIBRARIES} ${Wt_DBOSQLITE3_DEBUG_LIBRARY} ) - ENDIF( Wt_DBOSQLITE3_DEBUG_LIBRARY ) - IF( Wt_DBOPOSTGRES_DEBUG_LIBRARY ) - SET( Wt_DEBUG_LIBRARIES ${Wt_DEBUG_LIBRARIES} ${Wt_DBOPOSTGRES_DEBUG_LIBRARY} ) - ENDIF( Wt_DBOPOSTGRES_DEBUG_LIBRARY ) - ENDIF( Wt_DBO_DEBUG_LIBRARY ) - - IF( Wt_FCGI_DEBUG_LIBRARY ) - SET( Wt_DEBUG_LIBRARIES ${Wt_DEBUG_LIBRARIES} ${Wt_FCGI_DEBUG_LIBRARY} ) - ENDIF( Wt_FCGI_DEBUG_LIBRARY ) - - IF(Wt_FOUND) - IF (NOT Wt_FIND_QUIETLY) - MESSAGE(STATUS "Found the Wt libraries at ${Wt_LIBRARIES}") - MESSAGE(STATUS "Found the Wt headers at ${Wt_INCLUDE_DIR}") - ENDIF (NOT Wt_FIND_QUIETLY) - ELSE(Wt_FOUND) - IF(Wt_FIND_REQUIRED) - MESSAGE(FATAL_ERROR "Could NOT find Wt") - ENDIF(Wt_FIND_REQUIRED) - ENDIF(Wt_FOUND) - - IF(Wt_DEBUG_FOUND) - IF (NOT Wt_FIND_QUIETLY) - MESSAGE(STATUS "Found the Wt debug libraries at ${Wt_DEBUG_LIBRARIES}") - MESSAGE(STATUS "Found the Wt debug headers at ${Wt_INCLUDE_DIR}") - ENDIF (NOT Wt_FIND_QUIETLY) - ELSE(Wt_DEBUG_FOUND) - IF(Wt_FIND_REQUIRED_Debug) - MESSAGE(FATAL_ERROR "Could NOT find Wt debug libraries") - ENDIF(Wt_FIND_REQUIRED_Debug) - ENDIF(Wt_DEBUG_FOUND) - -ENDIF( Wt_INCLUDE_DIR ) From b94a338e56475943eb9bcc79be60ed6afd586796 Mon Sep 17 00:00:00 2001 From: Vikram Rajkumar Date: Thu, 1 Jun 2017 16:49:10 -0500 Subject: [PATCH 028/260] Add missing include https://github.com/EOSIO/eos/commit/4643586411a08e5e53851d9f41785b63dc975217 --- src/log/console_appender.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/log/console_appender.cpp b/src/log/console_appender.cpp index c012743f8..9c55ff06b 100644 --- a/src/log/console_appender.cpp +++ b/src/log/console_appender.cpp @@ -14,6 +14,7 @@ #include #include #include +#include namespace fc { @@ -27,7 +28,7 @@ namespace fc { #endif }; - console_appender::console_appender( const variant& args ) + console_appender::console_appender( const variant& args ) :my(new impl) { configure( args.as() ); @@ -66,7 +67,7 @@ namespace fc { #ifdef WIN32 static WORD #else - static const char* + static const char* #endif get_console_color(console_appender::color::type t ) { switch( t ) { @@ -140,7 +141,7 @@ namespace fc { #endif if( text.size() ) - fprintf( out, "%s", text.c_str() ); //fmt_str.c_str() ); + fprintf( out, "%s", text.c_str() ); //fmt_str.c_str() ); #ifdef WIN32 if (my->console_handle != INVALID_HANDLE_VALUE) From a30647d32e0580217e4bfcb7ccf5493766fcdc0c Mon Sep 17 00:00:00 2001 From: Vikram Rajkumar Date: Sun, 4 Jun 2017 17:44:25 -0500 Subject: [PATCH 029/260] Revert "Add OpenSSL 1.1.0 support" This reverts commit fee06a4c75d3215f9b502f8145383005bdda2c80. Max compatible Boost version is not compatible with OpenSSL 1.1.0 --- src/crypto/base58.cpp | 142 ++++++++++++++++++++---------------------- src/crypto/dh.cpp | 47 +------------- 2 files changed, 70 insertions(+), 119 deletions(-) diff --git a/src/crypto/base58.cpp b/src/crypto/base58.cpp index 46c9adcdd..e1d5d333e 100644 --- a/src/crypto/base58.cpp +++ b/src/crypto/base58.cpp @@ -66,71 +66,74 @@ class CAutoBN_CTX /** C++ wrapper for BIGNUM (OpenSSL bignum) */ -class CBigNum +class CBigNum : public BIGNUM { - BIGNUM* bn; public: CBigNum() - : bn(BN_new()) {} + { + BN_init(this); + } CBigNum(const CBigNum& b) - : CBigNum() { - if (!BN_copy(bn, b.bn)) + BN_init(this); + if (!BN_copy(this, &b)) { - BN_clear_free(bn); + BN_clear_free(this); throw bignum_error("CBigNum::CBigNum(const CBigNum&) : BN_copy failed"); } } CBigNum& operator=(const CBigNum& b) { - if (!BN_copy(bn, b.bn)) + if (!BN_copy(this, &b)) throw bignum_error("CBigNum::operator= : BN_copy failed"); return (*this); } ~CBigNum() { - BN_clear_free(bn); + BN_clear_free(this); } //CBigNum(char n) is not portable. Use 'signed char' or 'unsigned char'. - CBigNum(signed char n) :CBigNum() { if (n >= 0) setulong(n); else setint64(n); } - CBigNum(short n) :CBigNum() { if (n >= 0) setulong(n); else setint64(n); } - CBigNum(int n) :CBigNum() { if (n >= 0) setulong(n); else setint64(n); } - CBigNum(int64_t n) :CBigNum() { setint64(n); } - CBigNum(unsigned char n) :CBigNum() { setulong(n); } - CBigNum(unsigned short n) :CBigNum() { setulong(n); } - CBigNum(unsigned int n) :CBigNum() { setulong(n); } - CBigNum(uint64_t n) :CBigNum() { setuint64(n); } + CBigNum(signed char n) { BN_init(this); if (n >= 0) setulong(n); else setint64(n); } + CBigNum(short n) { BN_init(this); if (n >= 0) setulong(n); else setint64(n); } + CBigNum(int n) { BN_init(this); if (n >= 0) setulong(n); else setint64(n); } + //CBigNum(long n) { BN_init(this); if (n >= 0) setulong(n); else setint64(n); } + CBigNum(int64_t n) { BN_init(this); setint64(n); } + CBigNum(unsigned char n) { BN_init(this); setulong(n); } + CBigNum(unsigned short n) { BN_init(this); setulong(n); } + CBigNum(unsigned int n) { BN_init(this); setulong(n); } + //CBigNum(unsigned long n) { BN_init(this); setulong(n); } + CBigNum(uint64_t n) { BN_init(this); setuint64(n); } explicit CBigNum(const std::vector& vch) - : CBigNum() { + BN_init(this); setvch(vch); } void setulong(unsigned long n) { - if (!BN_set_word(bn, n)) + if (!BN_set_word(this, n)) throw bignum_error("CBigNum conversion from unsigned long : BN_set_word failed"); } unsigned long getulong() const { - return BN_get_word(bn); + return BN_get_word(this); } unsigned int getuint() const { - return BN_get_word(bn); + return BN_get_word(this); } int getint() const { - unsigned long n = BN_get_word(bn); - if (!BN_is_negative(bn)) + unsigned long n = BN_get_word(this); + if (!BN_is_negative(this)) return (n > (unsigned long)std::numeric_limits::max() ? std::numeric_limits::max() : n); else return (n > (unsigned long)std::numeric_limits::max() ? std::numeric_limits::min() : -(int)n); @@ -168,7 +171,7 @@ class CBigNum pch[1] = (nSize >> 16) & 0xff; pch[2] = (nSize >> 8) & 0xff; pch[3] = (nSize) & 0xff; - BN_mpi2bn(pch, p - pch, bn); + BN_mpi2bn(pch, p - pch, this); } void setuint64(uint64_t n) @@ -195,7 +198,7 @@ class CBigNum pch[1] = (nSize >> 16) & 0xff; pch[2] = (nSize >> 8) & 0xff; pch[3] = (nSize) & 0xff; - BN_mpi2bn(pch, p - pch, bn); + BN_mpi2bn(pch, p - pch, this); } @@ -211,16 +214,16 @@ class CBigNum vch2[3] = (nSize >> 0) & 0xff; // swap data to big endian reverse_copy(vch.begin(), vch.end(), vch2.begin() + 4); - BN_mpi2bn(&vch2[0], vch2.size(), bn); + BN_mpi2bn(&vch2[0], vch2.size(), this); } std::vector getvch() const { - unsigned int nSize = BN_bn2mpi(bn, NULL); + unsigned int nSize = BN_bn2mpi(this, NULL); if (nSize <= 4) return std::vector(); std::vector vch(nSize); - BN_bn2mpi(bn, &vch[0]); + BN_bn2mpi(this, &vch[0]); vch.erase(vch.begin(), vch.begin() + 4); reverse(vch.begin(), vch.end()); return vch; @@ -234,16 +237,16 @@ class CBigNum if (nSize >= 1) vch[4] = (nCompact >> 16) & 0xff; if (nSize >= 2) vch[5] = (nCompact >> 8) & 0xff; if (nSize >= 3) vch[6] = (nCompact >> 0) & 0xff; - BN_mpi2bn(&vch[0], vch.size(), bn); + BN_mpi2bn(&vch[0], vch.size(), this); return *this; } unsigned int GetCompact() const { - unsigned int nSize = BN_bn2mpi(bn, NULL); + unsigned int nSize = BN_bn2mpi(this, NULL); std::vector vch(nSize); nSize -= 4; - BN_bn2mpi(bn, &vch[0]); + BN_bn2mpi(this, &vch[0]); unsigned int nCompact = nSize << 24; if (nSize >= 1) nCompact |= (vch[4] << 16); if (nSize >= 2) nCompact |= (vch[5] << 8); @@ -278,7 +281,7 @@ class CBigNum *this += n; } if (fNegative) - BN_set_negative(bn, 1); + *this = 0 - *this; } std::string ToString(int nBase=10) const @@ -288,20 +291,20 @@ class CBigNum CBigNum bn0 = 0; std::string str; CBigNum bn = *this; - BN_set_negative(bn.bn, false); + BN_set_negative(&bn, false); CBigNum dv; CBigNum rem; - if (BN_cmp(bn.bn, bn0.bn) == 0) + if (BN_cmp(&bn, &bn0) == 0) return "0"; - while (BN_cmp(bn.bn, bn0.bn) > 0) + while (BN_cmp(&bn, &bn0) > 0) { - if (!BN_div(dv.bn, rem.bn, bn.bn, bnBase.bn, pctx)) + if (!BN_div(&dv, &rem, &bn, &bnBase, pctx)) throw bignum_error("CBigNum::ToString() : BN_div failed"); bn = dv; unsigned int c = rem.getulong(); str += "0123456789abcdef"[c]; } - if (BN_is_negative(this->bn)) + if (BN_is_negative(this)) str += "-"; reverse(str.begin(), str.end()); return str; @@ -316,50 +319,45 @@ class CBigNum bool operator!() const { - return BN_is_zero(bn); + return BN_is_zero(this); } CBigNum& operator+=(const CBigNum& b) { - if (!BN_add(bn, bn, b.bn)) + if (!BN_add(this, this, &b)) throw bignum_error("CBigNum::operator+= : BN_add failed"); return *this; } CBigNum& operator-=(const CBigNum& b) { - if (!BN_sub(bn, bn, b.bn)) - throw bignum_error("CBigNum::operator-= : BN_sub failed"); + *this = *this - b; return *this; } CBigNum& operator*=(const CBigNum& b) { CAutoBN_CTX pctx; - if (!BN_mul(bn, bn, b.bn, pctx)) + if (!BN_mul(this, this, &b, pctx)) throw bignum_error("CBigNum::operator*= : BN_mul failed"); return *this; } CBigNum& operator/=(const CBigNum& b) { - CAutoBN_CTX pctx; - if (!BN_div(bn, NULL, bn, b.bn, pctx)) - throw bignum_error("CBigNum::operator/= : BN_div failed"); + *this = *this / b; return *this; } CBigNum& operator%=(const CBigNum& b) { - CAutoBN_CTX pctx; - if (!BN_div(NULL, bn, bn, b.bn, pctx)) - throw bignum_error("CBigNum::operator%= : BN_div failed"); + *this = *this % b; return *this; } CBigNum& operator<<=(unsigned int shift) { - if (!BN_lshift(bn, bn, shift)) + if (!BN_lshift(this, this, shift)) throw bignum_error("CBigNum:operator<<= : BN_lshift failed"); return *this; } @@ -370,13 +368,13 @@ class CBigNum // if built on ubuntu 9.04 or 9.10, probably depends on version of openssl CBigNum a = 1; a <<= shift; - if (BN_cmp(a.bn, bn) > 0) + if (BN_cmp(&a, this) > 0) { *this = 0; return *this; } - if (!BN_rshift(bn, bn, shift)) + if (!BN_rshift(this, this, shift)) throw bignum_error("CBigNum:operator>>= : BN_rshift failed"); return *this; } @@ -385,7 +383,7 @@ class CBigNum CBigNum& operator++() { // prefix operator - if (!BN_add(bn, bn, BN_value_one())) + if (!BN_add(this, this, BN_value_one())) throw bignum_error("CBigNum::operator++ : BN_add failed"); return *this; } @@ -402,7 +400,7 @@ class CBigNum { // prefix operator CBigNum r; - if (!BN_sub(r.bn, bn, BN_value_one())) + if (!BN_sub(&r, this, BN_value_one())) throw bignum_error("CBigNum::operator-- : BN_sub failed"); *this = r; return *this; @@ -416,12 +414,10 @@ class CBigNum return ret; } - const BIGNUM* to_bignum() const { - return bn; - } - BIGNUM* to_bignum() { - return bn; - } + + friend inline const CBigNum operator-(const CBigNum& a, const CBigNum& b); + friend inline const CBigNum operator/(const CBigNum& a, const CBigNum& b); + friend inline const CBigNum operator%(const CBigNum& a, const CBigNum& b); }; @@ -429,7 +425,7 @@ class CBigNum inline const CBigNum operator+(const CBigNum& a, const CBigNum& b) { CBigNum r; - if (!BN_add(r.to_bignum(), a.to_bignum(), b.to_bignum())) + if (!BN_add(&r, &a, &b)) throw bignum_error("CBigNum::operator+ : BN_add failed"); return r; } @@ -437,7 +433,7 @@ inline const CBigNum operator+(const CBigNum& a, const CBigNum& b) inline const CBigNum operator-(const CBigNum& a, const CBigNum& b) { CBigNum r; - if (!BN_sub(r.to_bignum(), a.to_bignum(), b.to_bignum())) + if (!BN_sub(&r, &a, &b)) throw bignum_error("CBigNum::operator- : BN_sub failed"); return r; } @@ -445,7 +441,7 @@ inline const CBigNum operator-(const CBigNum& a, const CBigNum& b) inline const CBigNum operator-(const CBigNum& a) { CBigNum r(a); - BN_set_negative(r.to_bignum(), !BN_is_negative(r.to_bignum())); + BN_set_negative(&r, !BN_is_negative(&r)); return r; } @@ -453,7 +449,7 @@ inline const CBigNum operator*(const CBigNum& a, const CBigNum& b) { CAutoBN_CTX pctx; CBigNum r; - if (!BN_mul(r.to_bignum(), a.to_bignum(), b.to_bignum(), pctx)) + if (!BN_mul(&r, &a, &b, pctx)) throw bignum_error("CBigNum::operator* : BN_mul failed"); return r; } @@ -462,7 +458,7 @@ inline const CBigNum operator/(const CBigNum& a, const CBigNum& b) { CAutoBN_CTX pctx; CBigNum r; - if (!BN_div(r.to_bignum(), NULL, a.to_bignum(), b.to_bignum(), pctx)) + if (!BN_div(&r, NULL, &a, &b, pctx)) throw bignum_error("CBigNum::operator/ : BN_div failed"); return r; } @@ -471,7 +467,7 @@ inline const CBigNum operator%(const CBigNum& a, const CBigNum& b) { CAutoBN_CTX pctx; CBigNum r; - if (!BN_mod(r.to_bignum(), a.to_bignum(), b.to_bignum(), pctx)) + if (!BN_mod(&r, &a, &b, pctx)) throw bignum_error("CBigNum::operator% : BN_div failed"); return r; } @@ -479,7 +475,7 @@ inline const CBigNum operator%(const CBigNum& a, const CBigNum& b) inline const CBigNum operator<<(const CBigNum& a, unsigned int shift) { CBigNum r; - if (!BN_lshift(r.to_bignum(), a.to_bignum(), shift)) + if (!BN_lshift(&r, &a, shift)) throw bignum_error("CBigNum:operator<< : BN_lshift failed"); return r; } @@ -491,12 +487,12 @@ inline const CBigNum operator>>(const CBigNum& a, unsigned int shift) return r; } -inline bool operator==(const CBigNum& a, const CBigNum& b) { return (BN_cmp(a.to_bignum(), b.to_bignum()) == 0); } -inline bool operator!=(const CBigNum& a, const CBigNum& b) { return (BN_cmp(a.to_bignum(), b.to_bignum()) != 0); } -inline bool operator<=(const CBigNum& a, const CBigNum& b) { return (BN_cmp(a.to_bignum(), b.to_bignum()) <= 0); } -inline bool operator>=(const CBigNum& a, const CBigNum& b) { return (BN_cmp(a.to_bignum(), b.to_bignum()) >= 0); } -inline bool operator<(const CBigNum& a, const CBigNum& b) { return (BN_cmp(a.to_bignum(), b.to_bignum()) < 0); } -inline bool operator>(const CBigNum& a, const CBigNum& b) { return (BN_cmp(a.to_bignum(), b.to_bignum()) > 0); } +inline bool operator==(const CBigNum& a, const CBigNum& b) { return (BN_cmp(&a, &b) == 0); } +inline bool operator!=(const CBigNum& a, const CBigNum& b) { return (BN_cmp(&a, &b) != 0); } +inline bool operator<=(const CBigNum& a, const CBigNum& b) { return (BN_cmp(&a, &b) <= 0); } +inline bool operator>=(const CBigNum& a, const CBigNum& b) { return (BN_cmp(&a, &b) >= 0); } +inline bool operator<(const CBigNum& a, const CBigNum& b) { return (BN_cmp(&a, &b) < 0); } +inline bool operator>(const CBigNum& a, const CBigNum& b) { return (BN_cmp(&a, &b) > 0); } static const char* pszBase58 = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"; @@ -526,7 +522,7 @@ inline std::string EncodeBase58(const unsigned char* pbegin, const unsigned char CBigNum rem; while (bn > bn0) { - if (!BN_div(dv.to_bignum(), rem.to_bignum(), bn.to_bignum(), bn58.to_bignum(), pctx)) + if (!BN_div(&dv, &rem, &bn, &bn58, pctx)) throw bignum_error("EncodeBase58 : BN_div failed"); bn = dv; unsigned int c = rem.getulong(); @@ -576,7 +572,7 @@ inline bool DecodeBase58(const char* psz, std::vector& vchRet) break; } bnChar.setulong(p1 - pszBase58); - if (!BN_mul(bn.to_bignum(), bn.to_bignum(), bn58.to_bignum(), pctx)) + if (!BN_mul(&bn, &bn, &bn58, pctx)) throw bignum_error("DecodeBase58 : BN_mul failed"); bn += bnChar; } diff --git a/src/crypto/dh.cpp b/src/crypto/dh.cpp index e7f6c59d3..cbd7dcc25 100644 --- a/src/crypto/dh.cpp +++ b/src/crypto/dh.cpp @@ -1,9 +1,6 @@ #include #include -#if OPENSSL_VERSION_NUMBER >= 0x10100000L -#endif - namespace fc { SSL_TYPE(ssl_dh, DH, DH_free) @@ -15,19 +12,10 @@ namespace fc { bool diffie_hellman::generate_params( int s, uint8_t g ) { - ssl_dh dh; - DH_generate_parameters_ex(dh.obj, s, g, NULL); -#if OPENSSL_VERSION_NUMBER >= 0x10100000L - ssl_bignum bn_p; - DH_get0_pqg(dh.obj, (const BIGNUM**)&bn_p.obj, NULL, NULL); - p.resize( BN_num_bytes( bn_p ) ); - if( p.size() ) - BN_bn2bin( bn_p, (unsigned char*)&p.front() ); -#else + ssl_dh dh = DH_generate_parameters( s, g, NULL, NULL ); p.resize( BN_num_bytes( dh->p ) ); if( p.size() ) BN_bn2bin( dh->p, (unsigned char*)&p.front() ); -#endif this->g = g; return fc::validate( dh, valid ); } @@ -37,14 +25,8 @@ namespace fc { if( !p.size() ) return valid = false; ssl_dh dh = DH_new(); -#if OPENSSL_VERSION_NUMBER >= 0x10100000L - const auto bn_p = BN_bin2bn( (unsigned char*)&p.front(), p.size(), NULL ); - const auto bn_g = BN_bin2bn( (unsigned char*)&g, 1, NULL ); - DH_set0_pqg(dh.obj, bn_p, NULL, bn_g); -#else dh->p = BN_bin2bn( (unsigned char*)&p.front(), p.size(), NULL ); dh->g = BN_bin2bn( (unsigned char*)&g, 1, NULL ); -#endif return fc::validate( dh, valid ); } @@ -53,14 +35,8 @@ namespace fc { if( !p.size() ) return valid = false; ssl_dh dh = DH_new(); -#if OPENSSL_VERSION_NUMBER >= 0x10100000L - const auto bn_p = BN_bin2bn( (unsigned char*)&p.front(), p.size(), NULL ); - const auto bn_g = BN_bin2bn( (unsigned char*)&g, 1, NULL ); - DH_set0_pqg(dh.obj, bn_p, NULL, bn_g); -#else dh->p = BN_bin2bn( (unsigned char*)&p.front(), p.size(), NULL ); dh->g = BN_bin2bn( (unsigned char*)&g, 1, NULL ); -#endif if( !fc::validate( dh, valid ) ) { @@ -68,42 +44,21 @@ namespace fc { } DH_generate_key(dh); -#if OPENSSL_VERSION_NUMBER >= 0x10100000L - ssl_bignum bn_pub_key; - ssl_bignum bn_priv_key; - DH_get0_key(dh.obj, (const BIGNUM**)&bn_pub_key.obj, (const BIGNUM**)&bn_priv_key.obj); - pub_key.resize( BN_num_bytes( bn_pub_key ) ); - priv_key.resize( BN_num_bytes( bn_priv_key ) ); - if( pub_key.size() ) - BN_bn2bin( bn_pub_key.obj, (unsigned char*)&pub_key.front() ); - if( priv_key.size() ) - BN_bn2bin( bn_priv_key.obj, (unsigned char*)&priv_key.front() ); -#else pub_key.resize( BN_num_bytes( dh->pub_key ) ); priv_key.resize( BN_num_bytes( dh->priv_key ) ); if( pub_key.size() ) BN_bn2bin( dh->pub_key, (unsigned char*)&pub_key.front() ); if( priv_key.size() ) BN_bn2bin( dh->priv_key, (unsigned char*)&priv_key.front() ); -#endif return true; } bool diffie_hellman::compute_shared_key( const char* buf, uint32_t s ) { ssl_dh dh = DH_new(); -#if OPENSSL_VERSION_NUMBER >= 0x10100000L - auto bn_p = BN_bin2bn( (unsigned char*)&p.front(), p.size(), NULL ); - auto bn_pub_key = BN_bin2bn( (unsigned char*)&pub_key.front(), pub_key.size(), NULL ); - auto bn_priv_key = BN_bin2bn( (unsigned char*)&priv_key.front(), priv_key.size(), NULL ); - auto bn_g = BN_bin2bn( (unsigned char*)&g, 1, NULL ); - DH_set0_pqg(dh.obj, bn_p, NULL, bn_g); - DH_set0_key(dh.obj, bn_pub_key, bn_priv_key); -#else dh->p = BN_bin2bn( (unsigned char*)&p.front(), p.size(), NULL ); dh->pub_key = BN_bin2bn( (unsigned char*)&pub_key.front(), pub_key.size(), NULL ); dh->priv_key = BN_bin2bn( (unsigned char*)&priv_key.front(), priv_key.size(), NULL ); dh->g = BN_bin2bn( (unsigned char*)&g, 1, NULL ); -#endif int check; DH_check(dh,&check); From cb627980a5ff5f65fe129414dd96d3c2bd51b095 Mon Sep 17 00:00:00 2001 From: Vikram Rajkumar Date: Sun, 4 Jun 2017 18:13:13 -0500 Subject: [PATCH 030/260] Remove unused CyoEncode and Base32 https://github.com/EOSIO/eos/commit/5c466150ecea814af2bf8a7f7ccea6a3d2179999 --- CMakeLists.txt | 4 - include/fc/crypto/base32.hpp | 10 - src/crypto/base32.cpp | 29 -- tests/crypto/base_n_tests.cpp | 24 -- vendor/cyoencode-1.0.2/LICENSE.TXT | 27 -- vendor/cyoencode-1.0.2/README.TXT | 50 --- vendor/cyoencode-1.0.2/src/CyoDecode.c | 398 ------------------ vendor/cyoencode-1.0.2/src/CyoDecode.h | 58 --- vendor/cyoencode-1.0.2/src/CyoEncode.c | 283 ------------- vendor/cyoencode-1.0.2/src/CyoEncode.h | 55 --- vendor/cyoencode-1.0.2/src/build.sh | 2 - .../src/cyoencode-vc100.vcxproj | 162 ------- .../cyoencode-1.0.2/src/cyoencode-vc71.vcproj | 129 ------ .../cyoencode-1.0.2/src/cyoencode-vc80.vcproj | 195 --------- .../cyoencode-1.0.2/src/cyoencode-vc90.vcproj | 341 --------------- vendor/cyoencode-1.0.2/src/test.c | 191 --------- 16 files changed, 1958 deletions(-) delete mode 100644 include/fc/crypto/base32.hpp delete mode 100644 src/crypto/base32.cpp delete mode 100644 vendor/cyoencode-1.0.2/LICENSE.TXT delete mode 100644 vendor/cyoencode-1.0.2/README.TXT delete mode 100644 vendor/cyoencode-1.0.2/src/CyoDecode.c delete mode 100644 vendor/cyoencode-1.0.2/src/CyoDecode.h delete mode 100644 vendor/cyoencode-1.0.2/src/CyoEncode.c delete mode 100644 vendor/cyoencode-1.0.2/src/CyoEncode.h delete mode 100755 vendor/cyoencode-1.0.2/src/build.sh delete mode 100644 vendor/cyoencode-1.0.2/src/cyoencode-vc100.vcxproj delete mode 100644 vendor/cyoencode-1.0.2/src/cyoencode-vc71.vcproj delete mode 100644 vendor/cyoencode-1.0.2/src/cyoencode-vc80.vcproj delete mode 100644 vendor/cyoencode-1.0.2/src/cyoencode-vc90.vcproj delete mode 100644 vendor/cyoencode-1.0.2/src/test.c diff --git a/CMakeLists.txt b/CMakeLists.txt index 62b579d47..1f7787d7c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -207,7 +207,6 @@ set( fc_sources src/crypto/aes.cpp src/crypto/crc.cpp src/crypto/city.cpp - src/crypto/base32.cpp src/crypto/base36.cpp src/crypto/base58.cpp src/crypto/base64.cpp @@ -235,8 +234,6 @@ set( fc_sources src/network/url.cpp src/compress/smaz.cpp src/compress/zlib.cpp - vendor/cyoencode-1.0.2/src/CyoDecode.c - vendor/cyoencode-1.0.2/src/CyoEncode.c ) file( GLOB_RECURSE fc_headers ${CMAKE_CURRENT_SOURCE_DIR} *.hpp *.h ) @@ -369,7 +366,6 @@ target_include_directories(fc PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/vendor/boost_1.51/include - ${CMAKE_CURRENT_SOURCE_DIR}/vendor/cyoencode-1.0.2/src ${CMAKE_CURRENT_SOURCE_DIR}/vendor/secp256k1-zkp ) diff --git a/include/fc/crypto/base32.hpp b/include/fc/crypto/base32.hpp deleted file mode 100644 index 15bf16982..000000000 --- a/include/fc/crypto/base32.hpp +++ /dev/null @@ -1,10 +0,0 @@ -#pragma once -#include -#include - -namespace fc -{ - std::vector from_base32( const fc::string& b32 ); - fc::string to_base32( const std::vector& vec ); - fc::string to_base32( const char* data, size_t len ); -} diff --git a/src/crypto/base32.cpp b/src/crypto/base32.cpp deleted file mode 100644 index bb5354d82..000000000 --- a/src/crypto/base32.cpp +++ /dev/null @@ -1,29 +0,0 @@ -#include -#include -#include -namespace fc -{ - std::vector from_base32( const std::string& b32 ) - { - auto len = cyoBase32DecodeGetLength( b32.size() ); - std::vector v(len); - len = cyoBase32Decode( v.data(), b32.c_str(), b32.size() ); - v.resize( len ); - return v; - } - - std::string to_base32( const char* data, size_t len ) - { - auto s = cyoBase32EncodeGetLength(len); - std::vector b32; - b32.resize(s); - cyoBase32Encode( b32.data(), data, len ); - b32.resize( b32.size()-1); // strip the nullterm - return std::string(b32.begin(),b32.end()); - } - - std::string to_base32( const std::vector& vec ) - { - return to_base32( vec.data(), vec.size() ); - } -} diff --git a/tests/crypto/base_n_tests.cpp b/tests/crypto/base_n_tests.cpp index a501123fb..4ec3c1d58 100644 --- a/tests/crypto/base_n_tests.cpp +++ b/tests/crypto/base_n_tests.cpp @@ -1,7 +1,6 @@ #include #include -#include #include #include #include @@ -44,29 +43,6 @@ BOOST_AUTO_TEST_CASE(hex_test) } -static void test_32( const std::string& test, const std::string& expected ) -{ - std::vector vec( test.begin(), test.end() ); - fc::string enc1 = fc::to_base32( vec ); - fc::string enc2 = fc::to_base32( test.c_str(), test.size() ); - BOOST_CHECK_EQUAL( enc1, enc2 ); - BOOST_CHECK_EQUAL( expected, enc2 ); - - std::vector dec = fc::from_base32( enc1 ); - BOOST_CHECK_EQUAL( vec.size(), dec.size() ); - BOOST_CHECK( !memcmp( vec.data(), dec.data(), vec.size() ) ); -} - -BOOST_AUTO_TEST_CASE(base32_test) -{ - test_32( TEST1, "" ); - test_32( TEST2, "AAATAMI=" ); - test_32( TEST3, "IFBEGRCFIZDUQSKKJNGE2TSPKBIVEU2UKVLFOWCZLI======" ); - test_32( TEST4, "777AB7IB7Q======" ); - test_32( TEST5, "AAAAA===" ); -} - - static void test_36( const std::string& test, const std::string& expected ) { std::vector vec( test.begin(), test.end() ); diff --git a/vendor/cyoencode-1.0.2/LICENSE.TXT b/vendor/cyoencode-1.0.2/LICENSE.TXT deleted file mode 100644 index 4e10e7378..000000000 --- a/vendor/cyoencode-1.0.2/LICENSE.TXT +++ /dev/null @@ -1,27 +0,0 @@ -All the files in this library are covered under the terms of the Berkeley -Software Distribution (BSD) License: - -Copyright (c) 2009-2012, Graham Bull. -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation - and/or other materials provided with the distribution. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - diff --git a/vendor/cyoencode-1.0.2/README.TXT b/vendor/cyoencode-1.0.2/README.TXT deleted file mode 100644 index 30df17d8b..000000000 --- a/vendor/cyoencode-1.0.2/README.TXT +++ /dev/null @@ -1,50 +0,0 @@ -=============================================================================== -CyoEncode -http://cyoencode.sourceforge.net/ - -Copyright (c) 2009-2012, Graham Bull. All rights reserved. -=============================================================================== - -Version 1.0.2 -Release Date 5th January 2012 - -------------------------------------------------------------------------------- -1. License -------------------------------------------------------------------------------- - -CyoEncode is made available under the terms of the Berkeley Software -Distribution (BSD) licence, as detailed in LICENSE.TXT. This allows you -complete freedom to use and distribute the code in source and/or binary form, -as long as you respect the original copyright. - -------------------------------------------------------------------------------- -2. Instructions -------------------------------------------------------------------------------- - -Simply copy the required source files (CyoEncode.h/cpp and CyoDecode.h/cpp) -into your C/C++ project. - -Examples of usage can be found in the test.c file. - -For Unix/Linux developers, there's a shell script that will build the test -using GCC. - -For Windows developers, Visual Studio projects are included. - -------------------------------------------------------------------------------- -3. Release Notes -------------------------------------------------------------------------------- - -1.0.2 - 5th January 2012 -- A little refactoring, added some shared functions. -- Added VS42010 project file. -- Added x64 build configurations. - -1.0.1 - 25th September 2009 -- Added the cyoBase??Validate() functions. -- Added detection of invalid encodings in the cyoBase??Decode() functions, - rather than relying on assertions. - -1.0.0 - 19th August 2009 -- First release. - diff --git a/vendor/cyoencode-1.0.2/src/CyoDecode.c b/vendor/cyoencode-1.0.2/src/CyoDecode.c deleted file mode 100644 index d40e3a82f..000000000 --- a/vendor/cyoencode-1.0.2/src/CyoDecode.c +++ /dev/null @@ -1,398 +0,0 @@ -/* - * CyoDecode.c - part of the CyoEncode library - * - * Copyright (c) 2009-2012, Graham Bull. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * * Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include "CyoDecode.h" - -#include - -#include //TEMP - -/********************************** Shared ***********************************/ - -static int cyoBaseXXValidate( const char* src, size_t size, size_t inputBytes, size_t maxPadding, - unsigned char maxValue, const unsigned char table[] ) -{ - /* - * returns 0 if the source is a valid baseXX encoding - */ - - if (!src) - return -1; /*ERROR - NULL pointer*/ - - if (size % inputBytes != 0) - return -1; /*ERROR - extra characters*/ - - /* check the bytes */ - for (; size >= 1; --size, ++src) - { - unsigned char ch = *src; - if ((ch >= 0x80) || (table[ ch ] > maxValue)) - break; - } - - /* check any padding */ - for (; 1 <= size && size <= maxPadding; --size, ++src) - { - unsigned char ch = *src; - if ((ch >= 0x80) || (table[ ch ] != maxValue + 1)) - break; - } - - /* if size isn't zero then the encoded string isn't valid */ - if (size != 0) - return -2; /*ERROR - invalid baseXX character*/ - - /* OK */ - return 0; -} - -static size_t cyoBaseXXDecodeGetLength( size_t size, size_t inputBytes, size_t outputBytes ) -{ - if (size % inputBytes != 0) - return 0; /*ERROR - extra characters*/ - - /* OK */ - return (((size + inputBytes - 1) / inputBytes) * outputBytes) + 1; /*plus terminator*/ -} - -/****************************** Base16 Decoding ******************************/ - -static const size_t BASE16_INPUT = 2; -static const size_t BASE16_OUTPUT = 1; -static const size_t BASE16_MAX_PADDING = 0; -static const unsigned char BASE16_MAX_VALUE = 15; -static const unsigned char BASE16_TABLE[ 0x80 ] = { - /*00-07*/ 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - /*08-0f*/ 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - /*10-17*/ 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - /*18-1f*/ 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - /*20-27*/ 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - /*28-2f*/ 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - /*30-37*/ 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, /*8 = '0'-'7'*/ - /*38-3f*/ 0x08, 0x09, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, /*2 = '8'-'9'*/ - /*40-47*/ 0xFF, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0xFF, /*6 = 'A'-'F'*/ - /*48-4f*/ 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - /*50-57*/ 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - /*58-5f*/ 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - /*60-67*/ 0xFF, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0xFF, /*6 = 'a'-'f' (same as 'A'-'F')*/ - /*68-6f*/ 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - /*70-77*/ 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - /*78-7f*/ 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF -}; - -int cyoBase16Validate( const char* src, size_t size ) -{ - return cyoBaseXXValidate( src, size, BASE16_INPUT, BASE16_MAX_PADDING, BASE16_MAX_VALUE, BASE16_TABLE ); -} - -size_t cyoBase16DecodeGetLength( size_t size ) -{ - return cyoBaseXXDecodeGetLength( size, BASE16_INPUT, BASE16_OUTPUT ); -} - -size_t cyoBase16Decode( void* dest, const char* src, size_t size ) -{ - /* - * output 1 byte for every 2 input: - * - * outputs: 1 - * inputs: 1 = ----1111 = 1111---- - * 2 = ----2222 = ----2222 - */ - - if (dest && src && (size % BASE16_INPUT == 0)) - { - unsigned char* pDest = (unsigned char*)dest; - size_t dwSrcSize = size; - size_t dwDestSize = 0; - unsigned char in1, in2; - - while (dwSrcSize >= 1) - { - /* 2 inputs */ - in1 = *src++; - in2 = *src++; - dwSrcSize -= BASE16_INPUT; - - /* Validate ascii */ - if (in1 >= 0x80 || in2 >= 0x80) - return 0; /*ERROR - invalid base16 character*/ - - /* Convert ascii to base16 */ - in1 = BASE16_TABLE[ in1 ]; - in2 = BASE16_TABLE[ in2 ]; - - /* Validate base16 */ - if (in1 > BASE16_MAX_VALUE || in2 > BASE16_MAX_VALUE) - return 0; /*ERROR - invalid base16 character*/ - - /* 1 output */ - *pDest++ = ((in1 << 4) | in2); - dwDestSize += BASE16_OUTPUT; - } - *pDest++ = '\x0'; /*append terminator*/ - - return dwDestSize; - } - else - return 0; /*ERROR - null pointer, or size isn't a multiple of 2*/ -} - -/****************************** Base32 Decoding ******************************/ - -static const size_t BASE32_INPUT = 8; -static const size_t BASE32_OUTPUT = 5; -static const size_t BASE32_MAX_PADDING = 6; -static const unsigned char BASE32_MAX_VALUE = 31; -static const unsigned char BASE32_TABLE[ 0x80 ] = { - /*00-07*/ 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - /*08-0f*/ 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - /*10-17*/ 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - /*18-1f*/ 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - /*20-27*/ 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - /*28-2f*/ 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - /*30-37*/ 0xFF, 0xFF, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, /*6 = '2'-'7'*/ - /*38-3f*/ 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x20, 0xFF, 0xFF, /*1 = '='*/ - /*40-47*/ 0xFF, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, /*7 = 'A'-'G'*/ - /*48-4f*/ 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, /*8 = 'H'-'O'*/ - /*50-57*/ 0x0f, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, /*8 = 'P'-'W'*/ - /*58-5f*/ 0x17, 0x18, 0x19, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, /*3 = 'X'-'Z'*/ - /*60-67*/ 0xFF, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, /*7 = 'a'-'g' (same as 'A'-'G')*/ - /*68-6f*/ 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, /*8 = 'h'-'o' (same as 'H'-'O')*/ - /*70-77*/ 0x0f, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, /*8 = 'p'-'w' (same as 'P'-'W')*/ - /*78-7f*/ 0x17, 0x18, 0x19, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF /*3 = 'x'-'z' (same as 'X'-'Z')*/ -}; - -int cyoBase32Validate( const char* src, size_t size ) -{ - return cyoBaseXXValidate( src, size, BASE32_INPUT, BASE32_MAX_PADDING, BASE32_MAX_VALUE, BASE32_TABLE ); -} - -size_t cyoBase32DecodeGetLength( size_t size ) -{ - return cyoBaseXXDecodeGetLength( size, BASE32_INPUT, BASE32_OUTPUT ); -} - -size_t cyoBase32Decode( void* dest, const char* src, size_t size ) -{ - /* - * output 5 bytes for every 8 input: - * - * outputs: 1 2 3 4 5 - * inputs: 1 = ---11111 = 11111--- - * 2 = ---222XX = -----222 XX------ - * 3 = ---33333 = --33333- - * 4 = ---4XXXX = -------4 XXXX---- - * 5 = ---5555X = ----5555 X------- - * 6 = ---66666 = -66666-- - * 7 = ---77XXX = ------77 XXX----- - * 8 = ---88888 = ---88888 - */ - - if (dest && src && (size % BASE32_INPUT == 0)) - { - unsigned char* pDest = (unsigned char*)dest; - size_t dwSrcSize = size; - size_t dwDestSize = 0; - unsigned char in1, in2, in3, in4, in5, in6, in7, in8; - - while (dwSrcSize >= 1) - { - /* 8 inputs */ - in1 = *src++; - in2 = *src++; - in3 = *src++; - in4 = *src++; - in5 = *src++; - in6 = *src++; - in7 = *src++; - in8 = *src++; - dwSrcSize -= BASE32_INPUT; - - /* Validate ascii */ - if ( in1 >= 0x80 || in2 >= 0x80 || in3 >= 0x80 || in4 >= 0x80 - || in5 >= 0x80 || in6 >= 0x80 || in7 >= 0x80 || in8 >= 0x80) - return 0; /*ERROR - invalid base32 character*/ - - /* Convert ascii to base16 */ - in1 = BASE32_TABLE[ in1 ]; - in2 = BASE32_TABLE[ in2 ]; - in3 = BASE32_TABLE[ in3 ]; - in4 = BASE32_TABLE[ in4 ]; - in5 = BASE32_TABLE[ in5 ]; - in6 = BASE32_TABLE[ in6 ]; - in7 = BASE32_TABLE[ in7 ]; - in8 = BASE32_TABLE[ in8 ]; - - /* Validate base32 */ - if (in1 > BASE32_MAX_VALUE || in2 > BASE32_MAX_VALUE) - return 0; /*ERROR - invalid base32 character*/ - /*the following can be padding*/ - if ( in3 > BASE32_MAX_VALUE + 1 || in4 > BASE32_MAX_VALUE + 1 || in5 > BASE32_MAX_VALUE + 1 - || in6 > BASE32_MAX_VALUE + 1 || in7 > BASE32_MAX_VALUE + 1 || in8 > BASE32_MAX_VALUE + 1) - return 0; /*ERROR - invalid base32 character*/ - - /* 5 outputs */ - *pDest++ = ((in1 & 0x1f) << 3) | ((in2 & 0x1c) >> 2); - *pDest++ = ((in2 & 0x03) << 6) | ((in3 & 0x1f) << 1) | ((in4 & 0x10) >> 4); - *pDest++ = ((in4 & 0x0f) << 4) | ((in5 & 0x1e) >> 1); - *pDest++ = ((in5 & 0x01) << 7) | ((in6 & 0x1f) << 2) | ((in7 & 0x18) >> 3); - *pDest++ = ((in7 & 0x07) << 5) | (in8 & 0x1f); - dwDestSize += BASE32_OUTPUT; - - /* Padding */ - if (in8 == BASE32_MAX_VALUE + 1) - { - --dwDestSize; - assert( (in7 == BASE32_MAX_VALUE + 1 && in6 == BASE32_MAX_VALUE + 1) || (in7 != BASE32_MAX_VALUE + 1) ); - if (in6 == BASE32_MAX_VALUE + 1) - { - --dwDestSize; - if (in5 == BASE32_MAX_VALUE + 1) - { - --dwDestSize; - assert( (in4 == BASE32_MAX_VALUE + 1 && in3 == BASE32_MAX_VALUE + 1) || (in4 != BASE32_MAX_VALUE + 1) ); - if (in3 == BASE32_MAX_VALUE + 1) - { - --dwDestSize; - } - } - } - } - } - *pDest++ = '\x0'; /*append terminator*/ - - return dwDestSize; - } - else - return 0; /*ERROR - null pointer, or size isn't a multiple of 8*/ -} - -/****************************** Base64 Decoding ******************************/ - -static const size_t BASE64_INPUT = 4; -static const size_t BASE64_OUTPUT = 3; -static const size_t BASE64_MAX_PADDING = 2; -static const unsigned char BASE64_MAX_VALUE = 63; -static const unsigned char BASE64_TABLE[ 0x80 ] = { - /*00-07*/ 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - /*08-0f*/ 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - /*10-17*/ 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - /*18-1f*/ 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - /*20-27*/ 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - /*28-2f*/ 0xFF, 0xFF, 0xFF, 0x3e, 0xFF, 0xFF, 0xFF, 0x3f, /*2 = '+' and '/'*/ - /*30-37*/ 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x3b, /*8 = '0'-'7'*/ - /*38-3f*/ 0x3c, 0x3d, 0xFF, 0xFF, 0xFF, 0x40, 0xFF, 0xFF, /*2 = '8'-'9' and '='*/ - /*40-47*/ 0xFF, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, /*7 = 'A'-'G'*/ - /*48-4f*/ 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, /*8 = 'H'-'O'*/ - /*50-57*/ 0x0f, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, /*8 = 'P'-'W'*/ - /*58-5f*/ 0x17, 0x18, 0x19, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, /*3 = 'X'-'Z'*/ - /*60-67*/ 0xFF, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20, /*7 = 'a'-'g'*/ - /*68-6f*/ 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, /*8 = 'h'-'o'*/ - /*70-77*/ 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, 0x30, /*8 = 'p'-'w'*/ - /*78-7f*/ 0x31, 0x32, 0x33, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF /*3 = 'x'-'z'*/ -}; - -int cyoBase64Validate( const char* src, size_t size ) -{ - return cyoBaseXXValidate( src, size, BASE64_INPUT, BASE64_MAX_PADDING, BASE64_MAX_VALUE, BASE64_TABLE ); -} - -size_t cyoBase64DecodeGetLength( size_t size ) -{ - return cyoBaseXXDecodeGetLength( size, BASE64_INPUT, BASE64_OUTPUT ); -} - -size_t cyoBase64Decode( void* dest, const char* src, size_t size ) -{ - /* - * output 3 bytes for every 4 input: - * - * outputs: 1 2 3 - * inputs: 1 = --111111 = 111111-- - * 2 = --22XXXX = ------22 XXXX---- - * 3 = --3333XX = ----3333 XX------ - * 4 = --444444 = --444444 - */ - - if (dest && src && (size % BASE64_INPUT == 0)) - { - unsigned char* pDest = (unsigned char*)dest; - size_t dwSrcSize = size; - size_t dwDestSize = 0; - unsigned char in1, in2, in3, in4; - - while (dwSrcSize >= 1) - { - /* 4 inputs */ - in1 = *src++; - in2 = *src++; - in3 = *src++; - in4 = *src++; - dwSrcSize -= BASE64_INPUT; - - /* Validate ascii */ - if (in1 >= 0x80 || in2 >= 0x80 || in3 >= 0x80 || in4 >= 0x80) - return 0; /*ERROR - invalid base64 character*/ - - /* Convert ascii to base64 */ - in1 = BASE64_TABLE[ in1 ]; - in2 = BASE64_TABLE[ in2 ]; - in3 = BASE64_TABLE[ in3 ]; - in4 = BASE64_TABLE[ in4 ]; - - /* Validate base64 */ - if (in1 > BASE64_MAX_VALUE || in2 > BASE64_MAX_VALUE) - return 0; /*ERROR - invalid base64 character*/ - /*the following can be padding*/ - if (in3 > BASE64_MAX_VALUE + 1 || in4 > BASE64_MAX_VALUE + 1) - return 0; /*ERROR - invalid base64 character*/ - - /* 3 outputs */ - *pDest++ = ((in1 & 0x3f) << 2) | ((in2 & 0x30) >> 4); - *pDest++ = ((in2 & 0x0f) << 4) | ((in3 & 0x3c) >> 2); - *pDest++ = ((in3 & 0x03) << 6) | (in4 & 0x3f); - dwDestSize += BASE64_OUTPUT; - - /* Padding */ - if (in4 == BASE64_MAX_VALUE + 1) - { - --dwDestSize; - if (in3 == BASE64_MAX_VALUE + 1) - { - --dwDestSize; - } - } - } - *pDest++ = '\x0'; /*append terminator*/ - - return dwDestSize; - } - else - return 0; /*ERROR - null pointer, or size isn't a multiple of 4*/ -} diff --git a/vendor/cyoencode-1.0.2/src/CyoDecode.h b/vendor/cyoencode-1.0.2/src/CyoDecode.h deleted file mode 100644 index 873ed20d7..000000000 --- a/vendor/cyoencode-1.0.2/src/CyoDecode.h +++ /dev/null @@ -1,58 +0,0 @@ -/* - * CyoDecode.h - part of the CyoEncode library - * - * Copyright (c) 2009-2012, Graham Bull. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * * Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef __CYODECODE_H -#define __CYODECODE_H - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/* Base16 Decoding */ -int cyoBase16Validate( const char* src, size_t size ); -size_t cyoBase16DecodeGetLength( size_t size ); -size_t cyoBase16Decode( void* dest, const char* src, size_t size ); - -/* Base32 Decoding */ -int cyoBase32Validate( const char* src, size_t size ); -size_t cyoBase32DecodeGetLength( size_t size ); -size_t cyoBase32Decode( void* dest, const char* src, size_t size ); - -/* Base64 Decoding */ -int cyoBase64Validate( const char* src, size_t size ); -size_t cyoBase64DecodeGetLength( size_t size ); -size_t cyoBase64Decode( void* dest, const char* src, size_t size ); - -#ifdef __cplusplus -} -#endif - -#endif /*__CYODECODE_H*/ - diff --git a/vendor/cyoencode-1.0.2/src/CyoEncode.c b/vendor/cyoencode-1.0.2/src/CyoEncode.c deleted file mode 100644 index 3e9191fdc..000000000 --- a/vendor/cyoencode-1.0.2/src/CyoEncode.c +++ /dev/null @@ -1,283 +0,0 @@ -/* - * CyoEncode.c - part of the CyoEncode library - * - * Copyright (c) 2009-2012, Graham Bull. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * * Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include "CyoEncode.h" - -#include - -/********************************** Shared ***********************************/ - -static size_t cyoBaseXXEncodeGetLength( size_t size, size_t inputBytes, size_t outputBytes ) -{ - return (((size + inputBytes - 1) / inputBytes) * outputBytes) + 1; /*plus terminator*/ -} - -/****************************** Base16 Encoding ******************************/ - -static const size_t BASE16_INPUT = 1; -static const size_t BASE16_OUTPUT = 2; -static const char* const BASE16_TABLE = "0123456789ABCDEF"; - -size_t cyoBase16EncodeGetLength( size_t size ) -{ - return cyoBaseXXEncodeGetLength( size, BASE16_INPUT, BASE16_OUTPUT ); -} - -size_t cyoBase16Encode( char* dest, const void* src, size_t size ) -{ - /* - * output 2 bytes for every 1 input: - * - * inputs: 1 - * outputs: 1 = ----1111 = 1111---- - * 2 = ----2222 = ----2222 - */ - - if (dest && src) - { - unsigned char* pSrc = (unsigned char*)src; - size_t dwSrcSize = size; - size_t dwDestSize = 0; - unsigned char ch; - - while (dwSrcSize >= 1) - { - /* 1 input */ - ch = *pSrc++; - dwSrcSize -= BASE16_INPUT; - - /* 2 outputs */ - *dest++ = BASE16_TABLE[ (ch & 0xf0) >> 4 ]; - *dest++ = BASE16_TABLE[ (ch & 0x0f) ]; - dwDestSize += BASE16_OUTPUT; - } - *dest++ = '\x0'; /*append terminator*/ - - return dwDestSize; - } - else - return 0; /*ERROR - null pointer*/ -} - -/****************************** Base32 Encoding ******************************/ - -static const size_t BASE32_INPUT = 5; -static const size_t BASE32_OUTPUT = 8; -static const char* const BASE32_TABLE = "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567="; - -size_t cyoBase32EncodeGetLength( size_t size ) -{ - return cyoBaseXXEncodeGetLength( size, BASE32_INPUT, BASE32_OUTPUT ); -} - -size_t cyoBase32Encode( char* dest, const void* src, size_t size ) -{ - /* - * output 8 bytes for every 5 input: - * - * inputs: 1 2 3 4 5 - * outputs: 1 = ---11111 = 11111--- - * 2 = ---222XX = -----222 XX------ - * 3 = ---33333 = --33333- - * 4 = ---4XXXX = -------4 XXXX---- - * 5 = ---5555X = ----5555 X------- - * 6 = ---66666 = -66666-- - * 7 = ---77XXX = ------77 XXX----- - * 8 = ---88888 = ---88888 - */ - - if (dest && src) - { - unsigned char* pSrc = (unsigned char*)src; - size_t dwSrcSize = size; - size_t dwDestSize = 0; - size_t dwBlockSize; - unsigned char n1, n2, n3, n4, n5, n6, n7, n8; - - while (dwSrcSize >= 1) - { - /* Encode inputs */ - dwBlockSize = (dwSrcSize < BASE32_INPUT ? dwSrcSize : BASE32_INPUT); - n1 = n2 = n3 = n4 = n5 = n6 = n7 = n8 = 0; - switch (dwBlockSize) - { - case 5: - n8 = (pSrc[ 4 ] & 0x1f); - n7 = ((pSrc[ 4 ] & 0xe0) >> 5); - case 4: - n7 |= ((pSrc[ 3 ] & 0x03) << 3); - n6 = ((pSrc[ 3 ] & 0x7c) >> 2); - n5 = ((pSrc[ 3 ] & 0x80) >> 7); - case 3: - n5 |= ((pSrc[ 2 ] & 0x0f) << 1); - n4 = ((pSrc[ 2 ] & 0xf0) >> 4); - case 2: - n4 |= ((pSrc[ 1 ] & 0x01) << 4); - n3 = ((pSrc[ 1 ] & 0x3e) >> 1); - n2 = ((pSrc[ 1 ] & 0xc0) >> 6); - case 1: - n2 |= ((pSrc[ 0 ] & 0x07) << 2); - n1 = ((pSrc[ 0 ] & 0xf8) >> 3); - break; - - default: - assert( 0 ); - } - pSrc += dwBlockSize; - dwSrcSize -= dwBlockSize; - - /* Validate */ - assert( n1 <= 31 ); - assert( n2 <= 31 ); - assert( n3 <= 31 ); - assert( n4 <= 31 ); - assert( n5 <= 31 ); - assert( n6 <= 31 ); - assert( n7 <= 31 ); - assert( n8 <= 31 ); - - /* Padding */ - switch (dwBlockSize) - { - case 1: n3 = n4 = 32; - case 2: n5 = 32; - case 3: n6 = n7 = 32; - case 4: n8 = 32; - case 5: - break; - - default: - assert( 0 ); - } - - /* 8 outputs */ - *dest++ = BASE32_TABLE[ n1 ]; - *dest++ = BASE32_TABLE[ n2 ]; - *dest++ = BASE32_TABLE[ n3 ]; - *dest++ = BASE32_TABLE[ n4 ]; - *dest++ = BASE32_TABLE[ n5 ]; - *dest++ = BASE32_TABLE[ n6 ]; - *dest++ = BASE32_TABLE[ n7 ]; - *dest++ = BASE32_TABLE[ n8 ]; - dwDestSize += BASE32_OUTPUT; - } - *dest++ = '\x0'; /*append terminator*/ - - return dwDestSize; - } - else - return 0; /*ERROR - null pointer*/ -} - -/****************************** Base64 Encoding ******************************/ - -static const size_t BASE64_INPUT = 3; -static const size_t BASE64_OUTPUT = 4; -static const char* const BASE64_TABLE = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="; - -size_t cyoBase64EncodeGetLength( size_t size ) -{ - return cyoBaseXXEncodeGetLength( size, BASE64_INPUT, BASE64_OUTPUT ); -} - -size_t cyoBase64Encode( char* dest, const void* src, size_t size ) -{ - /* - * output 4 bytes for every 3 input: - * - * inputs: 1 2 3 - * outputs: 1 = --111111 = 111111-- - * 2 = --22XXXX = ------22 XXXX---- - * 3 = --3333XX = ----3333 XX------ - * 4 = --444444 = --444444 - */ - - if (dest && src) - { - unsigned char* pSrc = (unsigned char*)src; - size_t dwSrcSize = size; - size_t dwDestSize = 0; - size_t dwBlockSize = 0; - unsigned char n1, n2, n3, n4; - - while (dwSrcSize >= 1) - { - /* Encode inputs */ - dwBlockSize = (dwSrcSize < BASE64_INPUT ? dwSrcSize : BASE64_INPUT); - n1 = n2 = n3 = n4 = 0; - switch (dwBlockSize) - { - case 3: - n4 = (pSrc[ 2 ] & 0x3f); - n3 = ((pSrc[ 2 ] & 0xc0) >> 6); - case 2: - n3 |= ((pSrc[ 1 ] & 0x0f) << 2); - n2 = ((pSrc[ 1 ] & 0xf0) >> 4); - case 1: - n2 |= ((pSrc[ 0 ] & 0x03) << 4); - n1 = ((pSrc[ 0 ] & 0xfc) >> 2); - break; - - default: - assert( 0 ); - } - pSrc += dwBlockSize; - dwSrcSize -= dwBlockSize; - - /* Validate */ - assert( n1 <= 63 ); - assert( n2 <= 63 ); - assert( n3 <= 63 ); - assert( n4 <= 63 ); - - /* Padding */ - switch (dwBlockSize) - { - case 1: n3 = 64; - case 2: n4 = 64; - case 3: - break; - - default: - assert( 0 ); - } - - /* 4 outputs */ - *dest++ = BASE64_TABLE[ n1 ]; - *dest++ = BASE64_TABLE[ n2 ]; - *dest++ = BASE64_TABLE[ n3 ]; - *dest++ = BASE64_TABLE[ n4 ]; - dwDestSize += BASE64_OUTPUT; - } - *dest++ = '\x0'; /*append terminator*/ - - return dwDestSize; - } - else - return 0; /*ERROR - null pointer*/ -} diff --git a/vendor/cyoencode-1.0.2/src/CyoEncode.h b/vendor/cyoencode-1.0.2/src/CyoEncode.h deleted file mode 100644 index 183a66e06..000000000 --- a/vendor/cyoencode-1.0.2/src/CyoEncode.h +++ /dev/null @@ -1,55 +0,0 @@ -/* - * CyoEncode.h - part of the CyoEncode library - * - * Copyright (c) 2009-2012, Graham Bull. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * * Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef __CYOENCODE_H -#define __CYOENCODE_H - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/* Base16 Encoding */ -size_t cyoBase16EncodeGetLength( size_t size ); -size_t cyoBase16Encode( char* dest, const void* src, size_t size ); - -/* Base32 Encoding */ -size_t cyoBase32EncodeGetLength( size_t size ); -size_t cyoBase32Encode( char* dest, const void* src, size_t size ); - -/* Base64 Encoding */ -size_t cyoBase64EncodeGetLength( size_t size ); -size_t cyoBase64Encode( char* dest, const void* src, size_t size ); - -#ifdef __cplusplus -} -#endif - -#endif /*__CYOENCODE_H*/ - diff --git a/vendor/cyoencode-1.0.2/src/build.sh b/vendor/cyoencode-1.0.2/src/build.sh deleted file mode 100755 index 67c0907eb..000000000 --- a/vendor/cyoencode-1.0.2/src/build.sh +++ /dev/null @@ -1,2 +0,0 @@ -gcc test.c CyoEncode.c CyoDecode.c -o test - diff --git a/vendor/cyoencode-1.0.2/src/cyoencode-vc100.vcxproj b/vendor/cyoencode-1.0.2/src/cyoencode-vc100.vcxproj deleted file mode 100644 index 8c3a8d236..000000000 --- a/vendor/cyoencode-1.0.2/src/cyoencode-vc100.vcxproj +++ /dev/null @@ -1,162 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - cyoencode-vc100 - {C773C1E9-CAC6-40AF-A400-567F73AB0178} - cyoencodevc100 - Win32Proj - - - - Application - Unicode - true - - - Application - Unicode - true - - - Application - Unicode - - - Application - Unicode - - - - - - - - - - - - - - - - - - - <_ProjectFileVersion>10.0.40219.1 - $(SolutionDir)$(Configuration)\ - $(SolutionDir)$(Configuration)\ - $(Configuration)\ - $(Configuration)\ - true - true - $(SolutionDir)$(Configuration)\ - $(SolutionDir)$(Configuration)\ - $(Configuration)\ - $(Configuration)\ - false - false - - - - Disabled - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - - - Level4 - EditAndContinue - - - true - Console - MachineX86 - - - - - Disabled - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - EnableFastChecks - MultiThreadedDebugDLL - - - Level4 - ProgramDatabase - - - true - Console - - - - - MaxSpeed - true - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreadedDLL - true - - - Level4 - ProgramDatabase - - - true - Console - true - true - MachineX86 - - - - - MaxSpeed - true - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreadedDLL - true - - - Level4 - ProgramDatabase - - - true - Console - true - true - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/vendor/cyoencode-1.0.2/src/cyoencode-vc71.vcproj b/vendor/cyoencode-1.0.2/src/cyoencode-vc71.vcproj deleted file mode 100644 index 26c46ff5e..000000000 --- a/vendor/cyoencode-1.0.2/src/cyoencode-vc71.vcproj +++ /dev/null @@ -1,129 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/vendor/cyoencode-1.0.2/src/cyoencode-vc80.vcproj b/vendor/cyoencode-1.0.2/src/cyoencode-vc80.vcproj deleted file mode 100644 index c08685ade..000000000 --- a/vendor/cyoencode-1.0.2/src/cyoencode-vc80.vcproj +++ /dev/null @@ -1,195 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/vendor/cyoencode-1.0.2/src/cyoencode-vc90.vcproj b/vendor/cyoencode-1.0.2/src/cyoencode-vc90.vcproj deleted file mode 100644 index ee5927b81..000000000 --- a/vendor/cyoencode-1.0.2/src/cyoencode-vc90.vcproj +++ /dev/null @@ -1,341 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/vendor/cyoencode-1.0.2/src/test.c b/vendor/cyoencode-1.0.2/src/test.c deleted file mode 100644 index 927410513..000000000 --- a/vendor/cyoencode-1.0.2/src/test.c +++ /dev/null @@ -1,191 +0,0 @@ -/* - * test.c - part of the CyoEncode library - * - * Copyright (c) 2009-2012, Graham Bull. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * * Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include "CyoEncode.h" -#include "CyoDecode.h" - -#include -#include -#include - -#define TEST_BASExx(base,str,expected) \ - printf( "TEST_BASE%s('%s')='%s'", #base, str, expected ); \ - required = cyoBase##base##EncodeGetLength( strlen( str )); \ - encoded = (char*)malloc( required ); \ - if (encoded == NULL) { \ - printf( "\n*** ERROR: Unable to allocate buffer for encoding ***\n" ); \ - goto exit; \ - } \ - cyoBase##base##Encode( encoded, str, strlen( str )); \ - if (strcmp( encoded, expected ) != 0) { \ - printf( "\n*** ERROR: Encoding failure ***\n" ); \ - goto exit; \ - } \ - valid = cyoBase##base##Validate( encoded, strlen( encoded )); \ - if (valid < 0) \ - { \ - printf( "\n*** ERROR: Unable to validate encoding (error %d) ***\n", valid ); \ - goto exit; \ - } \ - printf( " [passed]\n" ); \ - free( encoded ); encoded = NULL; - -#define TEST_BASE64(str,expected) TEST_BASExx(64,str,expected) -#define TEST_BASE32(str,expected) TEST_BASExx(32,str,expected) -#define TEST_BASE16(str,expected) TEST_BASExx(16,str,expected) - -#define CHECK_INVALID_BASExx(base,str,res) \ - printf( "CHECK_INVALID_BASE%s('%s')=%d", #base, str, res ); \ - valid = cyoBase##base##Validate( str, strlen( str )); \ - if (valid == 0) \ - { \ - printf( "\n*** ERROR: This is a valid encoding! ***\n" ); \ - goto exit; \ - } \ - if (valid != res) \ - { \ - printf( "\n*** ERROR: Expected a different return code! (%d) ***\n", valid ); \ - goto exit; \ - } \ - printf( " [passed]\n", #base, str ); \ - -#define CHECK_INVALID_BASE16(enc,res) CHECK_INVALID_BASExx(16,enc,res) -#define CHECK_INVALID_BASE32(enc,res) CHECK_INVALID_BASExx(32,enc,res) -#define CHECK_INVALID_BASE64(enc,res) CHECK_INVALID_BASExx(64,enc,res) - -int main( void ) -{ - const char* const original = "A wise man speaks when he has something to say"; - size_t required = 0; - char* encoded = NULL; - char* decoded = NULL; - int valid = 0; - int retcode = 1; - - printf( "Running CyoEncode tests...\n" ); - - /* Encode using Base64 */ - - printf( "Original = '%s'\n", original ); - required = cyoBase64EncodeGetLength( strlen( original )); - encoded = (char*)malloc( required ); - if (encoded == NULL) - { - printf( "*** ERROR: Unable to allocate buffer for encoding ***\n" ); - goto exit; - } - cyoBase64Encode( encoded, original, strlen( original )); - printf( "Encoded = '%s'\n", encoded ); - - /* Validate encoding */ - - valid = cyoBase64Validate( encoded, strlen( encoded )); - if (valid < 0) - { - printf( "*** ERROR: Encoding failure (error %d) ***\n", valid ); - goto exit; - } - - /* Decode using Base64 */ - - required = cyoBase64DecodeGetLength( strlen( encoded )); - decoded = (char*)malloc( required ); - if (decoded == NULL) - { - printf( "*** ERROR: Unable to allocate buffer for decoding ***\n" ); - goto exit; - } - cyoBase64Decode( decoded, encoded, strlen( encoded )); - printf( "Decoded = '%s'\n", decoded ); - - /* Validate */ - - if (strcmp( original, decoded ) != 0) - { - printf( "*** ERROR: Encoding/decoding failure ***\n" ); - goto exit; - } - - free( encoded ); - encoded = NULL; - free( decoded ); - decoded = NULL; - - /* Test vectors from RFC 4648 */ - - TEST_BASE16( "", "" ); - TEST_BASE16( "f", "66" ); - TEST_BASE16( "fo", "666F" ); - TEST_BASE16( "foo", "666F6F" ); - TEST_BASE16( "foob", "666F6F62" ); - TEST_BASE16( "fooba", "666F6F6261" ); - TEST_BASE16( "foobar", "666F6F626172" ); - - TEST_BASE32( "", "" ); - TEST_BASE32( "f", "MY======" ); - TEST_BASE32( "fo", "MZXQ====" ); - TEST_BASE32( "foo", "MZXW6===" ); - TEST_BASE32( "foob", "MZXW6YQ=" ); - TEST_BASE32( "fooba", "MZXW6YTB" ); - TEST_BASE32( "foobar", "MZXW6YTBOI======" ); - - TEST_BASE64( "", "" ); - TEST_BASE64( "f", "Zg==" ); - TEST_BASE64( "fo", "Zm8=" ); - TEST_BASE64( "foo", "Zm9v" ); - TEST_BASE64( "foob", "Zm9vYg==" ); - TEST_BASE64( "fooba", "Zm9vYmE=" ); - TEST_BASE64( "foobar", "Zm9vYmFy" ); - - /* Other tests */ - - CHECK_INVALID_BASE16( "1", -1 ); - CHECK_INVALID_BASE16( "123", -1 ); - CHECK_INVALID_BASE16( "1G", -2 ); - - CHECK_INVALID_BASE32( "A", -1 ); - CHECK_INVALID_BASE32( "ABCDEFG", -1 ); - CHECK_INVALID_BASE32( "ABCDEFG1", -2 ); - CHECK_INVALID_BASE32( "A=======", -2 ); - - CHECK_INVALID_BASE64( "A", -1 ); - CHECK_INVALID_BASE64( "ABCDE", -1 ); - CHECK_INVALID_BASE64( "A&B=", -2 ); - CHECK_INVALID_BASE64( "A===", -2 ); - - printf( "*** All tests passed ***\n" ); - retcode = 0; - -exit: - if (encoded != NULL) - free( encoded ); - if (decoded != NULL) - free( decoded ); - - return retcode; -} From c2a37a83bd3f6047440e0d236a5b35ea78acb583 Mon Sep 17 00:00:00 2001 From: Anton Autushka Date: Thu, 9 Nov 2017 15:18:58 +0300 Subject: [PATCH 031/260] Boost 1.61 compatibility fix --- src/thread/context.hpp | 16 +++++- src/thread/thread_d.hpp | 22 +++++++- tests/CMakeLists.txt | 1 + tests/thread/thread_tests.cpp | 95 +++++++++++++++++++++++++++++++++++ 4 files changed, 130 insertions(+), 4 deletions(-) create mode 100644 tests/thread/thread_tests.cpp diff --git a/src/thread/context.hpp b/src/thread/context.hpp index f6e8a7749..221df76ce 100644 --- a/src/thread/context.hpp +++ b/src/thread/context.hpp @@ -6,7 +6,14 @@ #include -#if BOOST_VERSION >= 105400 +#define BOOST_COROUTINES_NO_DEPRECATION_WARNING + +#if BOOST_VERSION >= 106100 + #include + namespace bc = boost::context::detail; + namespace bco = boost::coroutines; + typedef bco::stack_allocator stack_allocator; +#elif BOOST_VERSION >= 105400 # include namespace bc = boost::context; namespace bco = boost::coroutines; @@ -47,8 +54,13 @@ namespace fc { bco::stack_context stack_ctx; #endif +#if BOOST_VERSION >= 106100 + using context_fn = void (*)(bc::transfer_t); +#else + using context_fn = void(*)(intptr_t); +#endif - context( void (*sf)(intptr_t), stack_allocator& alloc, fc::thread* t ) + context( context_fn sf, stack_allocator& alloc, fc::thread* t ) : caller_context(0), stack_alloc(&alloc), next_blocked(0), diff --git a/src/thread/thread_d.hpp b/src/thread/thread_d.hpp index 941b2fa01..6ad942121 100644 --- a/src/thread/thread_d.hpp +++ b/src/thread/thread_d.hpp @@ -18,6 +18,8 @@ namespace fc { class thread_d { public: + using context_pair = std::pair; + thread_d(fc::thread& s) :self(s), boost_thread(0), task_in_queue(0), @@ -397,7 +399,11 @@ namespace fc { } // slog( "jump to %p from %p", next, prev ); // fc_dlog( logger::get("fc_context"), "from ${from} to ${to}", ( "from", int64_t(prev) )( "to", int64_t(next) ) ); -#if BOOST_VERSION >= 105600 +#if BOOST_VERSION >= 106100 + auto p = context_pair{nullptr, prev}; + auto t = bc::jump_fcontext( next->my_context, &p ); + static_cast(t.data)->second->my_context = t.fctx; +#elif BOOST_VERSION >= 105600 bc::jump_fcontext( &prev->my_context, next->my_context, 0 ); #elif BOOST_VERSION >= 105300 bc::jump_fcontext( prev->my_context, next->my_context, 0 ); @@ -439,7 +445,11 @@ namespace fc { // slog( "jump to %p from %p", next, prev ); // fc_dlog( logger::get("fc_context"), "from ${from} to ${to}", ( "from", int64_t(prev) )( "to", int64_t(next) ) ); -#if BOOST_VERSION >= 105600 +#if BOOST_VERSION >= 106100 + auto p = context_pair{this, prev}; + auto t = bc::jump_fcontext( next->my_context, &p ); + static_cast(t.data)->second->my_context = t.fctx; +#elif BOOST_VERSION >= 105600 bc::jump_fcontext( &prev->my_context, next->my_context, (intptr_t)this ); #elif BOOST_VERSION >= 105300 bc::jump_fcontext( prev->my_context, next->my_context, (intptr_t)this ); @@ -467,9 +477,17 @@ namespace fc { return true; } +#if BOOST_VERSION >= 106100 + static void start_process_tasks( bc::transfer_t my ) + { + auto p = static_cast(my.data); + auto self = static_cast(p->first); + p->second->my_context = my.fctx; +#else static void start_process_tasks( intptr_t my ) { thread_d* self = (thread_d*)my; +#endif try { self->process_tasks(); diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 1043e505c..f5d5a2407 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -51,6 +51,7 @@ add_executable( all_tests all_tests.cpp crypto/sha_tests.cpp network/http/websocket_test.cpp thread/task_cancel.cpp + thread/thread_tests.cpp bloom_test.cpp real128_test.cpp utf8_test.cpp diff --git a/tests/thread/thread_tests.cpp b/tests/thread/thread_tests.cpp new file mode 100644 index 000000000..a1f3d1b47 --- /dev/null +++ b/tests/thread/thread_tests.cpp @@ -0,0 +1,95 @@ + +#include + +#include + +using namespace fc; + +BOOST_AUTO_TEST_SUITE(thread_tests) + +BOOST_AUTO_TEST_CASE(executes_task) +{ + bool called = false; + fc::thread thread("my"); + thread.async([&called]{called = true;}).wait(); + BOOST_CHECK(called); +} + +BOOST_AUTO_TEST_CASE(returns_value_from_function) +{ + fc::thread thread("my"); + BOOST_CHECK_EQUAL(10, thread.async([]{return 10;}).wait()); +} + +BOOST_AUTO_TEST_CASE(executes_multiple_tasks) +{ + bool called1 = false; + bool called2 = false; + + fc::thread thread("my"); + auto future1 = thread.async([&called1]{called1 = true;}); + auto future2 = thread.async([&called2]{called2 = true;}); + + future2.wait(); + future1.wait(); + + BOOST_CHECK(called1); + BOOST_CHECK(called2); +} + +BOOST_AUTO_TEST_CASE(calls_tasks_in_order) +{ + std::string result; + + fc::thread thread("my"); + auto future1 = thread.async([&result]{result += "hello ";}); + auto future2 = thread.async([&result]{result += "world";}); + + future2.wait(); + future1.wait(); + + BOOST_CHECK_EQUAL("hello world", result); +} + +BOOST_AUTO_TEST_CASE(yields_execution) +{ + std::string result; + + fc::thread thread("my"); + auto future1 = thread.async([&result]{fc::yield(); result += "world";}); + auto future2 = thread.async([&result]{result += "hello ";}); + + future2.wait(); + future1.wait(); + + BOOST_CHECK_EQUAL("hello world", result); +} + +BOOST_AUTO_TEST_CASE(quits_infinite_loop) +{ + fc::thread thread("my"); + auto f = thread.async([]{while (true) fc::yield();}); + + thread.quit(); + BOOST_CHECK_THROW(f.wait(), fc::canceled_exception); +} + +BOOST_AUTO_TEST_CASE(reschedules_yielded_task) +{ + int reschedule_count = 0; + + fc::thread thread("my"); + auto future = thread.async([&reschedule_count] + { + while (reschedule_count < 10) + { + fc::yield(); + reschedule_count++; + } + }); + + future.wait(); + BOOST_CHECK_EQUAL(10, reschedule_count); +} + +BOOST_AUTO_TEST_SUITE_END() From 20836338d2cfb79620b5254c587a806d5e4469e8 Mon Sep 17 00:00:00 2001 From: Anton Autushka Date: Thu, 9 Nov 2017 15:41:44 +0300 Subject: [PATCH 032/260] Suppress coroutines deprecation warning in boost 1.62 --- src/thread/context.hpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/thread/context.hpp b/src/thread/context.hpp index 221df76ce..18a060c69 100644 --- a/src/thread/context.hpp +++ b/src/thread/context.hpp @@ -6,7 +6,8 @@ #include -#define BOOST_COROUTINES_NO_DEPRECATION_WARNING +#define BOOST_COROUTINES_NO_DEPRECATION_WARNING // Boost 1.61 +#define BOOST_COROUTINE_NO_DEPRECATION_WARNING // Boost 1.62 #if BOOST_VERSION >= 106100 #include From e754b4940e2142553029c693dc62318139a3824a Mon Sep 17 00:00:00 2001 From: cwyyprog Date: Tue, 14 Nov 2017 17:09:08 +0800 Subject: [PATCH 033/260] Update static_variant.hpp --- include/fc/static_variant.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/fc/static_variant.hpp b/include/fc/static_variant.hpp index 9aab79037..d6206c2b3 100644 --- a/include/fc/static_variant.hpp +++ b/include/fc/static_variant.hpp @@ -382,5 +382,5 @@ struct visitor { s.visit( to_static_variant(ar[1]) ); } - template struct get_typename { static const char* name() { return typeid(static_variant).name(); } }; + template struct get_typename { static const char* name() { return typeid(static_variant).name(); } }; } // namespace fc From d157c2c756f1b65f7bb12af789c3ca1f9dcc647d Mon Sep 17 00:00:00 2001 From: cwyyprog Date: Tue, 14 Nov 2017 17:11:24 +0800 Subject: [PATCH 034/260] Update typename.hpp --- include/fc/reflect/typename.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/fc/reflect/typename.hpp b/include/fc/reflect/typename.hpp index 312c92711..5cd55c9cc 100644 --- a/include/fc/reflect/typename.hpp +++ b/include/fc/reflect/typename.hpp @@ -15,7 +15,7 @@ namespace fc { class exception; namespace ip { class address; } - template class get_typename{}; + template struct get_typename; template<> struct get_typename { static const char* name() { return "int32_t"; } }; template<> struct get_typename { static const char* name() { return "int64_t"; } }; template<> struct get_typename { static const char* name() { return "int16_t"; } }; From dffe2a444e63be8afc771f89fac7083de32ef2b0 Mon Sep 17 00:00:00 2001 From: Abit Date: Sat, 20 Jan 2018 16:54:09 +0100 Subject: [PATCH 035/260] static_variant::set_which() rejects negative param --- include/fc/static_variant.hpp | 1 + 1 file changed, 1 insertion(+) diff --git a/include/fc/static_variant.hpp b/include/fc/static_variant.hpp index d6206c2b3..688d4b9f8 100644 --- a/include/fc/static_variant.hpp +++ b/include/fc/static_variant.hpp @@ -327,6 +327,7 @@ class static_variant { static int count() { return impl::type_info::count; } void set_which( int w ) { + FC_ASSERT( w >= 0 ); FC_ASSERT( w < count() ); this->~static_variant(); _tag = w; From c02fe0aaf68f899bd77c381c9f05d40d1a762d45 Mon Sep 17 00:00:00 2001 From: Peter Conrad Date: Tue, 23 Jan 2018 17:58:37 +0100 Subject: [PATCH 036/260] Added unit test to demonstrate problem with time_point_sec::to_iso_string --- tests/CMakeLists.txt | 1 + tests/time_test.cpp | 102 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 103 insertions(+) create mode 100644 tests/time_test.cpp diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index f5d5a2407..bf7a01d6a 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -54,6 +54,7 @@ add_executable( all_tests all_tests.cpp thread/thread_tests.cpp bloom_test.cpp real128_test.cpp + time_test.cpp utf8_test.cpp ) target_link_libraries( all_tests fc ) diff --git a/tests/time_test.cpp b/tests/time_test.cpp new file mode 100644 index 000000000..58b7f9030 --- /dev/null +++ b/tests/time_test.cpp @@ -0,0 +1,102 @@ +#include + +#include + +using namespace fc; + +BOOST_AUTO_TEST_SUITE(fc) + +BOOST_AUTO_TEST_CASE(time_point_sec_test) +{ + time_point_sec tp0(0); + BOOST_CHECK_EQUAL( "1970-01-01T00:00:00", tp0.to_iso_string() ); + BOOST_CHECK_EQUAL( "19700101T000000", tp0.to_non_delimited_iso_string() ); + + time_point_sec tp1(1); + BOOST_CHECK_EQUAL( "1970-01-01T00:00:01", tp1.to_iso_string() ); + BOOST_CHECK_EQUAL( "19700101T000001", tp1.to_non_delimited_iso_string() ); + + time_point_sec tp256(0x100); + BOOST_CHECK_EQUAL( "1970-01-01T00:04:16", tp256.to_iso_string() ); + BOOST_CHECK_EQUAL( "19700101T000416", tp256.to_non_delimited_iso_string() ); + + time_point_sec tp64k(0x10000); + BOOST_CHECK_EQUAL( "1970-01-01T18:12:16", tp64k.to_iso_string() ); + BOOST_CHECK_EQUAL( "19700101T181216", tp64k.to_non_delimited_iso_string() ); + + time_point_sec tp16m(0x1000000); + BOOST_CHECK_EQUAL( "1970-07-14T04:20:16", tp16m.to_iso_string() ); + BOOST_CHECK_EQUAL( "19700714T042016", tp16m.to_non_delimited_iso_string() ); + + time_point_sec tp2gm1(0x7fffffffU); + BOOST_CHECK_EQUAL( "2038-01-19T03:14:07", tp2gm1.to_iso_string() ); + BOOST_CHECK_EQUAL( "20380119T031407", tp2gm1.to_non_delimited_iso_string() ); + + time_point_sec tp2g(0x80000000U); + BOOST_CHECK_EQUAL( "2038-01-19T03:14:08", tp2g.to_iso_string() ); + BOOST_CHECK_EQUAL( "20380119T031408", tp2g.to_non_delimited_iso_string() ); + + time_point_sec tp3g(0xc0000000U); + BOOST_CHECK_EQUAL( "2072-01-28T16:51:12", tp3g.to_iso_string() ); + BOOST_CHECK_EQUAL( "20720128T165112", tp3g.to_non_delimited_iso_string() ); + + BOOST_CHECK( tp0 == time_point_sec() ); + BOOST_CHECK( tp0 < tp1 ); + BOOST_CHECK( tp0 < tp256 ); + BOOST_CHECK( tp0 < tp64k ); + BOOST_CHECK( tp0 < tp16m ); + BOOST_CHECK( tp0 < tp2gm1 ); + BOOST_CHECK( tp0 < tp2g ); + BOOST_CHECK( tp0 < tp3g ); + BOOST_CHECK( tp1 > tp0 ); + BOOST_CHECK( tp1 < tp256 ); + BOOST_CHECK( tp1 < tp64k ); + BOOST_CHECK( tp1 < tp16m ); + BOOST_CHECK( tp1 < tp2gm1 ); + BOOST_CHECK( tp1 < tp2g ); + BOOST_CHECK( tp1 < tp3g ); + BOOST_CHECK( tp256 > tp0 ); + BOOST_CHECK( tp256 > tp1 ); + BOOST_CHECK( tp256 < tp64k ); + BOOST_CHECK( tp256 < tp16m ); + BOOST_CHECK( tp256 < tp2gm1 ); + BOOST_CHECK( tp256 < tp2g ); + BOOST_CHECK( tp256 < tp3g ); + BOOST_CHECK( tp64k > tp0 ); + BOOST_CHECK( tp64k > tp1 ); + BOOST_CHECK( tp64k > tp256 ); + BOOST_CHECK( tp64k < tp16m ); + BOOST_CHECK( tp64k < tp2gm1 ); + BOOST_CHECK( tp64k < tp2g ); + BOOST_CHECK( tp64k < tp3g ); + BOOST_CHECK( tp16m > tp0 ); + BOOST_CHECK( tp16m > tp1 ); + BOOST_CHECK( tp16m > tp256 ); + BOOST_CHECK( tp16m > tp64k ); + BOOST_CHECK( tp16m < tp2gm1 ); + BOOST_CHECK( tp16m < tp2g ); + BOOST_CHECK( tp16m < tp3g ); + BOOST_CHECK( tp2gm1 > tp0 ); + BOOST_CHECK( tp2gm1 > tp1 ); + BOOST_CHECK( tp2gm1 > tp256 ); + BOOST_CHECK( tp2gm1 > tp64k ); + BOOST_CHECK( tp2gm1 > tp16m ); + BOOST_CHECK( tp2gm1 < tp2g ); + BOOST_CHECK( tp2gm1 < tp3g ); + BOOST_CHECK( tp2g > tp0 ); + BOOST_CHECK( tp2g > tp1 ); + BOOST_CHECK( tp2g > tp256 ); + BOOST_CHECK( tp2g > tp64k ); + BOOST_CHECK( tp2g > tp16m ); + BOOST_CHECK( tp2g > tp2gm1 ); + BOOST_CHECK( tp2g < tp3g ); + BOOST_CHECK( tp3g > tp0 ); + BOOST_CHECK( tp3g > tp1 ); + BOOST_CHECK( tp3g > tp256 ); + BOOST_CHECK( tp3g > tp64k ); + BOOST_CHECK( tp3g > tp2gm1 ); + BOOST_CHECK( tp3g > tp2g ); + BOOST_CHECK( tp3g > tp16m ); +} + +BOOST_AUTO_TEST_SUITE_END() From 5138c58e0905430f4bff39a774f6d04b2d0bc150 Mon Sep 17 00:00:00 2001 From: Alexey Frolov Date: Fri, 2 Feb 2018 15:29:46 +0300 Subject: [PATCH 037/260] sanitize, remove warnings --- include/fc/io/json_relaxed.hpp | 2 ++ include/fc/static_variant.hpp | 7 +++--- include/fc/thread/thread.hpp | 1 + src/asio.cpp | 8 +++++++ src/compress/miniz.c | 6 ++--- src/crypto/aes.cpp | 12 +++++----- src/crypto/base36.cpp | 5 +++- src/crypto/base58.cpp | 4 +++- src/crypto/elliptic_common.cpp | 8 +++---- src/crypto/elliptic_secp256k1.cpp | 5 ++-- src/crypto/rand.cpp | 4 ++-- src/rpc/cli.cpp | 6 ++--- src/thread/mutex.cpp | 2 +- src/thread/thread.cpp | 20 ++++++++++------ src/utf8.cpp | 1 - tests/bloom_test.cpp | 2 +- tests/crypto/base_n_tests.cpp | 13 ++++------ tests/crypto/blowfish_test.cpp | 34 +++++++++++++-------------- tests/crypto/rand_test.cpp | 4 +++- tests/crypto/sha_tests.cpp | 2 +- tests/hmac_test.cpp | 2 +- tests/network/http/websocket_test.cpp | 6 ++--- tests/real128_test.cpp | 10 ++++---- 23 files changed, 91 insertions(+), 73 deletions(-) diff --git a/include/fc/io/json_relaxed.hpp b/include/fc/io/json_relaxed.hpp index e4876f259..c1a09668b 100644 --- a/include/fc/io/json_relaxed.hpp +++ b/include/fc/io/json_relaxed.hpp @@ -231,6 +231,8 @@ namespace fc { namespace json_relaxed } } FC_RETHROW_EXCEPTIONS( warn, "while parsing string" ); + + return {}; } struct CharValueTable diff --git a/include/fc/static_variant.hpp b/include/fc/static_variant.hpp index 688d4b9f8..4f13f5b00 100644 --- a/include/fc/static_variant.hpp +++ b/include/fc/static_variant.hpp @@ -181,7 +181,7 @@ class static_variant { static_assert(impl::type_info::no_reference_types, "Reference types are not permitted in static_variant."); static_assert(impl::type_info::no_duplicates, "static_variant type arguments contain duplicate types."); - int _tag; + size_t _tag; char storage[impl::type_info::size]; template @@ -326,15 +326,14 @@ class static_variant { } static int count() { return impl::type_info::count; } - void set_which( int w ) { - FC_ASSERT( w >= 0 ); + void set_which( size_t w ) { FC_ASSERT( w < count() ); this->~static_variant(); _tag = w; impl::storage_ops<0, Types...>::con(_tag, storage); } - int which() const {return _tag;} + size_t which() const {return _tag;} }; template diff --git a/include/fc/thread/thread.hpp b/include/fc/thread/thread.hpp index bb8271076..aea55da2f 100644 --- a/include/fc/thread/thread.hpp +++ b/include/fc/thread/thread.hpp @@ -32,6 +32,7 @@ namespace fc { an existing "unknown" boost thread). In such cases, thread_d doesn't have access boost::thread object. */ static thread& current(); + static void cleanup(); /** diff --git a/src/asio.cpp b/src/asio.cpp index 01695769f..1313ed7e3 100644 --- a/src/asio.cpp +++ b/src/asio.cpp @@ -3,6 +3,7 @@ #include #include #include +#include namespace fc { namespace asio { @@ -104,6 +105,13 @@ namespace fc { asio_threads.push_back( new boost::thread( [=]() { fc::thread::current().set_name("asio"); + + BOOST_SCOPE_EXIT(void) + { + fc::thread::cleanup(); + } + BOOST_SCOPE_EXIT_END + while (!io->stopped()) { try diff --git a/src/compress/miniz.c b/src/compress/miniz.c index 7123d6226..987614d1d 100644 --- a/src/compress/miniz.c +++ b/src/compress/miniz.c @@ -1497,7 +1497,7 @@ tinfl_status tinfl_decompress(tinfl_decompressor *r, const mz_uint8 *pIn_buf_nex { mz_uint8 *p = r->m_tables[0].m_code_size; mz_uint i; r->m_table_sizes[0] = 288; r->m_table_sizes[1] = 32; TINFL_MEMSET(r->m_tables[1].m_code_size, 5, 32); - for ( i = 0; i <= 143; ++i) *p++ = 8; for ( ; i <= 255; ++i) *p++ = 9; for ( ; i <= 279; ++i) *p++ = 7; for ( ; i <= 287; ++i) *p++ = 8; + for (i = 0; i <= 143; ++i) {*p++ = 8;} for (; i <= 255; ++i) {*p++ = 9;} for (; i <= 279; ++i) {*p++ = 7;} for (; i <= 287; ++i) {*p++ = 8;} } else { @@ -2281,7 +2281,7 @@ static MZ_FORCEINLINE void tdefl_find_match(tdefl_compressor *d, mz_uint lookahe if (TDEFL_READ_UNALIGNED_WORD(&d->m_dict[probe_pos + match_len - 1]) == c01) break; TDEFL_PROBE; TDEFL_PROBE; TDEFL_PROBE; } - if (!dist) break; q = (const mz_uint16*)(d->m_dict + probe_pos); if (TDEFL_READ_UNALIGNED_WORD(q) != s01) continue; p = s; probe_len = 32; + if (!dist) {break;} q = (const mz_uint16*)(d->m_dict + probe_pos); if (TDEFL_READ_UNALIGNED_WORD(q) != s01) {continue;} p = s; probe_len = 32; do { } while ( (TDEFL_READ_UNALIGNED_WORD(++p) == TDEFL_READ_UNALIGNED_WORD(++q)) && (TDEFL_READ_UNALIGNED_WORD(++p) == TDEFL_READ_UNALIGNED_WORD(++q)) && (TDEFL_READ_UNALIGNED_WORD(++p) == TDEFL_READ_UNALIGNED_WORD(++q)) && (TDEFL_READ_UNALIGNED_WORD(++p) == TDEFL_READ_UNALIGNED_WORD(++q)) && (--probe_len > 0) ); if (!probe_len) @@ -2848,7 +2848,7 @@ void *tdefl_write_image_to_png_file_in_memory(const void *pImage, int w, int h, #include #include - #if defined(_MSC_VER) + #if defined(_MSC_VER) static FILE *mz_fopen(const char *pFilename, const char *pMode) { FILE* pFile = NULL; diff --git a/src/crypto/aes.cpp b/src/crypto/aes.cpp index 7564816e0..09db92b67 100644 --- a/src/crypto/aes.cpp +++ b/src/crypto/aes.cpp @@ -29,7 +29,7 @@ struct aes_encoder::impl aes_encoder::aes_encoder() { - static int init = init_openssl(); + static __attribute__((unused)) int init = init_openssl(); } aes_encoder::~aes_encoder() @@ -70,7 +70,7 @@ uint32_t aes_encoder::encode( const char* plaintxt, uint32_t plaintext_len, char FC_THROW_EXCEPTION( aes_exception, "error during aes 256 cbc encryption update", ("s", ERR_error_string( ERR_get_error(), nullptr) ) ); } - FC_ASSERT( ciphertext_len == plaintext_len, "", ("ciphertext_len",ciphertext_len)("plaintext_len",plaintext_len) ); + FC_ASSERT( (uint32_t) ciphertext_len == plaintext_len, "", ("ciphertext_len",ciphertext_len)("plaintext_len",plaintext_len) ); return ciphertext_len; } #if 0 @@ -96,9 +96,9 @@ struct aes_decoder::impl }; aes_decoder::aes_decoder() - { - static int init = init_openssl(); - } +{ + static __attribute__((unused)) int init = init_openssl(); +} void aes_decoder::init( const fc::sha256& key, const fc::uint128& init_value ) { @@ -137,7 +137,7 @@ uint32_t aes_decoder::decode( const char* ciphertxt, uint32_t ciphertxt_len, cha FC_THROW_EXCEPTION( aes_exception, "error during aes 256 cbc decryption update", ("s", ERR_error_string( ERR_get_error(), nullptr) ) ); } - FC_ASSERT( ciphertxt_len == plaintext_len, "", ("ciphertxt_len",ciphertxt_len)("plaintext_len",plaintext_len) ); + FC_ASSERT( ciphertxt_len == (uint32_t)plaintext_len, "", ("ciphertxt_len",ciphertxt_len)("plaintext_len",plaintext_len) ); return plaintext_len; } #if 0 diff --git a/src/crypto/base36.cpp b/src/crypto/base36.cpp index d0685aea2..5e3bd5b3e 100644 --- a/src/crypto/base36.cpp +++ b/src/crypto/base36.cpp @@ -76,7 +76,10 @@ namespace fc while (len > 0 && *first == 0) { first++; len--; } std::vector result; result.resize(leading_zeros + len, 0); - memcpy( result.data() + leading_zeros, first, len ); + if (len) + { + memcpy( result.data() + leading_zeros, first, len ); + } return result; } } diff --git a/src/crypto/base58.cpp b/src/crypto/base58.cpp index e1d5d333e..455167824 100644 --- a/src/crypto/base58.cpp +++ b/src/crypto/base58.cpp @@ -632,7 +632,9 @@ size_t from_base58( const std::string& base58_str, char* out_data, size_t out_da FC_THROW_EXCEPTION( parse_error_exception, "Unable to decode base58 string ${base58_str}", ("base58_str",base58_str) ); } FC_ASSERT( out.size() <= out_data_len ); - memcpy( out_data, out.data(), out.size() ); + if (!out.empty()) { + memcpy( out_data, out.data(), out.size() ); + } return out.size(); } } diff --git a/src/crypto/elliptic_common.cpp b/src/crypto/elliptic_common.cpp index 66b75d098..9b9044c7a 100644 --- a/src/crypto/elliptic_common.cpp +++ b/src/crypto/elliptic_common.cpp @@ -85,8 +85,8 @@ namespace fc { namespace ecc { ssl_bignum order; FC_ASSERT( EC_GROUP_get_order( group, order, ctx ) ); private_key_secret bin; - FC_ASSERT( BN_num_bytes( order ) == bin.data_size() ); - FC_ASSERT( BN_bn2bin( order, (unsigned char*) bin.data() ) == bin.data_size() ); + FC_ASSERT( (size_t) BN_num_bytes( order ) == bin.data_size() ); + FC_ASSERT( (size_t) BN_bn2bin( order, (unsigned char*) bin.data() ) == bin.data_size() ); return bin; } @@ -104,8 +104,8 @@ namespace fc { namespace ecc { FC_ASSERT( EC_GROUP_get_order( group, order, ctx ) ); BN_rshift1( order, order ); private_key_secret bin; - FC_ASSERT( BN_num_bytes( order ) == bin.data_size() ); - FC_ASSERT( BN_bn2bin( order, (unsigned char*) bin.data() ) == bin.data_size() ); + FC_ASSERT( (size_t) BN_num_bytes( order ) == bin.data_size() ); + FC_ASSERT( (size_t) BN_bn2bin( order, (unsigned char*) bin.data() ) == bin.data_size() ); return bin; } diff --git a/src/crypto/elliptic_secp256k1.cpp b/src/crypto/elliptic_secp256k1.cpp index 91edc18d1..469cc1b7b 100644 --- a/src/crypto/elliptic_secp256k1.cpp +++ b/src/crypto/elliptic_secp256k1.cpp @@ -29,9 +29,8 @@ namespace fc { namespace ecc { } void _init_lib() { - static const secp256k1_context_t* ctx = _get_context(); - static int init_o = init_openssl(); - (void)ctx; + static __attribute__((unused)) const secp256k1_context_t* ctx = _get_context(); + static __attribute__((unused)) int init_o = init_openssl(); } class public_key_impl diff --git a/src/crypto/rand.cpp b/src/crypto/rand.cpp index 7235ab689..2b194c5d6 100644 --- a/src/crypto/rand.cpp +++ b/src/crypto/rand.cpp @@ -8,7 +8,7 @@ namespace fc { void rand_bytes(char* buf, int count) { - static int init = init_openssl(); + static __attribute__((unused)) int init = init_openssl(); int result = RAND_bytes((unsigned char*)buf, count); if (result != 1) @@ -17,7 +17,7 @@ void rand_bytes(char* buf, int count) void rand_pseudo_bytes(char* buf, int count) { - static int init = init_openssl(); + static __attribute__((unused)) int init = init_openssl(); int result = RAND_pseudo_bytes((unsigned char*)buf, count); if (result == -1) diff --git a/src/rpc/cli.cpp b/src/rpc/cli.cpp index d3070fb8b..e59d4bb1a 100644 --- a/src/rpc/cli.cpp +++ b/src/rpc/cli.cpp @@ -136,7 +136,7 @@ char * dupstr (const char* s) { char* my_generator(const char* text, int state) { - static int list_index, len; + static size_t list_index, len; const char *name; if (!state) { @@ -160,20 +160,20 @@ char* my_generator(const char* text, int state) } +#ifdef HAVE_READLINE static char** cli_completion( const char * text , int start, int end) { char **matches; matches = (char **)NULL; -#ifdef HAVE_READLINE if (start == 0) matches = rl_completion_matches ((char*)text, &my_generator); else rl_bind_key('\t',rl_abort); -#endif return (matches); } +#endif void cli::getline( const fc::string& prompt, fc::string& line) diff --git a/src/thread/mutex.cpp b/src/thread/mutex.cpp index 9f3f9baa2..2a875648f 100644 --- a/src/thread/mutex.cpp +++ b/src/thread/mutex.cpp @@ -15,7 +15,7 @@ namespace fc { mutex::~mutex() { if( m_blist ) { - context* c = m_blist; +// context* c = m_blist; fc::thread::current().debug("~mutex"); #if 0 while( c ) { diff --git a/src/thread/thread.cpp b/src/thread/thread.cpp index 7b899bbd6..7ca01f2c5 100644 --- a/src/thread/thread.cpp +++ b/src/thread/thread.cpp @@ -113,8 +113,10 @@ namespace fc { if( my ) { // wlog( "calling quit() on ${n}",("n",my->name) ); - quit(); // deletes `my` + quit(); } + + delete my; } thread& thread::current() { @@ -123,6 +125,11 @@ namespace fc { return *current_thread(); } + void thread::cleanup() { + delete current_thread(); + current_thread() = nullptr; + } + const string& thread::name()const { return my->name; @@ -152,19 +159,18 @@ namespace fc { { //if quitting from a different thread, start quit task on thread. //If we have and know our attached boost thread, wait for it to finish, then return. - if( ¤t() != this ) + if( !is_current() ) { + auto t = my->boost_thread; async( [=](){quit();}, "thread::quit" );//.wait(); - if( my->boost_thread ) + if( t ) { //wlog("destroying boost thread ${tid}",("tid",(uintptr_t)my->boost_thread->native_handle())); - my->boost_thread->join(); - delete my; - my = nullptr; + t->join(); } return; } - + my->done = true; // wlog( "${s}", ("s",name()) ); // We are quiting from our own thread... diff --git a/src/utf8.cpp b/src/utf8.cpp index 14551c489..d98cd87f2 100644 --- a/src/utf8.cpp +++ b/src/utf8.cpp @@ -13,7 +13,6 @@ namespace fc { bool is_utf8( const std::string& str ) { - auto itr = utf8::find_invalid(str.begin(), str.end()); return utf8::is_valid( str.begin(), str.end() ); } diff --git a/tests/bloom_test.cpp b/tests/bloom_test.cpp index ca1779231..1ba7e0d29 100644 --- a/tests/bloom_test.cpp +++ b/tests/bloom_test.cpp @@ -48,7 +48,7 @@ BOOST_AUTO_TEST_CASE(bloom_test_1) std::string line; std::ifstream in("README.md"); std::ofstream words("words.txt"); - while( !in.eof() && count < 100000 ) + while( in.good() && count < 100000 ) { std::getline(in, line); // std::cout << "'"< 10) { @@ -53,7 +53,7 @@ static void test_36( const std::string& test, const std::string& expected ) std::vector dec = fc::from_base36( enc1 ); BOOST_CHECK_EQUAL( vec.size(), dec.size() ); - BOOST_CHECK( !memcmp( vec.data(), dec.data(), vec.size() ) ); + BOOST_CHECK( vec == dec ); } BOOST_AUTO_TEST_CASE(base36_test) @@ -76,17 +76,14 @@ static void test_58( const std::string& test, const std::string& expected ) std::vector dec = fc::from_base58( enc1 ); BOOST_CHECK_EQUAL( vec.size(), dec.size() ); - BOOST_CHECK( !memcmp( vec.data(), dec.data(), vec.size() ) ); + BOOST_CHECK( vec == dec ); char buffer[64]; size_t len = fc::from_base58( enc1, buffer, 64 ); BOOST_CHECK( len <= 64 ); - BOOST_CHECK( !memcmp( vec.data(), buffer, len ) ); + BOOST_CHECK( vec.empty() || !memcmp( vec.data(), buffer, len ) ); if ( len > 10 ) { - try { - len = fc::from_base58( enc1, buffer, 10 ); - BOOST_CHECK( len <= 10 ); - } catch ( fc::exception expected ) {} + BOOST_CHECK_THROW(fc::from_base58( enc1, buffer, 10 ), fc::exception); } } diff --git a/tests/crypto/blowfish_test.cpp b/tests/crypto/blowfish_test.cpp index ec4ada7cc..ca55bca47 100644 --- a/tests/crypto/blowfish_test.cpp +++ b/tests/crypto/blowfish_test.cpp @@ -75,9 +75,9 @@ const char key_test_ciphers[][17] = { const std::string chain_test_key = "0123456789ABCDEFF0E1D2C3B4A59687"; const std::string chain_test_iv = "FEDCBA9876543210"; -const std::string chain_test_plain = "7654321 Now is the time for \0\0\0\0"; const std::string chain_test_cbc = "6B77B4D63006DEE605B156E27403979358DEB9E7154616D959F1652BD5FF92CC"; const std::string chain_test_cfb = "E73214A2822139CAF26ECF6D2EB9E76E3DA3DE04D1517200519D57A6C3"; +const char* chain_test_plain = "7654321 Now is the time for \0\0\0\0"; BOOST_AUTO_TEST_SUITE(fc_crypto) @@ -85,9 +85,9 @@ BOOST_AUTO_TEST_CASE(blowfish_ecb_test) { for ( int i = 0; i < 34; i++ ) { unsigned char key[8], plain[8], cipher[8], out[8]; - BOOST_CHECK_EQUAL( 8, fc::from_hex( ecb_tests[i].key, (char*) key, sizeof(key) ) ); - BOOST_CHECK_EQUAL( 8, fc::from_hex( ecb_tests[i].plain, (char*) plain, sizeof(plain) ) ); - BOOST_CHECK_EQUAL( 8, fc::from_hex( ecb_tests[i].cipher, (char*) cipher, sizeof(cipher) ) ); + BOOST_CHECK_EQUAL( 8u, fc::from_hex( ecb_tests[i].key, (char*) key, sizeof(key) ) ); + BOOST_CHECK_EQUAL( 8u, fc::from_hex( ecb_tests[i].plain, (char*) plain, sizeof(plain) ) ); + BOOST_CHECK_EQUAL( 8u, fc::from_hex( ecb_tests[i].cipher, (char*) cipher, sizeof(cipher) ) ); fc::blowfish fish; fish.start( key, 8 ); @@ -105,11 +105,11 @@ BOOST_AUTO_TEST_CASE(blowfish_ecb_test) BOOST_AUTO_TEST_CASE(blowfish_key_test) { unsigned char key[24], plain[8], cipher[8], out[8]; - BOOST_CHECK_EQUAL( 24, fc::from_hex( key_test_key.c_str(), (char*) key, sizeof(key) ) ); - BOOST_CHECK_EQUAL( 8, fc::from_hex( key_test_plain.c_str(), (char*) plain, sizeof(plain) ) ); + BOOST_CHECK_EQUAL( 24u, fc::from_hex( key_test_key.c_str(), (char*) key, sizeof(key) ) ); + BOOST_CHECK_EQUAL( 8u, fc::from_hex( key_test_plain.c_str(), (char*) plain, sizeof(plain) ) ); for ( unsigned int i = 0; i < sizeof(key); i++ ) { - BOOST_CHECK_EQUAL( 8, fc::from_hex( key_test_ciphers[i], (char*) cipher, sizeof(cipher) ) ); + BOOST_CHECK_EQUAL( 8u, fc::from_hex( key_test_ciphers[i], (char*) cipher, sizeof(cipher) ) ); fc::blowfish fish; fish.start( key, i + 1 ); fish.encrypt( plain, out, 8, fc::blowfish::ECB ); @@ -133,37 +133,37 @@ static unsigned int from_bytes( const unsigned char* p ) { BOOST_AUTO_TEST_CASE(blowfish_chain_test) { unsigned char key[16], iv[8], cipher[32], out[32]; - BOOST_CHECK_EQUAL( 16, fc::from_hex( chain_test_key.c_str(), (char*) key, sizeof(key) ) ); - BOOST_CHECK_EQUAL( 8, fc::from_hex( chain_test_iv.c_str(), (char*) iv, sizeof(iv) ) ); + BOOST_CHECK_EQUAL( 16u, fc::from_hex( chain_test_key.c_str(), (char*) key, sizeof(key) ) ); + BOOST_CHECK_EQUAL( 8u, fc::from_hex( chain_test_iv.c_str(), (char*) iv, sizeof(iv) ) ); - BOOST_CHECK_EQUAL( 32, fc::from_hex( chain_test_cbc.c_str(), (char*) cipher, sizeof(cipher) ) ); + BOOST_CHECK_EQUAL( 32u, fc::from_hex( chain_test_cbc.c_str(), (char*) cipher, sizeof(cipher) ) ); fc::blowfish fish; fish.start( key, sizeof(key), fc::sblock( from_bytes( iv ), from_bytes( iv + 4 ) ) ); - fish.encrypt( (unsigned char*) chain_test_plain.c_str(), out, sizeof(out), fc::blowfish::CBC ); + fish.encrypt( (unsigned char*) chain_test_plain, out, sizeof(out), fc::blowfish::CBC ); BOOST_CHECK( !memcmp( cipher, out, sizeof(cipher) ) ); fish.reset_chain(); fish.decrypt( out, sizeof(out), fc::blowfish::CBC ); - BOOST_CHECK( !memcmp( chain_test_plain.c_str(), out, 29 ) ); + BOOST_CHECK( !memcmp( chain_test_plain, out, 29 ) ); fish.reset_chain(); fish.encrypt( out, sizeof(out), fc::blowfish::CBC ); BOOST_CHECK( !memcmp( cipher, out, sizeof(cipher) ) ); fish.reset_chain(); fish.decrypt( cipher, out, sizeof(cipher), fc::blowfish::CBC ); - BOOST_CHECK( !memcmp( chain_test_plain.c_str(), out, 29 ) ); + BOOST_CHECK( !memcmp( chain_test_plain, out, 29 ) ); - BOOST_CHECK_EQUAL( 29, fc::from_hex( chain_test_cfb.c_str(), (char*) cipher, sizeof(cipher) ) ); + BOOST_CHECK_EQUAL( 29u, fc::from_hex( chain_test_cfb.c_str(), (char*) cipher, sizeof(cipher) ) ); fish.reset_chain(); - fish.encrypt( (unsigned char*) chain_test_plain.c_str(), out, sizeof(out), fc::blowfish::CFB ); + fish.encrypt( (unsigned char*) chain_test_plain, out, sizeof(out), fc::blowfish::CFB ); BOOST_CHECK( !memcmp( cipher, out, 29 ) ); fish.reset_chain(); memset( out + 29, 0, 3 ); fish.decrypt( out, sizeof(out), fc::blowfish::CFB ); - BOOST_CHECK( !memcmp( chain_test_plain.c_str(), out, 29 ) ); + BOOST_CHECK( !memcmp( chain_test_plain, out, 29 ) ); fish.reset_chain(); memset( out + 29, 0, 3 ); fish.encrypt( out, sizeof(out), fc::blowfish::CFB ); BOOST_CHECK( !memcmp( cipher, out, 29 ) ); fish.reset_chain(); memset( out + 29, 0, 3 ); fish.decrypt( cipher, out, sizeof(cipher), fc::blowfish::CFB ); - BOOST_CHECK( !memcmp( chain_test_plain.c_str(), out, 29 ) ); + BOOST_CHECK( !memcmp( chain_test_plain, out, 29 ) ); } BOOST_AUTO_TEST_SUITE_END() diff --git a/tests/crypto/rand_test.cpp b/tests/crypto/rand_test.cpp index 09533be70..6d6a26ff0 100644 --- a/tests/crypto/rand_test.cpp +++ b/tests/crypto/rand_test.cpp @@ -21,7 +21,9 @@ static void check_randomness( const char* buffer, size_t len ) { double E = 1 + (zc + oc) / 2.0; double variance = (E - 1) * (E - 2) / (oc + zc - 1); double sigma = sqrt(variance); - BOOST_CHECK( rc > E - sigma && rc < E + sigma); + + BOOST_CHECK_GT(rc, E - sigma); + BOOST_CHECK_LT(rc, E + sigma); } BOOST_AUTO_TEST_SUITE(fc_crypto) diff --git a/tests/crypto/sha_tests.cpp b/tests/crypto/sha_tests.cpp index 850c2f86b..104f0c218 100644 --- a/tests/crypto/sha_tests.cpp +++ b/tests/crypto/sha_tests.cpp @@ -75,7 +75,7 @@ void test_big( const std::string& expected ) { template void test_stream( ) { - H hash( TEST1 ); + H hash = H::hash( TEST1 ); std::stringstream stream; stream << hash; diff --git a/tests/hmac_test.cpp b/tests/hmac_test.cpp index a8f21dd6d..140b2117f 100644 --- a/tests/hmac_test.cpp +++ b/tests/hmac_test.cpp @@ -72,7 +72,7 @@ static fc::hmac mac_224; static fc::hmac mac_256; static fc::hmac mac_512; -template +template static void run_test( const fc::string& key, const fc::string& data, const fc::string& expect_224, const fc::string& expect_256, const fc::string& expect_512 ) { diff --git a/tests/network/http/websocket_test.cpp b/tests/network/http/websocket_test.cpp index 03bfdd154..83fcba9a4 100644 --- a/tests/network/http/websocket_test.cpp +++ b/tests/network/http/websocket_test.cpp @@ -39,7 +39,7 @@ BOOST_AUTO_TEST_CASE(websocket_test) try { c_conn->send_message( "again" ); BOOST_FAIL("expected assertion failure"); - } catch (const fc::assert_exception& e) { + } catch (const fc::exception& e) { //std::cerr << e.to_string() << "\n"; } @@ -55,14 +55,14 @@ BOOST_AUTO_TEST_CASE(websocket_test) try { c_conn->send_message( "again" ); BOOST_FAIL("expected assertion failure"); - } catch (const fc::assert_exception& e) { + } catch (const fc::exception& e) { std::cerr << e.to_string() << "\n"; } try { c_conn = client.connect( "ws://localhost:8090" ); BOOST_FAIL("expected assertion failure"); - } catch (const fc::assert_exception& e) { + } catch (const fc::exception& e) { std::cerr << e.to_string() << "\n"; } } diff --git a/tests/real128_test.cpp b/tests/real128_test.cpp index beae9b7e4..5020af9b2 100644 --- a/tests/real128_test.cpp +++ b/tests/real128_test.cpp @@ -11,9 +11,9 @@ BOOST_AUTO_TEST_CASE(real128_test) { BOOST_CHECK_EQUAL(string(real128()), string("0.")); BOOST_CHECK_EQUAL(string(real128(0)), string("0.")); - BOOST_CHECK_EQUAL(real128(8).to_uint64(), 8); - BOOST_CHECK_EQUAL(real128(6789).to_uint64(), 6789); - BOOST_CHECK_EQUAL(real128(10000).to_uint64(), 10000); + BOOST_CHECK_EQUAL(real128(8).to_uint64(), 8u); + BOOST_CHECK_EQUAL(real128(6789).to_uint64(), 6789u); + BOOST_CHECK_EQUAL(real128(10000).to_uint64(), 10000u); BOOST_CHECK_EQUAL(string(real128(1)), string("1.")); BOOST_CHECK_EQUAL(string(real128(5)), string("5.")); BOOST_CHECK_EQUAL(string(real128(12345)), string("12345.")); @@ -41,8 +41,8 @@ BOOST_AUTO_TEST_CASE(real128_test) BOOST_CHECK_EQUAL( string(pi*1), "3.1415926535" ); BOOST_CHECK_EQUAL( string(pi*0), "0." ); - BOOST_CHECK_EQUAL(real128("12345.6789").to_uint64(), 12345); - BOOST_CHECK_EQUAL((real128("12345.6789")*10000).to_uint64(), 123456789); + BOOST_CHECK_EQUAL(real128("12345.6789").to_uint64(), 12345u); + BOOST_CHECK_EQUAL((real128("12345.6789")*10000).to_uint64(), 123456789u); BOOST_CHECK_EQUAL(string(real128("12345.6789")), string("12345.6789")); BOOST_CHECK_EQUAL( real128(uint64_t(-1)).to_uint64(), uint64_t(-1) ); From 1ae7f6bb0206497d2e6eb45845bcb6b1a0dadd37 Mon Sep 17 00:00:00 2001 From: Alexey Frolov Date: Mon, 5 Feb 2018 12:19:06 +0300 Subject: [PATCH 038/260] FIXES: - 'bloom_test_1': infinite loop if file not exists - 'websocket_test': uncatched exceptions - 'fc_crypto*' test_stream<>: uninitialized variable (hash) - 'blowfish_chain_test': using memory after allocated heap - memcmp: passing nullptr, when non-null expected - undefined behavior: return value from function - static_variant: member alignment - performance issue on 64-bit arch - memory leak: fc::thread cleanup in asio thread - warning: signed-unsigned comparison - warning: unused variables --- src/crypto/aes.cpp | 6 ++++-- src/crypto/elliptic_secp256k1.cpp | 6 ++++-- src/crypto/rand.cpp | 6 ++++-- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/crypto/aes.cpp b/src/crypto/aes.cpp index 09db92b67..2dbae6c96 100644 --- a/src/crypto/aes.cpp +++ b/src/crypto/aes.cpp @@ -29,7 +29,8 @@ struct aes_encoder::impl aes_encoder::aes_encoder() { - static __attribute__((unused)) int init = init_openssl(); + static int init = init_openssl(); + (void)init; } aes_encoder::~aes_encoder() @@ -97,7 +98,8 @@ struct aes_decoder::impl aes_decoder::aes_decoder() { - static __attribute__((unused)) int init = init_openssl(); + static int init = init_openssl(); + (void)init; } void aes_decoder::init( const fc::sha256& key, const fc::uint128& init_value ) diff --git a/src/crypto/elliptic_secp256k1.cpp b/src/crypto/elliptic_secp256k1.cpp index 469cc1b7b..ecb2c0c40 100644 --- a/src/crypto/elliptic_secp256k1.cpp +++ b/src/crypto/elliptic_secp256k1.cpp @@ -29,8 +29,10 @@ namespace fc { namespace ecc { } void _init_lib() { - static __attribute__((unused)) const secp256k1_context_t* ctx = _get_context(); - static __attribute__((unused)) int init_o = init_openssl(); + static const secp256k1_context_t* ctx = _get_context(); + (void)ctx; + static int init_o = init_openssl(); + (void)init_o; } class public_key_impl diff --git a/src/crypto/rand.cpp b/src/crypto/rand.cpp index 2b194c5d6..6b26b466a 100644 --- a/src/crypto/rand.cpp +++ b/src/crypto/rand.cpp @@ -8,7 +8,8 @@ namespace fc { void rand_bytes(char* buf, int count) { - static __attribute__((unused)) int init = init_openssl(); + static int init = init_openssl(); + (void)init; int result = RAND_bytes((unsigned char*)buf, count); if (result != 1) @@ -17,7 +18,8 @@ void rand_bytes(char* buf, int count) void rand_pseudo_bytes(char* buf, int count) { - static __attribute__((unused)) int init = init_openssl(); + static int init = init_openssl(); + (void)init; int result = RAND_pseudo_bytes((unsigned char*)buf, count); if (result == -1) From bf86466be1f027e4c48fda8d907c8ba779089f62 Mon Sep 17 00:00:00 2001 From: Anton Autushka Date: Tue, 6 Feb 2018 13:00:51 +0300 Subject: [PATCH 039/260] In static_variant use int64_t as a tag type --- include/fc/static_variant.hpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/include/fc/static_variant.hpp b/include/fc/static_variant.hpp index 4f13f5b00..4bfca851a 100644 --- a/include/fc/static_variant.hpp +++ b/include/fc/static_variant.hpp @@ -181,7 +181,8 @@ class static_variant { static_assert(impl::type_info::no_reference_types, "Reference types are not permitted in static_variant."); static_assert(impl::type_info::no_duplicates, "static_variant type arguments contain duplicate types."); - size_t _tag; + using tag_type = int64_t; + tag_type _tag; char storage[impl::type_info::size]; template @@ -326,14 +327,14 @@ class static_variant { } static int count() { return impl::type_info::count; } - void set_which( size_t w ) { + void set_which( tag_type w ) { FC_ASSERT( w < count() ); this->~static_variant(); _tag = w; impl::storage_ops<0, Types...>::con(_tag, storage); } - size_t which() const {return _tag;} + tag_type which() const {return _tag;} }; template From 7d7872cb7b490f0de9aae668c84e273c189168d4 Mon Sep 17 00:00:00 2001 From: Anton Autushka Date: Tue, 6 Feb 2018 15:37:14 +0300 Subject: [PATCH 040/260] some minor fixes --- CMakeLists.txt | 2 ++ include/fc/static_variant.hpp | 1 + src/thread/mutex.cpp | 2 +- 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 1f7787d7c..d0819c07d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,6 +4,8 @@ PROJECT( fc ) CMAKE_MINIMUM_REQUIRED( VERSION 2.8.12 ) +add_compile_options(-std=c++14) + MESSAGE(STATUS "Configuring project fc located in: ${CMAKE_CURRENT_SOURCE_DIR}") SET( CMAKE_AUTOMOC OFF ) diff --git a/include/fc/static_variant.hpp b/include/fc/static_variant.hpp index 4bfca851a..d38408d49 100644 --- a/include/fc/static_variant.hpp +++ b/include/fc/static_variant.hpp @@ -328,6 +328,7 @@ class static_variant { static int count() { return impl::type_info::count; } void set_which( tag_type w ) { + FC_ASSERT( w >= 0 ); FC_ASSERT( w < count() ); this->~static_variant(); _tag = w; diff --git a/src/thread/mutex.cpp b/src/thread/mutex.cpp index 2a875648f..222d32ed7 100644 --- a/src/thread/mutex.cpp +++ b/src/thread/mutex.cpp @@ -15,9 +15,9 @@ namespace fc { mutex::~mutex() { if( m_blist ) { -// context* c = m_blist; fc::thread::current().debug("~mutex"); #if 0 + context* c = m_blist; while( c ) { // elog( "still blocking on context %p (%s)", m_blist, (m_blist->cur_task ? m_blist->cur_task->get_desc() : "no current task") ); c = c->next_blocked_mutex; From 48187769872f1ebab637321d41c8ccd021d5976c Mon Sep 17 00:00:00 2001 From: oxarbitrage Date: Tue, 6 Feb 2018 18:36:07 -0300 Subject: [PATCH 041/260] Add Doxyfile --- Doxyfile | 2362 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 2362 insertions(+) create mode 100644 Doxyfile diff --git a/Doxyfile b/Doxyfile new file mode 100644 index 000000000..c1948c99b --- /dev/null +++ b/Doxyfile @@ -0,0 +1,2362 @@ +# Doxyfile 1.8.9.1 + +# This file describes the settings to be used by the documentation system +# doxygen (www.doxygen.org) for a project. +# +# All text after a double hash (##) is considered a comment and is placed in +# front of the TAG it is preceding. +# +# All text after a single hash (#) is considered a comment and will be ignored. +# The format is: +# TAG = value [value, ...] +# For lists, items can also be appended using: +# TAG += value [value, ...] +# Values that contain spaces should be placed between quotes (\" \"). + +#--------------------------------------------------------------------------- +# Project related configuration options +#--------------------------------------------------------------------------- + +# This tag specifies the encoding used for all characters in the config file +# that follow. The default is UTF-8 which is also the encoding used for all text +# before the first occurrence of this tag. Doxygen uses libiconv (or the iconv +# built into libc) for the transcoding. See http://www.gnu.org/software/libiconv +# for the list of possible encodings. +# The default value is: UTF-8. + +DOXYFILE_ENCODING = UTF-8 + +# The PROJECT_NAME tag is a single word (or a sequence of words surrounded by +# double-quotes, unless you are using Doxywizard) that should identify the +# project for which the documentation is generated. This name is used in the +# title of most generated pages and in a few other places. +# The default value is: My Project. + +PROJECT_NAME = "Bitshares-FC" + +# The PROJECT_NUMBER tag can be used to enter a project or revision number. This +# could be handy for archiving the generated documentation or if some version +# control system is used. + +PROJECT_NUMBER = "1.0" + +# Using the PROJECT_BRIEF tag one can provide an optional one line description +# for a project that appears at the top of each page and should give viewer a +# quick idea about the purpose of the project. Keep the description short. + +PROJECT_BRIEF = "fast-compiling c++ library" + +# With the PROJECT_LOGO tag one can specify a logo or an icon that is included +# in the documentation. The maximum height of the logo should not exceed 55 +# pixels and the maximum width should not exceed 200 pixels. Doxygen will copy +# the logo to the output directory. + +PROJECT_LOGO = + +# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) path +# into which the generated documentation will be written. If a relative path is +# entered, it will be relative to the location where doxygen was started. If +# left blank the current directory will be used. + +OUTPUT_DIRECTORY = doxygen + +# If the CREATE_SUBDIRS tag is set to YES then doxygen will create 4096 sub- +# directories (in 2 levels) under the output directory of each output format and +# will distribute the generated files over these directories. Enabling this +# option can be useful when feeding doxygen a huge amount of source files, where +# putting all generated files in the same directory would otherwise causes +# performance problems for the file system. +# The default value is: NO. + +CREATE_SUBDIRS = NO + +# If the ALLOW_UNICODE_NAMES tag is set to YES, doxygen will allow non-ASCII +# characters to appear in the names of generated files. If set to NO, non-ASCII +# characters will be escaped, for example _xE3_x81_x84 will be used for Unicode +# U+3044. +# The default value is: NO. + +ALLOW_UNICODE_NAMES = NO + +# The OUTPUT_LANGUAGE tag is used to specify the language in which all +# documentation generated by doxygen is written. Doxygen will use this +# information to generate all constant output in the proper language. +# Possible values are: Afrikaans, Arabic, Armenian, Brazilian, Catalan, Chinese, +# Chinese-Traditional, Croatian, Czech, Danish, Dutch, English (United States), +# Esperanto, Farsi (Persian), Finnish, French, German, Greek, Hungarian, +# Indonesian, Italian, Japanese, Japanese-en (Japanese with English messages), +# Korean, Korean-en (Korean with English messages), Latvian, Lithuanian, +# Macedonian, Norwegian, Persian (Farsi), Polish, Portuguese, Romanian, Russian, +# Serbian, Serbian-Cyrillic, Slovak, Slovene, Spanish, Swedish, Turkish, +# Ukrainian and Vietnamese. +# The default value is: English. + +OUTPUT_LANGUAGE = English + +# If the BRIEF_MEMBER_DESC tag is set to YES, doxygen will include brief member +# descriptions after the members that are listed in the file and class +# documentation (similar to Javadoc). Set to NO to disable this. +# The default value is: YES. + +BRIEF_MEMBER_DESC = YES + +# If the REPEAT_BRIEF tag is set to YES, doxygen will prepend the brief +# description of a member or function before the detailed description +# +# Note: If both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the +# brief descriptions will be completely suppressed. +# The default value is: YES. + +REPEAT_BRIEF = YES + +# This tag implements a quasi-intelligent brief description abbreviator that is +# used to form the text in various listings. Each string in this list, if found +# as the leading text of the brief description, will be stripped from the text +# and the result, after processing the whole list, is used as the annotated +# text. Otherwise, the brief description is used as-is. If left blank, the +# following values are used ($name is automatically replaced with the name of +# the entity):The $name class, The $name widget, The $name file, is, provides, +# specifies, contains, represents, a, an and the. + +ABBREVIATE_BRIEF = + +# If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then +# doxygen will generate a detailed section even if there is only a brief +# description. +# The default value is: NO. + +ALWAYS_DETAILED_SEC = NO + +# If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all +# inherited members of a class in the documentation of that class as if those +# members were ordinary class members. Constructors, destructors and assignment +# operators of the base classes will not be shown. +# The default value is: NO. + +INLINE_INHERITED_MEMB = NO + +# If the FULL_PATH_NAMES tag is set to YES, doxygen will prepend the full path +# before files name in the file list and in the header files. If set to NO the +# shortest path that makes the file name unique will be used +# The default value is: YES. + +FULL_PATH_NAMES = YES + +# The STRIP_FROM_PATH tag can be used to strip a user-defined part of the path. +# Stripping is only done if one of the specified strings matches the left-hand +# part of the path. The tag can be used to show relative paths in the file list. +# If left blank the directory from which doxygen is run is used as the path to +# strip. +# +# Note that you can specify absolute paths here, but also relative paths, which +# will be relative from the directory where doxygen is started. +# This tag requires that the tag FULL_PATH_NAMES is set to YES. + +STRIP_FROM_PATH = + +# The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of the +# path mentioned in the documentation of a class, which tells the reader which +# header file to include in order to use a class. If left blank only the name of +# the header file containing the class definition is used. Otherwise one should +# specify the list of include paths that are normally passed to the compiler +# using the -I flag. + +STRIP_FROM_INC_PATH = + +# If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter (but +# less readable) file names. This can be useful is your file systems doesn't +# support long names like on DOS, Mac, or CD-ROM. +# The default value is: NO. + +SHORT_NAMES = NO + +# If the JAVADOC_AUTOBRIEF tag is set to YES then doxygen will interpret the +# first line (until the first dot) of a Javadoc-style comment as the brief +# description. If set to NO, the Javadoc-style will behave just like regular Qt- +# style comments (thus requiring an explicit @brief command for a brief +# description.) +# The default value is: NO. + +JAVADOC_AUTOBRIEF = NO + +# If the QT_AUTOBRIEF tag is set to YES then doxygen will interpret the first +# line (until the first dot) of a Qt-style comment as the brief description. If +# set to NO, the Qt-style will behave just like regular Qt-style comments (thus +# requiring an explicit \brief command for a brief description.) +# The default value is: NO. + +QT_AUTOBRIEF = NO + +# The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make doxygen treat a +# multi-line C++ special comment block (i.e. a block of //! or /// comments) as +# a brief description. This used to be the default behavior. The new default is +# to treat a multi-line C++ comment block as a detailed description. Set this +# tag to YES if you prefer the old behavior instead. +# +# Note that setting this tag to YES also means that rational rose comments are +# not recognized any more. +# The default value is: NO. + +MULTILINE_CPP_IS_BRIEF = NO + +# If the INHERIT_DOCS tag is set to YES then an undocumented member inherits the +# documentation from any documented member that it re-implements. +# The default value is: YES. + +INHERIT_DOCS = YES + +# If the SEPARATE_MEMBER_PAGES tag is set to YES then doxygen will produce a new +# page for each member. If set to NO, the documentation of a member will be part +# of the file/class/namespace that contains it. +# The default value is: NO. + +SEPARATE_MEMBER_PAGES = NO + +# The TAB_SIZE tag can be used to set the number of spaces in a tab. Doxygen +# uses this value to replace tabs by spaces in code fragments. +# Minimum value: 1, maximum value: 16, default value: 4. + +TAB_SIZE = 4 + +# This tag can be used to specify a number of aliases that act as commands in +# the documentation. An alias has the form: +# name=value +# For example adding +# "sideeffect=@par Side Effects:\n" +# will allow you to put the command \sideeffect (or @sideeffect) in the +# documentation, which will result in a user-defined paragraph with heading +# "Side Effects:". You can put \n's in the value part of an alias to insert +# newlines. + +ALIASES = + +# This tag can be used to specify a number of word-keyword mappings (TCL only). +# A mapping has the form "name=value". For example adding "class=itcl::class" +# will allow you to use the command class in the itcl::class meaning. + +TCL_SUBST = + +# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C sources +# only. Doxygen will then generate output that is more tailored for C. For +# instance, some of the names that are used will be different. The list of all +# members will be omitted, etc. +# The default value is: NO. + +OPTIMIZE_OUTPUT_FOR_C = NO + +# Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java or +# Python sources only. Doxygen will then generate output that is more tailored +# for that language. For instance, namespaces will be presented as packages, +# qualified scopes will look different, etc. +# The default value is: NO. + +OPTIMIZE_OUTPUT_JAVA = NO + +# Set the OPTIMIZE_FOR_FORTRAN tag to YES if your project consists of Fortran +# sources. Doxygen will then generate output that is tailored for Fortran. +# The default value is: NO. + +OPTIMIZE_FOR_FORTRAN = NO + +# Set the OPTIMIZE_OUTPUT_VHDL tag to YES if your project consists of VHDL +# sources. Doxygen will then generate output that is tailored for VHDL. +# The default value is: NO. + +OPTIMIZE_OUTPUT_VHDL = NO + +# Doxygen selects the parser to use depending on the extension of the files it +# parses. With this tag you can assign which parser to use for a given +# extension. Doxygen has a built-in mapping, but you can override or extend it +# using this tag. The format is ext=language, where ext is a file extension, and +# language is one of the parsers supported by doxygen: IDL, Java, Javascript, +# C#, C, C++, D, PHP, Objective-C, Python, Fortran (fixed format Fortran: +# FortranFixed, free formatted Fortran: FortranFree, unknown formatted Fortran: +# Fortran. In the later case the parser tries to guess whether the code is fixed +# or free formatted code, this is the default for Fortran type files), VHDL. For +# instance to make doxygen treat .inc files as Fortran files (default is PHP), +# and .f files as C (default is Fortran), use: inc=Fortran f=C. +# +# Note: For files without extension you can use no_extension as a placeholder. +# +# Note that for custom extensions you also need to set FILE_PATTERNS otherwise +# the files are not read by doxygen. + +EXTENSION_MAPPING = + +# If the MARKDOWN_SUPPORT tag is enabled then doxygen pre-processes all comments +# according to the Markdown format, which allows for more readable +# documentation. See http://daringfireball.net/projects/markdown/ for details. +# The output of markdown processing is further processed by doxygen, so you can +# mix doxygen, HTML, and XML commands with Markdown formatting. Disable only in +# case of backward compatibilities issues. +# The default value is: YES. + +MARKDOWN_SUPPORT = YES + +# When enabled doxygen tries to link words that correspond to documented +# classes, or namespaces to their corresponding documentation. Such a link can +# be prevented in individual cases by putting a % sign in front of the word or +# globally by setting AUTOLINK_SUPPORT to NO. +# The default value is: YES. + +AUTOLINK_SUPPORT = YES + +# If you use STL classes (i.e. std::string, std::vector, etc.) but do not want +# to include (a tag file for) the STL sources as input, then you should set this +# tag to YES in order to let doxygen match functions declarations and +# definitions whose arguments contain STL classes (e.g. func(std::string); +# versus func(std::string) {}). This also make the inheritance and collaboration +# diagrams that involve STL classes more complete and accurate. +# The default value is: NO. + +BUILTIN_STL_SUPPORT = NO + +# If you use Microsoft's C++/CLI language, you should set this option to YES to +# enable parsing support. +# The default value is: NO. + +CPP_CLI_SUPPORT = NO + +# Set the SIP_SUPPORT tag to YES if your project consists of sip (see: +# http://www.riverbankcomputing.co.uk/software/sip/intro) sources only. Doxygen +# will parse them like normal C++ but will assume all classes use public instead +# of private inheritance when no explicit protection keyword is present. +# The default value is: NO. + +SIP_SUPPORT = NO + +# For Microsoft's IDL there are propget and propput attributes to indicate +# getter and setter methods for a property. Setting this option to YES will make +# doxygen to replace the get and set methods by a property in the documentation. +# This will only work if the methods are indeed getting or setting a simple +# type. If this is not the case, or you want to show the methods anyway, you +# should set this option to NO. +# The default value is: YES. + +IDL_PROPERTY_SUPPORT = YES + +# If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC +# tag is set to YES then doxygen will reuse the documentation of the first +# member in the group (if any) for the other members of the group. By default +# all members of a group must be documented explicitly. +# The default value is: NO. + +DISTRIBUTE_GROUP_DOC = NO + +# Set the SUBGROUPING tag to YES to allow class member groups of the same type +# (for instance a group of public functions) to be put as a subgroup of that +# type (e.g. under the Public Functions section). Set it to NO to prevent +# subgrouping. Alternatively, this can be done per class using the +# \nosubgrouping command. +# The default value is: YES. + +SUBGROUPING = YES + +# When the INLINE_GROUPED_CLASSES tag is set to YES, classes, structs and unions +# are shown inside the group in which they are included (e.g. using \ingroup) +# instead of on a separate page (for HTML and Man pages) or section (for LaTeX +# and RTF). +# +# Note that this feature does not work in combination with +# SEPARATE_MEMBER_PAGES. +# The default value is: NO. + +INLINE_GROUPED_CLASSES = NO + +# When the INLINE_SIMPLE_STRUCTS tag is set to YES, structs, classes, and unions +# with only public data fields or simple typedef fields will be shown inline in +# the documentation of the scope in which they are defined (i.e. file, +# namespace, or group documentation), provided this scope is documented. If set +# to NO, structs, classes, and unions are shown on a separate page (for HTML and +# Man pages) or section (for LaTeX and RTF). +# The default value is: NO. + +INLINE_SIMPLE_STRUCTS = NO + +# When TYPEDEF_HIDES_STRUCT tag is enabled, a typedef of a struct, union, or +# enum is documented as struct, union, or enum with the name of the typedef. So +# typedef struct TypeS {} TypeT, will appear in the documentation as a struct +# with name TypeT. When disabled the typedef will appear as a member of a file, +# namespace, or class. And the struct will be named TypeS. This can typically be +# useful for C code in case the coding convention dictates that all compound +# types are typedef'ed and only the typedef is referenced, never the tag name. +# The default value is: NO. + +TYPEDEF_HIDES_STRUCT = NO + +# The size of the symbol lookup cache can be set using LOOKUP_CACHE_SIZE. This +# cache is used to resolve symbols given their name and scope. Since this can be +# an expensive process and often the same symbol appears multiple times in the +# code, doxygen keeps a cache of pre-resolved symbols. If the cache is too small +# doxygen will become slower. If the cache is too large, memory is wasted. The +# cache size is given by this formula: 2^(16+LOOKUP_CACHE_SIZE). The valid range +# is 0..9, the default is 0, corresponding to a cache size of 2^16=65536 +# symbols. At the end of a run doxygen will report the cache usage and suggest +# the optimal cache size from a speed point of view. +# Minimum value: 0, maximum value: 9, default value: 0. + +LOOKUP_CACHE_SIZE = 0 + +#--------------------------------------------------------------------------- +# Build related configuration options +#--------------------------------------------------------------------------- + +# If the EXTRACT_ALL tag is set to YES, doxygen will assume all entities in +# documentation are documented, even if no documentation was available. Private +# class members and static file members will be hidden unless the +# EXTRACT_PRIVATE respectively EXTRACT_STATIC tags are set to YES. +# Note: This will also disable the warnings about undocumented members that are +# normally produced when WARNINGS is set to YES. +# The default value is: NO. + +EXTRACT_ALL = YES + +# If the EXTRACT_PRIVATE tag is set to YES, all private members of a class will +# be included in the documentation. +# The default value is: NO. + +EXTRACT_PRIVATE = NO + +# If the EXTRACT_PACKAGE tag is set to YES, all members with package or internal +# scope will be included in the documentation. +# The default value is: NO. + +EXTRACT_PACKAGE = NO + +# If the EXTRACT_STATIC tag is set to YES, all static members of a file will be +# included in the documentation. +# The default value is: NO. + +EXTRACT_STATIC = NO + +# If the EXTRACT_LOCAL_CLASSES tag is set to YES, classes (and structs) defined +# locally in source files will be included in the documentation. If set to NO, +# only classes defined in header files are included. Does not have any effect +# for Java sources. +# The default value is: YES. + +EXTRACT_LOCAL_CLASSES = YES + +# This flag is only useful for Objective-C code. If set to YES, local methods, +# which are defined in the implementation section but not in the interface are +# included in the documentation. If set to NO, only methods in the interface are +# included. +# The default value is: NO. + +EXTRACT_LOCAL_METHODS = NO + +# If this flag is set to YES, the members of anonymous namespaces will be +# extracted and appear in the documentation as a namespace called +# 'anonymous_namespace{file}', where file will be replaced with the base name of +# the file that contains the anonymous namespace. By default anonymous namespace +# are hidden. +# The default value is: NO. + +EXTRACT_ANON_NSPACES = NO + +# If the HIDE_UNDOC_MEMBERS tag is set to YES, doxygen will hide all +# undocumented members inside documented classes or files. If set to NO these +# members will be included in the various overviews, but no documentation +# section is generated. This option has no effect if EXTRACT_ALL is enabled. +# The default value is: NO. + +HIDE_UNDOC_MEMBERS = NO + +# If the HIDE_UNDOC_CLASSES tag is set to YES, doxygen will hide all +# undocumented classes that are normally visible in the class hierarchy. If set +# to NO, these classes will be included in the various overviews. This option +# has no effect if EXTRACT_ALL is enabled. +# The default value is: NO. + +HIDE_UNDOC_CLASSES = NO + +# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, doxygen will hide all friend +# (class|struct|union) declarations. If set to NO, these declarations will be +# included in the documentation. +# The default value is: NO. + +HIDE_FRIEND_COMPOUNDS = NO + +# If the HIDE_IN_BODY_DOCS tag is set to YES, doxygen will hide any +# documentation blocks found inside the body of a function. If set to NO, these +# blocks will be appended to the function's detailed documentation block. +# The default value is: NO. + +HIDE_IN_BODY_DOCS = NO + +# The INTERNAL_DOCS tag determines if documentation that is typed after a +# \internal command is included. If the tag is set to NO then the documentation +# will be excluded. Set it to YES to include the internal documentation. +# The default value is: NO. + +INTERNAL_DOCS = NO + +# If the CASE_SENSE_NAMES tag is set to NO then doxygen will only generate file +# names in lower-case letters. If set to YES, upper-case letters are also +# allowed. This is useful if you have classes or files whose names only differ +# in case and if your file system supports case sensitive file names. Windows +# and Mac users are advised to set this option to NO. +# The default value is: system dependent. + +CASE_SENSE_NAMES = NO + +# If the HIDE_SCOPE_NAMES tag is set to NO then doxygen will show members with +# their full class and namespace scopes in the documentation. If set to YES, the +# scope will be hidden. +# The default value is: NO. + +HIDE_SCOPE_NAMES = NO + +# If the HIDE_COMPOUND_REFERENCE tag is set to NO (default) then doxygen will +# append additional text to a page's title, such as Class Reference. If set to +# YES the compound reference will be hidden. +# The default value is: NO. + +HIDE_COMPOUND_REFERENCE= NO + +# If the SHOW_INCLUDE_FILES tag is set to YES then doxygen will put a list of +# the files that are included by a file in the documentation of that file. +# The default value is: YES. + +SHOW_INCLUDE_FILES = YES + +# If the SHOW_GROUPED_MEMB_INC tag is set to YES then Doxygen will add for each +# grouped member an include statement to the documentation, telling the reader +# which file to include in order to use the member. +# The default value is: NO. + +SHOW_GROUPED_MEMB_INC = NO + +# If the FORCE_LOCAL_INCLUDES tag is set to YES then doxygen will list include +# files with double quotes in the documentation rather than with sharp brackets. +# The default value is: NO. + +FORCE_LOCAL_INCLUDES = NO + +# If the INLINE_INFO tag is set to YES then a tag [inline] is inserted in the +# documentation for inline members. +# The default value is: YES. + +INLINE_INFO = YES + +# If the SORT_MEMBER_DOCS tag is set to YES then doxygen will sort the +# (detailed) documentation of file and class members alphabetically by member +# name. If set to NO, the members will appear in declaration order. +# The default value is: YES. + +SORT_MEMBER_DOCS = YES + +# If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the brief +# descriptions of file, namespace and class members alphabetically by member +# name. If set to NO, the members will appear in declaration order. Note that +# this will also influence the order of the classes in the class list. +# The default value is: NO. + +SORT_BRIEF_DOCS = NO + +# If the SORT_MEMBERS_CTORS_1ST tag is set to YES then doxygen will sort the +# (brief and detailed) documentation of class members so that constructors and +# destructors are listed first. If set to NO the constructors will appear in the +# respective orders defined by SORT_BRIEF_DOCS and SORT_MEMBER_DOCS. +# Note: If SORT_BRIEF_DOCS is set to NO this option is ignored for sorting brief +# member documentation. +# Note: If SORT_MEMBER_DOCS is set to NO this option is ignored for sorting +# detailed member documentation. +# The default value is: NO. + +SORT_MEMBERS_CTORS_1ST = NO + +# If the SORT_GROUP_NAMES tag is set to YES then doxygen will sort the hierarchy +# of group names into alphabetical order. If set to NO the group names will +# appear in their defined order. +# The default value is: NO. + +SORT_GROUP_NAMES = NO + +# If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be sorted by +# fully-qualified names, including namespaces. If set to NO, the class list will +# be sorted only by class name, not including the namespace part. +# Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES. +# Note: This option applies only to the class list, not to the alphabetical +# list. +# The default value is: NO. + +SORT_BY_SCOPE_NAME = NO + +# If the STRICT_PROTO_MATCHING option is enabled and doxygen fails to do proper +# type resolution of all parameters of a function it will reject a match between +# the prototype and the implementation of a member function even if there is +# only one candidate or it is obvious which candidate to choose by doing a +# simple string match. By disabling STRICT_PROTO_MATCHING doxygen will still +# accept a match between prototype and implementation in such cases. +# The default value is: NO. + +STRICT_PROTO_MATCHING = NO + +# The GENERATE_TODOLIST tag can be used to enable (YES) or disable (NO) the todo +# list. This list is created by putting \todo commands in the documentation. +# The default value is: YES. + +GENERATE_TODOLIST = YES + +# The GENERATE_TESTLIST tag can be used to enable (YES) or disable (NO) the test +# list. This list is created by putting \test commands in the documentation. +# The default value is: YES. + +GENERATE_TESTLIST = YES + +# The GENERATE_BUGLIST tag can be used to enable (YES) or disable (NO) the bug +# list. This list is created by putting \bug commands in the documentation. +# The default value is: YES. + +GENERATE_BUGLIST = YES + +# The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or disable (NO) +# the deprecated list. This list is created by putting \deprecated commands in +# the documentation. +# The default value is: YES. + +GENERATE_DEPRECATEDLIST= YES + +# The ENABLED_SECTIONS tag can be used to enable conditional documentation +# sections, marked by \if ... \endif and \cond +# ... \endcond blocks. + +ENABLED_SECTIONS = + +# The MAX_INITIALIZER_LINES tag determines the maximum number of lines that the +# initial value of a variable or macro / define can have for it to appear in the +# documentation. If the initializer consists of more lines than specified here +# it will be hidden. Use a value of 0 to hide initializers completely. The +# appearance of the value of individual variables and macros / defines can be +# controlled using \showinitializer or \hideinitializer command in the +# documentation regardless of this setting. +# Minimum value: 0, maximum value: 10000, default value: 30. + +MAX_INITIALIZER_LINES = 30 + +# Set the SHOW_USED_FILES tag to NO to disable the list of files generated at +# the bottom of the documentation of classes and structs. If set to YES, the +# list will mention the files that were used to generate the documentation. +# The default value is: YES. + +SHOW_USED_FILES = YES + +# Set the SHOW_FILES tag to NO to disable the generation of the Files page. This +# will remove the Files entry from the Quick Index and from the Folder Tree View +# (if specified). +# The default value is: YES. + +SHOW_FILES = YES + +# Set the SHOW_NAMESPACES tag to NO to disable the generation of the Namespaces +# page. This will remove the Namespaces entry from the Quick Index and from the +# Folder Tree View (if specified). +# The default value is: YES. + +SHOW_NAMESPACES = YES + +# The FILE_VERSION_FILTER tag can be used to specify a program or script that +# doxygen should invoke to get the current version for each file (typically from +# the version control system). Doxygen will invoke the program by executing (via +# popen()) the command command input-file, where command is the value of the +# FILE_VERSION_FILTER tag, and input-file is the name of an input file provided +# by doxygen. Whatever the program writes to standard output is used as the file +# version. For an example see the documentation. + +FILE_VERSION_FILTER = + +# The LAYOUT_FILE tag can be used to specify a layout file which will be parsed +# by doxygen. The layout file controls the global structure of the generated +# output files in an output format independent way. To create the layout file +# that represents doxygen's defaults, run doxygen with the -l option. You can +# optionally specify a file name after the option, if omitted DoxygenLayout.xml +# will be used as the name of the layout file. +# +# Note that if you run doxygen from a directory containing a file called +# DoxygenLayout.xml, doxygen will parse it automatically even if the LAYOUT_FILE +# tag is left empty. + +LAYOUT_FILE = + +# The CITE_BIB_FILES tag can be used to specify one or more bib files containing +# the reference definitions. This must be a list of .bib files. The .bib +# extension is automatically appended if omitted. This requires the bibtex tool +# to be installed. See also http://en.wikipedia.org/wiki/BibTeX for more info. +# For LaTeX the style of the bibliography can be controlled using +# LATEX_BIB_STYLE. To use this feature you need bibtex and perl available in the +# search path. See also \cite for info how to create references. + +CITE_BIB_FILES = + +#--------------------------------------------------------------------------- +# Configuration options related to warning and progress messages +#--------------------------------------------------------------------------- + +# The QUIET tag can be used to turn on/off the messages that are generated to +# standard output by doxygen. If QUIET is set to YES this implies that the +# messages are off. +# The default value is: NO. + +QUIET = NO + +# The WARNINGS tag can be used to turn on/off the warning messages that are +# generated to standard error (stderr) by doxygen. If WARNINGS is set to YES +# this implies that the warnings are on. +# +# Tip: Turn warnings on while writing the documentation. +# The default value is: YES. + +WARNINGS = YES + +# If the WARN_IF_UNDOCUMENTED tag is set to YES then doxygen will generate +# warnings for undocumented members. If EXTRACT_ALL is set to YES then this flag +# will automatically be disabled. +# The default value is: YES. + +WARN_IF_UNDOCUMENTED = YES + +# If the WARN_IF_DOC_ERROR tag is set to YES, doxygen will generate warnings for +# potential errors in the documentation, such as not documenting some parameters +# in a documented function, or documenting parameters that don't exist or using +# markup commands wrongly. +# The default value is: YES. + +WARN_IF_DOC_ERROR = YES + +# This WARN_NO_PARAMDOC option can be enabled to get warnings for functions that +# are documented, but have no documentation for their parameters or return +# value. If set to NO, doxygen will only warn about wrong or incomplete +# parameter documentation, but not about the absence of documentation. +# The default value is: NO. + +WARN_NO_PARAMDOC = NO + +# The WARN_FORMAT tag determines the format of the warning messages that doxygen +# can produce. The string should contain the $file, $line, and $text tags, which +# will be replaced by the file and line number from which the warning originated +# and the warning text. Optionally the format may contain $version, which will +# be replaced by the version of the file (if it could be obtained via +# FILE_VERSION_FILTER) +# The default value is: $file:$line: $text. + +WARN_FORMAT = "$file:$line: $text" + +# The WARN_LOGFILE tag can be used to specify a file to which warning and error +# messages should be written. If left blank the output is written to standard +# error (stderr). + +WARN_LOGFILE = + +#--------------------------------------------------------------------------- +# Configuration options related to the input files +#--------------------------------------------------------------------------- + +# The INPUT tag is used to specify the files and/or directories that contain +# documented source files. You may enter file names like myfile.cpp or +# directories like /usr/src/myproject. Separate the files or directories with +# spaces. +# Note: If this tag is empty the current directory is searched. + +INPUT = README.md src include/fc + +# This tag can be used to specify the character encoding of the source files +# that doxygen parses. Internally doxygen uses the UTF-8 encoding. Doxygen uses +# libiconv (or the iconv built into libc) for the transcoding. See the libiconv +# documentation (see: http://www.gnu.org/software/libiconv) for the list of +# possible encodings. +# The default value is: UTF-8. + +INPUT_ENCODING = UTF-8 + +# If the value of the INPUT tag contains directories, you can use the +# FILE_PATTERNS tag to specify one or more wildcard patterns (like *.cpp and +# *.h) to filter out the source-files in the directories. If left blank the +# following patterns are tested:*.c, *.cc, *.cxx, *.cpp, *.c++, *.java, *.ii, +# *.ixx, *.ipp, *.i++, *.inl, *.idl, *.ddl, *.odl, *.h, *.hh, *.hxx, *.hpp, +# *.h++, *.cs, *.d, *.php, *.php4, *.php5, *.phtml, *.inc, *.m, *.markdown, +# *.md, *.mm, *.dox, *.py, *.f90, *.f, *.for, *.tcl, *.vhd, *.vhdl, *.ucf, +# *.qsf, *.as and *.js. + +FILE_PATTERNS = + +# The RECURSIVE tag can be used to specify whether or not subdirectories should +# be searched for input files as well. +# The default value is: NO. + +RECURSIVE = YES + +# The EXCLUDE tag can be used to specify files and/or directories that should be +# excluded from the INPUT source files. This way you can easily exclude a +# subdirectory from a directory tree whose root is specified with the INPUT tag. +# +# Note that relative paths are relative to the directory from which doxygen is +# run. + +EXCLUDE = + +# The EXCLUDE_SYMLINKS tag can be used to select whether or not files or +# directories that are symbolic links (a Unix file system feature) are excluded +# from the input. +# The default value is: NO. + +EXCLUDE_SYMLINKS = NO + +# If the value of the INPUT tag contains directories, you can use the +# EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude +# certain files from those directories. +# +# Note that the wildcards are matched against the file with absolute path, so to +# exclude all test directories for example use the pattern */test/* + +EXCLUDE_PATTERNS = + +# The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names +# (namespaces, classes, functions, etc.) that should be excluded from the +# output. The symbol name can be a fully qualified name, a word, or if the +# wildcard * is used, a substring. Examples: ANamespace, AClass, +# AClass::ANamespace, ANamespace::*Test +# +# Note that the wildcards are matched against the file with absolute path, so to +# exclude all test directories use the pattern */test/* + +EXCLUDE_SYMBOLS = + +# The EXAMPLE_PATH tag can be used to specify one or more files or directories +# that contain example code fragments that are included (see the \include +# command). + +EXAMPLE_PATH = + +# If the value of the EXAMPLE_PATH tag contains directories, you can use the +# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp and +# *.h) to filter out the source-files in the directories. If left blank all +# files are included. + +EXAMPLE_PATTERNS = + +# If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be +# searched for input files to be used with the \include or \dontinclude commands +# irrespective of the value of the RECURSIVE tag. +# The default value is: NO. + +EXAMPLE_RECURSIVE = NO + +# The IMAGE_PATH tag can be used to specify one or more files or directories +# that contain images that are to be included in the documentation (see the +# \image command). + +IMAGE_PATH = + +# The INPUT_FILTER tag can be used to specify a program that doxygen should +# invoke to filter for each input file. Doxygen will invoke the filter program +# by executing (via popen()) the command: +# +# +# +# where is the value of the INPUT_FILTER tag, and is the +# name of an input file. Doxygen will then use the output that the filter +# program writes to standard output. If FILTER_PATTERNS is specified, this tag +# will be ignored. +# +# Note that the filter must not add or remove lines; it is applied before the +# code is scanned, but not when the output code is generated. If lines are added +# or removed, the anchors will not be placed correctly. + +INPUT_FILTER = + +# The FILTER_PATTERNS tag can be used to specify filters on a per file pattern +# basis. Doxygen will compare the file name with each pattern and apply the +# filter if there is a match. The filters are a list of the form: pattern=filter +# (like *.cpp=my_cpp_filter). See INPUT_FILTER for further information on how +# filters are used. If the FILTER_PATTERNS tag is empty or if none of the +# patterns match the file name, INPUT_FILTER is applied. + +FILTER_PATTERNS = + +# If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using +# INPUT_FILTER) will also be used to filter the input files that are used for +# producing the source files to browse (i.e. when SOURCE_BROWSER is set to YES). +# The default value is: NO. + +FILTER_SOURCE_FILES = NO + +# The FILTER_SOURCE_PATTERNS tag can be used to specify source filters per file +# pattern. A pattern will override the setting for FILTER_PATTERN (if any) and +# it is also possible to disable source filtering for a specific pattern using +# *.ext= (so without naming a filter). +# This tag requires that the tag FILTER_SOURCE_FILES is set to YES. + +FILTER_SOURCE_PATTERNS = + +# If the USE_MDFILE_AS_MAINPAGE tag refers to the name of a markdown file that +# is part of the input, its contents will be placed on the main page +# (index.html). This can be useful if you have a project on for instance GitHub +# and want to reuse the introduction page also for the doxygen output. + +USE_MDFILE_AS_MAINPAGE = "README.md" + +#--------------------------------------------------------------------------- +# Configuration options related to source browsing +#--------------------------------------------------------------------------- + +# If the SOURCE_BROWSER tag is set to YES then a list of source files will be +# generated. Documented entities will be cross-referenced with these sources. +# +# Note: To get rid of all source code in the generated output, make sure that +# also VERBATIM_HEADERS is set to NO. +# The default value is: NO. + +SOURCE_BROWSER = YES + +# Setting the INLINE_SOURCES tag to YES will include the body of functions, +# classes and enums directly into the documentation. +# The default value is: NO. + +INLINE_SOURCES = NO + +# Setting the STRIP_CODE_COMMENTS tag to YES will instruct doxygen to hide any +# special comment blocks from generated source code fragments. Normal C, C++ and +# Fortran comments will always remain visible. +# The default value is: YES. + +STRIP_CODE_COMMENTS = YES + +# If the REFERENCED_BY_RELATION tag is set to YES then for each documented +# function all documented functions referencing it will be listed. +# The default value is: NO. + +REFERENCED_BY_RELATION = NO + +# If the REFERENCES_RELATION tag is set to YES then for each documented function +# all documented entities called/used by that function will be listed. +# The default value is: NO. + +REFERENCES_RELATION = NO + +# If the REFERENCES_LINK_SOURCE tag is set to YES and SOURCE_BROWSER tag is set +# to YES then the hyperlinks from functions in REFERENCES_RELATION and +# REFERENCED_BY_RELATION lists will link to the source code. Otherwise they will +# link to the documentation. +# The default value is: YES. + +REFERENCES_LINK_SOURCE = YES + +# If SOURCE_TOOLTIPS is enabled (the default) then hovering a hyperlink in the +# source code will show a tooltip with additional information such as prototype, +# brief description and links to the definition and documentation. Since this +# will make the HTML file larger and loading of large files a bit slower, you +# can opt to disable this feature. +# The default value is: YES. +# This tag requires that the tag SOURCE_BROWSER is set to YES. + +SOURCE_TOOLTIPS = YES + +# If the USE_HTAGS tag is set to YES then the references to source code will +# point to the HTML generated by the htags(1) tool instead of doxygen built-in +# source browser. The htags tool is part of GNU's global source tagging system +# (see http://www.gnu.org/software/global/global.html). You will need version +# 4.8.6 or higher. +# +# To use it do the following: +# - Install the latest version of global +# - Enable SOURCE_BROWSER and USE_HTAGS in the config file +# - Make sure the INPUT points to the root of the source tree +# - Run doxygen as normal +# +# Doxygen will invoke htags (and that will in turn invoke gtags), so these +# tools must be available from the command line (i.e. in the search path). +# +# The result: instead of the source browser generated by doxygen, the links to +# source code will now point to the output of htags. +# The default value is: NO. +# This tag requires that the tag SOURCE_BROWSER is set to YES. + +USE_HTAGS = NO + +# If the VERBATIM_HEADERS tag is set the YES then doxygen will generate a +# verbatim copy of the header file for each class for which an include is +# specified. Set to NO to disable this. +# See also: Section \class. +# The default value is: YES. + +VERBATIM_HEADERS = YES + +#--------------------------------------------------------------------------- +# Configuration options related to the alphabetical class index +#--------------------------------------------------------------------------- + +# If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index of all +# compounds will be generated. Enable this if the project contains a lot of +# classes, structs, unions or interfaces. +# The default value is: YES. + +ALPHABETICAL_INDEX = YES + +# The COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns in +# which the alphabetical index list will be split. +# Minimum value: 1, maximum value: 20, default value: 5. +# This tag requires that the tag ALPHABETICAL_INDEX is set to YES. + +COLS_IN_ALPHA_INDEX = 5 + +# In case all classes in a project start with a common prefix, all classes will +# be put under the same header in the alphabetical index. The IGNORE_PREFIX tag +# can be used to specify a prefix (or a list of prefixes) that should be ignored +# while generating the index headers. +# This tag requires that the tag ALPHABETICAL_INDEX is set to YES. + +IGNORE_PREFIX = + +#--------------------------------------------------------------------------- +# Configuration options related to the HTML output +#--------------------------------------------------------------------------- + +# If the GENERATE_HTML tag is set to YES, doxygen will generate HTML output +# The default value is: YES. + +GENERATE_HTML = YES + +# The HTML_OUTPUT tag is used to specify where the HTML docs will be put. If a +# relative path is entered the value of OUTPUT_DIRECTORY will be put in front of +# it. +# The default directory is: html. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_OUTPUT = html + +# The HTML_FILE_EXTENSION tag can be used to specify the file extension for each +# generated HTML page (for example: .htm, .php, .asp). +# The default value is: .html. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_FILE_EXTENSION = .html + +# The HTML_HEADER tag can be used to specify a user-defined HTML header file for +# each generated HTML page. If the tag is left blank doxygen will generate a +# standard header. +# +# To get valid HTML the header file that includes any scripts and style sheets +# that doxygen needs, which is dependent on the configuration options used (e.g. +# the setting GENERATE_TREEVIEW). It is highly recommended to start with a +# default header using +# doxygen -w html new_header.html new_footer.html new_stylesheet.css +# YourConfigFile +# and then modify the file new_header.html. See also section "Doxygen usage" +# for information on how to generate the default header that doxygen normally +# uses. +# Note: The header is subject to change so you typically have to regenerate the +# default header when upgrading to a newer version of doxygen. For a description +# of the possible markers and block names see the documentation. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_HEADER = + +# The HTML_FOOTER tag can be used to specify a user-defined HTML footer for each +# generated HTML page. If the tag is left blank doxygen will generate a standard +# footer. See HTML_HEADER for more information on how to generate a default +# footer and what special commands can be used inside the footer. See also +# section "Doxygen usage" for information on how to generate the default footer +# that doxygen normally uses. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_FOOTER = + +# The HTML_STYLESHEET tag can be used to specify a user-defined cascading style +# sheet that is used by each HTML page. It can be used to fine-tune the look of +# the HTML output. If left blank doxygen will generate a default style sheet. +# See also section "Doxygen usage" for information on how to generate the style +# sheet that doxygen normally uses. +# Note: It is recommended to use HTML_EXTRA_STYLESHEET instead of this tag, as +# it is more robust and this tag (HTML_STYLESHEET) will in the future become +# obsolete. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_STYLESHEET = + +# The HTML_EXTRA_STYLESHEET tag can be used to specify additional user-defined +# cascading style sheets that are included after the standard style sheets +# created by doxygen. Using this option one can overrule certain style aspects. +# This is preferred over using HTML_STYLESHEET since it does not replace the +# standard style sheet and is therefore more robust against future updates. +# Doxygen will copy the style sheet files to the output directory. +# Note: The order of the extra style sheet files is of importance (e.g. the last +# style sheet in the list overrules the setting of the previous ones in the +# list). For an example see the documentation. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_EXTRA_STYLESHEET = + +# The HTML_EXTRA_FILES tag can be used to specify one or more extra images or +# other source files which should be copied to the HTML output directory. Note +# that these files will be copied to the base HTML output directory. Use the +# $relpath^ marker in the HTML_HEADER and/or HTML_FOOTER files to load these +# files. In the HTML_STYLESHEET file, use the file name only. Also note that the +# files will be copied as-is; there are no commands or markers available. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_EXTRA_FILES = + +# The HTML_COLORSTYLE_HUE tag controls the color of the HTML output. Doxygen +# will adjust the colors in the style sheet and background images according to +# this color. Hue is specified as an angle on a colorwheel, see +# http://en.wikipedia.org/wiki/Hue for more information. For instance the value +# 0 represents red, 60 is yellow, 120 is green, 180 is cyan, 240 is blue, 300 +# purple, and 360 is red again. +# Minimum value: 0, maximum value: 359, default value: 220. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_COLORSTYLE_HUE = 220 + +# The HTML_COLORSTYLE_SAT tag controls the purity (or saturation) of the colors +# in the HTML output. For a value of 0 the output will use grayscales only. A +# value of 255 will produce the most vivid colors. +# Minimum value: 0, maximum value: 255, default value: 100. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_COLORSTYLE_SAT = 100 + +# The HTML_COLORSTYLE_GAMMA tag controls the gamma correction applied to the +# luminance component of the colors in the HTML output. Values below 100 +# gradually make the output lighter, whereas values above 100 make the output +# darker. The value divided by 100 is the actual gamma applied, so 80 represents +# a gamma of 0.8, The value 220 represents a gamma of 2.2, and 100 does not +# change the gamma. +# Minimum value: 40, maximum value: 240, default value: 80. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_COLORSTYLE_GAMMA = 80 + +# If the HTML_TIMESTAMP tag is set to YES then the footer of each generated HTML +# page will contain the date and time when the page was generated. Setting this +# to NO can help when comparing the output of multiple runs. +# The default value is: YES. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_TIMESTAMP = YES + +# If the HTML_DYNAMIC_SECTIONS tag is set to YES then the generated HTML +# documentation will contain sections that can be hidden and shown after the +# page has loaded. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_DYNAMIC_SECTIONS = NO + +# With HTML_INDEX_NUM_ENTRIES one can control the preferred number of entries +# shown in the various tree structured indices initially; the user can expand +# and collapse entries dynamically later on. Doxygen will expand the tree to +# such a level that at most the specified number of entries are visible (unless +# a fully collapsed tree already exceeds this amount). So setting the number of +# entries 1 will produce a full collapsed tree by default. 0 is a special value +# representing an infinite number of entries and will result in a full expanded +# tree by default. +# Minimum value: 0, maximum value: 9999, default value: 100. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_INDEX_NUM_ENTRIES = 100 + +# If the GENERATE_DOCSET tag is set to YES, additional index files will be +# generated that can be used as input for Apple's Xcode 3 integrated development +# environment (see: http://developer.apple.com/tools/xcode/), introduced with +# OSX 10.5 (Leopard). To create a documentation set, doxygen will generate a +# Makefile in the HTML output directory. Running make will produce the docset in +# that directory and running make install will install the docset in +# ~/Library/Developer/Shared/Documentation/DocSets so that Xcode will find it at +# startup. See http://developer.apple.com/tools/creatingdocsetswithdoxygen.html +# for more information. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTML is set to YES. + +GENERATE_DOCSET = NO + +# This tag determines the name of the docset feed. A documentation feed provides +# an umbrella under which multiple documentation sets from a single provider +# (such as a company or product suite) can be grouped. +# The default value is: Doxygen generated docs. +# This tag requires that the tag GENERATE_DOCSET is set to YES. + +DOCSET_FEEDNAME = "Doxygen generated docs" + +# This tag specifies a string that should uniquely identify the documentation +# set bundle. This should be a reverse domain-name style string, e.g. +# com.mycompany.MyDocSet. Doxygen will append .docset to the name. +# The default value is: org.doxygen.Project. +# This tag requires that the tag GENERATE_DOCSET is set to YES. + +DOCSET_BUNDLE_ID = org.doxygen.Project + +# The DOCSET_PUBLISHER_ID tag specifies a string that should uniquely identify +# the documentation publisher. This should be a reverse domain-name style +# string, e.g. com.mycompany.MyDocSet.documentation. +# The default value is: org.doxygen.Publisher. +# This tag requires that the tag GENERATE_DOCSET is set to YES. + +DOCSET_PUBLISHER_ID = org.doxygen.Publisher + +# The DOCSET_PUBLISHER_NAME tag identifies the documentation publisher. +# The default value is: Publisher. +# This tag requires that the tag GENERATE_DOCSET is set to YES. + +DOCSET_PUBLISHER_NAME = Publisher + +# If the GENERATE_HTMLHELP tag is set to YES then doxygen generates three +# additional HTML index files: index.hhp, index.hhc, and index.hhk. The +# index.hhp is a project file that can be read by Microsoft's HTML Help Workshop +# (see: http://www.microsoft.com/en-us/download/details.aspx?id=21138) on +# Windows. +# +# The HTML Help Workshop contains a compiler that can convert all HTML output +# generated by doxygen into a single compiled HTML file (.chm). Compiled HTML +# files are now used as the Windows 98 help format, and will replace the old +# Windows help format (.hlp) on all Windows platforms in the future. Compressed +# HTML files also contain an index, a table of contents, and you can search for +# words in the documentation. The HTML workshop also contains a viewer for +# compressed HTML files. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTML is set to YES. + +GENERATE_HTMLHELP = NO + +# The CHM_FILE tag can be used to specify the file name of the resulting .chm +# file. You can add a path in front of the file if the result should not be +# written to the html output directory. +# This tag requires that the tag GENERATE_HTMLHELP is set to YES. + +CHM_FILE = + +# The HHC_LOCATION tag can be used to specify the location (absolute path +# including file name) of the HTML help compiler (hhc.exe). If non-empty, +# doxygen will try to run the HTML help compiler on the generated index.hhp. +# The file has to be specified with full path. +# This tag requires that the tag GENERATE_HTMLHELP is set to YES. + +HHC_LOCATION = + +# The GENERATE_CHI flag controls if a separate .chi index file is generated +# (YES) or that it should be included in the master .chm file (NO). +# The default value is: NO. +# This tag requires that the tag GENERATE_HTMLHELP is set to YES. + +GENERATE_CHI = NO + +# The CHM_INDEX_ENCODING is used to encode HtmlHelp index (hhk), content (hhc) +# and project file content. +# This tag requires that the tag GENERATE_HTMLHELP is set to YES. + +CHM_INDEX_ENCODING = + +# The BINARY_TOC flag controls whether a binary table of contents is generated +# (YES) or a normal table of contents (NO) in the .chm file. Furthermore it +# enables the Previous and Next buttons. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTMLHELP is set to YES. + +BINARY_TOC = NO + +# The TOC_EXPAND flag can be set to YES to add extra items for group members to +# the table of contents of the HTML help documentation and to the tree view. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTMLHELP is set to YES. + +TOC_EXPAND = NO + +# If the GENERATE_QHP tag is set to YES and both QHP_NAMESPACE and +# QHP_VIRTUAL_FOLDER are set, an additional index file will be generated that +# can be used as input for Qt's qhelpgenerator to generate a Qt Compressed Help +# (.qch) of the generated HTML documentation. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTML is set to YES. + +GENERATE_QHP = NO + +# If the QHG_LOCATION tag is specified, the QCH_FILE tag can be used to specify +# the file name of the resulting .qch file. The path specified is relative to +# the HTML output folder. +# This tag requires that the tag GENERATE_QHP is set to YES. + +QCH_FILE = + +# The QHP_NAMESPACE tag specifies the namespace to use when generating Qt Help +# Project output. For more information please see Qt Help Project / Namespace +# (see: http://qt-project.org/doc/qt-4.8/qthelpproject.html#namespace). +# The default value is: org.doxygen.Project. +# This tag requires that the tag GENERATE_QHP is set to YES. + +QHP_NAMESPACE = org.doxygen.Project + +# The QHP_VIRTUAL_FOLDER tag specifies the namespace to use when generating Qt +# Help Project output. For more information please see Qt Help Project / Virtual +# Folders (see: http://qt-project.org/doc/qt-4.8/qthelpproject.html#virtual- +# folders). +# The default value is: doc. +# This tag requires that the tag GENERATE_QHP is set to YES. + +QHP_VIRTUAL_FOLDER = doc + +# If the QHP_CUST_FILTER_NAME tag is set, it specifies the name of a custom +# filter to add. For more information please see Qt Help Project / Custom +# Filters (see: http://qt-project.org/doc/qt-4.8/qthelpproject.html#custom- +# filters). +# This tag requires that the tag GENERATE_QHP is set to YES. + +QHP_CUST_FILTER_NAME = + +# The QHP_CUST_FILTER_ATTRS tag specifies the list of the attributes of the +# custom filter to add. For more information please see Qt Help Project / Custom +# Filters (see: http://qt-project.org/doc/qt-4.8/qthelpproject.html#custom- +# filters). +# This tag requires that the tag GENERATE_QHP is set to YES. + +QHP_CUST_FILTER_ATTRS = + +# The QHP_SECT_FILTER_ATTRS tag specifies the list of the attributes this +# project's filter section matches. Qt Help Project / Filter Attributes (see: +# http://qt-project.org/doc/qt-4.8/qthelpproject.html#filter-attributes). +# This tag requires that the tag GENERATE_QHP is set to YES. + +QHP_SECT_FILTER_ATTRS = + +# The QHG_LOCATION tag can be used to specify the location of Qt's +# qhelpgenerator. If non-empty doxygen will try to run qhelpgenerator on the +# generated .qhp file. +# This tag requires that the tag GENERATE_QHP is set to YES. + +QHG_LOCATION = + +# If the GENERATE_ECLIPSEHELP tag is set to YES, additional index files will be +# generated, together with the HTML files, they form an Eclipse help plugin. To +# install this plugin and make it available under the help contents menu in +# Eclipse, the contents of the directory containing the HTML and XML files needs +# to be copied into the plugins directory of eclipse. The name of the directory +# within the plugins directory should be the same as the ECLIPSE_DOC_ID value. +# After copying Eclipse needs to be restarted before the help appears. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTML is set to YES. + +GENERATE_ECLIPSEHELP = NO + +# A unique identifier for the Eclipse help plugin. When installing the plugin +# the directory name containing the HTML and XML files should also have this +# name. Each documentation set should have its own identifier. +# The default value is: org.doxygen.Project. +# This tag requires that the tag GENERATE_ECLIPSEHELP is set to YES. + +ECLIPSE_DOC_ID = org.doxygen.Project + +# If you want full control over the layout of the generated HTML pages it might +# be necessary to disable the index and replace it with your own. The +# DISABLE_INDEX tag can be used to turn on/off the condensed index (tabs) at top +# of each HTML page. A value of NO enables the index and the value YES disables +# it. Since the tabs in the index contain the same information as the navigation +# tree, you can set this option to YES if you also set GENERATE_TREEVIEW to YES. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTML is set to YES. + +DISABLE_INDEX = NO + +# The GENERATE_TREEVIEW tag is used to specify whether a tree-like index +# structure should be generated to display hierarchical information. If the tag +# value is set to YES, a side panel will be generated containing a tree-like +# index structure (just like the one that is generated for HTML Help). For this +# to work a browser that supports JavaScript, DHTML, CSS and frames is required +# (i.e. any modern browser). Windows users are probably better off using the +# HTML help feature. Via custom style sheets (see HTML_EXTRA_STYLESHEET) one can +# further fine-tune the look of the index. As an example, the default style +# sheet generated by doxygen has an example that shows how to put an image at +# the root of the tree instead of the PROJECT_NAME. Since the tree basically has +# the same information as the tab index, you could consider setting +# DISABLE_INDEX to YES when enabling this option. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTML is set to YES. + +GENERATE_TREEVIEW = NO + +# The ENUM_VALUES_PER_LINE tag can be used to set the number of enum values that +# doxygen will group on one line in the generated HTML documentation. +# +# Note that a value of 0 will completely suppress the enum values from appearing +# in the overview section. +# Minimum value: 0, maximum value: 20, default value: 4. +# This tag requires that the tag GENERATE_HTML is set to YES. + +ENUM_VALUES_PER_LINE = 4 + +# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be used +# to set the initial width (in pixels) of the frame in which the tree is shown. +# Minimum value: 0, maximum value: 1500, default value: 250. +# This tag requires that the tag GENERATE_HTML is set to YES. + +TREEVIEW_WIDTH = 250 + +# If the EXT_LINKS_IN_WINDOW option is set to YES, doxygen will open links to +# external symbols imported via tag files in a separate window. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTML is set to YES. + +EXT_LINKS_IN_WINDOW = NO + +# Use this tag to change the font size of LaTeX formulas included as images in +# the HTML documentation. When you change the font size after a successful +# doxygen run you need to manually remove any form_*.png images from the HTML +# output directory to force them to be regenerated. +# Minimum value: 8, maximum value: 50, default value: 10. +# This tag requires that the tag GENERATE_HTML is set to YES. + +FORMULA_FONTSIZE = 10 + +# Use the FORMULA_TRANPARENT tag to determine whether or not the images +# generated for formulas are transparent PNGs. Transparent PNGs are not +# supported properly for IE 6.0, but are supported on all modern browsers. +# +# Note that when changing this option you need to delete any form_*.png files in +# the HTML output directory before the changes have effect. +# The default value is: YES. +# This tag requires that the tag GENERATE_HTML is set to YES. + +FORMULA_TRANSPARENT = YES + +# Enable the USE_MATHJAX option to render LaTeX formulas using MathJax (see +# http://www.mathjax.org) which uses client side Javascript for the rendering +# instead of using pre-rendered bitmaps. Use this if you do not have LaTeX +# installed or if you want to formulas look prettier in the HTML output. When +# enabled you may also need to install MathJax separately and configure the path +# to it using the MATHJAX_RELPATH option. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTML is set to YES. + +USE_MATHJAX = NO + +# When MathJax is enabled you can set the default output format to be used for +# the MathJax output. See the MathJax site (see: +# http://docs.mathjax.org/en/latest/output.html) for more details. +# Possible values are: HTML-CSS (which is slower, but has the best +# compatibility), NativeMML (i.e. MathML) and SVG. +# The default value is: HTML-CSS. +# This tag requires that the tag USE_MATHJAX is set to YES. + +MATHJAX_FORMAT = HTML-CSS + +# When MathJax is enabled you need to specify the location relative to the HTML +# output directory using the MATHJAX_RELPATH option. The destination directory +# should contain the MathJax.js script. For instance, if the mathjax directory +# is located at the same level as the HTML output directory, then +# MATHJAX_RELPATH should be ../mathjax. The default value points to the MathJax +# Content Delivery Network so you can quickly see the result without installing +# MathJax. However, it is strongly recommended to install a local copy of +# MathJax from http://www.mathjax.org before deployment. +# The default value is: http://cdn.mathjax.org/mathjax/latest. +# This tag requires that the tag USE_MATHJAX is set to YES. + +MATHJAX_RELPATH = http://cdn.mathjax.org/mathjax/latest + +# The MATHJAX_EXTENSIONS tag can be used to specify one or more MathJax +# extension names that should be enabled during MathJax rendering. For example +# MATHJAX_EXTENSIONS = TeX/AMSmath TeX/AMSsymbols +# This tag requires that the tag USE_MATHJAX is set to YES. + +MATHJAX_EXTENSIONS = + +# The MATHJAX_CODEFILE tag can be used to specify a file with javascript pieces +# of code that will be used on startup of the MathJax code. See the MathJax site +# (see: http://docs.mathjax.org/en/latest/output.html) for more details. For an +# example see the documentation. +# This tag requires that the tag USE_MATHJAX is set to YES. + +MATHJAX_CODEFILE = + +# When the SEARCHENGINE tag is enabled doxygen will generate a search box for +# the HTML output. The underlying search engine uses javascript and DHTML and +# should work on any modern browser. Note that when using HTML help +# (GENERATE_HTMLHELP), Qt help (GENERATE_QHP), or docsets (GENERATE_DOCSET) +# there is already a search function so this one should typically be disabled. +# For large projects the javascript based search engine can be slow, then +# enabling SERVER_BASED_SEARCH may provide a better solution. It is possible to +# search using the keyboard; to jump to the search box use + S +# (what the is depends on the OS and browser, but it is typically +# , /