mirror of
https://github.com/jedisct1/libsodium.git
synced 2024-12-24 12:36:01 -07:00
Prepare for pluggable randombytes*() implementations.
This commit is contained in:
parent
4c6e162c52
commit
3444a46f35
@ -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 <sys/types.h>
|
||||
|
||||
#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 <inttypes.h>
|
||||
#include <stdio.h>
|
||||
|
||||
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
|
||||
|
@ -5,10 +5,18 @@
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#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
|
||||
|
Loading…
Reference in New Issue
Block a user