encryption methods

Previous section: The Enigma machine and Bletchley Park

Returning to the modern age, every file or message stored or transmitted by a computer is ultimately represented as a long string of 1s and 0s. Each 1 or 0 is referred to as a bit. A computer has a different way of representing in bits each of the types of object it processes – texts, pictures, films and so on. For example, one way in which a computer can store a text involves it using 16 bits to represent each letter, so that 1000101001011011 might denote one letter, and 0010011000111100 some other letter. Modern encryption techniques work with strings of bits. This means that the same methods can be used regardless of whether it is a document, a photograph or some other type of file that is being encoded.

A typical encryption method starts by splitting into blocks of a predefined length the string of bits to be encoded. Each block might consist of 128 bits, corresponding to eight letters in the above representation. All blocks are then encrypted using the same set of steps. The bits that make up each block are subjected to a long series of changes that mangle them up. Some changes switch 1s for 0s and 0s for 1s at various positions within each block. For example, the values of the bits at the third, fifty-fourth and ninty-seventh positions within each block might be switched. Other changes swap the bits within each block around. For example, the values of the twenty-seventh and eighty-first bits within each block might be exchanged. (This would only have an effect if they happened to be different.)

The steps that make up a real encryption method are considerably more complex than these, but still conform to the same general idea. The types of steps that are used depend on the individual encryption method. However, which steps are performed in which order and on which bits within each block depends on a key. The key is itself a string of bits and is typically the same length or slightly longer than the blocks being encrypted. The encryption method uses the key to derive the list of changes to apply to each block. For example, if the key length and the block length are both 128 bits, the encryption method might start by looking to see which of the 128 positions within the key have a bit with the value 1 rather than the value 0. It might then switch the values of the bits at all of the corresponding positions within each block in the data to be encrypted.

Knowing the details of how an encryption method works is of no help in decrypting a message it was used to encode unless you have the right key. Nowadays, keys are generated randomly by a computer to prevent the sort of problems seen with Enigma when operators were left to make up their own. Unlike Enigma, modern mechanisms distinguish between encryption and decryption. The sender of the message used a key to derive a list of actions to transform the original version into the encrypted version. The recipient uses the same key to obtain a list of opposite actions that are performed in reverse order on the encrypted version to get back to the original version.

One of the hallmarks of an effective encryption technique is that it can encode a message securely with a relatively short key. A typical modern encryption method uses a chain of bit-switching, bit-swapping and other steps described by a key that is between 128 and 256 bits long. Compare this to a one-time pad, which uses a very simple message transformation in conjunction with a key that is the same length as the information to be encoded.

The fact that each block is several times longer than the individual letters that were encoded using the Enigma system is one of many features that make modern techniques more secure and harder to crack. At the same time, there is one important sense in which block-based encryption in its simplest form is less secure than Enigma. All blocks are encrypted in the same way where Enigma generated a new substitution alphabet for each letter. However thoroughly the bits within each block are encoded, applying the same transformations to all blocks in the original data can lead to problems if there are two or more blocks that are identical.

Cybertwists book cover
Publication of Cybertwists is planned for early 2018.

For example, a high-resolution picture of a sketch of a castle on a white background will contain a large number of identical blocks that represent empty space. If all these blocks are encrypted using the same encryption method and the same key, their encoded versions will all be exactly the same. Someone examining the resulting data, despite not being able to decode it, could surmise that these identical blocks probably represent empty space. He could create a picture where the identical blocks are white and all the other blocks are black. The picture would be blotchy and without details but would still show the unmistakable outline of a castle.

In order to guard against this weakness, the original version of each block is normally subjected to changes that are based on the encrypted version of the previous block before itself being encrypted. At the beginning of the process when the first block in the string of bits is to be encrypted, there is obviously no encrypted previous block to use. The original version of the first block is combined with a randomly generated string of bits called an initialization vector. The initialization vector is transmitted or stored at the start of the encrypted message, although it itself remains unencrypted. Using an initialization vector achieves what initial rotor positions achieved for the Enigma system. It means that even if an identical message is encrypted twice, the two encoded versions that result will be completely different from each other.

Tweet about block-based encryption methods

Next section: Private and public keys