Botan 3.6.1
Crypto and TLS for C&
|
#include <botan/ffi.h>
#include <botan/auto_rng.h>
#include <botan/system_rng.h>
#include <botan/internal/ffi_rng.h>
#include <botan/internal/ffi_util.h>
#include <functional>
#include <memory>
Go to the source code of this file.
Functions | |
int | botan_rng_add_entropy (botan_rng_t rng, const uint8_t *input, size_t len) |
int | botan_rng_destroy (botan_rng_t rng) |
int | botan_rng_get (botan_rng_t rng, uint8_t *out, size_t out_len) |
int | botan_rng_init (botan_rng_t *rng_out, const char *rng_type) |
int | botan_rng_init_custom (botan_rng_t *rng_out, const char *rng_name, void *context, int(*get_cb)(void *context, uint8_t *out, size_t out_len), int(*add_entropy_cb)(void *context, const uint8_t input[], size_t length), void(*destroy_cb)(void *context)) |
int | botan_rng_reseed (botan_rng_t rng, size_t bits) |
int | botan_rng_reseed_from_rng (botan_rng_t rng, botan_rng_t source_rng, size_t bits) |
int | botan_system_rng_get (uint8_t *out, size_t out_len) |
int botan_rng_add_entropy | ( | botan_rng_t | rng, |
const uint8_t * | entropy, | ||
size_t | entropy_len ) |
Add some seed material to a random number generator
rng | rng object |
entropy | the data to add |
entropy_len | length of entropy buffer |
Definition at line 171 of file ffi_rng.cpp.
References BOTAN_FFI_VISIT.
int botan_rng_destroy | ( | botan_rng_t | rng | ) |
Frees all resources of the random number generator object
rng | rng object |
Definition at line 152 of file ffi_rng.cpp.
References BOTAN_FFI_CHECKED_DELETE.
int botan_rng_get | ( | botan_rng_t | rng, |
uint8_t * | out, | ||
size_t | out_len ) |
Get random bytes from a random number generator
rng | rng object |
out | output buffer of size out_len |
out_len | number of requested bytes |
Definition at line 156 of file ffi_rng.cpp.
References BOTAN_FFI_VISIT.
int botan_rng_init | ( | botan_rng_t * | rng, |
const char * | rng_type ) |
Initialize a random number generator object
rng | rng object |
rng_type | type of the rng, possible values: "system": system RNG "user": userspace RNG "user-threadsafe": userspace RNG, with internal locking "rdrand": directly read RDRAND Set rng_type to null to let the library choose some default. |
Definition at line 30 of file ffi_rng.cpp.
References Botan::Processor_RNG::available(), BOTAN_FFI_ERROR_NOT_IMPLEMENTED, BOTAN_FFI_ERROR_NULL_POINTER, BOTAN_FFI_SUCCESS, and Botan_FFI::ffi_guard_thunk().
int botan_rng_init_custom | ( | botan_rng_t * | rng_out, |
const char * | rng_name, | ||
void * | context, | ||
int(* | get_cb )(void *context, uint8_t *out, size_t out_len), | ||
int(* | add_entropy_cb )(void *context, const uint8_t input[], size_t length), | ||
void(* | destroy_cb )(void *context) ) |
Initialize a custom random number generator from a set of callback functions
rng_out | rng object to create |
rng_name | name of the rng |
context | An application-specific context passed to the callback functions |
get_cb | Callback for getting random bytes from the rng, return 0 for success |
add_entropy_cb | Callback for adding entropy to the rng, return 0 for success, may be NULL |
destroy_cb | Callback called when rng is destroyed, may be NULL |
Definition at line 67 of file ffi_rng.cpp.
References BOTAN_FFI_ERROR_NULL_POINTER, BOTAN_FFI_SUCCESS, Botan_FFI::ffi_guard_thunk(), and name.
int botan_rng_reseed | ( | botan_rng_t | rng, |
size_t | bits ) |
Reseed a random number generator Uses the System_RNG as a seed generator.
rng | rng object |
bits | number of bits to reseed with |
Definition at line 167 of file ffi_rng.cpp.
References BOTAN_FFI_VISIT, and Botan::system_rng().
int botan_rng_reseed_from_rng | ( | botan_rng_t | rng, |
botan_rng_t | source_rng, | ||
size_t | bits ) |
Reseed a random number generator
rng | rng object |
source_rng | the rng that will be read from |
bits | number of bits to reseed with |
Definition at line 175 of file ffi_rng.cpp.
References BOTAN_FFI_VISIT, and Botan_FFI::safe_get().
int botan_system_rng_get | ( | uint8_t * | out, |
size_t | out_len ) |
Get random bytes from system random number generator
out | output buffer of size out_len |
out_len | number of requested bytes |
Definition at line 160 of file ffi_rng.cpp.
References BOTAN_FFI_SUCCESS, Botan_FFI::ffi_guard_thunk(), Botan::RandomNumberGenerator::randomize(), and Botan::system_rng().