Changeset View
Changeset View
Standalone View
Standalone View
sys/libkern/arc4random.c
Show First 20 Lines • Show All 169 Lines • ▼ Show 20 Lines | chacha20_init(void) | ||||
CHACHA20_FOREACH(chacha20) { | CHACHA20_FOREACH(chacha20) { | ||||
mtx_init(&chacha20->mtx, "chacha20_mtx", NULL, MTX_DEF); | mtx_init(&chacha20->mtx, "chacha20_mtx", NULL, MTX_DEF); | ||||
chacha20->t_reseed = -1; | chacha20->t_reseed = -1; | ||||
chacha20->numbytes = 0; | chacha20->numbytes = 0; | ||||
explicit_bzero(chacha20->m_buffer, CHACHA20_BUFFER_SIZE); | explicit_bzero(chacha20->m_buffer, CHACHA20_BUFFER_SIZE); | ||||
explicit_bzero(&chacha20->ctx, sizeof(chacha20->ctx)); | explicit_bzero(&chacha20->ctx, sizeof(chacha20->ctx)); | ||||
} | } | ||||
} | } | ||||
SYSINIT(chacha20, SI_SUB_LOCK, SI_ORDER_ANY, chacha20_init, NULL); | SYSINIT(chacha20, SI_SUB_LOCK, SI_ORDER_ANY, chacha20_init); | ||||
static void | static void | ||||
chacha20_uninit(void) | chacha20_uninit(void) | ||||
{ | { | ||||
struct chacha20_s *chacha20; | struct chacha20_s *chacha20; | ||||
CHACHA20_FOREACH(chacha20) | CHACHA20_FOREACH(chacha20) | ||||
mtx_destroy(&chacha20->mtx); | mtx_destroy(&chacha20->mtx); | ||||
free(chacha20inst, M_CHACHA20RANDOM); | free(chacha20inst, M_CHACHA20RANDOM); | ||||
} | } | ||||
SYSUNINIT(chacha20, SI_SUB_LOCK, SI_ORDER_ANY, chacha20_uninit, NULL); | SYSUNINIT(chacha20, SI_SUB_LOCK, SI_ORDER_ANY, chacha20_uninit); | ||||
/* | /* | ||||
* MPSAFE | * MPSAFE | ||||
*/ | */ | ||||
void | void | ||||
arc4rand(void *ptr, u_int len, int reseed) | arc4rand(void *ptr, u_int len, int reseed) | ||||
{ | { | ||||
▲ Show 20 Lines • Show All 63 Lines • Show Last 20 Lines |