Lines Matching full:ec

153  * @ec [in] Reference to entropy collector
155 static void jent_apt_reset(struct rand_data *ec, unsigned int delta_masked) in jent_apt_reset() argument
158 ec->apt_count = 0; in jent_apt_reset()
159 ec->apt_base = delta_masked; in jent_apt_reset()
160 ec->apt_observations = 0; in jent_apt_reset()
166 * @ec [in] Reference to entropy collector
169 static void jent_apt_insert(struct rand_data *ec, unsigned int delta_masked) in jent_apt_insert() argument
172 if (!ec->apt_base_set) { in jent_apt_insert()
173 ec->apt_base = delta_masked; in jent_apt_insert()
174 ec->apt_base_set = 1; in jent_apt_insert()
178 if (delta_masked == ec->apt_base) in jent_apt_insert()
179 ec->apt_count++; in jent_apt_insert()
181 ec->apt_observations++; in jent_apt_insert()
183 if (ec->apt_observations >= JENT_APT_WINDOW_SIZE) in jent_apt_insert()
184 jent_apt_reset(ec, delta_masked); in jent_apt_insert()
188 static int jent_apt_permanent_failure(struct rand_data *ec) in jent_apt_permanent_failure() argument
190 return (ec->apt_count >= JENT_APT_CUTOFF_PERMANENT) ? 1 : 0; in jent_apt_permanent_failure()
193 static int jent_apt_failure(struct rand_data *ec) in jent_apt_failure() argument
195 return (ec->apt_count >= JENT_APT_CUTOFF) ? 1 : 0; in jent_apt_failure()
217 * @ec [in] Reference to entropy collector
220 static void jent_rct_insert(struct rand_data *ec, int stuck) in jent_rct_insert() argument
223 ec->rct_count++; in jent_rct_insert()
226 ec->rct_count = 0; in jent_rct_insert()
245 * @ec [in] Reference to entropy collector
252 static int jent_stuck(struct rand_data *ec, __u64 current_delta) in jent_stuck() argument
254 __u64 delta2 = jent_delta(ec->last_delta, current_delta); in jent_stuck()
255 __u64 delta3 = jent_delta(ec->last_delta2, delta2); in jent_stuck()
257 ec->last_delta = current_delta; in jent_stuck()
258 ec->last_delta2 = delta2; in jent_stuck()
264 jent_apt_insert(ec, current_delta); in jent_stuck()
268 jent_rct_insert(ec, 1); in jent_stuck()
273 jent_rct_insert(ec, 0); in jent_stuck()
279 static int jent_rct_permanent_failure(struct rand_data *ec) in jent_rct_permanent_failure() argument
281 return (ec->rct_count >= JENT_RCT_CUTOFF_PERMANENT) ? 1 : 0; in jent_rct_permanent_failure()
284 static int jent_rct_failure(struct rand_data *ec) in jent_rct_failure() argument
286 return (ec->rct_count >= JENT_RCT_CUTOFF) ? 1 : 0; in jent_rct_failure()
290 static int jent_health_failure(struct rand_data *ec) in jent_health_failure() argument
292 return jent_rct_failure(ec) | jent_apt_failure(ec); in jent_health_failure()
295 static int jent_permanent_health_failure(struct rand_data *ec) in jent_permanent_health_failure() argument
297 return jent_rct_permanent_failure(ec) | jent_apt_permanent_failure(ec); in jent_permanent_health_failure()
347 * ec [in] entropy collector
354 static int jent_condition_data(struct rand_data *ec, __u64 time, int stuck) in jent_condition_data() argument
363 ec->rct_count, in jent_condition_data()
364 ec->apt_observations, in jent_condition_data()
365 ec->apt_count, in jent_condition_data()
366 ec->apt_base in jent_condition_data()
369 return jent_hash_time(ec->hash_state, time, (u8 *)&addtl, sizeof(addtl), in jent_condition_data()
388 * to reliably access either L3 or memory, the ec->mem memory must be quite
391 * @ec [in] Reference to the entropy collector with the memory access data -- if
397 static void jent_memaccess(struct rand_data *ec, __u64 loop_cnt) in jent_memaccess() argument
406 if (NULL == ec || NULL == ec->mem) in jent_memaccess()
408 wrap = ec->memblocksize * ec->memblocks; in jent_memaccess()
417 for (i = 0; i < (ec->memaccessloops + acc_loop_cnt); i++) { in jent_memaccess()
418 unsigned char *tmpval = ec->mem + ec->memlocation; in jent_memaccess()
430 ec->memlocation = ec->memlocation + ec->memblocksize - 1; in jent_memaccess()
431 ec->memlocation = ec->memlocation % wrap; in jent_memaccess()
447 * @ec [in] Reference to entropy collector
451 static int jent_measure_jitter(struct rand_data *ec) in jent_measure_jitter() argument
458 jent_memaccess(ec, 0); in jent_measure_jitter()
465 current_delta = jent_delta(ec->prev_time, time); in jent_measure_jitter()
466 ec->prev_time = time; in jent_measure_jitter()
469 stuck = jent_stuck(ec, current_delta); in jent_measure_jitter()
472 if (jent_condition_data(ec, current_delta, stuck)) in jent_measure_jitter()
482 * @ec [in] Reference to entropy collector
484 static void jent_gen_entropy(struct rand_data *ec) in jent_gen_entropy() argument
492 jent_measure_jitter(ec); in jent_gen_entropy()
494 while (!jent_health_failure(ec)) { in jent_gen_entropy()
496 if (jent_measure_jitter(ec)) in jent_gen_entropy()
503 if (++k >= ((DATA_SIZE_BITS + safety_factor) * ec->osr)) in jent_gen_entropy()
518 * @ec [in] Reference to entropy collector
531 int jent_read_entropy(struct rand_data *ec, unsigned char *data, in jent_read_entropy() argument
536 if (!ec) in jent_read_entropy()
542 jent_gen_entropy(ec); in jent_read_entropy()
544 if (jent_permanent_health_failure(ec)) { in jent_read_entropy()
552 } else if (jent_health_failure(ec)) { in jent_read_entropy()
557 if (jent_entropy_init(ec->hash_state)) in jent_read_entropy()
567 if (jent_read_random_block(ec->hash_state, p, tocopy)) in jent_read_entropy()
634 struct rand_data ec = { 0 }; in jent_entropy_init() local
637 ec.osr = 1; in jent_entropy_init()
638 ec.hash_state = hash_state; in jent_entropy_init()
675 ec.prev_time = time; in jent_entropy_init()
676 jent_condition_data(&ec, time, 0); in jent_entropy_init()
691 stuck = jent_stuck(&ec, delta); in jent_entropy_init()
717 jent_apt_reset(&ec, in jent_entropy_init()
723 if (jent_health_failure(&ec)) in jent_entropy_init()