diff --git a/.circleci/config.yml b/.circleci/config.yml index 69811f4d7f..3fae7ff0c6 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -4,14 +4,15 @@ version: 2 workflows: version: 2 program-analysis: + # TODO(iphydf): Re-enable tsan when it's fixed. jobs: # Dynamic analysis in the Bazel build - bazel-asan - bazel-msan - - bazel-tsan + # - bazel-tsan # Dynamic analysis with CMake - asan - - tsan + # - tsan - ubsan # Static analysis - clang-analyze diff --git a/CMakeLists.txt b/CMakeLists.txt index f211207794..acf9684be9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -352,7 +352,9 @@ set(toxcore_SOURCES toxcore/tox_unpack.h toxcore/util.c toxcore/util.h) -if(TARGET unofficial-sodium::sodium) +if(TARGET libsodium::libsodium) + set(toxcore_LINK_LIBRARIES ${toxcore_LINK_LIBRARIES} libsodium::libsodium) +elseif(TARGET unofficial-sodium::sodium) set(toxcore_LINK_LIBRARIES ${toxcore_LINK_LIBRARIES} unofficial-sodium::sodium) else() set(toxcore_LINK_LIBRARIES ${toxcore_LINK_LIBRARIES} ${LIBSODIUM_LIBRARIES}) @@ -399,7 +401,9 @@ if(BUILD_TOXAV) set(toxcore_API_HEADERS ${toxcore_API_HEADERS} ${toxcore_SOURCE_DIR}/toxav/toxav.h^toxav) - if(MSVC) + if(TARGET Opus::opus AND TARGET libvpx::libvpx) + set(toxcore_LINK_LIBRARIES ${toxcore_LINK_LIBRARIES} Opus::opus libvpx::libvpx) + elseif(TARGET PkgConfig::OPUS AND TARGET PkgConfig::VPX) set(toxcore_LINK_LIBRARIES ${toxcore_LINK_LIBRARIES} PkgConfig::OPUS PkgConfig::VPX) else() set(toxcore_LINK_LIBRARIES ${toxcore_LINK_LIBRARIES} ${OPUS_LIBRARIES} ${VPX_LIBRARIES}) @@ -452,7 +456,9 @@ if(SOCKET_LIBRARIES) set(toxcore_PKGCONFIG_LIBS ${toxcore_PKGCONFIG_LIBS} -lsocket) endif() -if(TARGET PThreads4W::PThreads4W) +if(TARGET pthreads4w::pthreads4w) + set(toxcore_LINK_LIBRARIES ${toxcore_LINK_LIBRARIES} pthreads4w::pthreads4w) +elseif(TARGET PThreads4W::PThreads4W) set(toxcore_LINK_LIBRARIES ${toxcore_LINK_LIBRARIES} PThreads4W::PThreads4W) elseif(TARGET Threads::Threads) set(toxcore_LINK_LIBRARIES ${toxcore_LINK_LIBRARIES} Threads::Threads) @@ -510,26 +516,47 @@ install_module(toxcore DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/tox) # ################################################################################ -add_library(test_util STATIC - toxcore/DHT_test_util.cc - toxcore/DHT_test_util.hh - toxcore/crypto_core_test_util.cc - toxcore/crypto_core_test_util.hh - toxcore/mem_test_util.cc - toxcore/mem_test_util.hh - toxcore/network_test_util.cc - toxcore/network_test_util.hh - toxcore/test_util.cc - toxcore/test_util.hh) +if(UNITTEST) + add_library(test_util STATIC + toxcore/DHT_test_util.cc + toxcore/DHT_test_util.hh + toxcore/crypto_core_test_util.cc + toxcore/crypto_core_test_util.hh + toxcore/mem_test_util.cc + toxcore/mem_test_util.hh + toxcore/network_test_util.cc + toxcore/network_test_util.hh + toxcore/test_util.cc + toxcore/test_util.hh) +endif() function(unit_test subdir target) add_executable(unit_${target}_test ${subdir}/${target}_test.cc) target_link_libraries(unit_${target}_test PRIVATE test_util) + if(TARGET toxcore_static) + target_link_libraries(auto_${target}_test PRIVATE toxcore_static) + else() + target_link_libraries(auto_${target}_test PRIVATE toxcore_shared) + endif() + if(TARGET pthreads4w::pthreads4w) + target_link_libraries(auto_${target}_test PRIVATE pthreads4w::pthreads4w) + elseif(TARGET PThreads4W::PThreads4W) + target_link_libraries(auto_${target}_test PRIVATE PThreads4W::PThreads4W) + elseif(TARGET Threads::Threads) + target_link_libraries(auto_${target}_test PRIVATE Threads::Threads) + endif() if(TARGET toxcore_static) target_link_libraries(unit_${target}_test PRIVATE toxcore_static) else() target_link_libraries(unit_${target}_test PRIVATE toxcore_shared) endif() + if(TARGET pthreads4w::pthreads4w) + target_link_libraries(unit_${target}_test PRIVATE pthreads4w::pthreads4w) + elseif(TARGET PThreads4W::PThreads4W) + target_link_libraries(unit_${target}_test PRIVATE PThreads4W::PThreads4W) + elseif(TARGET Threads::Threads) + target_link_libraries(unit_${target}_test PRIVATE Threads::Threads) + endif() target_link_libraries(unit_${target}_test PRIVATE GTest::gtest GTest::gtest_main GTest::gmock) set_target_properties(unit_${target}_test PROPERTIES COMPILE_FLAGS "${TEST_CXX_FLAGS}") add_test(NAME ${target} COMMAND ${CROSSCOMPILING_EMULATOR} unit_${target}_test) @@ -583,10 +610,14 @@ if(DHT_BOOTSTRAP) target_link_libraries(DHT_bootstrap PRIVATE toxcore_shared) endif() target_link_libraries(DHT_bootstrap PRIVATE misc_tools) - if(TARGET unofficial-sodium::sodium) + if(TARGET libsodium::libsodium) + target_link_libraries(DHT_bootstrap PRIVATE libsodium::libsodium) + elseif(TARGET unofficial-sodium::sodium) target_link_libraries(DHT_bootstrap PRIVATE unofficial-sodium::sodium) endif() - if(TARGET PThreads4W::PThreads4W) + if(TARGET pthreads4w::pthreads4w) + target_link_libraries(DHT_bootstrap PRIVATE pthreads4w::pthreads4w) + elseif(TARGET PThreads4W::PThreads4W) target_link_libraries(DHT_bootstrap PRIVATE PThreads4W::PThreads4W) elseif(TARGET Threads::Threads) target_link_libraries(DHT_bootstrap PRIVATE Threads::Threads) diff --git a/auto_tests/CMakeLists.txt b/auto_tests/CMakeLists.txt index d891ba122b..8413e1d144 100644 --- a/auto_tests/CMakeLists.txt +++ b/auto_tests/CMakeLists.txt @@ -9,7 +9,9 @@ if(TARGET toxcore_static) else() target_link_libraries(auto_test_support PRIVATE toxcore_shared) endif() -if(TARGET PThreads4W::PThreads4W) +if(TARGET pthreads4w::pthreads4w) + target_link_libraries(auto_test_support PRIVATE pthreads4w::pthreads4w) +elseif(TARGET PThreads4W::PThreads4W) target_link_libraries(auto_test_support PRIVATE PThreads4W::PThreads4W) elseif(TARGET Threads::Threads) target_link_libraries(auto_test_support PRIVATE Threads::Threads) @@ -23,7 +25,9 @@ function(auto_test target) else() target_link_libraries(auto_${target}_test PRIVATE toxcore_shared) endif() - if(TARGET PThreads4W::PThreads4W) + if(TARGET pthreads4w::pthreads4w) + target_link_libraries(auto_${target}_test PRIVATE pthreads4w::pthreads4w) + elseif(TARGET PThreads4W::PThreads4W) target_link_libraries(auto_${target}_test PRIVATE PThreads4W::PThreads4W) elseif(TARGET Threads::Threads) target_link_libraries(auto_${target}_test PRIVATE Threads::Threads) @@ -98,7 +102,10 @@ if(BUILD_TOXAV) auto_test(toxav_basic) auto_test(toxav_many) - if(MSVC) + if(TARGET libvpx::libvpx) + target_link_libraries(auto_toxav_basic_test PRIVATE libvpx::libvpx) + target_link_libraries(auto_toxav_many_test PRIVATE libvpx::libvpx) + elseif(TARGET PkgConfig::VPX) target_link_libraries(auto_toxav_basic_test PRIVATE PkgConfig::VPX) target_link_libraries(auto_toxav_many_test PRIVATE PkgConfig::VPX) else() diff --git a/auto_tests/encryptsave_test.c b/auto_tests/encryptsave_test.c index e433e410a8..3573337e49 100644 --- a/auto_tests/encryptsave_test.c +++ b/auto_tests/encryptsave_test.c @@ -3,8 +3,6 @@ #include #include -#include - #include "../testing/misc_tools.h" #include "../toxcore/ccompat.h" #include "../toxcore/crypto_core.h" @@ -14,13 +12,10 @@ #include "check_compat.h" static unsigned char test_salt[TOX_PASS_SALT_LENGTH] = {0xB1, 0xC2, 0x09, 0xEE, 0x50, 0x6C, 0xF0, 0x20, 0xC4, 0xD6, 0xEB, 0xC0, 0x44, 0x51, 0x3B, 0x60, 0x4B, 0x39, 0x4A, 0xCF, 0x09, 0x53, 0x4F, 0xEA, 0x08, 0x41, 0xFA, 0xCA, 0x66, 0xD2, 0x68, 0x7F}; -static unsigned char known_key[TOX_PASS_KEY_LENGTH] = {0x29, 0x36, 0x1c, 0x9e, 0x65, 0xbb, 0x46, 0x8b, 0xde, 0xa1, 0xac, 0xf, 0xd5, 0x11, 0x81, 0xc8, 0x29, 0x28, 0x17, 0x23, 0xa6, 0xc3, 0x6b, 0x77, 0x2e, 0xd7, 0xd3, 0x10, 0xeb, 0xd2, 0xf7, 0xc8}; +static unsigned char known_key[CRYPTO_SHARED_KEY_SIZE] = {0x7a, 0xfa, 0x95, 0x45, 0x36, 0x8a, 0xa2, 0x5c, 0x40, 0xfd, 0xc0, 0xe2, 0x35, 0x8, 0x7, 0x88, 0xfa, 0xf9, 0x37, 0x86, 0xeb, 0xff, 0x50, 0x4f, 0x3, 0xe2, 0xf6, 0xd9, 0xef, 0x9, 0x17, 0x1}; static const char *pw = "hunter2"; static unsigned int pwlen = 7; -static unsigned char known_key2[CRYPTO_SHARED_KEY_SIZE] = {0x7a, 0xfa, 0x95, 0x45, 0x36, 0x8a, 0xa2, 0x5c, 0x40, 0xfd, 0xc0, 0xe2, 0x35, 0x8, 0x7, 0x88, 0xfa, 0xf9, 0x37, 0x86, 0xeb, 0xff, 0x50, 0x4f, 0x3, 0xe2, 0xf6, 0xd9, 0xef, 0x9, 0x17, 0x1}; -// same as above, except standard opslimit instead of extra ops limit for test_known_kdf, and hash pw before kdf for compat - /* cause I'm shameless */ static void accept_friend_request(Tox *m, const uint8_t *public_key, const uint8_t *data, size_t length, void *userdata) { @@ -33,20 +28,6 @@ static void accept_friend_request(Tox *m, const uint8_t *public_key, const uint8 } } -static void test_known_kdf(void) -{ - unsigned char out[CRYPTO_SHARED_KEY_SIZE]; - int16_t res = crypto_pwhash_scryptsalsa208sha256(out, - CRYPTO_SHARED_KEY_SIZE, - pw, - pwlen, - test_salt, - crypto_pwhash_scryptsalsa208sha256_OPSLIMIT_INTERACTIVE * 8, - crypto_pwhash_scryptsalsa208sha256_MEMLIMIT_INTERACTIVE); - ck_assert_msg(res != -1, "crypto function failed"); - ck_assert_msg(memcmp(out, known_key, CRYPTO_SHARED_KEY_SIZE) == 0, "derived key is wrong"); -} - static void test_save_friend(void) { Tox *tox1 = tox_new_log(nullptr, nullptr, nullptr); @@ -101,7 +82,7 @@ static void test_save_friend(void) Tox_Pass_Key *key = tox_pass_key_derive((const uint8_t *)"123qweasdzxc", 12, &keyerr); ck_assert_msg(key != nullptr, "pass key allocation failure"); memcpy((uint8_t *)key, test_salt, TOX_PASS_SALT_LENGTH); - memcpy((uint8_t *)key + TOX_PASS_SALT_LENGTH, known_key2, TOX_PASS_KEY_LENGTH); + memcpy((uint8_t *)key + TOX_PASS_SALT_LENGTH, known_key, TOX_PASS_KEY_LENGTH); size2 = size + TOX_PASS_ENCRYPTION_EXTRA_LENGTH; uint8_t *encdata2 = (uint8_t *)malloc(size2); ck_assert(encdata2 != nullptr); @@ -224,7 +205,6 @@ static void test_keys(void) int main(void) { setvbuf(stdout, nullptr, _IONBF, 0); - test_known_kdf(); test_save_friend(); test_keys(); diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 941bc33158..a8bc0b9bf8 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -9,7 +9,13 @@ jobs: shared: conan.shared: "True" steps: - - bash: python -m pip install conan==1.59.0 + - bash: choco install pkgconfiglite + displayName: "Install pkg-config" + - bash: python -m pip install conan + displayName: "Install Conan" - bash: git submodule update --init --recursive - - bash: conan install -if _build -o with_tests=True -o shared=$(conan.shared) . - - bash: CONAN_CPU_COUNT=50 CTEST_OUTPUT_ON_FAILURE=1 conan build -bf _build -if _build . || true + displayName: "Fetch git submodules" + - bash: conan profile detect + displayName: "Detect Conan profile" + - bash: conan build -o "&:with_tests=True" -o "&:shared=$(conan.shared)" . + displayName: "Build with Conan" diff --git a/cmake/Dependencies.cmake b/cmake/Dependencies.cmake index 900e9b185a..fb30fdcefa 100644 --- a/cmake/Dependencies.cmake +++ b/cmake/Dependencies.cmake @@ -12,14 +12,20 @@ find_library(SOCKET_LIBRARIES socket) find_package(pthreads QUIET) if(NOT TARGET PThreads4W::PThreads4W) + find_package(pthreads4w QUIET) +endif() +if(NOT TARGET pthreads4w::pthreads4w) set(THREADS_PREFER_PTHREAD_FLAG ON) find_package(Threads REQUIRED) endif() # For toxcore. -pkg_search_module(LIBSODIUM libsodium IMPORTED_TARGET REQUIRED) +pkg_search_module(LIBSODIUM libsodium IMPORTED_TARGET) if(MSVC) - find_package(unofficial-sodium REQUIRED) + find_package(libsodium) + if(NOT TARGET libsodium::libsodium) + find_package(unofficial-sodium REQUIRED) + endif() endif() # For toxav. @@ -27,10 +33,23 @@ pkg_search_module(OPUS opus IMPORTED_TARGET) if(NOT OPUS_FOUND) pkg_search_module(OPUS Opus IMPORTED_TARGET) endif() +if(NOT OPUS_FOUND) + find_package(Opus) + if(TARGET Opus::opus) + set(OPUS_FOUND TRUE) + endif() +endif() + pkg_search_module(VPX vpx IMPORTED_TARGET) if(NOT VPX_FOUND) pkg_search_module(VPX libvpx IMPORTED_TARGET) endif() +if(NOT VPX_FOUND) + find_package(libvpx) + if(TARGET libvpx::libvpx) + set(VPX_FOUND TRUE) + endif() +endif() # For tox-bootstrapd. pkg_search_module(LIBCONFIG libconfig IMPORTED_TARGET) diff --git a/conanfile.py b/conanfile.py index e9af70b5c9..85569e43db 100644 --- a/conanfile.py +++ b/conanfile.py @@ -1,21 +1,25 @@ # pylint: disable=not-callable -import os -import re - -from conans import CMake -from conans import ConanFile -from conans.tools import collect_libs -from conans.tools import load +from conan import ConanFile +from conan.tools.cmake import CMake +from conan.tools.cmake import cmake_layout +from conan.tools.cmake import CMakeDeps +from conan.tools.cmake import CMakeToolchain class ToxConan(ConanFile): name = "c-toxcore" + version = "0.2.20" url = "https://tox.chat" description = "The future of online communications." license = "GPL-3.0-only" settings = "os", "compiler", "build_type", "arch" - requires = "libsodium/1.0.18", "opus/1.3.1", "libvpx/1.9.0" - generators = "cmake_find_package" + requires = ( + "libsodium/1.0.20", + "opus/1.5.2", + "libvpx/1.14.1", + "pthreads4w/3.0.0", + "gtest/1.15.0", + ) scm = {"type": "git", "url": "auto", "revision": "auto"} options = { @@ -27,61 +31,38 @@ class ToxConan(ConanFile): "with_tests": False, } - _cmake = None - - def _create_cmake(self): - if self._cmake is not None: - return self._cmake + exports_sources = "CMakeLists.txt", "toxav/*", "toxcore/*" - self._cmake = CMake(self) - self._cmake.definitions["AUTOTEST"] = self.options.with_tests - self._cmake.definitions["BUILD_MISC_TESTS"] = self.options.with_tests - self._cmake.definitions["TEST_TIMEOUT_SECONDS"] = "300" + def layout(self): + cmake_layout(self) - self._cmake.definitions[ - "CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS"] = self.options.shared - self._cmake.definitions["ENABLE_SHARED"] = self.options.shared - self._cmake.definitions["ENABLE_STATIC"] = not self.options.shared - self._cmake.definitions["MUST_BUILD_TOXAV"] = True - if self.settings.compiler == "Visual Studio": - self._cmake.definitions["MSVC_STATIC_SODIUM"] = True - self._cmake.definitions[ - "FLAT_OUTPUT_STRUCTURE"] = self.options.shared + def generate(self): + deps = CMakeDeps(self) + deps.generate() + tc = CMakeToolchain(self) + tc.variables["AUTOTEST"] = self.options.with_tests + tc.variables["BUILD_MISC_TESTS"] = self.options.with_tests + tc.variables["UNITTEST"] = self.options.with_tests + tc.variables["TEST_TIMEOUT_SECONDS"] = "300" - self._cmake.configure() - return self._cmake - - def set_version(self): - content = load(os.path.join(self.recipe_folder, "CMakeLists.txt")) - version_major = re.search(r"set\(PROJECT_VERSION_MAJOR \"(.*)\"\)", - content).group(1) - version_minor = re.search(r"set\(PROJECT_VERSION_MINOR \"(.*)\"\)", - content).group(1) - version_patch = re.search(r"set\(PROJECT_VERSION_PATCH \"(.*)\"\)", - content).group(1) - self.version = "%s.%s.%s" % ( - version_major.strip(), - version_minor.strip(), - version_patch.strip(), - ) - - def requirements(self): - if self.settings.os == "Windows": - self.requires("pthreads4w/3.0.0") + tc.variables["CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS"] = self.options.shared + tc.variables["ENABLE_SHARED"] = self.options.shared + tc.variables["ENABLE_STATIC"] = not self.options.shared + tc.variables["MUST_BUILD_TOXAV"] = True + tc.generate() def build(self): - cmake = self._create_cmake() + cmake = CMake(self) + cmake.configure() cmake.build() - if self.options.with_tests: - cmake.test(output_on_failure=True) + cmake.ctest(cli_args=["--output-on-failure"]) def package(self): - cmake = self._create_cmake() + cmake = CMake(self) cmake.install() def package_info(self): self.cpp_info.libs = collect_libs(self) - if self.settings.os == "Windows": self.cpp_info.system_libs = ["Ws2_32", "Iphlpapi"] diff --git a/testing/BUILD.bazel b/testing/BUILD.bazel index 4427347f16..d907be3c7e 100644 --- a/testing/BUILD.bazel +++ b/testing/BUILD.bazel @@ -75,7 +75,6 @@ cc_library( deps = [ "//c-toxcore/toxcore:ccompat", "//c-toxcore/toxcore:tox", - "@libsodium", ], ) diff --git a/testing/CMakeLists.txt b/testing/CMakeLists.txt index d664c0fa86..3c2bea1c41 100644 --- a/testing/CMakeLists.txt +++ b/testing/CMakeLists.txt @@ -8,15 +8,9 @@ if(TARGET toxcore_static) else() target_link_libraries(misc_tools PRIVATE toxcore_shared) endif() -if(TARGET unofficial-sodium::sodium) - target_link_libraries(misc_tools PRIVATE unofficial-sodium::sodium) -else() - target_link_libraries(misc_tools PRIVATE ${LIBSODIUM_LIBRARIES}) - target_link_directories(misc_tools PUBLIC ${LIBSODIUM_LIBRARY_DIRS}) - target_include_directories(misc_tools SYSTEM PRIVATE ${LIBSODIUM_INCLUDE_DIRS}) - target_compile_options(misc_tools PRIVATE ${LIBSODIUM_CFLAGS_OTHER}) -endif() -if(TARGET PThreads4W::PThreads4W) +if(TARGET pthreads4w::pthreads4w) + target_link_libraries(misc_tools PRIVATE pthreads4w::pthreads4w) +elseif(TARGET PThreads4W::PThreads4W) target_link_libraries(misc_tools PRIVATE PThreads4W::PThreads4W) elseif(TARGET Threads::Threads) target_link_libraries(misc_tools PRIVATE Threads::Threads) @@ -36,7 +30,9 @@ if(BUILD_MISC_TESTS) else() target_link_libraries(Messenger_test PRIVATE toxcore_shared) endif() - if(TARGET PThreads4W::PThreads4W) + if(TARGET pthreads4w::pthreads4w) + target_link_libraries(Messenger_test PRIVATE pthreads4w::pthreads4w) + elseif(TARGET PThreads4W::PThreads4W) target_link_libraries(Messenger_test PRIVATE PThreads4W::PThreads4W) elseif(TARGET Threads::Threads) target_link_libraries(Messenger_test PRIVATE Threads::Threads) diff --git a/testing/Makefile.inc b/testing/Makefile.inc index 223ebdcf0c..7d5f24babc 100644 --- a/testing/Makefile.inc +++ b/testing/Makefile.inc @@ -8,10 +8,6 @@ endif noinst_LTLIBRARIES += libmisc_tools.la libmisc_tools_la_SOURCES = ../testing/misc_tools.c ../testing/misc_tools.h -libmisc_tools_la_CFLAGS = $(LIBSODIUM_CFLAGS) - -libmisc_tools_la_LIBADD = $(LIBSODIUM_LDFLAGS) - if BUILD_TESTING noinst_PROGRAMS += Messenger_test diff --git a/testing/misc_tools.c b/testing/misc_tools.c index a2b950c1da..6352f4716e 100644 --- a/testing/misc_tools.c +++ b/testing/misc_tools.c @@ -20,8 +20,6 @@ #include #include -#include - #if defined(_WIN32) || defined(__WIN32__) || defined(WIN32) #include #else @@ -137,60 +135,3 @@ int cmdline_parsefor_ipv46(int argc, char **argv, bool *ipv6enabled) return argvoffset; } - -static const char *test_rng_name(void) -{ - return "test_rng"; -} - -static uint32_t rng_state; - -static uint32_t test_rng_random(void) -{ - rng_state = 2624534371 * rng_state + 1; - return rng_state; -} - -static void test_rng_buf(void *const buf, const size_t size) -{ - uint8_t *p = (uint8_t *)buf; - uint32_t r = 0; - - for (size_t i = 0; i < size; i++) { - if ((i % 4) == 0) { - r = test_rng_random(); - } - - *p = (r >> ((i % 4) * 8)) & 0xff; - ++p; - } -} - -static uint32_t test_rng_uniform(const uint32_t upper_bound) -{ - // XXX: Not uniform! But that's ok for testing purposes. - return test_rng_random() % upper_bound; -} - -static void test_rng_stir(void) { } -static int test_rng_close(void) -{ - return 0; -} - -static randombytes_implementation test_rng = { - test_rng_name, - test_rng_random, - test_rng_stir, - test_rng_uniform, - test_rng_buf, - test_rng_close -}; - -/* Simple insecure PRNG for testing purposes */ -int use_test_rng(uint32_t seed) -{ - rng_state = seed; - - return randombytes_set_implementation(&test_rng); -}