After the age of rotor machines came the age of computing. As more and more information was stored on computers and sent between them, the need to protect digital information grew. Most of the details are hidden from the user, but modern computers store and work with all data, including text, as binary numbers.
In this chapter you’ll learn the binary tools that modern ciphers are built from, and use them to build, and break, a family of ciphers called stream ciphers.
In This Chapter¶
Binary, hexadecimal and octal, and converting between them by hand and in Python.
How computers turn text into numbers, from teleprinter codes to ASCII and UTF-8, and the Python functions ord and chr.
Binary addition, the bitwise operations XOR, AND, OR and NOT, shifts and bitmasks.
Enciphering bit by bit with a keystream, and making keystreams with pseudorandom number generators.
A simple keystream generator, its period, and characteristic polynomials.
Breaking an LFSR with a known-plaintext attack.
Combining two LFSRs with XOR, and why that is still not enough.
Combining two LFSRs with addition with carry, the system that protected DVDs, and how it was broken.
Throughout the chapter, text is written in 8-bit ASCII, and the bits of a binary number or an LFSR are numbered from the right, starting at 0.