diff --git a/libraries/CMakeLists.txt b/libraries/CMakeLists.txt index b56cdc728e..f9b1430ded 100644 --- a/libraries/CMakeLists.txt +++ b/libraries/CMakeLists.txt @@ -1,9 +1,7 @@ add_subdirectory( fc ) add_subdirectory( db ) -add_subdirectory( deterministic_openssl_rand ) add_subdirectory( chain ) add_subdirectory( net ) -#add_subdirectory( p2p ) add_subdirectory( time ) add_subdirectory( utilities ) add_subdirectory( app ) diff --git a/libraries/deterministic_openssl_rand/CMakeLists.txt b/libraries/deterministic_openssl_rand/CMakeLists.txt deleted file mode 100644 index 51d4ab7146..0000000000 --- a/libraries/deterministic_openssl_rand/CMakeLists.txt +++ /dev/null @@ -1,28 +0,0 @@ - -file(GLOB headers "include/graphene/utilities/*.hpp") - -set(sources deterministic_openssl_rand.cpp - ${headers}) - -add_library( deterministic_openssl_rand - ${sources} - ${HEADERS} ) -target_link_libraries( deterministic_openssl_rand fc ) -target_include_directories( deterministic_openssl_rand - PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include" - "${CMAKE_CURRENT_SOURCE_DIR}/../blockchain/include" - ) - -if (USE_PCH) - set_target_properties(deterministic_openssl_rand PROPERTIES COTIRE_ADD_UNITY_BUILD FALSE) - cotire(deterministic_openssl_rand) -endif(USE_PCH) - -install( TARGETS - deterministic_openssl_rand - - RUNTIME DESTINATION bin - LIBRARY DESTINATION lib - ARCHIVE DESTINATION lib -) -install( FILES ${headers} DESTINATION "include/graphene/utilities" ) diff --git a/libraries/deterministic_openssl_rand/deterministic_openssl_rand.cpp b/libraries/deterministic_openssl_rand/deterministic_openssl_rand.cpp deleted file mode 100644 index e88e5c26c7..0000000000 --- a/libraries/deterministic_openssl_rand/deterministic_openssl_rand.cpp +++ /dev/null @@ -1,104 +0,0 @@ -/* - * Copyright (c) 2015 Cryptonomex, Inc., and contributors. - * - * The MIT License - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -#include -#include -#include -#include -#include -#include -#include -//#include - -#include -#include -#include -#include - -static bool deterministic_rand_warning_shown = false; - -static void _warn() -{ - if (!deterministic_rand_warning_shown) - { - std::cerr << "********************************************************************************\n" - << "DETERMINISTIC RANDOM NUMBER GENERATION ENABLED\n" - << "********************************************************************************\n" - << "TESTING PURPOSES ONLY -- NOT SUITABLE FOR PRODUCTION USE\n" - << "DO NOT USE PRIVATE KEYS GENERATED WITH THIS PROGRAM FOR LIVE FUNDS\n" - << "********************************************************************************\n"; - deterministic_rand_warning_shown = true; - } -#ifndef GRAPHENE_TEST_NETWORK - std::cerr << "This program looks like a production application, but is calling the deterministic RNG.\n" - << "Perhaps the compile-time options in config.hpp were misconfigured?\n"; - exit(1); -#else - return; -#endif -} - -// These don't need to do anything if you don't have anything for them to do. -static void deterministic_rand_cleanup() { _warn(); } -static void deterministic_rand_add(const void *buf, int num, double add_entropy) { _warn(); } -static int deterministic_rand_status() { _warn(); return 1; } -static void deterministic_rand_seed(const void *buf, int num) { _warn(); } - -static fc::sha512 seed; - -static int deterministic_rand_bytes(unsigned char *buf, int num) -{ - _warn(); - while (num) - { - seed = fc::sha512::hash(seed); - - int bytes_to_copy = std::min(num, sizeof(seed)); - memcpy(buf, &seed, bytes_to_copy); - num -= bytes_to_copy; - buf += bytes_to_copy; - } - return 1; -} - -// Create the table that will link OpenSSL's rand API to our functions. -static RAND_METHOD deterministic_rand_vtable = { - deterministic_rand_seed, - deterministic_rand_bytes, - deterministic_rand_cleanup, - deterministic_rand_add, - deterministic_rand_bytes, - deterministic_rand_status -}; - -namespace graphene { namespace utilities { - -void set_random_seed_for_testing(const fc::sha512& new_seed) -{ - _warn(); - RAND_set_rand_method(&deterministic_rand_vtable); - seed = new_seed; - return; -} - -} } diff --git a/libraries/deterministic_openssl_rand/include/graphene/utilities/deterministic_openssl_rand.hpp b/libraries/deterministic_openssl_rand/include/graphene/utilities/deterministic_openssl_rand.hpp deleted file mode 100644 index 693723cb4e..0000000000 --- a/libraries/deterministic_openssl_rand/include/graphene/utilities/deterministic_openssl_rand.hpp +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (c) 2015 Cryptonomex, Inc., and contributors. - * - * The MIT License - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -#pragma once -#include - -namespace graphene { namespace utilities { - -void set_random_seed_for_testing(const fc::sha512& new_seed); - -} } // end namespace graphene::utilities