Classical Encryption Techniques.
1. Cryptography
Study of Secure data communication is called cryptography.
Fig. 1 explains the entire working of cryptography.
Plaintext : Human Readable Data
Encryption Algorithm : Which converts plaintext into ciphertext.
Secret Key : It is an input which is used for encryption and decryption algorithm.
Ciphertext : It may be human readable or may be non readable but always contains a logic.
Decryption Algorithm : Which converts ciphertext into plaintext.
Mathematical Background :
Assume
Plaintext (P) : {p1,p2,p3,p4,....pm}
Key (K) : {k1,k2,k3,...,km}
Ciphertext (C) : {c1,c2,c3,.....,cm}
Now after Encryption -
C = E(K,P)
Now after Decryption -
P = D(K,C)
Now opponent observing 'C' but having no access to 'K' and 'P' will try to find out the 'K', or 'P', or both. so to recover the message the opponent generate a plaintext estimate 'Px' and if interested in Key so generate estimate key 'Kx'.
Independent Dimensions of Cryptography :
A. Transformation :
1. Substitution : Means mapping plaintext into another elements.
2. Transposition : Elements in plaintext are rearranged
B. Numbers of Key Used :
1. Symmetric Key : If sender and user use same key for encryption as well for decryption.
2. Asymmetric Key : If sender and receiver use different key for encryption as well for decryption i.e. Public and Private key.
C. Processing of Plaintext : Means if we send plaintext so at the time of cipher text how data is processed means one by one or all processed.
Types of Attacks :
A. Cryptanalysis : The attacker attacks on the nature of the algorithm and some basic characteristics of plaintext and pair of plaintext-ciphertext.
B. Brute Force Analysis : In which attackers attacks on the all possible keys until the message is not converted into plaintext.
2. Substitution Techniques
A. Caesar Cipher : Replacing each letter of the plaintext with some shift.
For encryption : C = (P+S)%26
For decryption : P = (C-S)%26
Example : Let us assume that Plaintext (P) is "meet me after party" , and shift (S) is "3" then ciphertext (C) can be written as -
P : meet me after party
C : PHHW PH DIWHU SDUWB
If it is known a given text is caesar cipher then brute force technique is applied because in that case we have 25 keys which is easy to apply.
B. Monoalphabetic Cipher : Suppose in case of caesar cipher you studied
P : abcdefghijklmnopqrstuvwxyz
C : DEFGHIJKLMNOPQRSTUVWXYZABC
but now in case monoalphabetic cipher the cipher text can be the permutation of above C.
In this case total number of possible keys are 26!, which is quite large. So in this algo we tries to find out the sequence means frequency of that sequence or subsequence and compare it with English alphabetic frequency table (as shown in Fig. 2).
Note 1 : A research around over 40,000 words is conducted and the frequency of each character is noted and on the behalf of this a frequency table is drawn which is shown in Fig. 2.
Example : Suppose ciphertext (C) is :
UZQSOVZWPXMOPVGPOGPEPSZWSZ
so the most occurring letter is P here so P can be replaced with E (from the Fig. 2) and the second most occurring element is Z which can be replaced with T
so approximate you will get : TH_ TH_ T
so the most occurring word is THE when TH comes together so ZW can be written as TH and ZWP can be written as THE.
The four most occurring letter in english alphabets are THAT so here ZWSZ be the most occurring four letters. So in this way you can convert any plaintext into ciphertext and vice versa.
C. Playfair Cipher : Which treats diagrams in the plaintext a single units and translates these units into ciphertext diagrams.
Sir Wheatson developed this beautiful cipher technique but it bears the name of his friend baron playfair, who championed the cipher at the british foreign office.
Sir Whaetson uses the 5 x 5 square matrix and this matrix they try to fill al the 26 letters of english alphabets.
Note 2 : 1. I and J comes together because some letters such as J,Z,X,Q have very less frequency and out of these J have more frequency among them and I and J are the most occurring elements in a sentence so I and J comes together.
2. Sir Wheatson uses the diagraph instead of using trigraph, or single letter because the reason behind it that they assume that two players are playing one is you and another is your opponent. That's why they considered two elements together.
3. if key letters is repeating then write it only once.
Rules : 1. If two same letters comes together then add bogus element 'X' with first letter. i.e. Hello is He lx lo
2. If the last letter is single then add bogus letter 'Z' at the end of single letter. i.e. Hell is He lx lz
3. if the two letter falls into same row then you can write the immediate letter in that row.
4. if two letters falls into same column then write the immediate next letter in that same column.
5. if two letter falls into different row and column them writes its intersection points.
Example : Suppose the Key is Akshit and plaintext is Hello.
A |
K |
S |
H |
I/J |
T |
B |
C |
D |
E |
F |
G |
L |
M |
N |
O |
P |
Q |
R |
U |
V |
W |
X |
Y |
Z |
Now Hello can be written as HE LX LO
so HE ---> ID or JD
LX --> QS
LO --> FQ
So the ciphertext is IDQSFQ or JDQSFQ
D. Hill Cipher : it is a polygraphic substitution cipher which is based on linear algebra.
Note 3. 1. Key matrix should always be square matrix if it is not square matrix then add null at the end.
2. if key matrix is m x m order then split plaintext into m x p {here m, and p are any arbitrary numbers}
3. The key matrix should be invertible {for checking invertible the product of that matrix with its inverse should always be identity matrix.}
Suppose C be the ciphertext, P be the plaintext and K be the key then for encryption side
C = KP%26
Similarly for decryption side
P = XC%26 { Here X is the inverse of Key (K)}
Example : Suppose P is : ACT, and K = GYBNQKURP
So C = KP%26
K can be written as
6 |
24 |
1 |
13 |
16 |
10 |
20 |
17 |
15 |
, and P can be written as
0 |
2 |
19 |
So C can be obtained as -
15 |
4 |
7 |
, Hence C = POH
and for decryption side
X can be written as -
8 |
5 |
10 |
21 |
8 |
21 |
21 |
12 |
8 |
so P can be obtained as -
0 |
2 |
19 |
, Hence P = ACT
E. Polyalphabetic Cipher :
. To improve on the simple monoalphabetic technique.
Common Rules : . A set of related monoalphabetic substitution rules is used.
. A key determines which particular rule is chosen for a given transformation.
E.1. Vigener Cipher
Vigenere Cipher is a method of encrypting alphabetic text. It uses a simple form of polyalphabetic substitution. The table consists of the alphabets written out 26 times in different rows, each alphabet shifted cyclically to the left compared to the previous alphabet, corresponding to the 26 possible Caesar Ciphers (as shown in fig. 3).
For Encryption Ci = (Pi+k(i %m)) %26
For Decryption Pi = (Ci-k(i %m))%26
Example : K = Red, P = Howareyou
so for calculating C
K : REDREDRED {Repeated key}
P : HOWAREYOU
C : YSZRVHPSX { Obtained from Fig. 3.}
Note 4. The decryption is quite difficult in vigener cipher due to entire word shift. if you try to decrypt the above message then at final output you will get a shifted message.
Autokey System
Vigener proposed autokey system in which a keyword is concatenated with the plaintext itself to provide a running key.
Example :
K : REDHOWARE
P : HOWAREYOU
So C can be written as {from Fig. 3.}-
C : YSZHFAYFY
E.2 Vernam Cipher
works on binary data
Encryption : Ci = Pi XOR Ki
Decryption : Pi = Ci XOR Ki
One time Pad : Actually, in vernam cipher the key is repeated but in one time pad the key is not repeated and it's a random keywords. The key is used once for encrypt and decrypt a single message and then it is discarded that's why it's name is one time pad but one time pad is difficult to implement in real life. Even more daunting is the problem of key distribution and protection so for that purpose one time pad is mainly used for low bandwidth channels requiring very high security.
3. Transposition
A. Rail Fence : Plaintext is written down as a sequence of diagonals and then read off as a sequence of rows. This technique is also called Zig-Zag technique.
Example : Suppose Plaintext (P) is : meet me after toga party, and key length is 2
so m e m a t r h t g p r y
e t e f e t e o a a t
C : MEMATRHTGPRYETEFETEOAAT
Note : if the key length is more or comparatively equal to plaintext then it is very easy to break the message.
B. Rectangular-Columnar : message is written in rectangle row wise then encrypted according to key value.
Example : K : 4312, P : HOWAREYOU
So C can be obtained as
4 3 1 2
HOWA
REYO
U
C : WYAOOEHRU
if you again apply this procedure on above message then it's again become difficult to break.
4. Rotor Machine : This is as true of substitution ciphers as it is of transposition ciphers. The machine consists of a set of independently rotating cylinders through which electrical pulses can flow. Each cylinder has 26 input pins and 26 output pins, with internal wiring that connects each input pin to a unique output pin (as shown in fig. 4).
Very well explained
ReplyDeleteThat's how a Ph.d. student looks like.
ReplyDeleteKeep shining bhai
ReplyDeleteInformative and easy to understand well done bhai 🔥
ReplyDeleteSei hain bhai 👍
ReplyDeleteExplained very well.
ReplyDelete