Skip to content
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

chacha20: remove Clone impls on RNGs #220

Merged
merged 1 commit into from
Mar 16, 2021

Conversation

tarcieri
Copy link
Member

Removes derive(Clone) on ChaCha*Rng*.

They date back to the original PR which added RNG support (#63).

Allowing Clone on an RNG is problematic because the cloned RNG will have the same internal state, duplicating outputs which can be catastrophic in a cryptographic context.

Instead, the SeedableRng::from_rng method can be used to "fork" one RNG from another, seeing a new RNG with an output from another:

https://docs.rs/rand_core/0.6.2/rand_core/trait.SeedableRng.html#method.from_rng

Removes `derive(Clone)` on `ChaCha*Rng*`.

They date back to the original PR which added RNG support (#63).

Allowing `Clone` on an RNG is problematic because the cloned RNG will
have the same internal state, duplicating outputs which can be
catastrophic in a cryptographic context.

Instead, the `SeedableRng::from_rng` method can be used to "fork" one
RNG from another, seeing a new RNG with an output from another:

https://docs.rs/rand_core/0.6.2/rand_core/trait.SeedableRng.html#method.from_rng
@tarcieri tarcieri merged commit ba7d695 into master Mar 16, 2021
@tarcieri tarcieri deleted the chacha20/remove-rng-clone-impls branch March 16, 2021 14:43
@tarcieri tarcieri mentioned this pull request Apr 29, 2021
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.

1 participant