Implement secure password generation #8

Closed
opened 2026-08-09 18:56:59 +00:00 by hugo · 1 comment
Owner

Objective

Implement cryptographically secure generate behavior.

Scope

  • Generate unbiased passwords from operating-system randomness with configured length and character sets.
  • Support default length, explicit length, --no-symbols/-n, --force/-f, and --in-place/-i.
  • Preserve all lines after the first for in-place generation.
  • Return a presentation action for normal, clipboard, or QR output and commit the encrypted result through Git.

Acceptance criteria

  • Reject zero, invalid lengths, empty/invalid character sets, and incompatible flags.
  • Tests prove every generated character belongs to the requested set and that in-place mode preserves remaining bytes exactly.
  • Failure or cancellation changes neither the entry nor Git history.

Prerequisites

Safe password-store core; embedded GPG-compatible cryptography; recipient policy.

## Objective Implement cryptographically secure `generate` behavior. ## Scope - Generate unbiased passwords from operating-system randomness with configured length and character sets. - Support default length, explicit length, `--no-symbols/-n`, `--force/-f`, and `--in-place/-i`. - Preserve all lines after the first for in-place generation. - Return a presentation action for normal, clipboard, or QR output and commit the encrypted result through Git. ## Acceptance criteria - Reject zero, invalid lengths, empty/invalid character sets, and incompatible flags. - Tests prove every generated character belongs to the requested set and that in-place mode preserves remaining bytes exactly. - Failure or cancellation changes neither the entry nor Git history. ## Prerequisites Safe password-store core; embedded GPG-compatible cryptography; recipient policy.
hugo added this to the 01 - Full Rust pass CLI parity milestone 2026-08-09 18:56:59 +00:00
hugo added the enhancement label 2026-08-09 18:56:59 +00:00
Author
Owner

Implemented and pushed in 834df46 (Implement secure password generation (#8)).

Implementation:

  • Added storage-owned GeneratorConfig with pass-compatible 25-character defaults, printable symbol/alphanumeric set, --no-symbols set, explicit/default lengths, and duplicate/control/empty-set validation.
  • Added fallible rejection sampling over OsRng for unbiased indexes at arbitrary set sizes; operating-system randomness failure is typed and occurs before mutation.
  • Added deterministic cryptographic RNG injection for compatibility tests.
  • Added --force/overwrite and --in-place behavior; in-place requires an existing entry and preserves the first newline and every following byte exactly.
  • Added typed terminal/clipboard/QR presentation actions while keeping generated passwords redacted and zeroizing.
  • Added destination recipient-policy encryption, atomic generation-specific writes, compatible Add generated password commit intent, and exact rollback on commit error.
  • Documented algorithms, validation, in-place semantics, presentation, and failure guarantees in docs/password-generation.md.

Issue-isolated verification:

  • cargo test -p ironstorage --test password_generation: 5 passed
  • Covers configured/default lengths and sets, every-character membership, no-symbols, all presentation actions, exact suffix preservation, invalid/zero/oversized lengths, empty/duplicate/control sets, incompatible flags, missing in-place target, overwrite decline, RNG failure, and commit rollback.

Required repository gates all passed:

  • cargo fmt --all -- --check
  • RUSTFLAGS=-D warnings cargo check --workspace --all-targets
  • cargo clippy --workspace --all-targets -- -D warnings
  • cargo test --workspace
Implemented and pushed in 834df46 (Implement secure password generation (#8)). Implementation: - Added storage-owned GeneratorConfig with pass-compatible 25-character defaults, printable symbol/alphanumeric set, --no-symbols set, explicit/default lengths, and duplicate/control/empty-set validation. - Added fallible rejection sampling over OsRng for unbiased indexes at arbitrary set sizes; operating-system randomness failure is typed and occurs before mutation. - Added deterministic cryptographic RNG injection for compatibility tests. - Added --force/overwrite and --in-place behavior; in-place requires an existing entry and preserves the first newline and every following byte exactly. - Added typed terminal/clipboard/QR presentation actions while keeping generated passwords redacted and zeroizing. - Added destination recipient-policy encryption, atomic generation-specific writes, compatible Add generated password commit intent, and exact rollback on commit error. - Documented algorithms, validation, in-place semantics, presentation, and failure guarantees in docs/password-generation.md. Issue-isolated verification: - cargo test -p ironstorage --test password_generation: 5 passed - Covers configured/default lengths and sets, every-character membership, no-symbols, all presentation actions, exact suffix preservation, invalid/zero/oversized lengths, empty/duplicate/control sets, incompatible flags, missing in-place target, overwrite decline, RNG failure, and commit rollback. Required repository gates all passed: - cargo fmt --all -- --check - RUSTFLAGS=-D warnings cargo check --workspace --all-targets - cargo clippy --workspace --all-targets -- -D warnings - cargo test --workspace
hugo closed this issue 2026-08-09 22:42:18 +00:00
Sign in to join this conversation.