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

Use one PRNG even if user requests multiple passphrases #22

Closed
wants to merge 1 commit into from

Conversation

sts10
Copy link
Owner

@sts10 sts10 commented Nov 11, 2023

In my amateur research of CSPRNGs for #21, I came across some cryptographic notes of caution about generating many pseudo-random number generators (I'll try to find some of these links).

The current version of Phraze creats a CSPRNG for each passphrase the user requests. So for example, if the user runs phraze -n 5 to get 5 passphrases, Phraze creates 5 CSPRNGs, one for each.

In contrast, this PR has Phraze create one CSPRNG in main.rs and use that to generate all passphrases that the user might ask for.

I'm not yet sure which approach is more safe/secure, but like #21, I'm opening a PR as a question for research/comments/thoughts. Also, of course, it might not really be significant for Phraze.

@sts10
Copy link
Owner Author

sts10 commented Nov 11, 2023

This section from the Rust Rand Book on Parallel RNGs seems to imply that it's fine to use "a custom RNG per worker thread" or "per work unit". If we assume it's safe to think of each requested passphrase as a "work unit", Phraze existing approach of creating a "custom" generator for each passphrase is inline with a "suggested approach" from the Rand Book, which is good enough for me.

@sts10
Copy link
Owner Author

sts10 commented Nov 11, 2023

If we do end up doing this, I should move the PRNG creation to src/lib.rs, but we'll cross that bridge when we get there.

@sts10
Copy link
Owner Author

sts10 commented Nov 20, 2023

I think using multiple PRNGs is fine, from a security-perspective. Closing this without merging at this time.

@sts10 sts10 closed this Nov 20, 2023
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