Skip to content

Latest commit

 

History

8 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

passmake

passmake is a tiny, Linux-first command-line password generator written in C. It prints a cryptographically secure alphanumeric password using uppercase letters, lowercase letters, and numbers. The same source also builds natively on macOS.

The normal generation path writes only the password to stdout. Warnings and errors go to stderr. Help, version, and security text are printed only when explicitly requested.

There are no third-party runtime or cryptography dependencies. In particular, passmake does not use libbsd or require packages from FreeBSD.

Requirements

  • A C11 compiler (cc, GCC, or Clang)
  • make
  • Standard POSIX build tools (install, mkdir, and a POSIX shell)

On Linux, secure randomness comes from getrandom(2), with /dev/urandom as a compatibility fallback. On macOS, it comes from getentropy(2), with the same fallback.

Build

make

That creates ./passmake.

Run the full built-in test suite:

make check

Remove the executable and build products:

make clean

Install the binary:

sudo make install

Install somewhere else:

make PREFIX="$HOME/.local" install

Usage

Generate the default 24-character password:

./passmake

Generate a specific length:

./passmake 24
./passmake 32

Use named length options if desired:

./passmake --length 24
./passmake --length=24

--count is accepted as a compatibility alias:

./passmake --count 24
./passmake --count=24

Suppress the default trailing newline:

./passmake 24 --no-newline

This is useful when piping into clipboard tools:

./passmake 24 --no-newline | your-clipboard-command

Show help, version, or the security explanation:

./passmake --help
./passmake --version
./passmake --security

Arguments after -- are treated as positional values:

./passmake -- 24

Lengths

  • Default length: 24 characters.
  • Recommended website password length: 24 or more characters.
  • Valid range: 3 to 4096 characters.
  • Lengths below 12 are allowed but warn to stderr unless --quiet is used.
  • The minimum length is mechanical, not recommended. It exists only because the program enforces at least one uppercase letter, one lowercase letter, and one digit.

Security

  • Linux uses the kernel CSPRNG through getrandom(2).
  • macOS uses the operating-system CSPRNG through getentropy(2).
  • /dev/urandom is used only as a compatibility fallback.
  • The alphabet is intentionally alphanumeric: A-Z, a-z, and 0-9.
  • Rejection sampling avoids modulo bias when mapping random bytes to characters.
  • Whole-password rejection keeps output uniform over the subset of alphanumeric strings that satisfy the uppercase, lowercase, and digit requirement.
  • Password output uses unbuffered descriptor writes so the password is not copied into a libc-managed stdout buffer.
  • Random-byte and password buffers are cleared before exit.
  • Core dumps are disabled during password generation where supported.
  • Password memory is locked against swapping when the operating system permits it. Failure to lock memory does not prevent generation.

Printing to a terminal can leave the password visible in terminal scrollback. passmake does not put generated passwords in shell history by itself, but command substitution, environment variables, clipboards, or manual handling can expose them. Avoid storing generated passwords in environment variables, and store generated passwords in a password manager.

Exit Status

  • 0: success
  • 2: usage or argument error
  • 3: randomness or generation failure
  • 4: memory allocation failure
  • 5: stdout write failure

Implementation

The implementation is intentionally small but no longer monolithic:

  • src/cli.c parses the stable command-line interface and prints diagnostics.
  • src/entropy.c contains the native Linux/macOS entropy backends and fallback.
  • src/generator.c performs unbiased character and whole-password sampling.
  • src/platform.c owns memory wiping, process hardening, and descriptor output.
  • src/main.c coordinates the lifecycle and guarantees cleanup.
  • tests/ covers the documented CLI, error codes, output separation, generator internals, output failures, and staged installation.

About

A simple, powerful, and cryptographically sound password generator

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages