dexios icon indicating copy to clipboard operation
dexios copied to clipboard

Question: Why not ThreadRng?

Open pleshevskiy opened this issue 2 years ago • 9 comments

The documentation shows that ThreadRng is safer than StdRng::from_entropy

Unlike StdRng, ThreadRng uses the ReseedingRng wrapper to reseed the PRNG from fresh entropy every 64 kiB of random data as well as after a fork on Unix (though not quite immediately; see documentation of ReseedingRng). Note that the reseeding is done as an extra precaution against side-channel attacks and mis-use (e.g. if somehow weak entropy were supplied initially). The PRNG algorithms used are assumed to be secure.

Correct me if I'm wrong.

pleshevskiy avatar Jul 15 '22 19:07 pleshevskiy

Both are seeded from the same source, just ThreadRng has an extra wrapper. Both are sufficient security-wise, as mentioned here in the docs.

We could make the switch if necessary, but I'm impartial to it.

EDIT: The additional protection against side-channel attacks seems worth it in my eyes.

brxken128 avatar Jul 15 '22 21:07 brxken128

@pleshevskiy I tried to contact you by email but Yandex filtered it as spam. I wanted to let you know that I probably won't be too active over the next few days as my country is due a major heat wave, with the highest temperatures that we've seen before.

I apologise for this, and hope to get back to fully working on Dexios very, very soon :)

brxken128 avatar Jul 17 '22 17:07 brxken128

Thank you very much for the important information! Take care of yourself!!! I will look forward to hearing from you :)

pleshevskiy avatar Jul 17 '22 19:07 pleshevskiy

Thank you very much for the important information! Take care of yourself!!! I will look forward to hearing from you :)

Things are cooling down, so I'll work on it as much as I can. Tomorrow is going to be a lot worse though rip

I'll get ThreadRng implemented first :)

brxken128 avatar Jul 18 '22 17:07 brxken128

@pleshevskiy What's up with everything grabbing things such as gen_salt from the utils.rs file? Are they just re-directed to the core crate? I'm going to add master key generation to the core, so they're all in one place and got curious :))

brxken128 avatar Jul 18 '22 17:07 brxken128

@brxken128 For tests, I need to be able to specify SEED so that the result of the tests is always the same. Ideally, We should make a struct/trait that works with multiple RandCore implementations (ThreadRng, StdRng)

pleshevskiy avatar Jul 18 '22 19:07 pleshevskiy

@brxken128 For tests, I need to be able to specify SEED so that the result of the tests is always the same. Ideally, We should make a struct/trait that works with multiple RandCore implementations (ThreadRng, StdRng)

Would an enum-based approach be adequate for this? I can probably get to work on that if so - I'd just need a list of everything that should be included.

brxken128 avatar Jul 18 '22 19:07 brxken128

@brxken128 I don't think so) If you want you can be inspired by the storage.

For example: trait Generator, struct AutoSeedGenerator, struct StaticSeedGenerator

pleshevskiy avatar Jul 18 '22 20:07 pleshevskiy

I'd just need a list of everything that should be included.

A search showed that only 3 functions use random. If you know any others, they should be added here too.

pleshevskiy avatar Jul 18 '22 20:07 pleshevskiy

Closing this as ThreadRng has been in use since #136.

brxken128 avatar Apr 08 '23 21:04 brxken128