3.2 Cryptographic keys
We saw in the last section that keys are extremely important because they are the only things that are supposed to be secret in a cryptosystem. But what exactly is a key?
A cryptographic key K comes from a large (but finite) set 𝒦. This large set is called the key space. If we assume that K is some bit sequence of length N, then 𝒦 = {0,1}N and the size of 𝒦 is 2N.
Figure 3.1: A cryptographic key k, the shared secret between Alice and Bob that ensures the security of their communication, is an element of a large (but finite) key space 𝒦. If the length of the key is N bits, then the size of 𝒦 is 2N
Naturally, we only want Alice and Bob to know the key, so Eve should neither be able to guess K, nor should she be able to eavesdrop on K when it is exchanged or obtain K by other means. These other means can be anything from a malware attack on Alice or Bob to spying on the electromagnetic radiation emanating from their computer screens. However, these are attacks on the endpoints of the secure channel, and while being important and highly relevant, they are not the main focus of this book.
While passwords should never be used directly as cryptographic keys, they provide a very common example for a shared secret upon which a secure channel can be built. A password can be guessed by an attacker for two reasons:
- It can be inferred from some other information (for example, a simple generation rule)
- There are too few possibilities (that is, the password is too short)
You should easily recognize these potential problems from so-called password policies that oblige you not to choose a password that is contained in a dictionary and to choose a password that is sufficiently long. It is straightforward to reformulate these requirements for cryptographic keys in general. Adding the fact that the key needs to be agreed on in a secure manner, we get the following three basic requirements of cryptographic keys:
- The key is either exchanged or agreed upon between Alice and Bob in a secure way, that is, the CIA triad should be satisfied for the key exchange process
- The key should not contain any kind of information, or in other words, the key should be generated in a completely random way
- The keyspace 𝒦 should be so large that is not possible to search through it within a reasonable time frame
The first requirement sounds rather strange as it seems we need to set up a secure channel first before we can exchange a key for setting up a secure channel. The second requirement is also rather tricky, as real randomness is quite hard to come by. The third requirement is the most straightforward, and we will deal with that one first.