• Home
  • Raw
  • Download

Lines Matching full:ec

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