updated comments
This commit is contained in:
+9
-11
@@ -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<String,String> {
|
||||
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<Stri
|
||||
Ok(res)
|
||||
}
|
||||
|
||||
// todo: we should add symbols, numbers, and Capitalization
|
||||
//
|
||||
// we can take a slice of "words" because we don't care about:
|
||||
// capacity, mutation (push/pop), allocation strategy
|
||||
// todo: haven't updated bits of entropy since adding capitalization, symbols and numbers
|
||||
// it will add a few, but not many since it's fairly predictable
|
||||
//
|
||||
// How many bits of entropy?
|
||||
// log2(104078) -> 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<String,String> {
|
||||
if config.phrases < 2 {
|
||||
|
||||
Reference in New Issue
Block a user