|
Botan 3.12.0
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_generate_with_input (botan_rng_t rng, uint8_t *out, size_t out_len, const uint8_t *addl_input, size_t addl_len) |
| 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_init_drbg (botan_rng_t *rng_out, const char *drbg_name, const uint8_t *seed, size_t seed_len) |
| 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
| Random Number Generators | rng object |
| Entropy Collection | the data to add |
| entropy_len | length of entropy buffer |
Definition at line 189 of file ffi_rng.cpp.
References BOTAN_FFI_ERROR_NULL_POINTER, and BOTAN_FFI_VISIT.
| int botan_rng_destroy | ( | botan_rng_t | rng | ) |
Frees all resources of the random number generator object
| Random Number Generators | rng object |
Definition at line 164 of file ffi_rng.cpp.
References BOTAN_FFI_CHECKED_DELETE.
| int botan_rng_generate_with_input | ( | botan_rng_t | rng, |
| uint8_t * | out, | ||
| size_t | out_len, | ||
| const uint8_t * | addl_input, | ||
| size_t | addl_len ) |
Generate random bytes from an RNG with additional input.
For a DRBG, the additional input is mixed in before generating. Many other RNG types (eg RDRAND or system RNG) will ignore the input.
| Random Number Generators | the RNG object |
| out | output buffer |
| out_len | number of bytes to generate |
| addl_input | additional input to mix in (may be NULL if addl_len is 0) |
| addl_len | length of additional input |
Definition at line 230 of file ffi_rng.cpp.
References BOTAN_FFI_ERROR_NULL_POINTER, and BOTAN_FFI_VISIT.
| int botan_rng_get | ( | botan_rng_t | rng, |
| uint8_t * | out, | ||
| size_t | out_len ) |
Get random bytes from a random number generator
| Random Number Generators | rng object |
| out | output buffer of size out_len |
| out_len | number of requested bytes |
Definition at line 168 of file ffi_rng.cpp.
References BOTAN_FFI_ERROR_NULL_POINTER, and BOTAN_FFI_VISIT.
| int botan_rng_init | ( | botan_rng_t * | rng, |
| const char * | rng_type ) |
Initialize a random number generator object
| Random Number Generators | rng object |
| rng_type | type of the rng, possible values: "system": system RNG "esdm-full": ESDM RNG (fully seeded) "esdm-pr": ESDM RNG (w. prediction resistance) "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 38 of file ffi_rng.cpp.
References Botan::Processor_RNG::available(), BOTAN_FFI_ERROR_NOT_IMPLEMENTED, BOTAN_FFI_ERROR_NULL_POINTER, Botan_FFI::ffi_guard_thunk(), and Botan_FFI::ffi_new_object().
| 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 81 of file ffi_rng.cpp.
References BOTAN_FFI_ERROR_NULL_POINTER, Botan_FFI::ffi_guard_thunk(), and Botan_FFI::ffi_new_object().
| int botan_rng_init_drbg | ( | botan_rng_t * | rng_out, |
| const char * | drbg_name, | ||
| const uint8_t * | seed, | ||
| size_t | seed_len ) |
Create and seed a DRBG
| rng_out | the new DRBG object |
| drbg_name | the name of the DRBG (e.g. "HMAC_DRBG(SHA-256)") |
| SEED | the seed material (entropy || nonce || personalization_string) |
| seed_len | length of seed in bytes |
Definition at line 200 of file ffi_rng.cpp.
References BOTAN_FFI_ERROR_NOT_IMPLEMENTED, BOTAN_FFI_ERROR_NULL_POINTER, Botan_FFI::ffi_guard_thunk(), and Botan_FFI::ffi_new_object().
| int botan_rng_reseed | ( | botan_rng_t | rng, |
| size_t | bits ) |
Reseed a random number generator Uses the System_RNG as a seed generator.
| Random Number Generators | rng object |
| bits | number of bits to reseed with |
Definition at line 185 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
| Random Number Generators | rng object |
| source_rng | the rng that will be read from |
| bits | number of bits to reseed with |
Definition at line 196 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 175 of file ffi_rng.cpp.
References BOTAN_FFI_ERROR_NULL_POINTER, BOTAN_FFI_SUCCESS, Botan_FFI::ffi_guard_thunk(), Botan::RandomNumberGenerator::randomize(), and Botan::system_rng().