Randomness
Randomness has come up quite a bit, but Richard only really mentions it in passing, like he’ll say things need to be generated randomly or its susceptible to statistical analysis attacks, but doesn’t really go into it more. I was just wondering how all this randomness works, because I know that pseudorandom number generators are widely used, but since they aren’t truly random are they good enough, and also is anything really truly random? How can we prove something to be random?
Pseudorandom number generators (PRNG)
Take the PRNG function rand() in C for example, by default it uses the system’s current time, which Is something like milliseconds since 1970, so it’s kind of random, but absolutely not good enough for security. This is because the seed can be easily guessed if for example one can narrow down the range of when the random number was generated. Like if you knew what day the seed was generated you would only have to try all possible time values from that day as the seed.
Pseudorandom RNGs are essentially deterministic functions, but the idea is their seed or input should be somehow unpredictable and random.
Randomness in cryptography
Why do we need it why do we care
Many reasons, but some of the main ones are:
Keys
Salts
Initialisation vectors sometimes
Nonces
Padding strings in block ciphers that need to be a certain length
Possibly password generation
Cryptographically secure random number generator (CSPRNG)
CSPRNG need to satisfy the next-bit test
They should withstand state compromise attacks, so if any or all of their state has been revealed it should still be impossible to reconstruct the stream of random numbers
/dev/random in unix systems polls system noise which has high enough entropy to pass CSPRNG tests
Java has the inbuilt ‘SecureRandom’ class
AES implementations generally use something called AES-CTR DRBG
Many other implementations
NIST standards
NIST actually have some randomness standards - statistical test suite for evaluating random data. So we don’t need true randomness, but what we want is our pseudo random number generators to be statistically indistinguishable from a truly random process. We want unpredictability and as high randomness as possible