How many keys are possible in a cipher?

1.2 Encryption keys

How many keys are possible in a cipher?

Show description|Hide description

This is an abstract image of different coloured numbers and patterns.

Figure 3

Keys are pieces of information that determine the output from an encryption (or decryption) process. A single cipher can produce an almost limitless number of different outputs with different key values, allowing secure communication even if the cipher itself is known to hostile third parties.

It might surprise you to know that almost all ciphers are published in the scientific press or in standards documents. Having them available for widespread scrutiny allows many people to check that they are secure and do not contain weaknesses which could be exploited to compromise the security of the data encrypted using that cipher.

A computer encryption key is nothing more than a string of bits where each bit can have a value of either 0 or 1. The number of possible values for a key is simply the total number of values that the key can have. So our one-bit long key can only have two possible values – 0 and 1. If we choose to have a two-bit key it could have one of four possible values – 00, 01, 10 and 11. In fact every time we increase the length of the key by one bit we double the number of possible keys – so a three-bit key has eight possible values – 000, 001, 010, 011, 100, 101, 110 and 111.

The total number of keys can be written in scientific form as 2key length; so a key with a length of eight has 28 – that is 256 – values.

But how long should a key be? How short is too short?

The problem with short keys

Short keys are vulnerable to what is known as a brute force attack, just like you learned in Week 2 about passwords. A brute force attack is where a computer, or a number of computers, try every possible value for a key until they produce recognisable plaintext.

Since computers can work through key values extremely rapidly, keys must be sufficiently long that they offer a very large number of possible values.

Keys may be known to the user in the form of passwords, or they may be stored in a computer’s hardware (such as the decryption keys stored on a DVD player that allow it to play the encrypted data stored on the movie disk), or they can be generated by a computer as and when they are needed (such as conducting a secure transaction on a shopping site).

Next, you’ll learn about the key distribution problem.

How many keys are possible in a cipher?

When you read about cryptography (the science of secrecy), you will encounter lots of jargon, as well as different words that all seem to mean roughly the same thing. This short, rather boring section is supposed to clarify some of the jargon.

Definitions

Code: A system for hiding the meaning of a message by replacing each word or phrase in the original message with another character or set of characters. The list of replacements is contained within a so-called codebook. A code has no built in flexibility, other than re-writing the codebook. (An alternative definition of a code is any form of encryption which has no built in flexibility.) To protect a message in this way is called encoding.

Cipher: Any general system for hiding the meaning of a message by replacing each letter in the original message with another letter. To protect a message in this way is called enciphering. Each cipher can be split into two halves � the algorithm and the key. The key gives a cipher some built in flexibility.

Encrypt: A term that covers encoding and enciphering.

Encicode: The process of encoding a message followed by enciphering. The application of multiple layers of encryption is also known as superencipherment.

Key: The flexible component of a cipher. The cipher is a general algorithm that is specified by the key. For example, substitution is a general algorithm that is specified by a key, which is the substitution for each letter. Rival groups can use the same substitution cipher, but they will choose different keys so that they can not read each other�s messages.

The Enigma Cipher

To put some of the definitions into context, let's use the Enigma cipher machine (pictured above with Simon Singh) as an example. It is definitely a cipher, because it encrypts at the level of letters and the algorithm depends on a flexible key that is chosen by the sender.
The key is the set-up of the machine - rotor orientations, plug selections, etc. all determine the encipherment. The receiver must have an Enigma machine, but must also know the key in order to decipher the message.

The More Keys The Better

A secure cipher system must have a wide range of potential keys. For example, if the sender uses the pigpen cipher to encrypt a message, then encryption is very weak because there is only 1 potential key, given by the pigpen grid. From the enemy's point of view, if they intercept the message and suspect that the pigpen cipher is being used, then they merely have to use the grid to decode the message. Let us look at the number of keys used in other methods of encryption.

The Caesar Cipher: The alphabet can be shifted up to 25 places, but shifting a letter 26 places takes it back to its original position, and shifting it 27 places is the same as shifting it 1 place. So there are 25 keys.

The Kama-Sutra Cipher: This is a much stronger cipher. To construct the cipher alphabet, the letter A could be paired with any of the remaining 25 letters. Another letter could be paired with any of the remaining 23 letters. This continues until there is only 1 letter left. The number of keys is therefore 25 x 23 x ... x 1 = 7,905,853,580,625.

General Monoalphabetic Cipher:To construct the cipher alphabet, the letter A could be represented as any of the 26 letters. The letter B could be represented as any of the remaining 25 letters, C could be represented as any of the remaining 24 letters, and so on until the entire cipher alphabet has been formed. The total number of keys is therefore 26 x 25 x 24 x ... x 1 = 403,291,461,126,605,635,584,000,000.

How many different keys are possible in cipher?

So, every (enciphering) key has a corresponding “deciphering key,” which is sometimes called the key inverse. Unfortunately, Caesar ciphers have a small key space; there are only 26 possible keys (shifts), and one of those is plaintext (a shift of 0 or 26).

How many possible keys can a Caesar cipher have?

Because there are only 25 possible keys, Caesar ciphers are very vulnerable to a “brute force” attack, where the decoder simply tries each possible combination of letters.

How many possible keys are there for a 26 letter substitution cipher?

Rather than only 25 possible keys, we have 26! (26 factorial, the number of permutations of the alphabet, assuming a 26 letter alphabet.) A brute force approach to cracking this cipher, even if one spends only 1 millisecond per permutation, would take roughly 10 trillion years.

What is a key of 3 cipher?

For example, if the key is 3, the letter A, which is the first letter in the alphabet, is substituted by the letter D, which is the fourth letter in the alphabet. B (the second letter) is replaced by E (the fifth letter), and so on.