diff --git a/src/libsodium/include/sodium/randombytes.h b/src/libsodium/include/sodium/randombytes.h index eb047a6a..dd2a285c 100644 --- a/src/libsodium/include/sodium/randombytes.h +++ b/src/libsodium/include/sodium/randombytes.h @@ -1,27 +1,38 @@ -#ifndef randombytes_salsa20_random_H -#define randombytes_salsa20_random_H - -#include "salsa20_random.h" +#ifndef randombytes_H +#define randombytes_H #ifdef __cplusplus extern "C" { #endif -void randombytes(unsigned char *, unsigned long long); +#include -#define randombytes_random salsa20_random -#define randombytes_stir salsa20_random_stir -#define randombytes_uniform salsa20_random_uniform -#define randombytes_buf salsa20_random_buf -#define randombytes_close salsa20_random_close +#include +#include + +typedef struct randombytes_implementation { + const char (**randombytes_implementation_name)(void); + uint32_t (*randombytes_random)(void); + void (*randombytes_stir)(void); + uint32_t (*randombytes_uniform)(const uint32_t upper_bound); + void (*randombytes_buf)(void * const buf, const size_t size); + int (*randombytes_close)(void); +} randombytes_implementation; + +int randombytes_set_implementation(randombytes_implementation *impl); + +void randombytes(unsigned char *buf, unsigned long long size); + +const char *randombytes_implementation_name(void); +uint32_t randombytes_random(void); +void randombytes_stir(void); +uint32_t randombytes_uniform(const uint32_t upper_bound); +void randombytes_buf(void * const buf, const size_t size); +int randombytes_close(void); #ifdef __cplusplus } #endif -#ifndef randombytes_implementation -#define randombytes_implementation "salsa20_random" -#endif - #endif diff --git a/src/libsodium/include/sodium/salsa20_random.h b/src/libsodium/include/sodium/salsa20_random.h index 2df9c2e9..23aeae15 100644 --- a/src/libsodium/include/sodium/salsa20_random.h +++ b/src/libsodium/include/sodium/salsa20_random.h @@ -5,10 +5,18 @@ #include #include +#ifdef __cplusplus +extern "C" { +#endif + uint32_t salsa20_random(void); void salsa20_random_stir(void); uint32_t salsa20_random_uniform(const uint32_t upper_bound); void salsa20_random_buf(void * const buf, const size_t size); int salsa20_random_close(void); +#ifdef __cplusplus +} +#endif + #endif