Encryption
Whether you open a website, play a multi-player game, or simply make a WhatsApp call, there is always the risk of being intercepted.
Imagine an open area with a large crevice. On one side is Alice, on the other is Bob. Alice wants to tell Bob something important, but Eve wants to hear this message. How can Alice and Bob talk to each other now that they can only call?
Symmetric encryption
The term “symmetric” is used to refer to an encryption method when Alice and Bob use the same secret, the same key. This is in contrast to asymmetrical encryption.
Caesar Cipher
In the so-called Caesar procedure, which is ascribed to this, only the common alphabet from A to Z is used to encode data. Before that, Alice and Bob agreed on a secret number. Now Alice wants to send the sentence “HELLO WORLD” to Bob. For this purpose, she takes the position in the alphabet for each letter, adds the secret number, and writes the letter in the alphabet at this new index. Bob just turns this process around, so subtracts. “H” is on the 8th letter. Alice now calculates 8 + 5 = 13 and writes the 13th letter down: “M”. For the whole sentence “HELLO WORLD”, it is used as follows: “MJQQT BTWQI”. Bob now only has to subtract the secret number to get back to “HELLO WORLD”.
Data Encryption Standard (DES)
DES is a modern application of block cipher. Block ciphers divide the data to be encrypted by size (here 64 bits) into blocks, which are individually encrypted. However, the keys are very short for DES (for encryption only 56 bits), so that a computer can crack the key quickly by simply trying out (Brute-Force) of around 72 billion possibilities. To prevent the lack of data encrypted with DES, you can use the encryption method several times, resulting in Triple-DES if you do it three times. At the beginning, the secret key is split into sub-keys. In block interlocking, each block passes through several rounds of encryption, where each of the sub-keys is applied. The encryption consists of substitutions and permutations.
The aim is to make the encrypted data appear as random as possible, so that potential attackers cannot detect any patterns.
Advanced Encryption Standard (AES) / Rijndael
AES has been the official successor of DES since 2001, and therefore also a block-cipher, but each block has a size of 128 bit. It is split into AES-128, AES-192 and AES-256, with the number always indicating the key length in bits. AES-256 is used today for most data encryption, such as hard disk backups and data exchange with HTTPS. First, the key is read with the corresponding length, which generates 10 further partial keys with the defined key length (128,192 or 256 bits). Each block is now placed in a 4x4 table, so that each field has a byte. Then each block is combined with a partial key via XOR. The following shall be repeated for each round:
- bytes are substituted to
- the last three rows are moved cyclically
- the columns are multiplied by the following vector
- each block will be combined with a partial key via XOR At the last run, the columns are not multiplied.
Here, too, the goal is to make the encrypted data appear as randomly as possible.
Asymmetric encryption
The term “asymmetric” is used to describe an encryption method when Alice and Bob use different secrets. Often only in one direction, i.e. only from Alice to Bob and not from vise-versa can be encrypted. This is in contrast to symmetric encryption. Often, asymmetrical procedures are used for key exchange such as for HTTPS, and the actual data is then exchanged by symmetrical encryption.
RSA (Rivest–Shamir–Adleman)
RSA is still used in many protocols for key exchange, such as SSH and HTTPS, but is no longer the preferred method of choice. At the beginning Alice and Bob choose a prime number. Now a public key and a private key are generated from these prime numbers. To cover up, irreversible calculations are carried out based on the public key and data. The only way Bob can now decrypt the encrypted data is to perform another calculation using the private key.
Key Generation
Given the primes and .
represents the Euler’s totient function, which indicates how many positive are relatively prime to . Now you search for a number which is not part of , with the greatest common divisor () of and being .
To ensure the irreversibility, is used.
This results in for the public key and for the private key.
The remarkable thing about this is that you cannot conclude from the public key on the private. So Bob can now freely distribute the public key, so that every one encode data, but only he can decode it again, using the private key.
As an example, Bob now selects the prime numbers and .
Bob now chooses for .
As a public key, he receives and as a private key.
Encryption
Encryption is relatively simple thanks to the public key:
Suppose Alice wants to send the message “B” now, she takes the position in the alphabet, , and Bob’s public key, .
The 8th letter in the alphabet is “H”, so the letter “B” is now encrypted to “H”.
Decryption
Decryption is similar to encryption:
Bob is now getting the letter “H” from Alice and wants to decode it. For this, he takes the place in the alphabet again, that is , and his private key, that is .
The second letter in the alphabet is “B”, so Bob successfully decrypted the message.
Diffie–Hellman key exchange
This procedure is used in TLS 1.3, i.e. the latest version of SSL/TLS for key exchange. To explain it easier, imagine Alice and Bob swap colors instead of numbers. First they think of a common color, then everyone thinks of a secret color. They add up and send the result. To the received result they now add their color again, and thus ever get to the same common secret without ever publishing their private secret colors. It is assumed that one cannot conclude from the mixed colour on the original colors. This is not yet proven in a mathematical way for the Diffie Hellman method.