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

[bug] random.string function does not use rand_chacha::ChaCha20Rng #774

Open
Cictrone opened this issue May 12, 2024 · 2 comments · May be fixed by #777
Open

[bug] random.string function does not use rand_chacha::ChaCha20Rng #774

Cictrone opened this issue May 12, 2024 · 2 comments · May be fixed by #777
Assignees
Labels
bug Something isn't working

Comments

@Cictrone
Copy link
Collaborator

Describe the bug
Although rand::thread_rng seems to be good for most use cases it has not undergone the same level of scrutiny as rand_chacha::ChaCha20Rng which is why we chose it for random.bool and random.int. As we are trying to allow for the random library to be cryptographically secure we should try to collapse to just rand_chacha::ChaCha20Rng.

Additional context
https://rust-random.github.io/book/guide-gen.html#cryptographically-secure-pseudo-random-number-generator
https://rust-random.github.io/rand/rand_chacha/struct.ChaCha20Rng.html

@Cictrone Cictrone added the bug Something isn't working label May 12, 2024
@flemingcaleb
Copy link
Collaborator

As mentioned on the MR, its my understanding of the documentation of StdRng here that it uses ChaCha20 internally and is cryptographically equivalent but with the added benefit of periodic reseeding. I'm happy to make the change if wanted, but I do think it's worth considering staying with the default configuration if it is equally secure. That way if there is a change in the future to address some issue we will automatically inherit the change once it hits the standard library instead of needing to make internal modifications.

@Cictrone
Copy link
Collaborator Author

I do think we want this change. ChaCha20Rng is a standard way to operate a CSPRNG and StdRng just does not make that guarantee/promise.

@flemingcaleb flemingcaleb linked a pull request May 25, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants