rewrite password generation for more secure and convivial options #16
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
When I boot a GRML system with
ssh
(without arguments) right now, it generates a 8 character, hex password. Now, I'm not a cryptographer, but I believe that gives about 32 bits of entropy (log2(16)*8), roughly the equivalent of a 8 character, all lowercase, [a-z] password, which is now widely recognized to be extremely poor.That password is generated by dumping random bytes and piping them into hexdump, taking the first four bytes (hey, look, 32 bits again).
There are other routines in there: if pwgen, gpw, or apg are available, they are used. But pwgen was dropped from in 2009 (#511613), and gpw is not present at all.
apg is in GRML_FULL, but I would argue it fares as poorly as hexdump: with the given configuration, it also generates a 8 to 12 character, lowercase and digits "pronouncable" password. It's hard to estimate the damage the "pronouncable" algorithm does to the entropy, but even just relying on the 36 character possibilities (26 + 10), we end up with a meager 41 bits of entropy on those passwords.
In comparison, the passwords generated by diceware and xkcdpass each use 6 words from a ~8000 words dictionnary, which adds up to a whopping 77 bits of entropy, while still generating a rememberable password, much more than apg or pwgen.
If those are not available, we fall back to a much simpler routine: extract alphanumeric characters from /dev/urandom (non-depleting), and dump 28 characters, which gives us 167 bits of entropy.
I'm not directly proposing to install diceware or xkcdpass here yet, but I believe that would also be a nice addition (and I would deprecate apg).
That's a different discussion, however: let's get rid of 8-character passwords for now, first.