Lines Matching refs:ec

131  * @ec [in] Reference to entropy collector
133 static void jent_apt_reset(struct rand_data *ec, unsigned int delta_masked)
136 ec->apt_count = 0;
137 ec->apt_base = delta_masked;
138 ec->apt_observations = 0;
144 * @ec [in] Reference to entropy collector
147 static void jent_apt_insert(struct rand_data *ec, unsigned int delta_masked)
150 if (!ec->apt_base_set) {
151 ec->apt_base = delta_masked;
152 ec->apt_base_set = 1;
156 if (delta_masked == ec->apt_base) {
157 ec->apt_count++;
159 if (ec->apt_count >= JENT_APT_CUTOFF)
160 ec->health_failure = 1;
163 ec->apt_observations++;
165 if (ec->apt_observations >= JENT_APT_WINDOW_SIZE)
166 jent_apt_reset(ec, delta_masked);
188 * @ec [in] Reference to entropy collector
191 static void jent_rct_insert(struct rand_data *ec, int stuck)
197 if (ec->rct_count < 0)
201 ec->rct_count++;
212 * Note, ec->rct_count (which equals to value B in the pseudo
217 if ((unsigned int)ec->rct_count >= (31 * ec->osr)) {
218 ec->rct_count = -1;
219 ec->health_failure = 1;
222 ec->rct_count = 0;
229 * @ec [in] Reference to entropy collector
235 static int jent_rct_failure(struct rand_data *ec)
237 if (ec->rct_count < 0)
257 * @ec [in] Reference to entropy collector
264 static int jent_stuck(struct rand_data *ec, __u64 current_delta)
266 __u64 delta2 = jent_delta(ec->last_delta, current_delta);
267 __u64 delta3 = jent_delta(ec->last_delta2, delta2);
269 ec->last_delta = current_delta;
270 ec->last_delta2 = delta2;
276 jent_apt_insert(ec, current_delta);
280 jent_rct_insert(ec, 1);
285 jent_rct_insert(ec, 0);
293 * @ec [in] Reference to entropy collector
299 static int jent_health_failure(struct rand_data *ec)
305 return ec->health_failure;
317 * @ec entropy collector struct -- may be NULL
324 static __u64 jent_loop_shuffle(struct rand_data *ec,
337 if (ec)
338 time ^= ec->data;
369 * @ec [in] entropy collector struct
376 * updated ec->data
380 static void jent_lfsr_time(struct rand_data *ec, __u64 time, __u64 loop_cnt,
389 jent_loop_shuffle(ec, MAX_FOLD_LOOP_BIT, MIN_FOLD_LOOP_BIT);
398 new = ec->data;
434 ec->data = new;
452 * to reliably access either L3 or memory, the ec->mem memory must be quite
455 * @ec [in] Reference to the entropy collector with the memory access data -- if
461 static void jent_memaccess(struct rand_data *ec, __u64 loop_cnt)
468 jent_loop_shuffle(ec, MAX_ACC_LOOP_BIT, MIN_ACC_LOOP_BIT);
470 if (NULL == ec || NULL == ec->mem)
472 wrap = ec->memblocksize * ec->memblocks;
481 for (i = 0; i < (ec->memaccessloops + acc_loop_cnt); i++) {
482 unsigned char *tmpval = ec->mem + ec->memlocation;
494 ec->memlocation = ec->memlocation + ec->memblocksize - 1;
495 ec->memlocation = ec->memlocation % wrap;
511 * @ec [in] Reference to entropy collector
515 static int jent_measure_jitter(struct rand_data *ec)
522 jent_memaccess(ec, 0);
529 current_delta = jent_delta(ec->prev_time, time);
530 ec->prev_time = time;
533 stuck = jent_stuck(ec, current_delta);
536 jent_lfsr_time(ec, current_delta, 0, stuck);
545 * @ec [in] Reference to entropy collector
547 static void jent_gen_entropy(struct rand_data *ec)
552 jent_measure_jitter(ec);
556 if (jent_measure_jitter(ec))
563 if (++k >= (DATA_SIZE_BITS * ec->osr))
578 * @ec [in] Reference to entropy collector
591 int jent_read_entropy(struct rand_data *ec, unsigned char *data,
596 if (!ec)
602 jent_gen_entropy(ec);
604 if (jent_health_failure(ec)) {
607 if (jent_rct_failure(ec))
623 jent_apt_reset(ec, 0);
624 ec->apt_base_set = 0;
627 ec->rct_count = 0;
630 ec->health_failure = 0;
643 jent_memcpy(p, &ec->data, tocopy);
706 struct rand_data ec = { 0 };
709 ec.osr = 1;
746 ec.prev_time = time;
747 jent_lfsr_time(&ec, time, 0, 0);
762 stuck = jent_stuck(&ec, delta);
788 jent_apt_reset(&ec,
790 if (jent_health_failure(&ec))
796 if (jent_rct_failure(&ec))