banner

Blog

Let’s Talk About Classical Cryptography

9

January 24, 2024


Cryptography has a wide range of applications in our lives and serves as the foundation of information security. From the emergence of cryptography in ancient times to the development of modern cryptography, the cryptographic techniques used by people are called classical cryptography.


Classical cryptography is mainly concerned with the confidential transmission of information, and the corresponding deciphering methods. The design of classical cryptographic algorithms usually depends on the creativity of the designer, and the security depends on the secrecy of the algorithm. Let's take a look at some common classical ciphers.


1. “Fan Qie” Code


During the Ming Dynasty, the “Fan Qie” code invented by Qi Jiguang used two poems as the "codebook" (see Table 1 and 2). The initials of the first poem’s lyrics were assigned numbers 1-15 while the vowels of the second poem’s lyrics were assigned numbers 1-36. Then the eight tones of pronunciation at that time were then assigned numbers 1-8, forming a complete “Fan Qie code” system.



Table 1: Initials Table



Table 2: Vowels Table


For example, if the code of a certain Chinese character is "5-25-2", referring to the tables we can determine that the initial corresponding to number 5 is "d", the vowel corresponding to number 25 is "i", and the tone corresponding to number 2 is the second tone. Therefore, we can conclude that the Chinese character is "敌".


2. Permutation Cipher


The Permutation Cipher is characterized by keeping all the letters of the plaintext unchanged and only using the permutation rule to rearrange the position and order of the plaintext characters. Here’s an example:


Plaintext: “HELLO,WORLD!”, displayed in columns as .


Key: (14) (23), which means the contents of columns 1 and 4 are exchanged, and the contents of columns 2 and 3 are exchanged.


Ciphertext: Plaintext by columns can be interchanged to get , making the ciphertext “LO! LWDE, LHOR ".


3. Caesar Cipher


The Caesar Cipher circularly shifts the alphabet by “k” bits for encryption and decryption. When k = 3, the shift relationship between plaintext and ciphertext is shown in Figure 1:



Figure 1Caesar Cipher Shift Relationship (k=3)


For example, if the plaintext message is "CAESAR", the shifted ciphertext message would be "FDHVDU". The Caesar Cipher is a cyclic shift of English letters for encryption and decryption, also known as the "shift cipher".


In the Caesar Cipher, the key “k” represents the number of positions by which the plaintext letters are shifted. Since there are 26 letters in the alphabet, there are only 26 possible cases in the key space, which means k ∈ [0, 25]. Also, due to the limited key numbers, trying out all 26 keys is sufficient to obtain the correct plaintext. This method of attempting all possible keys is also known as brute-force cracking. It can be seen that the necessary condition of a cryptosystem security is to resist the exhaustive key search attack.


4. Substitution Cipher


Another well-known classical cipher is the Substitution Cipher. Substitution involves replacing the letters in the plaintext with other letters or symbols. Usually, a substitution table is created for substitution cipher. During encryption, the plaintext is sequentially replaced with the corresponding characters obtained from the table, resulting in the ciphertext. This substitution table serves as the key for the substitution cipher.


Take a substitution table shown in Figure 2 for example. If the plaintext message is "SUBSTITUTION", referring to the table will get the ciphertext message "YNHYWOWNWOAL".



Figure 2Substitution Table


The substitution table shown in Figure 2 is just one kind of substitution. There are “26!" possible substitutions for 26 letters, meaning the size of the key space of the Substitution Cipher is more than4.0×1026. At this point, the difficulty of using exhaustive key search attack would significantly increase. However, this does not imply that Substitution Ciphers are secure, as they can be cracked using frequency analysis.


Frequency analysis is mainly used to study the frequency of letters or letter combinations in the text, and use statistical laws to realize cryptanalysis through speculation and verification. In a text with large sample capacity and meaning, the frequency of each letter is not the same. Taking English as an example, the most frequently occurring letter is "e", followed by "t", "a", and "o". By statistically analyzing the frequencies of each letter or letter combination in the ciphertext and based on linguistic foundations and characteristics of letter combinations, the corresponding relationship between the plaintext and the ciphertext can be inferred.


5. Vigenere Cipher


In the Caesar Cipher and Substitution Cipher introduced earlier, once the key has been selected, identical letters in the plaintext message are replaced by fixed letters when encrypted (i.e. if the letters in the plaintext are the same, then the letters in the ciphertext are the same). This cipher system is called Monoalphabetic Substitution Cipher. The Vigenere Cipher is a Polyalphabetic Substitution Cipher based on this. Even if the letter is the same in the plaintext message, it may be encrypted with different ciphertext. The relationship between plaintext and ciphertext in the Vigenere Cipher is shown in Figure 3.



Figure 3Vigenere Cipher Plaintext-Ciphertext Relationship Diagram


For example, if the plaintext message is "HELLOWORLD" and the key is "CIPHER", referring to the figure, we can determine that the ciphertext is "JMASSNQZAK". It can be seen that the letter "O" in the plaintext message (in different positions of the plaintext sequence) will get different ciphertext "S" and "Q".


The key space of the Vigenere Cipher is 26m, where m represents the length of the key. Even if the value of m is small, it would still require a long time using exhaustive key search attack. For example, when m=5, the size of key space is more than1.1×107, and it is already very difficult to attack by manual exhaustive key search attack. Compared with the Monoalphabetic Substitution Cipher, Vigenere Cipher gets different ciphers with different positions of the same letter in the plaintext sequence, which has better resistance against frequency analysis. However, this does not mean that the Vigenere Cipher is unbreakable. Since the Vigenere Cipher reuses the key cyclically when encrypting long texts, when two identical groups of letters appear in the ciphertext, there is a high probability that they correspond to the same plaintext. The Kasiski test method is based on this idea to predict the length of the key, and then use the index of coincidence method to further decode the specific key.


With the rapid development of modern cryptography, classical cipher algorithms are rarely used in practice. However, the ideas of "permutation" and "substitution" in classical cryptography are still the core ideas in constructing block cipher, which are of great significance to the study and research of modern cryptography.


TOPIC:Cryptography Insight
9
More Blog

TOPIC:

MORE