The information to be shared can be secured using different cryptography techniques. But we should also analyse the reliability of this system. Techniques such as “Cryptanalysis” is used to obtain the meaning of encrypted information. Cryptanalysis is the study of cipher, ciphertext, and cryptosystems to understand how they work. And improving and finding techniques for defeating or decoding them.
This blog will discuss the cryptanalysis of Affine cipher with examples. We can consider the affine cipher as a type of substitution cipher that is monoalphabetic in nature. Each letter of the alphabet is mapped to a numeric equivalent. That is then encrypted using a mathematical function and converted back to the letter.
What is Cryptanalysis?
Cryptanalysis is a method for finding the meaning of encrypted information without access to a secret key. Typically, this involves information about how the system works and finding a secret key. We can also refer to cryptanalysis as decoding or cracking the code.
While the focus of cryptanalysis is to determine weaknesses in cryptographic algorithms. Cryptographers also use these results to improve and strengthen flawed algorithms.
Cryptanalysis is of various types. Some of them are as follows:
Ciphertext-only attack: In this attack, the attacker poses a ciphertext string only.
Known plaintext attack: Here, the attacker poses a ciphertext string and its decoded plaintext also.
Chosen plaintext attack: Here, the attacker can access the encrypting algorithm. And hence he can generate multiple corresponding ciphertexts from known plaintexts.
Chosen ciphertext attack: Here, the attacker gains access to the decrypting algorithm. Therefore, he can choose any cyphertext and generate the plaintext.
What is Affine Cipher?
The affine cipher is a type of monoalphabetic substitution cipher. Each letter of the alphabet is mapped to a numeric equivalent. That is then encrypted using a mathematical function and converted back to the letter.
Let’s understand this with a good example.
Plaintext
A
E
I
O
U
Mapped value (x)
0
1
2
3
4
The above table represents the letter of a plaintext with its mapped number value. This can be used for encrypting and decrypting the plaintext. For example,
Word: AOOI.
This word can be mapped as 0 3 3 2 in numerical form. Now, let’s apply an encrypting function f(x) = x + 1. Then after using this function, we get the mapped value as 1 4 4 3. Now, converting it back to characters, we get our final encrypted word. Encrypted string or ciphertext: EUUO.
Cryptanalysis of Affine Cipher
The cryptanalysis of the affine cipher is performed using statistical data. In this method, the cryptanalyst uses the ciphertext available to decode the message. Let’s understand this with the help of an example.
Step 1: Create the frequency table of the above ciphertext.
A
B
C
D
E
F
G
H
I
J
K
L
M
2
1
0
7
5
4
0
5
0
0
5
2
2
N
O
P
Q
R
S
T
U
V
W
X
Y
Z
1
1
2
0
8
3
0
2
4
0
2
1
0
Step 2: Now analyze the above ciphertext.
There are only 57 characters in the ciphertext.
The most frequent ciphertext letters are- R (8 times), D (7 times), E, H, K (5 times each), and F, S, V (4 times each).
As a first guess, we may assume that R is the encryption of e and D is the encryption of t. As e and t are the two most common characters. Numerically, f(4) = 17 & f(19) = 3. And we know that f(x) = ax + b. Hence, 4a + b = 17 and 19a + b = 3.
This has a unique value of a = 6 and b = 19. But this is an invalid key because gcd(a,26) <= 1 for a valid key. And gcd(6,26) = 2.
Next, we can assume that R is the encryption of e and E is of t. Moving ahead as above, we get a = 13, which is again invalid.
Moving on, let’s assume R is the encryption of e and K is that of t. This gives us a = 3, b = 5, which is at least a valid key.
Step 3: Now that we have a valid key pair, let’s try to find the decrypting algorithm. We will find a decrypting function K = (3, 5) to decode the encrypted message. And will see if we get a meaningful sentence or not. This will confirm the validity of (3, 5).
Transition Table
We only need to decrypt characters that are in the ciphertext. So, after the above calculations, we get this transition table.
A
B
D
E
F
H
K
L
M
↓
↓
↓
↓
↓
↓
↓
↓
↓
h
q
i
r
a
s
t
c
l
N
O
P
R
S
U
V
X
Y
↓
↓
↓
↓
↓
↓
↓
↓
↓
u
d
m
e
n
f
o
g
p
After performing various operations, we get K (y) = 9y − 19. And this will decode the ciphertext into a meaningful plaintext as follows: algorithmsarequitegeneraldefinitionsofarithmeticprocesses
Hence we can say that our encrypted ciphertext is decoded without the key.
Applications of Cryptanalysis of Affine Cipher
The Cryptanalysis of Affine Cipher is widely used for various purposes. Various organizations and individuals can use it. Like, For govt. Agencies, security companies, researchers, hackers, crackers, etc. It is mainly used in the following cases.
Governments are aiming to decipher enemy nations' confidential communications.
Security companies employ cryptanalysts to test their security products.
Researchers and academicians use it to find weaknesses in cryptographic protocols or algorithms.
Hackers and Crakers use it for unethical purposes.
Responsibilities of a cryptanalyst
A cryptanalyst's duties may include developing algorithms, ciphers, and security systems to encrypt sensitive information. His responsibilities also include analyzing and decrypting different types of confidential information, including encrypted data, cipher texts, and telecommunications protocols, in cryptographic security systems.
Cryptanalysis is a method for finding the meaning of encrypted information without access to a secret key.
What is Affine Cipher?
The affine cipher is a type of substitution cipher that is monoalphabetic in nature. Each letter of the alphabet is mapped to a numeric equivalent. That is then encrypted using a mathematical function and converted back to the letter.
Who uses cryptanalysis of affine cipher?
Various organizations and individuals can use it. Like, For govt. Agencies, security companies, researchers, hackers, crackers, etc.
What are the responsibilities of a Cryptanalyst?
Cryptanalyst is responsible for developing algorithms, ciphers, and security systems to encrypt sensitive information. He is also responsible for analyzing and decrypting different types of confidential information, including encrypted data, cipher texts, and telecommunications protocols, in cryptographic security systems.
Conclusion
In this article, we have discussed the Cryptanalysis of Affine Cipher extensively. Its examples and applications.
We hope this blog has helped you enhance your knowledge of the Cryptanalysis of Affine Cipher. And if you want to learn more, check out our articles onCryptosystem,Public Key Cryptography, andWhat are basic Cryptography tools? Do upvote our blogs if you find them helpful to help other ninjas grow.