222 karma · joined April 21, 2013
* Blog: https://pthree.org
* Tweet: https://twitter.com/AaronToponce
[ my public key: https://keybase.io/atoponce; my proof: https://keybase.io/atoponce/sigs/zcp1wU_NZgpMRlALIctUZbML2nkl4upiH8LBYAG1_UY ]
To illustrate, suppose you have a word list of 8,192 entries, and a cryptographically secure random function. Shannon entropy says that each word in that list then contains exactly 13-bits of entropy (2^13=8,192). According to https://gist.github.com/epixoip/a83d38f412b4737e99bbef804a27..., 8 Nvidia GTX 1080 GPUs with Hashcat 3.0 can process 200 billion MD5 hashes per second, which means 5 of those password cracking rigs, working in concert, can do 1 trillion MD5 hashes per second.
So, if you have a cryptographically secure random function choosing your words from that list of 8,192 words, what are we looking at?
- 1 word (13-bits): 1 in 8,192 possibilities
- 2 words (26-bits): 1 in 67,108,864
- 3 words (39-bits): 1 in 549,755,813,888
- 4 words (52-bits): 1 in 45,03,599,627,370,496
- 5 words (65-bits): 1 in 36,893,488,147,419,103,232
- 6 words (78-bits): 1 in 302,231,454,903,657,293,676,544
There is no need to go any higher than that, as we'll see in a second. If the password cracker is only interested in searching 1/2 of the total combinations, then that means at each hash, after completion, there is a 50% probability that the password was found (on average). So, armed with this, it would take the password cracker:
- 13-bits: < 1 second to search 1/2 the space
- 26-bits: < 1 second
- 39-bits: ~ .3 seconds
- 52-bits: ~ 38 minutes
- 65-bits: ~ 213 days
- 78-bits: ~ 4,792 years
It's reasonable to conclude that if your threat model is password cracking clusters working on leaked hashed password databases, and assuming the password is hashed with MD5, then at least 65-bits of entropy, or 5-6 words chosen from a list of 8,192 with a cryptographically secure random function, is a good target for a secure passphrase length.
For what it's worth, Diceware has been promoting this approach for years now, where the word list is 7,776 entries (~12.93-bits of entropy per word), and the cryptographically secure random function is 5 fair 6-sided dice. The XKCD "correct horse battery staple" approach is just a simplified implementation, forgetting the random factor.
Even then, don't get your hopes up. It should be worth noting that VPNs can give a false sense of security (such as not logging). All they're doing is moving the goalpost from one end of the playing field to another. They're useful for getting into internal networks, and they're useful for bypassing outbound firewalls in restrictive networks, like public schools and libraries, or churches, but that's about it. See https://gist.github.com/joepie91/5a9909939e6ce7d09e29
If you want online privacy, you really should be using Tor. if you want anonymity, you should stay offline. Regardless, realize your VPN provider isn't going to go to jail for you.
If you are defining "evil" as blind and bullheaded, then yes. I don't think NIST or the IETF are actively malicious, however.
I used to work as a contractor for the Dept. of V.A. and am familiar with the red-tape required to implement libraries in code, push patches to production, rely on 3rd-party libraries, etc. It's a nightmare. As an admin, I couldn't certify a hard drive was digitally wiped unless it did the DoD 3-pass, even though I'm confident a single pass of zeros is sufficient. I couldn't use my LUKS encrypted laptop on premesis, because the encryption process hadn't been vetted by a committee. I couldn't deploy bcrypt as the password hash for authentication.
So, my reference to "NIST/NSA monoculture", is the bullheaded requirement that only NIST-approved algorithms can be use, after committees and approval. It's a monoculture, because at least for the V.A., only government standardized algorithms are allowed.
This does reek a bit of the "Schneier Brand", but for what it's worth, Bruce hasn't developed horrible cryptographic primitives:
Block ciphers: Blowfish (bcrypt is based on the expensive Blowfish key schedule), Twofish (an AES finalist), Threefish (based on Skein).
Stream ciphers: Solitaire (a classical algorithm with playing cards), Helix (authenticated stream cipher), Phelix (authenticated stream cipher submitted to ECRYPT)
Random number generators: Yarrow (inital CSPRNG), Fortuna (CSPRNG replacing Yarrow- FreeBSD and OS X/iOS /dev/random)
Generic hashing algorithms: Skein (a SHA-3 finalist)
What I find interesting, is the monocultures created in cryptography. You have the NSA/NIST monoculture (3DES, AES, SHA-1, SHA-2, SHA-3), the Schneier monoculture (Blowfish/bcrypt, Fortuna, Skein) and the Berstein monoculture (Poly1305, Curve25519, ChaCha20). It seems to me that if you're against the NIST standards and NSA designs, then you're likely in the Schneier or Berstein monocultures, with possibly some overlap.
What bothers be about being anti-NIST or anti-NSA, is forgetting that we have some great algorithms that already exist, such as AES and SHA-2, that are well-studied, well-implemented, and near ubiquitous. I'm not saying we should just stick with those primitives, and I'm glad cryptographers are thinking of more, such as BLAKE2 and Argon2.
So, I guess this whole discussion boils down to "why?". Why is Skein being added to FreeBSD? What is the need? Is the package manager moving to file integrity with Skein? Is ZFS? Some other need? Or is this getting added, because of the Schneier monoculture, and the need to be "anti-NIST/NSA"? I tend to believe its the latter.
Agreed, but a tactical error in the opening is replicated and multiplied throughout the game. if I'm going to criticize it as an abstract strategy game, it's too sensitive in that regard. Yes, an error is an error, that's why they're called as such. In chess, opening errors have much more drastic consequences, depending on the error, than say Go, where you have more opportunity to recover from the error. An opening tactical error can spell doom for your middle game and end game (as analyzed by chess commentators, instructors, books, videos, etc.).
Outside of amateur casual play, you must play a stronger opening game than your opponent, if you want any hopes of winning. Even if your mid and end games are stronger, if you make a tactical opening error, you may never get the opportunity to play that genius finale, because you'll never get the opportunity to recover. Openings have to be damn-near perfect when playing seriously. That's what bothers me.
BoringSSL just uses /dev/urandom directly. It's not a userspace CSPRNG. And as you pointed out, for GNU/Linux systems, it's slow. This is why userspace designs, such as CTR_DRBG, HMAC_DRBG, and Hash_DRBG exist- so you can have a fast userspace CSPRNG with backtracking resistance.
Case in point. On my laptop:
$ pv < /dev/urandom > /dev/null
1.02GB 0:01:20 [13.3MB/s] [ < => ]
$ openssl enc -aes-128-ctr -pass pass:"sHgEOKTB8bo/52eDszkHow==" -nosalt < /dev/zero | pv > /dev/null
2.13GiB 0:00:11 [ 198MiB/s] [ <=> ]
And on a server with AES-NI:
$ pv < /dev/urandom > /dev/null
2.19GiB 0:01:06 [ 20MiB/s] [ <=> ]
$ openssl enc -aes-128-ctr -pass pass:"sHgEOKTB8bo/52eDszkHow==" -nosalt < /dev/zero | pv > /dev/null
31.9GB 0:00:34 [ 953MB/s] [ < => ]
I've seen other hardware with AES-NI that can go north of 2 GiBps, as I already mentioned. Although not backtracking resistant, those are fast userspace CSPRNGs, that are clean in design.
I've designed userspace CSPRNGs that adhere to the NIST SP 800-90A standards. They're seeded from /dev/urandom on every call, and perform much better than relying on /dev/urandom directly. I won't say they're bug free, but if you read and follow the standard (http://csrc.nist.gov/publications/nistpubs/800-90A/SP800-90A...), it's not too terribly difficult to get correct, and PHP, Perl, Python, Ruby, and other interpreted languages can outperform the kernelspace CSPRNG.
To pinpoint my gripe with chess, a single tactical error in your opening game can be unrecoverable, and the deciding factor on losing your game. It's too precise. Whereas with some other abstract strategy games, such as Go, you might make a strategical error, but the game might be more forgiving, where you can heal from your mistakes.
Of course, weak players should lose to strong players, regardless of game. I just wish chess didn't depend so strongly on defining a strong player by who has more opening variations memorized.
Some time in high school, while studying openings and their variations, I was curious if computers would ever beat the great Grand Masters regularly and consistently. It seemed to me that the key to this success would be a full comprehension of knowing which opening to start with, how to respond to your oponent's opening, and how deeply that opening variation was memorized.
So, it wasn't surprising to me to learn that the Grand Masters are Grand Masters because of their memorization of opening sequences, the depth of that memorization, and when to use which variation.
Then while studying old games played by the masters, I saw a trend that disturbed me: more and more, Grand Master games were ending in draws. I recall reading an article recently that more than 50% of said games are draws.
This bothers me for two reasons: first, that the game is designed so poorly, that draws can occur as frequently as they do. But, more disturbing, is knowing that they are ending in draws because of a mastery on the opening game.
I am no longer a chess proponent, and won't play it when asked (although that might change if my daughter wants to learn). The only chess I will play is Chess960, by Robert Fischer, where the back row is randomized to 1 of 960 possible starting positions. This way, the game is less sensitive to opening sequence memorization, but on more on basic tactical strategy, such as control of the center board, when to pull out your queen, and how knights can compliment bishops.
Now, I'm a large advocate of Go. The game is much more strategy based and less memorization (although there are a good amount of tsumego and joseki that should be memorized, and you should know opening theory). But, due to the size of the board, the games are considerably different, and it is less sensitive to tactics. Thus, draws occur mostly based on evenly matched strategies, and less on cognitive capacity.
Another game I am enjoying is the currently developed Tak by James Ernest (http://tinyurl.com/takgameks (link to Kickstarter campaign (I'm not a paid schill, I just enjoy the game))). A simpler game than chess and go to explain, yet deep with strategy, and new enough, that patterns and sequences are still being studied.
Don't get me wrong. Chess is entertaining. I am glad there are people that enjoy it, teach it, and play it. It's just no longer for me. Again, unless the game is Chess960.
1. Kernelspace CSPRNGs generally don't change, are well audited, and are generally accepted to be secure.
2. Userspace CSPRNGs don't provide any additional security benefit.
3. OpenSSL is a questionable security product with it's history of vulnerabilities.
So, with that said, let's look at each of them.
For the first point, I don't fully agree. The Linux kernel CSPRNG has changed from MD5 based to SHA-1 based. I have heard chatter (I don't have a source to cite this) that it should move to SHA-256 with the recent collision threats of SHA-1. There is also a separate movement to standardize it on NIST DRBG designs (CTR_DRBG, Hash_DRBG, HMAC_DRBG- https://lkml.org/lkml/2016/4/24/28). Starting with Windows Vista, Microsoft changed their CSPRNG to FIPS 186-2 or NIST SP 800-90A (depending on Windows version), which could be hash-based or AES counter based. OpenBSD changed from using Yarrow and arcfour to ChaCha20. So, no, kernelspace CSPRNGs change all the time.
For the second point, I greatly disagree. First, you need a specific RNG to compare to. It's considered "unsafe" to use MD5 as a CSPRNG, although that would require pre-image attacks on MD5, of which it still remains secure. Additionally, a userspace AES-256-CTR_DRBG is theoretically more secure than an AES-128-CTR_DRBG design. While that matters little it terms of practical use, the reality is that AES-256 has a larger security margin than AES-128, as I understand it. Same for using SHA-256-Hash_DRBG instead of SHA-1-Hash_DRBG. Userspace CSPRNGs can be more secure than kernelspace.
Finally, as far as I know, attacks on OpenSSL have been overwhelmingly CBC padding oracle attacks, in one form or another. There have been a couple RNG vulnerabilities with OpenSSL (https://www.openssl.org/news/vulnerabilities.html), but same with say the Linux RNG (https://github.com/torvalds/linux/commit/19acc77a36970958a4a...). So, I'm not sure this is a valid point.
The biggest reason why you should use a userspace CSPRNG is performance. System RNGs generally suck. The Linux kernel can't get much faster than about 15-20 MiBps. Similarly with Mac OS X and FreeBSD. OpenBSD can get about 80 MiBps (on testing with similar hardware), but that's just painful for a single host trying to serve up HTTPS websites, when the HDD (nevermind SSDs) can read data off at 100 MiBps without much problem. The kernelspace CSPRNG can't even keep up with disk IO.
Userspace CSPRNGs can get into 200-300 MiBps without much problem, and with AES-NI (provided that you're using AES-128-CTR_DRBG), 2 GiBps (https://pthree.org/2016/03/08/linux-kernel-csprng-performanc...).
But, I do agree with one very serious concern on using userspace RNGs in general: they can introduce bugs and vulnerabilities that don't exist with the system CSPRNG. Expecting a developer to get this right, especially one who is not familiar with cryptographic pitfalls, can be a massive challenge. But this isn't the case with the OpenSSL RNG.
So, I guess I don't see the point to move the node.js CSPRNG dependency from OpenSSL to kernelspace.
Completely agreed. I've already mentioned in this post about only using the Linux CSPRNG to seed a userspace CSPRNG, because the Linux CSPRNG is horrendously slow, due to its ad-hoc design. However, if the Linux CSPRNG was AES-128 using the standard CTR_DRBG, with AES-NI, it could go north of 2 GiBps without breaking a sweat, keeping clean random.c code (it already ships aes.h), and it's backtracking resistant.
However, if you're going to spend good money for hardware producing random values, at least for me, I'm going to want the best bang for my buck. If you look at https://en.wikipedia.org/wiki/Comparison_of_hardware_random_..., you can spend $35 for the WaywardGeek "Infinite Noise RNG", which outputs 300 Kbps, or spend $24 for an RTL-SDR dongle and get about 2.8 MiBps. The value of bits per dollar is much higher with the RTL-SDR than the WaywardGeek. This is considerably cheaper than getting a radioactive sample, coupled with a Geiger counter.
IDQuantique sells a product that purportedly generates millions of random bits per second. If I were gambling at a casino, I'd feel more comfortable with that than with randomness from an AES stream. Yeah, I know I'm thinking irrationally.
Yeah, that is irrational. The problem with most TRNGs is that their output is biased. As a casino operator, I might be interested if the bias benefits my casino, but I would also need to prove to regulators that I'm not cheating the public. Personally, I'd err on the side of caution when it comes to the law.
So either I would whiten the output with a cryptographic primitive (John von Neumann debiasing is too costly, losing at least 1/2 the bits), or just write a userspace CSPRNG, and get the throughput you'll need for the demand. I could then constantly rekey/rseed the generator with the TRNG if I was tinfoil-hat-paranoid.
In either case, TRNG or CSPRNG, you'll want exceptional throughput for your casino. Which brings us back to another example of which 800 bps just isn't going to cut it. :)
For seeding the system CSPRNG, that's fine. For securely destroying data, such as wiping hard drives, or creating underlying noise for encrypted filesystems, 800 Bps is going to take you years to work through a 4 TB hard drive.
In actual reality, the generator won't be influenced, because it will require a strong signal, close by, likely transmitting illegally on the frequency you are listening to (of course, the attacker would need to know the frequency you're tuned to). Simple monitoring tools and scripts can be used to test the quality of the generator output. If the quality of the randomness begins to fail, as would happen with deliberate RF interference, then the script would stop outputting bits, and alert the administrator. Or, even better, switch to a different frequency, chosen at random by the kernel CSPRNG.
What's great about using the RTL-SDR as an RNG, is these devices are cheap (about $20) and can output 3 MiBps, which vastly out performs any USB HWRNG that I have personally tested for the value (bits per second per dollar).
FWIW, random.org uses RF noise as the basis for delivering random numbers to the Internet.
Anyway, FYI.
Further, not all noise is RF-based. Thermal noise, for example, is not influenced by RF intereferrence.
If only the Linux kernel used as entropy everything that was available to it. That's the pitch of haveged(8) I think. There are significantly more timing events the kernel could use for input entropy that it's not. It would be great to see these timing events land in random.c, but they're not there.
Lastly, slightly off-topic, but the Linux CSPRNG is poorly designed. In reality, while preimage SHA-1 might still have a sufficient security margin, it suffers from poor performance due to ad-hoc design. Instead, using AES-128 CTR_DRBG with AES-NI would give the kernel CSPRNG a much needed performance boost, provide backtracking resistence, and remain secure. Current testing shows it could improve from 20 MiBps to 2 GiBps.
function openssl-encrypt() {
openssl enc -aes-256-cbc -salt -in "${1}" -out "${2}"
}On the other hand, I've learned more from continuing to read the manpages than probably anything else. And the OpenSSL commands that I use frequently, such as connecting to a site with TLS, or checking a certificate chain, can now be easily recalled from memory, and I feel I'm better off for it, especially if I'm at a terminal where my OpenSSL functions might not be installed.
Second, if the key was unprotected on a USB drive, and the drive is lost, what's stopping you from taking the key out of the authorized_keys file on the remote server?
Lastly, if there is a need for a single use SSH key, then it should be indicated as such in the key's comment, so when the scenario is over, it's easily identified as which key it is.
I guess I don't understand the practicality of this script, let alone one-time SSH keys.
Further, once a CSPRNG is properly seeded, there is no need to concern yourself with whether or not it can produce "high quality random numbers", provided the cryptographic primitive behind the CSPRNG contains conservative security margins. The Linux kernel CSPRNG uses SHA-1 as the underlying primitive. While SHA-1 is showing weaknesses in blind collision attacks, it still contains wide security margins for preimage attacks, which is what would need to be applied to a key generated by a CSPRNG (you have the output, now predict the state that produced it). Even MD5 remains secure against preimage and second preimage attacks.
Again, once properly seeded, the Linux CSPRNG can produce data indistinguishable from true random indefinitely until SHA-1 is sufficiently broken.
See http://ae7.st/p/5px. I'm using the reference code at https://github.com/BLAKE2/BLAKE2 for blake2, and https://jxself.org/git/?p=skeinsum.git for skein.