19 #include "app_config.h"
28 #include "exceptions.h"
32 #include "os_random.h"
35 void cx_rng_no_throw(
uint8_t *buffer,
size_t len)
39 error = cx_get_random_bytes(buffer, len);
47 uint32_t cx_rng_u32_range_func(uint32_t a, uint32_t b, cx_rng_u32_range_randfunc_t randfunc)
49 uint32_t range = b - a;
52 if ((range & (range - 1)) == 0) {
57 uint32_t chunk_size = UINT32_MAX / range;
58 uint32_t last_chunk_value = chunk_size * range;
60 while (r >= last_chunk_value) {
63 return a + r / chunk_size;
Random Number Generation.