From 383a1a2b8b3244abbe49140646248060c35da731 Mon Sep 17 00:00:00 2001 From: Ed Guloien Date: Thu, 23 Apr 2026 16:08:11 -0400 Subject: [PATCH] updated comments --- src/main.rs | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/src/main.rs b/src/main.rs index ec0d7bf..29c422b 100644 --- a/src/main.rs +++ b/src/main.rs @@ -157,13 +157,9 @@ fn random_ascii(rng: &mut impl Rng, char_set: &[u8]) -> u8 { *char_set.choose(rng).expect("char_set should not be empty") } -// todo: does not guarantee that a password will contain the necessary chars -// -// How many bits of entropy? -// max_chars_available -> 80 -// log2(possible_symbols^len) yields bits of entropy -// so say len is 20 and we use all 80 chars: -// that's log2(80^20) -> 126.4 bits of entropy per password +// returns error if generated password doesn't contain the necessary chars +// to satisfy the policy +// let the caller decide what to do fn generate_password(config: &PasswordConfig, rng: &mut impl Rng) -> Result { if config.len < 8 { return Err(String::from("Password length not long enough")); @@ -200,15 +196,17 @@ fn generate_password(config: &PasswordConfig, rng: &mut impl Rng) -> Result 16.6 bits per word derived from word_list size // log2(18) -> 4.1 bits for separator assuming seporator is one of our SYMBOLs // total 70.5 bits of entropy +// note: dictionary is provided by linux, so entropy is platform dependent ATM +// +// we can take a slice of "words" because we don't care about: +// capacity, mutation (push/pop), allocation strategy fn generate_passphrase(config: &PassphraseConfig, word_list: &[&str], rng: &mut impl Rng) -> Result { if config.phrases < 2 {