-
Notifications
You must be signed in to change notification settings - Fork 2
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
Constructing an PRNG from fresh entropy #17
Comments
One thing I was thinking about a few days ago was that it is often good enough to seed a new rng with It would be faster for sure. Its goal is to be about as secure as Would it be a good fall-back if the |
If your goal is secure crypto seeding, think about entropy. If If I don't actually see the point though — I mean most users won't need to seed a lot of PRNGs. I suppose a server creating a lot of encrypted communications might, but then that application should probably use its own master-CSPRNG and not piggy-back |
Continuing this. You said
I don’t really see either, why would anybody really want to write one. My problem with the trait is it giving a false sense of genericism, which doesn’t really exist here. e.g. if somebody is exposing API that might initialise its own RNG, they might end up writing something along the lines of fn banana<T: NewSeeded>() -> Result<Peach> {
let mut new_rng = T::try_new()?;
...
} hoping that they’re giving users the options to do something else, but that’s not really the case. Now, the trivial solution to this problem is to promise to make the blanket implementation specialisable (i.e. |
The Ok, I'll think some more about this. But if a user wanted, say, to use a different entropy source to initialise In other words, users are explicitly not supposed to override the behaviour of |
I opened #18 regarding seeding traits; lets keep this issue about where the entropy comes from and |
Well, an alternative would be simple functions. Personally I don't like it as much because the calling syntax isn't so simple and fn try_new_seeded<R: SeedFromRng>() -> Result<Self, Error> {
let mut r = OsRng::new()?;
R::from_rng(&mut r)
}
fn new_seeded_with_fallback<R: SeedFromRng>() -> Self {
match try_new_seeded() {
Some(result) => result,
Err(_) => { /* TODO */ },
}
} |
Note: IMO these functions shouldn't be member functions of |
I think the main source of confusion is the trait name, maybe it's worth to rename it to |
In principle I agree with @newpavlov but I'm not so keen on the suggested names, partly because we have multiple sources of entropy. I guess By the way, I made a PR implementing this, feel free to review. |
How about renaming pub trait AutoSeeded: Sized {
fn new() -> Result<Self, Error>;
} The real question is what to do if Thanks to @pitdicker's great work (#28) implementing jitterentropy we have a high quality alternative to Do we need another fallback in case both @pitdicker already suggested that Regarding Questions:
|
Apologies for being out of the loop, but I never understood why Is it merely so that |
Yes, it's so the crates can be separated. Personally I think it's a good split: There's another reason I'm against using a default method: that would imply that implementations may want to override the default. But IMO having this method should be an automatic consequence of implementing Basically I consider |
I do not understand the reasoning for split there, but maybe that's a derail here. If you prevent overriding anyways, then one can import a freestanding function like
with only Also, there is a tendency for |
Yes, there is a tendancy for types to define their own
In other words, the only sensible |
I think Andrew Tanenbaum quote "The nice thing about standards is that there are so many of them to choose from" agrees with your suggestion of I'd agree with dropping
or maybe
If you do not know if you'll ever seed it, then you need an
In fact, I think |
Your Yes, there are some other possible constructors one might want to name |
#54 is merged. I'm going to mark this "solved". |
For discussion of this section of the RFC.
It has been suggested that it should be possible to override the implementation of
NewSeeded
(see also using anfn
instead).A second point relevant to the
NewSeeded
trait is allowing seeding via a back-up entropy source, first suggested at the end of this comment, with another note at the end of this comment.Possibly we should have something like the following; this still doesn't address the question of allowing other implementations (regarding which I still don't understand the need for one):
The text was updated successfully, but these errors were encountered: