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