Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 4aac99fb47 | |||
| faa5d8dfc9 |
Generated
+4
-4
@@ -148,7 +148,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "custos-gen"
|
name = "custos-gen"
|
||||||
version = "0.2.0"
|
version = "0.2.1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"custos-vault",
|
"custos-vault",
|
||||||
"rand",
|
"rand",
|
||||||
@@ -159,11 +159,11 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "custos-qr"
|
name = "custos-qr"
|
||||||
version = "0.2.0"
|
version = "0.2.1"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "custos-totp"
|
name = "custos-totp"
|
||||||
version = "0.2.0"
|
version = "0.2.1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"custos-vault",
|
"custos-vault",
|
||||||
"data-encoding",
|
"data-encoding",
|
||||||
@@ -176,7 +176,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "custos-vault"
|
name = "custos-vault"
|
||||||
version = "0.2.0"
|
version = "0.2.1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"argon2",
|
"argon2",
|
||||||
"chacha20poly1305",
|
"chacha20poly1305",
|
||||||
|
|||||||
+1
-1
@@ -3,7 +3,7 @@ resolver = "3"
|
|||||||
members = ["crates/*"]
|
members = ["crates/*"]
|
||||||
|
|
||||||
[workspace.package]
|
[workspace.package]
|
||||||
version = "0.2.0"
|
version = "0.2.1"
|
||||||
edition = "2024"
|
edition = "2024"
|
||||||
license = "MPL-2.0"
|
license = "MPL-2.0"
|
||||||
repository = "https://gitea.marek-novak.cz/mnovak/CustosPublic"
|
repository = "https://gitea.marek-novak.cz/mnovak/CustosPublic"
|
||||||
|
|||||||
@@ -17,4 +17,4 @@ for what it does and does not protect. Report vulnerabilities as described in [`
|
|||||||
cargo test --workspace
|
cargo test --workspace
|
||||||
```
|
```
|
||||||
|
|
||||||
Licence: MPL-2.0. The EFF wordlist is CC BY 3.0 US (see `crates/custos-gen/wordlists/SOURCES.md`).
|
Licence: MPL-2.0. The memorable-password words come from the EFF wordlist (CC BY 3.0 US), filtered with the ESDB/SCOWL English dictionary (see `crates/custos-gen/wordlists/SOURCES.md`).
|
||||||
|
|||||||
@@ -48,23 +48,16 @@ const DIGITS: [char; 10] = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'];
|
|||||||
|
|
||||||
// ---------- word lists ----------
|
// ---------- word lists ----------
|
||||||
|
|
||||||
/// The EFF large wordlist (7,776 words), with its four hyphenated words made plain: the hyphen is
|
|
||||||
/// removed, and `yo-yo` (the list also has `yoyo`) becomes `yoyos`, so all 7,776 stay distinct.
|
|
||||||
pub static EFF_WORDS: LazyLock<Vec<String>> = LazyLock::new(|| {
|
|
||||||
include_str!("../wordlists/eff_large_wordlist.txt")
|
|
||||||
.lines()
|
|
||||||
.filter_map(|l| l.split('\t').nth(1))
|
|
||||||
.map(|w| match w.trim() {
|
|
||||||
"yo-yo" => "yoyos".to_owned(),
|
|
||||||
w => w.replace('-', ""),
|
|
||||||
})
|
|
||||||
.collect()
|
|
||||||
});
|
|
||||||
|
|
||||||
fn plain_list(text: &'static str) -> Vec<&'static str> {
|
fn plain_list(text: &'static str) -> Vec<&'static str> {
|
||||||
text.lines().filter(|l| !l.starts_with('#')).flat_map(str::split_whitespace).collect()
|
text.lines().filter(|l| !l.starts_with('#')).flat_map(str::split_whitespace).collect()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// The words of memorable passwords (7,322): the EFF large wordlist without the words a standard US
|
||||||
|
/// English spellchecker dictionary does not know (brand names, names, coinages, hyphenated words).
|
||||||
|
/// See `wordlists/SOURCES.md`.
|
||||||
|
pub static MEMORABLE_WORDS: LazyLock<Vec<&str>> =
|
||||||
|
LazyLock::new(|| plain_list(include_str!("../wordlists/memorable.txt")));
|
||||||
|
|
||||||
static NOUNS: LazyLock<Vec<&str>> = LazyLock::new(|| plain_list(include_str!("../wordlists/nouns.txt")));
|
static NOUNS: LazyLock<Vec<&str>> = LazyLock::new(|| plain_list(include_str!("../wordlists/nouns.txt")));
|
||||||
static ADJECTIVES: LazyLock<Vec<&str>> = LazyLock::new(|| plain_list(include_str!("../wordlists/adjectives.txt")));
|
static ADJECTIVES: LazyLock<Vec<&str>> = LazyLock::new(|| plain_list(include_str!("../wordlists/adjectives.txt")));
|
||||||
static VERBS: LazyLock<Vec<&str>> = LazyLock::new(|| plain_list(include_str!("../wordlists/verbs.txt")));
|
static VERBS: LazyLock<Vec<&str>> = LazyLock::new(|| plain_list(include_str!("../wordlists/verbs.txt")));
|
||||||
@@ -144,7 +137,7 @@ pub const MAX_WORDS: u8 = 10;
|
|||||||
/// Bits of entropy of a memorable password with these options.
|
/// Bits of entropy of a memorable password with these options.
|
||||||
pub fn memorable_entropy(o: &MemorableOptions) -> f64 {
|
pub fn memorable_entropy(o: &MemorableOptions) -> f64 {
|
||||||
let n = o.words.clamp(MIN_WORDS, MAX_WORDS) as f64;
|
let n = o.words.clamp(MIN_WORDS, MAX_WORDS) as f64;
|
||||||
let per_word = (EFF_WORDS.len() as f64).log2() + if o.digit_after_word { 10f64.log2() } else { 0.0 };
|
let per_word = (MEMORABLE_WORDS.len() as f64).log2() + if o.digit_after_word { 10f64.log2() } else { 0.0 };
|
||||||
n * per_word + (n - 1.0) * (o.separator.choices().len() as f64).log2()
|
n * per_word + (n - 1.0) * (o.separator.choices().len() as f64).log2()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -157,7 +150,7 @@ pub fn memorable(o: &MemorableOptions) -> Generated {
|
|||||||
if i > 0 {
|
if i > 0 {
|
||||||
out.push(pick(&seps));
|
out.push(pick(&seps));
|
||||||
}
|
}
|
||||||
let w = &EFF_WORDS[rng().random_range(0..EFF_WORDS.len())];
|
let w = pick(&MEMORABLE_WORDS);
|
||||||
if o.capitalize {
|
if o.capitalize {
|
||||||
out.push_str(&capitalize(w));
|
out.push_str(&capitalize(w));
|
||||||
} else {
|
} else {
|
||||||
@@ -376,6 +369,7 @@ pub fn nickname(title: &str, o: &NicknameOptions) -> Result<Generated, GenError>
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ---------- random, strict site, PIN ----------
|
// ---------- random, strict site, PIN ----------
|
||||||
|
// Only English letters A–Z/a–z, digits 0–9 and ASCII symbols: every keyboard layout can type them.
|
||||||
|
|
||||||
pub const RANDOM_SYMBOLS: &str = "!@#$%^&*()-_=+[]{};:,.?/~";
|
pub const RANDOM_SYMBOLS: &str = "!@#$%^&*()-_=+[]{};:,.?/~";
|
||||||
pub const LOOKALIKES: &str = "Il1O0o|";
|
pub const LOOKALIKES: &str = "Il1O0o|";
|
||||||
@@ -452,7 +446,8 @@ pub struct StrictOptions {
|
|||||||
pub upper: ClassRule,
|
pub upper: ClassRule,
|
||||||
pub digits: ClassRule,
|
pub digits: ClassRule,
|
||||||
pub symbols: ClassRule,
|
pub symbols: ClassRule,
|
||||||
/// The symbols the site accepts.
|
/// The symbols the site accepts. Only ASCII symbols count: letters, digits, spaces and anything
|
||||||
|
/// outside ASCII (`€`, `§`, `ž`) are ignored.
|
||||||
pub allowed_symbols: String,
|
pub allowed_symbols: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -471,8 +466,7 @@ impl Default for StrictOptions {
|
|||||||
|
|
||||||
pub fn strict(o: &StrictOptions) -> Result<Generated, GenError> {
|
pub fn strict(o: &StrictOptions) -> Result<Generated, GenError> {
|
||||||
let len = check_length(o.length)?;
|
let len = check_length(o.length)?;
|
||||||
let mut symbols: Vec<char> =
|
let mut symbols: Vec<char> = o.allowed_symbols.chars().filter(char::is_ascii_punctuation).collect();
|
||||||
o.allowed_symbols.chars().filter(|c| !c.is_alphanumeric() && !c.is_whitespace()).collect();
|
|
||||||
symbols.sort_unstable();
|
symbols.sort_unstable();
|
||||||
symbols.dedup();
|
symbols.dedup();
|
||||||
let rules = [
|
let rules = [
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
//! The mandatory generator tests (CLAUDE.md).
|
//! The mandatory generator tests (CLAUDE.md).
|
||||||
|
|
||||||
use custos_gen::{
|
use custos_gen::{
|
||||||
ClassRule, EFF_WORDS, MemorableOptions, NicknameOptions, RandomOptions, Separator, StrictOptions, WordKind,
|
ClassRule, MAX_LENGTH, MEMORABLE_WORDS, MemorableOptions, NicknameOptions, RandomOptions, Separator, StrictOptions,
|
||||||
memorable, memorable_entropy, nickname, nickname_parts, normalize_name, pin, random, strict,
|
WordKind, memorable, memorable_entropy, nickname, nickname_parts, normalize_name, pin, random, strict,
|
||||||
};
|
};
|
||||||
use regex::Regex;
|
use regex::Regex;
|
||||||
use std::collections::HashSet;
|
use std::collections::HashSet;
|
||||||
@@ -10,11 +10,24 @@ use std::collections::HashSet;
|
|||||||
const SAMPLES: usize = 10_000;
|
const SAMPLES: usize = 10_000;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn eff_list_is_complete_and_plain() {
|
fn memorable_words_are_real_english_words() {
|
||||||
assert_eq!(EFF_WORDS.len(), 7_776);
|
assert_eq!(MEMORABLE_WORDS.len(), 7_322);
|
||||||
let unique: HashSet<_> = EFF_WORDS.iter().collect();
|
let unique: HashSet<_> = MEMORABLE_WORDS.iter().collect();
|
||||||
assert_eq!(unique.len(), 7_776, "a word repeats after removing hyphens");
|
assert_eq!(unique.len(), 7_322);
|
||||||
assert!(EFF_WORDS.iter().all(|w| !w.is_empty() && w.bytes().all(|b| b.is_ascii_lowercase())));
|
assert!(MEMORABLE_WORDS.iter().all(|w| w.len() >= 3 && w.bytes().all(|b| b.is_ascii_lowercase())));
|
||||||
|
// Every word comes from the EFF list...
|
||||||
|
let eff: HashSet<&str> = include_str!("../wordlists/eff_large_wordlist.txt")
|
||||||
|
.lines()
|
||||||
|
.filter_map(|l| l.split('\t').nth(1))
|
||||||
|
.map(str::trim)
|
||||||
|
.collect();
|
||||||
|
assert!(MEMORABLE_WORDS.iter().all(|w| eff.contains(w)));
|
||||||
|
// ...minus brand names, names, coinages and hyphenated words that no dictionary lists.
|
||||||
|
for not_a_word in ["walmart", "iphone", "skype", "myspace", "monday", "december", "pranker", "finlike", "felt-tip"]
|
||||||
|
{
|
||||||
|
assert!(eff.contains(not_a_word), "{not_a_word} is not in the EFF list any more");
|
||||||
|
assert!(!MEMORABLE_WORDS.contains(¬_a_word), "{not_a_word}");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@@ -57,7 +70,7 @@ fn memorable_shape_at_every_slider_value_and_option() {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn memorable_entropy_counts_only_random_choices() {
|
fn memorable_entropy_counts_only_random_choices() {
|
||||||
let per_word = 7_776f64.log2() + 10f64.log2();
|
let per_word = 7_322f64.log2() + 10f64.log2();
|
||||||
for words in 3..=10u8 {
|
for words in 3..=10u8 {
|
||||||
let o = MemorableOptions { words, ..Default::default() };
|
let o = MemorableOptions { words, ..Default::default() };
|
||||||
let e = memorable_entropy(&o);
|
let e = memorable_entropy(&o);
|
||||||
@@ -70,7 +83,7 @@ fn memorable_entropy_counts_only_random_choices() {
|
|||||||
let four = memorable_entropy(&MemorableOptions::default());
|
let four = memorable_entropy(&MemorableOptions::default());
|
||||||
assert!((64.0..66.0).contains(&four), "4 words with digits is about 65 bits: {four}");
|
assert!((64.0..66.0).contains(&four), "4 words with digits is about 65 bits: {four}");
|
||||||
let no_digits = MemorableOptions { digit_after_word: false, ..Default::default() };
|
let no_digits = MemorableOptions { digit_after_word: false, ..Default::default() };
|
||||||
assert!((memorable_entropy(&no_digits) - 4.0 * 7_776f64.log2()).abs() < 1e-9);
|
assert!((memorable_entropy(&no_digits) - 4.0 * 7_322f64.log2()).abs() < 1e-9);
|
||||||
// A random-digit separator is a random choice per gap.
|
// A random-digit separator is a random choice per gap.
|
||||||
let digit_sep = MemorableOptions { separator: Separator::Digit, ..Default::default() };
|
let digit_sep = MemorableOptions { separator: Separator::Digit, ..Default::default() };
|
||||||
assert!((memorable_entropy(&digit_sep) - (four + 3.0 * 10f64.log2())).abs() < 1e-9);
|
assert!((memorable_entropy(&digit_sep) - (four + 3.0 * 10f64.log2())).abs() < 1e-9);
|
||||||
@@ -234,6 +247,24 @@ fn random_and_pin() {
|
|||||||
assert!((p.entropy_bits - 6.0 * 10f64.log2()).abs() < 1e-9);
|
assert!((p.entropy_bits - 6.0 * 10f64.log2()).abs() < 1e-9);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn random_and_strict_use_only_english_letters_digits_and_ascii_symbols() {
|
||||||
|
let ok = |c: char| c.is_ascii_alphanumeric() || c.is_ascii_punctuation();
|
||||||
|
let all = RandomOptions { length: MAX_LENGTH, ..RandomOptions::default() };
|
||||||
|
for _ in 0..SAMPLES / 10 {
|
||||||
|
let s = random(&all).unwrap().value.expose().to_owned();
|
||||||
|
assert!(s.chars().all(ok), "{s}");
|
||||||
|
}
|
||||||
|
// Symbols the site lists outside ASCII, letters, digits and spaces are ignored.
|
||||||
|
let o = StrictOptions { length: 32, allowed_symbols: "€§ž é1!".into(), ..StrictOptions::default() };
|
||||||
|
for _ in 0..SAMPLES / 10 {
|
||||||
|
let s = strict(&o).unwrap().value.expose().to_owned();
|
||||||
|
assert!(s.chars().all(|c| c.is_ascii_alphanumeric() || c == '!'), "{s}");
|
||||||
|
}
|
||||||
|
let none_left = StrictOptions { allowed_symbols: "€§".into(), ..StrictOptions::default() };
|
||||||
|
assert!(strict(&none_left).is_err(), "required symbols, but none of the listed ones is ASCII");
|
||||||
|
}
|
||||||
|
|
||||||
/// Nicknames (≈ 30 000 combinations by design: they are names, not secrets) and short PINs are
|
/// Nicknames (≈ 30 000 combinations by design: they are names, not secrets) and short PINs are
|
||||||
/// excluded: their spaces are small enough that repeats in 10 000 draws are expected.
|
/// excluded: their spaces are small enough that repeats in 10 000 draws are expected.
|
||||||
#[test]
|
#[test]
|
||||||
|
|||||||
@@ -2,14 +2,28 @@
|
|||||||
|
|
||||||
| File | Used for | Source | Licence |
|
| File | Used for | Source | Licence |
|
||||||
|:--|:--|:--|:--|
|
|:--|:--|:--|:--|
|
||||||
| `eff_large_wordlist.txt` | Memorable passwords (7,776 words, 12.925 bits each) | Electronic Frontier Foundation, "Deep Dive: EFF's New Wordlists for Random Passphrases" (2016), downloaded unchanged from https://www.eff.org/files/2016/07/18/eff_large_wordlist.txt (sha256 `addd35536511597a02fa0a9ff1e5284677b8883b83e986e43f15a3db996b903e`) | CC BY 3.0 US. Attribution: © Electronic Frontier Foundation. |
|
| `eff_large_wordlist.txt` | The source of `memorable.txt` (kept as published) | Electronic Frontier Foundation, "Deep Dive: EFF's New Wordlists for Random Passphrases" (2016), downloaded unchanged from https://www.eff.org/files/2016/07/18/eff_large_wordlist.txt (sha256 `addd35536511597a02fa0a9ff1e5284677b8883b83e986e43f15a3db996b903e`) | CC BY 3.0 US. Attribution: © Electronic Frontier Foundation. |
|
||||||
|
| `memorable.txt` | Memorable passwords (7,322 words, 12.838 bits each) | The EFF list minus every word that SCOWL/ESDB size 60, US spelling (the size of hunspell's `en_US` dictionary) does not list as a plain lowercase word. Made by `derive_memorable.py` from https://app.aspell.net/create?max_size=60&spelling=US&max_variant=0&diacritic=strip&download=wordlist&encoding=utf-8&format=inline (ESDB revision 1e5b7d3, 2026-06-24; sha256 of the download `bfbc258a6baaa50aec6fe07330b25b57cd90f3dd429345b8280df0414ccf242c`) | CC BY 3.0 US (© Electronic Frontier Foundation), and the ESDB notice below |
|
||||||
| `nouns.txt`, `adjectives.txt`, `verbs.txt` | Nicknames (`{Word}`) | Written for Custos Domi in 2026 by hand: common, family-friendly English words | CC0 1.0 (public domain dedication) |
|
| `nouns.txt`, `adjectives.txt`, `verbs.txt` | Nicknames (`{Word}`) | Written for Custos Domi in 2026 by hand: common, family-friendly English words | CC0 1.0 (public domain dedication) |
|
||||||
|
|
||||||
## How they are used
|
## How they are used
|
||||||
|
|
||||||
- The EFF list file is kept as published. Four of its words contain a hyphen (`drop-down`, `felt-tip`,
|
- Memorable passwords use only real English words. The EFF list has brand names (`walmart`, `iphone`,
|
||||||
`t-shirt`, `yo-yo`); the generator removes the hyphen so every word is plain letters (`dropdown`, …).
|
`skype`), names (`monday`, `december`), coinages (`pranker`, `finlike`) and four hyphenated words
|
||||||
`yoyo` is already in the list, so `yo-yo` becomes `yoyos` instead. All 7,776 words stay distinct (tested),
|
(`felt-tip`, …); a word stays only if the standard US spellchecker dictionary knows it. 454 words go,
|
||||||
so each word is still worth log2(7,776) bits.
|
7,322 stay (tested, with examples), so each word is worth log2(7,322) = 12.838 bits instead of 12.925.
|
||||||
|
- To rebuild `memorable.txt`, download the URL above and run `python derive_memorable.py <file>`.
|
||||||
- The nickname lists are not secret material: a nickname is a name, not a password. They are kept short,
|
- The nickname lists are not secret material: a nickname is a name, not a password. They are kept short,
|
||||||
friendly and unique (tested), and each word has at least three letters.
|
friendly and unique (tested), and each word has at least three letters.
|
||||||
|
|
||||||
|
## ESDB (SCOWL) notice
|
||||||
|
|
||||||
|
Copyright 2000-2026 by Kevin Atkinson
|
||||||
|
|
||||||
|
Permission to use, copy, modify, distribute, and sell any part of the English
|
||||||
|
Speller Database (ESDB, previously known as SCOWLv2), or word lists
|
||||||
|
created from it, is hereby granted without fee, provided that the above
|
||||||
|
copyright notice appears in all copies and that both the above copyright
|
||||||
|
notice and this notice appear in supporting documentation. Kevin Atkinson
|
||||||
|
makes no representations about the suitability of this database for any
|
||||||
|
purpose. It is provided "as is" without express or implied warranty.
|
||||||
|
|||||||
@@ -0,0 +1,24 @@
|
|||||||
|
"""Rebuilds memorable.txt: the EFF large wordlist minus every word that the standard US English
|
||||||
|
spellchecker dictionary (SCOWL/ESDB size 60, the size of hunspell's en_US) does not list as a plain
|
||||||
|
lowercase word. That removes brand names (walmart), names and capitalised words (monday) and coinages
|
||||||
|
(pranker). See SOURCES.md for the exact download.
|
||||||
|
|
||||||
|
python derive_memorable.py <scowl-size-60.txt>
|
||||||
|
"""
|
||||||
|
|
||||||
|
import sys
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
here = Path(__file__).parent
|
||||||
|
scowl = Path(sys.argv[1]).read_text(encoding="utf-8")
|
||||||
|
dictionary = set(scowl.split("---", 1)[1].split())
|
||||||
|
eff = [line.split("\t")[1].strip() for line in (here / "eff_large_wordlist.txt").read_text().splitlines()]
|
||||||
|
kept = [w for w in eff if w in dictionary]
|
||||||
|
|
||||||
|
header = """\
|
||||||
|
# Memorable-password words: the EFF large wordlist (CC BY 3.0 US, (c) Electronic Frontier Foundation)
|
||||||
|
# minus the words not in SCOWL/ESDB size 60 (US). Word list (c) 2000-2026 by Kevin Atkinson, see SOURCES.md.
|
||||||
|
# Generated by derive_memorable.py; do not edit by hand.
|
||||||
|
"""
|
||||||
|
(here / "memorable.txt").write_text(header + "\n".join(kept) + "\n", encoding="utf-8", newline="\n")
|
||||||
|
print(f"kept {len(kept)} of {len(eff)}")
|
||||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user