-
Notifications
You must be signed in to change notification settings - Fork 432
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
README: rand is not a crypto library #1514
Conversation
I think it's worth to explicitly state that |
/// - Not to leak internal state through [`Debug`] or serialization | ||
/// implementations. | ||
/// - No further protections exist to in-memory state. In particular, the | ||
/// implementation is not required to zero memory on exit (of the process or |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just curious.. is that because it's onerous to implement or causes a performance hit or something else?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
zeroize
? It's just not been done (so far). It has been implemented by the chacha20
crate, so we gain this feature when we switch (with a little adjustment to ThreadRng
).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These are useful clarifications that address the substance of #1358. Thanks for working through these.
Co-authored-by: Dan <[email protected]>
Co-authored-by: Dan <[email protected]>
Thanks for the review! |
README.md
Outdated
[`zeroize`](https://crates.io/crates/zeroize) used buffers and generators. | ||
We do not automatically reseed on fork (see | ||
[`ThreadRng`](https://docs.rs/rand/latest/rand/rngs/struct.ThreadRng.html)). | ||
Rand cannot provide any guarantees of security. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we can recommend using getrandom
directly if you need guarantees? Most crypto applications don't need a userspace CSPRNG, and I think this is what crypto libraries like ring do.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The current text is broken:
Rand cannot provide any guarantees of security. which retrieves random data from (operating) system sources without a local memory buffer.
Also you already stated that "Rand is not a cryptographic library and cannot provide guarantees of security" in the first sentence of this paragraph, so here you have a needless duplication.
In any case we should not forget to also update or remove the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The wording is a bit too conservative for my taste, but I guess it's fine.
Maybe we could move ThreadRng
into a separate crate and use slightly less scary wording in it? This also could help cryptographic crates that would like to use ThreadRng
, but do not want to pull the whole rand
for it.
README.md
Outdated
[`zeroize`](https://crates.io/crates/zeroize) used buffers and generators. | ||
We do not automatically reseed on fork (see | ||
[`ThreadRng`](https://docs.rs/rand/latest/rand/rngs/struct.ThreadRng.html)). | ||
Rand cannot provide any guarantees of security. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The current text is broken:
Rand cannot provide any guarantees of security. which retrieves random data from (operating) system sources without a local memory buffer.
Also you already stated that "Rand is not a cryptographic library and cannot provide guarantees of security" in the first sentence of this paragraph, so here you have a needless duplication.
Are there specific cases where the wording is too conservative (besides the "cannot provide guarantees of security" disclaimer)? We discussed moving |
It's a big disclaimer. Users may (rightfully) interpret it as "
I don't think so, at very least, I can not name a cryptographic library that depends on |
Moving Yes, it is a big disclaimer. Updated. |
To my understanding, APIs like |
@vks though I generally prefer |
@vks |
So we're okay with this as-is? I updated again after @newpavlov's last comment on the disclaimer. |
Closes #1358 by documenting what Rand is not.