{{Header}} {{#seo: |description=Generating Strong Passwords |image=Passwords2132341.jpg }} {{passwords_mininav}} {{Contributor| |status=stable |about=About this {{Code2|{{PAGENAME}}}} Page |difficulty=easy |contributor=[https://forums.whonix.org/users/hulahoop HulaHoop] |support=[[Support]] }} [[File:Passwords2132341.jpg|thumb]] {{intro| Generating Strong Passwords }} = Introduction = {{mbox | image = [[File:Ambox_warning_pn.svg.png|40px]] | text = '''Warning:''' In 2013, nation-state adversaries were supposedly capable of one trillion guesses per second when attempting to brute-force passwords. https://theintercept.com/2015/03/26/passphrases-can-memorize-attackers-cant-guess/ Considering Moore's Law it could have only improved since. https://web.archive.org/web/20170203020112/https://www.password-depot.com/know-how/brute-force-attacks.htm }} If weak passwords (passphrases) are used, they will be easily discovered by trying every possible character combination in reasonable time through [https://en.wikipedia.org/wiki/Brute-force_attack brute-force attacks]. This method is very fast for short and/or non-random passwords. This chapter discusses: * How to calculate entropy for both pre-quantum and post-quantum strength; * Estimating the brute force time for passwords of different length; * Key-stretching measures which help to make password length manageable in a post-quantum world; and * Principles for stronger passwords. = Generating Unbreakable Passwords = == Introduction == To generate strong passwords that are both easy to remember and have an easily calculatable large entropy, it is advised to use the Diceware package. Instead of generating a random sequence containing alphanumerical and special characters, Diceware selects a sequence of words equiprobably from a list containing several thousand that have been curated for their memorability, length and profanity. Passwords that are long enough should be safe for millions or billions of years, even if the list chosen is known to the attacker. This relies on the fact that the time taken to try all possible combinations would be infeasibly large, even for a well-equipped adversary. https://en.wikipedia.org/wiki/Diceware https://en.wikipedia.org/wiki/Password_strength#Random_passwords == Diceware Password Strength == When determining appropriate password length, ideally it should have at least as much entropy as the bit length of the symmetric key that is derived from it. https://www.whonix.org/pipermail/whonix-devel/2018-August/001184.html As will be explained later, one can deviate from this rule to have a shorter password while still having a realistically strong protection level. The entropy type referred to throughout this page is Shannon Entropy. The concept of Min-entropy https://crypto.stackexchange.com/questions/66097/why-is-min-entropy-significant-in-cryptography measures the worst case lower bound of passphrase entropy in case of diceware generating words that have semantic meaning as a sentence or short passphrases whose character length can be easily brute-forced. This in practice is extremely unlikely and is detectable by the user and in the latter case a recommended number of words is advised to mitigate this risk. https://www.whonix.org/pipermail/whonix-devel/2019-December/001487.html [https://theworld.com/~reinhold/dicewarefaq.html#entropy Entropy] per word is calculated by dividing log of number of words in list by log 2. List lengths vary. EFF list:
log (7776) / log (2) = 12.92 bits
SecureDrop list:
log (6800) / log (2) = 12.73 bits
Total password entropy is:
number of words * entropy per word
There are 32 special characters on a standard U.S. keyboard:
log (32) / log (2) = 5 bits per character
Alternatively, an alphanumeric string using lower/uppercase will have 62 characters in the set:
log (62) / log (2) = 5.95 bits per character
The relationship between entropy and the length of the diceware password is outlined below. '''Table:''' ''Diceware Password Strength'' https://www.rempe.us/diceware/#eff {| class="wikitable" |- ! scope="col"| Word Total ! scope="col"| Bits of Entropy ! scope="col"| Estimated Brute-force Time (Classical Computing) One trillion guesses per second. ! scope="col"| Future-proof Safety Safe until at least the year 2050. ! scope="col"| [[PQCrypto|Post-quantum]] Secure Assuming [https://en.wikipedia.org/wiki/Grover%27s_algorithm Grover's algorithm] halves the number of iterations required to brute-force a key. This means doubling the length of symmetric keys to protect against future (hypothetical) quantum attacks. |- ! scope="row"| Five | ~64 | ~165 days | {{No}} | {{No}} |- ! scope="row"| Six | ~78 | ~3,505 years | style="background-color: {{Yellow}}" | Maybe | {{No}} |- ! scope="row"| Seven | ~90 | ~27,256 millennia | {{Yes}} | {{No}} |- ! scope="row"| Eight | ~103 | ~15 x age Universe | {{Yes}} | {{No}} |- ! scope="row"| Nine | ~116 | ~119,441 x age Universe | {{Yes}} | {{No}} |- ! scope="row"| Ten | ~129 | ~928,773,415 x age Universe | {{Yes}} | {{No}} |- ! scope="row"| Fifteen | ~194 | ~26,405,295,715,806,668,059,525,829,264 x age Universe | {{Yes}} | {{Yes}} |- ! scope="row" | Twenty | ~259 | ~750,710,162,715,852,378,145,230,792,130,183,941,981,164,925,924 x age Universe | {{Yes}} | {{Yes}} |- |} == Calculating Brute-force Time == [https://en.wikipedia.org/wiki/Moore%27s_law Moore's Law] predicts the doubling of number of on-die transistors every 24 months (two years). Other estimates by the industry put that at 18 months. It is expected that Moore's Law ends by 2025 because of physical constraints of silicon. 1 trillion guesses in 2013 = 240 operations. Lower bound - Doubling every 24 months 2013-2025:
246
Upper bound - Every 18 months 2013-2025:
248
To gauge strength against adversary capabilities, an example 80-bit password versus an adversary capable of 1 trillion or (240 guesses per second):
2(80-40) = 240 seconds
Which is then divided by 31536000 seconds / year to get the number of years. https://security.stackexchange.com/questions/69374/is-an-80-bit-password-good-enough-for-all-practical-purposes/69378 https://security.stackexchange.com/questions/69374/is-an-80-bit-password-good-enough-for-all-practical-purposes/115397#115397 == Classical vs Quantum Computing == === Classical Computing Attack === * 7-word diceware passphrases are recommended, yielding ~90 bits of entropy against classical computing attacks. https://theintercept.com/2015/03/26/passphrases-can-memorize-attackers-cant-guess/ * 10-word diceware passphrases provide 128 bits of entropy. === Quantum Computing Attack === * Grover’s quantum search algorithm halves the key search space, so all entropy values in the table above are halved on quantum computers. For example, the cost of searching for the right 2128 passphrase drops to (very) roughly ~264. https://www.whonix.org/pipermail/whonix-devel/2018-August/001184.html * A 20-word passphrase with 2256 bit entropy today, yields 128-bit post-quantum protection. * Quantum computers do not impact the entropy provided by key-stretching algorithms. See below. https://www.whonix.org/pipermail/whonix-devel/2018-August/001215.html = Key-Stretching = Depending on how it is implemented, key-stretching introduces a major speed-bump for brute-forcing as it forces an adversary to undergo extra steps compared to processing vanilla, symmetric, master encryption keys. They allow passwords to be shorter while adding a certain entropy security margin. Note this does not help if bad passwords are chosen. Passwords for LUKS FDE are secured using a key-stretching implementation known as a Password-Based Key Derivation Function (PBKDF). The older HMAC-SHA* algorithm is less effective against parallelization by GPUs and ASICs -- the same weaknesses suffered by Bitcoin against dedicated mining hardware. Argon2id is the winner of the [https://en.wikipedia.org/wiki/Password_Hashing_Competition Password Hashing Competition] and the state-of-the-art hashing algorithm of choice when protecting encryption keys. Its memory-hard properties introduce a large penalty for brute-search on general computers and even more so on GPUs and ASICs. == Choosing Parameters == This is how to calculate entropy for Argon2id. An example https://www.whonix.org/pipermail/whonix-devel/2018-September/001255.html using arbitrary parameters is below: * 1 GiB RAM, 50 iterations and 4 threads * m=1GiB, t=50, p=4 The "20" comes from the exponent of 2 that gives the number of kibibytes that is used in 1 GiB RAM (220 = 1,048,576 kibibytes in this case). The number of 1 KiB block operations is most important. For 4 GiB, the exponent becomes "22" (222 = 4,194,304 kibibytes). '''General Computers "Lower Bound"'''
20 + (log (50) / log(2)) = ~26 bits
'''GPUs and ASICs "Upper Bound"'''
20 + (20 - (log (8*4) / log (2))) + (log (50) / log (2)) = ~41 bits
Subtracting the parallelism (8x within a block and 4x thread-level p=4), because for this sort of attack the parallelism reduces the duration for which the memory has to be occupied. '''Comments'''
Then, I think t=50 is excessive.  It isn't even the equivalent of a one
word longer passphrase, but it takes more time than typing a word would.

Perhaps you should consider t=3.  That will be only "4 bits" less,
giving you something like 22 to 40 bits (depending on attack hardware)
of stretching relative to BLAKE2b.

--SolarDesigner (OpenWall lead and cryptographer who participated in the Password Hashing Competition)
== Migrating LUKS FDE to Argon2id == These steps migrate systems which are currently encrypted with LUKS first from a LUKS1 to LUKS2 header, then shift to Argon2id. Removable media migration should be straightforward, however the main running system will require extra pre-boot steps because an open encrypted volume cannot be modified. https://web.archive.org/web/20200429150924/https://www.saout.de/pipermail/dm-crypt/2018-September/005974.html Take precautions such as backing up your data and make a copy of the required steps since they will be inaccessible during part of the process. {{Box|text= '''1.''' Enumerate all devices to determine partition name. {{CodeSelect|code= # ls /dev/ }} '''2.''' Verify the partition in question is an encrypted one (typically sda5 on default, non-customized installs). {{CodeSelect|code= # blkid -p /dev/sda5 }} '''3.''' Inspect LUKS header details and confirm it was converted in the end. {{CodeSelect|code= # cryptsetup luksDump --debug /dev/sda5 }} '''4.''' Check kernel module availability. Before rebooting, it is advisable to check the ‘algif_skcipher’ kernel module is included in the initramfs image, otherwise it might not be possible to open LUKS2 volumes. See: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=896968 for details. To do so, run the following two commands:
# echo algif_skcipher | sudo tee -a /etc/initramfs-tools/modules
sudo update-initramfs -u
'''5.''' Reboot and convert the header. Now assuming the bootloader is GRUB: * Reboot. * Press to obtain an emacs-like screen. * Append “ break=premount” to the line starting with “linux”. * Press Ctrl+X to boot - the edit is transient and will not survive the next reboot (users should land into an initramfs debug shell). Convert the header to LUKS2: {{CodeSelect|code= cryptsetup convert /dev/sda5 --type luks2 --debug }} Then convert to Argon2id. Parameters used in this example: * 1 GiB RAM. * 50 iterations. * 4 threads. {{CodeSelect|code= cryptsetup luksConvertKey --key-slot 0 --pbkdf argon2id --pbkdf-force-iterations 50 --pbkdf-memory 1048576 --pbkdf-parallel 4 /dev/sda5 }} }} = Guidelines = == Argon2id Entropy Estimates == {{mbox | type = notice | image = [[File:Ambox_notice.png|40px|alt=Info]] | text = '''Tip:''' post-quantum era words are 6.46 bits each. }} For LUKS FDE where memorization is a burden (assuming EFF list and 26 bit Argon2id lower bound): * [post-quantum] 10 words + Argon2id = ~90 bits * [post-quantum] 11 words + Argon2id = ~97 bits * [post-quantum] 12 words + Argon2id = ~103 bits For LUKS FDE where memorization is a burden (assuming EFF list and 24 bit Argon2id lower bound for faster logins [configured by 4 GiB, 3 iterations, 4 threads]): * [post-quantum] 10 words + Argon2id = ~88 bits * [post-quantum] 11 words + Argon2id = ~95 bits * [post-quantum] 12 words + Argon2id = ~102 bits In summary, 12 words is the safest compromise, giving a comfortable security margin at mild cognitive expense. For any other encrypted media/container that does not implement Argon2id or where memory is not a problem because you can safely store the password on your encrypted computer: * [post-quantum] 20 words = 128 bits Alternatively if memorization is not a problem in the case of non-system media, a shorter alphanumeric string consisting of 43 characters will achieve 128-bit post-quantum strength: https://web.archive.org/web/20230326083435/https://pthree.org/2011/03/07/strong-passwords-need-entropy/ https://unix.stackexchange.com/questions/230673/how-to-generate-a-random-string
head /dev/random | tr -dc A-Za-z0-9 | head -c 43 ; echo ''
For usability makepasswd can be used instead. Its reliance on ''/dev/urandom'' https://packages.debian.org/stable/makepasswd is no cause for concern: https://web.archive.org/web/20230530100652/https://pthree.org/2014/07/21/the-linux-random-number-generator/ https://www.mail-archive.com/cryptography@randombit.net/msg04763.html https://security.stackexchange.com/questions/3936/is-a-rand-from-dev-urandom-secure-for-a-login-key/3939#3939 https://stackoverflow.com/questions/5635277/is-dev-random-considered-truly-random/5639631#5639631
makepasswd --chars 43
== Password Generation == For all practical purposes the Linux RNG is sufficient for selecting words in a random fashion. To go one step further, dice can be used to physically choose the diceware words. https://theworld.com/~reinhold/dicewarefaq.html The reason is the [https://www.insidescience.org/news/dice-rolls-are-not-completely-random outcome of a dice roll] is influenced by the physics of gravity, air resistance, torque applied, surface friction, the initial position of the die and other factors. High-friction surfaces are recommended, since dice tend to bounce more times in a chaotic fashion. Also see: [https://www.eff.org/dice EFF Dice-Generated Passphrases] and [https://www.eff.org/files/2016/07/18/eff_large_wordlist.txt EFF's Long Wordlist (.txt)]. The [https://packages.debian.org/diceware "diceware" package] is available in Debian. To generate a 12-word password from the EFF's list, run: {{CodeSelect|code= diceware -n 12 -w en_eff }} Follow this additional advice for Diceware passwords: * Diceware passwords should have spaces between each word, otherwise the strength of the password is materially weakened. For example, a six-word passphrase without spaces “stray clam my aloof micro judo” has the same strength as a five-word passphrase “stray clammy aloof micro judo” with spaces. * Only change passwords if a compromise is suspected. * Random character capitalization is not recommended. Although it adds 1 bit per character, it requires regular pressing of the shift key - slowing down typing and increasing the number of keystrokes. Instead, it is better to just make the password longer if additional entropy is required. == Principles for Stronger Passwords == The human mind is notoriously bad at coming up with truly random passwords: https://www.schneier.com/blog/archives/2017/05/nsa_brute-force.html#c6753142 https://security.stackexchange.com/questions/6095/xkcd-936-short-complex-password-or-long-dictionary-passphrase Second reply.
The last time I sat down to work out the statistics from known password lists the initial letter of a password/phrase had less than 4bits of entropy which rapidly dropped to less than 1.5bits by the seventh character, and dropping to a little over 1bit after ten characters. ... The simple fact is computers are now faster and more adept at password cracking than humans can think up memorable ways to remember strings of information that to humans look random..." --Clive Robinson
Users should read [https://en.wikipedia.org/wiki/Password_strength#Examples_of_weak_passwords Wikipedia: Weak Passwords] to learn about better practices for generating strong passwords and to determine if current passwords are weak.. The general principles for stronger passwords are outlined below. https://en.wikipedia.org/wiki/Password_strength#Guidelines_for_strong_passwords '''Table:''' ''Stronger Password Principles'' {| class="wikitable" |- ! scope="col"| '''Domain''' ! scope="col"| '''Recommendation''' |- ! scope="row"| Content and Length | * Avoid Dictionary-based Passwords: It is unsafe to use passwords that are dependent on dictionary words, keyboard patterns, special letter or number sequences, usernames, phrases from anything read or seen, relative or pet names, biographical information, or persons known to the user. * Avoid Short Passwords: Passwords should not be less than 12-14 characters in length; longer passwords are exponentially more difficult to crack than shorter ones. https://www.password-depot.com/know-how/brute-force-attacks.htm * Generate True Password Randomness: Random passwords require the use of specialized tools like Diceware. The human brain is poor at creating passwords which are both easy to memorize and also secure. * Online Services vs FDE: Passwords used for online services do not need to be extremely long, since the server rate-limits how many passwords an attacker can attempt. However, passwords used for offline encryption such as full disk encryption should be far stronger, since the threat model is different. An attacker can parallelize brute-forcing the password and is only limited by available system resources. Edward Snowden estimated in 2013 that serious adversaries are capable of one trillion guesses per second. https://theintercept.com/2015/03/26/passphrases-can-memorize-attackers-cant-guess/ |- ! scope="row"| Poor Habits | * Avoid Personal Information: Any information that might be publicly linked to the user or the user's account, or which is known by friends or acquaintances, should never be used for passwords. * Avoid SMS-based Two-factor Authentication: Contrary to conventional wisdom, SMS-based [[2FA]] gives away a user's identity, and also makes it easier for third parties to break into an account; for example, by performing sim-cloning or conducting social engineering attacks on the cellular provider. https://www.wired.com/2016/06/hey-stop-using-texts-two-factor-authentication/ * Do not Re-use Passwords: Even slight variations of a password allows the linking of multiple identities back to an individual. Attackers can use these discoveries to make templates which do not completely rely on brute-force attacks. * Never Use Online Password Generators: These tools are only useful for satisfying curiosity or additional learning, since it is possible for the server to log the passwords. The only place where passwords should be generated is locally, and ideally by using physical measures (like dice) or via software in a VM disconnected from the Internet. |- ! scope="row"| Storage | * Password Managers: Consider using a [https://keepassxc.org/ secure password manager], so hundreds of different passwords can be kept stored in an encrypted password database. Access only requires one master password, which should be cryptographically strong to protect the contents. * Physical Records: If passwords are written down, they should be stored securely and not be left in obvious places. |} = Forum Discussion = https://forums.whonix.org/t/password-advice-wiki-page-enhancements = See Also = * [[Two-factor_authentication_2FA|Two-factor authentication (2FA)]] = Footnotes = {{reflist|close=1}} {{Footer}} [[Category:Documentation]]