2 Random number generators
This chapter covers
- The importance of random numbers for cryptography
- Qualities of random number generators
- Understanding the different types of random number generators
- Implementing and exploiting linear-congruential generators
In this chapter, we lay the foundations for understanding what random numbers are and some different kinds of random number generators (RNGs). We’ll implement and exploit an insecure but widely used type of RNG known as a linear-congruential generator (LCGs). LCGs are not meant to be used for security-sensitive applications but will help us get into the habit of implementing and exploiting algorithms. (In the next chapter, we’ll implement and exploit a cryptographically secure RNG.)
My first encounter with randomness was when I used the RAND
button on my father’s scientific calculator. Whenever I pressed it, I got a seemingly different number. This confused me endlessly. As a kid, you have some intuition about the limits of the world around you. For example, although folks on TV represent real people, you cannot physically go inside the box. I understood that human beings had created machines that could calculate 2 + 2 and give us answers. But the machine was under our control.