global: replace randombytes_buf() with randbytes() wrapper.

This allows us to override it for deterministic results.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell
2025-11-13 15:39:31 +10:30
parent 2086699b70
commit f8fd97fb5d
69 changed files with 112 additions and 45 deletions

View File

@@ -1,6 +1,6 @@
/* This header contains globals and helper functions used by all the
* fuzz-connectd-handshake-act* fuzz targets. It also takes care of intercepting
* io_read(), io_write(), and randombytes_buf(), so that the actual fuzz targets
* io_read(), io_write(), and randbytes(), so that the actual fuzz targets
* only need to implement the test_read() and test_write() interceptors and the
* run() function.
*/
@@ -11,6 +11,7 @@
#include <assert.h>
#include <ccan/io/io.h>
#include <ccan/str/hex/hex.h>
#include <common/randbytes.h>
#include <common/setup.h>
#include <common/status.h>
#include <common/wireaddr.h>
@@ -19,9 +20,9 @@
/* No randomness please, we want to replicate test vectors. */
#include <sodium/randombytes.h>
#undef randbytes
static void seeded_randombytes_buf(u8 *secret, size_t len);
#define randombytes_buf(secret, len) seeded_randombytes_buf((secret), (len))
#define randbytes(secret, len) seeded_randombytes_buf((secret), (len))
struct handshake;