Lines Matching refs:st
171 init_state(FState * st) in init_state() argument
175 memset(st, 0, sizeof(*st)); in init_state()
177 md_init(&st->pool[i]); in init_state()
178 st->pid = getpid(); in init_state()
186 inc_counter(FState * st) in inc_counter() argument
188 uint32_t *val = (uint32_t *) st->counter; in inc_counter()
203 encrypt_counter(FState * st, unsigned char *dst) in encrypt_counter() argument
205 ciph_encrypt(&st->ciph, st->counter, dst); in encrypt_counter()
206 inc_counter(st); in encrypt_counter()
215 enough_time_passed(FState * st) in enough_time_passed() argument
219 struct timeval *last = &st->last_reseed_time; in enough_time_passed()
248 reseed(FState * st) in reseed() argument
256 st->pool0_bytes = 0; in reseed()
261 n = ++st->reseed_count; in reseed()
269 md_result(&st->pool[k], buf); in reseed()
278 md_update(&key_md, st->key, BLOCK); in reseed()
281 md_update(&key_md, (const unsigned char *)&st->pid, sizeof(st->pid)); in reseed()
284 md_result(&key_md, st->key); in reseed()
287 ciph_init(&st->ciph, st->key, BLOCK); in reseed()
297 get_rand_pool(FState * st) in get_rand_pool() argument
304 rnd = st->key[st->rnd_pos] % NUM_POOLS; in get_rand_pool()
306 st->rnd_pos++; in get_rand_pool()
307 if (st->rnd_pos >= BLOCK) in get_rand_pool()
308 st->rnd_pos = 0; in get_rand_pool()
317 add_entropy(FState * st, const unsigned char *data, unsigned len) in add_entropy() argument
331 if (st->reseed_count == 0) in add_entropy()
334 pos = get_rand_pool(st); in add_entropy()
335 md_update(&st->pool[pos], hash, BLOCK); in add_entropy()
338 st->pool0_bytes += len; in add_entropy()
348 rekey(FState * st) in rekey() argument
350 encrypt_counter(st, st->key); in rekey()
351 encrypt_counter(st, st->key + CIPH_BLOCK); in rekey()
352 ciph_init(&st->ciph, st->key, BLOCK); in rekey()
362 startup_tricks(FState * st) in startup_tricks() argument
368 encrypt_counter(st, st->counter); in startup_tricks()
373 encrypt_counter(st, buf); in startup_tricks()
374 encrypt_counter(st, buf + CIPH_BLOCK); in startup_tricks()
375 md_update(&st->pool[i], buf, BLOCK); in startup_tricks()
380 rekey(st); in startup_tricks()
383 st->tricks_done = 1; in startup_tricks()
387 extract_data(FState * st, unsigned count, unsigned char *dst) in extract_data() argument
394 if (st->pool0_bytes >= POOL0_FILL || st->reseed_count == 0) in extract_data()
395 if (enough_time_passed(st)) in extract_data()
396 reseed(st); in extract_data()
399 if (!st->tricks_done) in extract_data()
400 startup_tricks(st); in extract_data()
403 if (pid != st->pid) { in extract_data()
404 st->pid = pid; in extract_data()
405 reseed(st); in extract_data()
411 encrypt_counter(st, st->result); in extract_data()
418 memcpy(dst, st->result, n); in extract_data()
426 rekey(st); in extract_data()
431 rekey(st); in extract_data()