Skip to content

Issue #4709 RFC: reseed task_rng #4885

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed

Issue #4709 RFC: reseed task_rng #4885

wants to merge 2 commits into from

Conversation

cpeterso
Copy link
Contributor

@graydon for issue #4709.

The first change (commit 294b4a9) is straightforward. It adds a new isaac_reseed() function and uninlines isaac_seed() and isaac_init().

The second change (commit 2ef8a32) is more questionable. It adds a rust_sched_loop::idle() function, which is called when rust_sched_driver::start_main_loop() has no runnable tasks. idle() checks whether rctx has drained its entropy pool, i.e. generated more than 256 random uint32_ts. If not reseeded, rctx will be stirring the same entropy bits to generate new random numbers.

Possible improvements:

  • Add a minimum and/or maximum reseed frequency to idle(). For example, Schneier and Ferguson's Fortuna PRNG doesn't reseed more often 10 times per second.
  • Reseed less frequently than 256 random numbers (isaac's RANDSIZ)?
  • If Rust's task scheduler supported alarm tasks to be run after a specified timeout, they could be used for periodic cleanup work like reseeding the RNG.

This change also adds a fast path to rust_sched_loop::schedule_task() when there is only 1 runnable task to avoid depleting task_rng's precious entropy.

@brson
Copy link
Contributor

brson commented Feb 11, 2013

The second commit reseeds the scheduler's random number generator, which is probably desirable, but is not the same as the TLS generator mentioned in #4709. That rng is created by core::rand::task_rng.

@cpeterso
Copy link
Contributor Author

doh!

@cpeterso cpeterso closed this Feb 12, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants