Lines Matching full:ec
147 * @ec [in] Reference to entropy collector
149 static void jent_apt_reset(struct rand_data *ec, unsigned int delta_masked) in jent_apt_reset() argument
152 ec->apt_count = 0; in jent_apt_reset()
153 ec->apt_base = delta_masked; in jent_apt_reset()
154 ec->apt_observations = 0; in jent_apt_reset()
160 * @ec [in] Reference to entropy collector
163 static void jent_apt_insert(struct rand_data *ec, unsigned int delta_masked) in jent_apt_insert() argument
166 if (!ec->apt_base_set) { in jent_apt_insert()
167 ec->apt_base = delta_masked; in jent_apt_insert()
168 ec->apt_base_set = 1; in jent_apt_insert()
172 if (delta_masked == ec->apt_base) { in jent_apt_insert()
173 ec->apt_count++; in jent_apt_insert()
175 if (ec->apt_count >= JENT_APT_CUTOFF) in jent_apt_insert()
176 ec->health_failure = 1; in jent_apt_insert()
179 ec->apt_observations++; in jent_apt_insert()
181 if (ec->apt_observations >= JENT_APT_WINDOW_SIZE) in jent_apt_insert()
182 jent_apt_reset(ec, delta_masked); in jent_apt_insert()
204 * @ec [in] Reference to entropy collector
207 static void jent_rct_insert(struct rand_data *ec, int stuck) in jent_rct_insert() argument
213 if (ec->rct_count < 0) in jent_rct_insert()
217 ec->rct_count++; in jent_rct_insert()
228 * Note, ec->rct_count (which equals to value B in the pseudo in jent_rct_insert()
233 if ((unsigned int)ec->rct_count >= (31 * ec->osr)) { in jent_rct_insert()
234 ec->rct_count = -1; in jent_rct_insert()
235 ec->health_failure = 1; in jent_rct_insert()
238 ec->rct_count = 0; in jent_rct_insert()
245 * @ec [in] Reference to entropy collector
251 static int jent_rct_failure(struct rand_data *ec) in jent_rct_failure() argument
253 if (ec->rct_count < 0) in jent_rct_failure()
273 * @ec [in] Reference to entropy collector
280 static int jent_stuck(struct rand_data *ec, __u64 current_delta) in jent_stuck() argument
282 __u64 delta2 = jent_delta(ec->last_delta, current_delta); in jent_stuck()
283 __u64 delta3 = jent_delta(ec->last_delta2, delta2); in jent_stuck()
285 ec->last_delta = current_delta; in jent_stuck()
286 ec->last_delta2 = delta2; in jent_stuck()
292 jent_apt_insert(ec, current_delta); in jent_stuck()
296 jent_rct_insert(ec, 1); in jent_stuck()
301 jent_rct_insert(ec, 0); in jent_stuck()
309 * @ec [in] Reference to entropy collector
315 static int jent_health_failure(struct rand_data *ec) in jent_health_failure() argument
317 return ec->health_failure; in jent_health_failure()
329 * @ec entropy collector struct -- may be NULL
336 static __u64 jent_loop_shuffle(struct rand_data *ec, in jent_loop_shuffle() argument
349 if (ec) in jent_loop_shuffle()
350 time ^= ec->data; in jent_loop_shuffle()
381 * @ec [in] entropy collector struct
388 * updated ec->data
392 static void jent_lfsr_time(struct rand_data *ec, __u64 time, __u64 loop_cnt, in jent_lfsr_time() argument
401 jent_loop_shuffle(ec, MAX_FOLD_LOOP_BIT, MIN_FOLD_LOOP_BIT); in jent_lfsr_time()
410 new = ec->data; in jent_lfsr_time()
446 ec->data = new; in jent_lfsr_time()
464 * to reliably access either L3 or memory, the ec->mem memory must be quite
467 * @ec [in] Reference to the entropy collector with the memory access data -- if
473 static void jent_memaccess(struct rand_data *ec, __u64 loop_cnt) in jent_memaccess() argument
480 jent_loop_shuffle(ec, MAX_ACC_LOOP_BIT, MIN_ACC_LOOP_BIT); in jent_memaccess()
482 if (NULL == ec || NULL == ec->mem) in jent_memaccess()
484 wrap = ec->memblocksize * ec->memblocks; in jent_memaccess()
493 for (i = 0; i < (ec->memaccessloops + acc_loop_cnt); i++) { in jent_memaccess()
494 unsigned char *tmpval = ec->mem + ec->memlocation; in jent_memaccess()
506 ec->memlocation = ec->memlocation + ec->memblocksize - 1; in jent_memaccess()
507 ec->memlocation = ec->memlocation % wrap; in jent_memaccess()
523 * @ec [in] Reference to entropy collector
527 static int jent_measure_jitter(struct rand_data *ec) in jent_measure_jitter() argument
534 jent_memaccess(ec, 0); in jent_measure_jitter()
541 current_delta = jent_delta(ec->prev_time, time); in jent_measure_jitter()
542 ec->prev_time = time; in jent_measure_jitter()
545 stuck = jent_stuck(ec, current_delta); in jent_measure_jitter()
548 jent_lfsr_time(ec, current_delta, 0, stuck); in jent_measure_jitter()
557 * @ec [in] Reference to entropy collector
559 static void jent_gen_entropy(struct rand_data *ec) in jent_gen_entropy() argument
567 jent_measure_jitter(ec); in jent_gen_entropy()
569 while (!jent_health_failure(ec)) { in jent_gen_entropy()
571 if (jent_measure_jitter(ec)) in jent_gen_entropy()
578 if (++k >= ((DATA_SIZE_BITS + safety_factor) * ec->osr)) in jent_gen_entropy()
593 * @ec [in] Reference to entropy collector
606 int jent_read_entropy(struct rand_data *ec, unsigned char *data, in jent_read_entropy() argument
611 if (!ec) in jent_read_entropy()
617 jent_gen_entropy(ec); in jent_read_entropy()
619 if (jent_health_failure(ec)) { in jent_read_entropy()
622 if (jent_rct_failure(ec)) in jent_read_entropy()
638 jent_apt_reset(ec, 0); in jent_read_entropy()
639 ec->apt_base_set = 0; in jent_read_entropy()
642 ec->rct_count = 0; in jent_read_entropy()
645 ec->health_failure = 0; in jent_read_entropy()
658 jent_memcpy(p, &ec->data, tocopy); in jent_read_entropy()
721 struct rand_data ec = { 0 }; in jent_entropy_init() local
724 ec.osr = 1; in jent_entropy_init()
761 ec.prev_time = time; in jent_entropy_init()
762 jent_lfsr_time(&ec, time, 0, 0); in jent_entropy_init()
777 stuck = jent_stuck(&ec, delta); in jent_entropy_init()
803 jent_apt_reset(&ec, in jent_entropy_init()
805 if (jent_health_failure(&ec)) in jent_entropy_init()
811 if (jent_rct_failure(&ec)) in jent_entropy_init()