Randomness

Where Passgen gets its random data from, and how to change it.

Passgen needs secure random data to generate sequences. By default, it uses the best source of randomness available on the system:

These pool randomness from various sources, such as jitter, interrupt timings and the random number generator built into the CPU.

Other sources

The --random flag selects a different source of randomness. Some sources take an argument.

SourceDescription
systemThe system random number generator. This is the default.
file:/path/to/fileReads random data from the given file. This can be a device, such as /dev/random or a hardware randomness generator.
master:VERSION:LEVEL:PASS:SEED:DOMAIN:USERWhat master-passphrase mode uses, without needing a configuration.
chacha20:KEY[:IV]The ChaCha20 stream cipher. The key is 64 hex digits, and the optional initialization vector is 16.
xorshift:SEEDXorshift, seeded with a number from 1 to 264-1. Produces very poor quality randomness.
zeroReturns only zeroes instead of random data. Only useful for testing.

For deterministic output that is still secure, use a master passphrase instead.

The master source

The master source generates the same as --master, with everything given on the command line instead of in the configuration:

$ passgen -r 'master:1:2:mymasterpass::example.com:username' -p apple2
eINh6m-RhafGJ-JgiKM0

All six fields have to be there. The seed, the domain and the user can be empty, as the seed is here. The seed is written in hex. A colon or a backslash inside a field is written as \: or \\.

Before 0.5.0, this source was called chacha20-argon2. It no longer exists, and master generates different passphrases.

Streams and offsets

The master, chacha20, xorshift and zero sources are deterministic: the same source always gives the same output. Each of them has many independent streams of random data, numbered from 0.

With --amount, every sequence is generated from its own stream. The first comes from stream 0, the second from stream 1, and so on. A sequence therefore only depends on its number, and not on the sequences before it.

With --offset N, Passgen starts at stream N instead of 0. So --offset 2 generates what the third sequence of --amount 3 is:

$ passgen -r xorshift:1 -a 3 '[a-z]{8}'
kgkrcixk
bbjffbrn
vosbtqbt
$ passgen -r xorshift:1 --offset 2 '[a-z]{8}'
vosbtqbt

The system and files have no streams, so --offset cannot be used with them.

Before 0.5.0, all sequences came from a single stream. With --amount, every sequence after the first one is different from what older versions generated.