Skip to content

Update READMEs.#328

Merged
pitdicker merged 8 commits intorust-random:masterfrom
dhardy:readme
Mar 25, 2018
Merged

Update READMEs.#328
pitdicker merged 8 commits intorust-random:masterfrom
dhardy:readme

Conversation

@dhardy
Copy link
Member

@dhardy dhardy commented Mar 23, 2018

Better doc of features in both crates.
Update version req to 0.5.0-pre.0. More updates are needed for final 0.5.

Copy link
Contributor

@pitdicker pitdicker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like a good improvement to me.

Still, it it said that having an example in the readme is good practise.

comprising `RngCore` support for `Box<R>` types where `R: RngCore`, as well as
extensions to the `Error` type's functionality.

Due to a bug in Cargo, `rand_core` is built without `std` support by default.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This sounds a bit negative. Can you say "Due to {issue-number}"?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was intended to be, and it's documented in Cargo.toml.

Maybe some day Cargo will have a lot less rough edges. I guess a flexible build/packaging tool turned out to be a considerably more complex than was initially envisaged. For now it still feels like a quick hack in many ways.

@dhardy
Copy link
Member Author

dhardy commented Mar 24, 2018

Added another commit with a lot of new library level documentation.

I'm considering moving or removing the big examples at the end of the library documentation; they're good but it's just too much doc in one place. Thoughts?

Copy link
Contributor

@pitdicker pitdicker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very nice improvements!

I'm considering moving or removing the big examples at the end of the library documentation; they're good but it's just too much doc in one place.

One of my wishes 😄.
It is nice documentation, but just too much in the wrong place. Is it possible to move it to a separate file?

src/lib.rs Outdated
//! much smaller state and faster initialisation while its disadvantage is
//! that it may be easy for an attacker to predict; actual performance varies).
//! These can be seeded from a parent generator (`SeedableRng::thread_rng`) or
//! with fresh entropy using `NewRng`:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

src/lib.rs Outdated
//! `thread_rng` and potentially much slower if `EntropyRng` must fall back to
//! `JitterRng` as a source.
//!
//! It is also common to use an algorithmic generator in local memory; for
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it is better to have this one as the second paragraph, and to reword a bit.

It is also quite common, and can have advantages, to use an algorithmic generator in local memory.
StdRng and SmallRng provide to generators selected for common use. StdRng can be recommended for all uses, the main advantages of SmallRng are much smaller state and faster initialisation while its disadvantage is that it may be easy for an attacker to predict; actual performance varies.
...

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't want to make the doc too long however — I'll try to find a compromise.

//!
//!
//! In case one wants specifically to have a reproducible stream of "random"
//! data (e.g. to procedurally generate a game world), select a named algorithm
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you want to link to the prng module here?

src/lib.rs Outdated
//! data (e.g. to procedurally generate a game world), select a named algorithm
//! (i.e. not `StdRng`/`SmallRng` which may be adjusted in the future), and
//! use `SeedableRng::from_seed`. Some generators provide additional
//! constructors suitable for some applications, e.g. `IsaacRng::new_from_u64`.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mostly unrelated though: most RNGs now have a new_unseeded method. They are a thorn in my eye 😄. Should we deprecate them with 0.5?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that was originally the plan but got forgotten? Sure, why not.

//!
//! The `seq` module has a few tools applicable to sliceable or iterable data.
//!
//! # Cryptographic security
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your new paragraphs are a good improvement, but I don't like it completely yet. It reads as very serious (can be a good thing), but Rand is not really a library for cryptography. I would mostly point away the responsibility to specialized crates, when one wants to start using an RNG for encrypting and stuff.

What I would like to see somewhere (just noting from my lazy chair) is that for many algorithms and situations it is good to be unpredictable. That is what I see as the reason for including CSPRNGs. We should make it that they are not only a good idea for some corner of problems, but are a good choice for many situations that are seemingly security-unrelated. Most things that are somehow using an RNG in a situation that can be influenced by users, do well using one. One example is the standard library's HashMap, another something like random-pivot quicksort from the PCG blog.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rand is not intended to be used for encryption directly (although there isn't much reason various generators couldn't be used as stream ciphers; just initialisation isn't standard), but I think Rand should be usable as a source of secrets — with caveats that (for now at least) the code hasn't had proper expert review and that currently we have limited means to mitigate side-channel attacks (which may or may not be improved upon).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BTW while this isn't intent to be a guide to cryptography I feel there are so many myths surrounding cryptography that it is worth trying to put people straight (e.g. distrust of CSPRNGs; the bigger problem is usually user-space PRNGs or poorly seeded PRNGs).

/// `/dev/random` is not better than `/dev/urandom` in most cases. However,
/// this means that `/dev/urandom` can yield somewhat predictable randomness
/// if the entropy pool is very small, such as immediately after first
/// booting. Linux 3.17 added the `getrandom(2)` system call which solves
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we should say a little less here, I am not sure this description is entirely up-to-date. Maybe we should just say that that the quality difference between /dev/random and /dev/urandom is a myth or at least outdated information. Making this a very short paragraph, as an addition to the list of system interfaces used.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's also about getrandom; I did consider just referring to the man page. It's just a cut-and-paste.

dhardy added 3 commits March 24, 2018 16:36
Better doc of features in both crates.
Update version req to 0.5.0-pre.0. More updates are needed for final 0.5.
@dhardy
Copy link
Member Author

dhardy commented Mar 24, 2018

Updated (rebased + 1 new commit).

I'm not sure what to do with the doc on OsRng.

Edit: still need to link stuff on that lib doc.

dhardy added 4 commits March 24, 2018 16:57
Note: links are predictive. Unfortunately example code is not included in
generated documentation, so we must link to the repo.
This uses relative paths between crates which works fine with locally-generated
documentation and should also with this:
https://rust-lang-nursery.github.io/rand/rand/index.html
@dhardy
Copy link
Member Author

dhardy commented Mar 24, 2018

I extracted the examples and fixed links, plus a couple of trivial fixes.

@pitdicker
Copy link
Contributor

Keeps getting better. Adding links was one of the things I wanted to suggest, but you did so already 👍. But I think you are not completely done with making changes, right?

@dhardy
Copy link
Member Author

dhardy commented Mar 24, 2018

What makes you say that? I don't know what to do with the OsRng comments.

@pitdicker
Copy link
Contributor

I did not mean to say that you should change any more things, more that that was the impression I got.

If it is up to me I'd say this is good to merge. Shall I try to take a stab at the documentation for OsRng?

To be honest I would like to see the change I suggested in #328 (comment). As a crate in the nursery, let's not sound to critical...

@pitdicker pitdicker mentioned this pull request Mar 25, 2018
@dhardy
Copy link
Member Author

dhardy commented Mar 25, 2018

No, I haven't any more changes. Go ahead and add your changes on top of this, or merge first if you like.

@pitdicker pitdicker merged commit b264f38 into rust-random:master Mar 25, 2018
@dhardy dhardy deleted the readme branch March 26, 2018 11:24
pitdicker added a commit that referenced this pull request Apr 4, 2018
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