Module 1 - Classical Encryption Techniues - Lecture Notes. 16859642199280 PDF
Module 1 - Classical Encryption Techniues - Lecture Notes. 16859642199280 PDF
MODULE 1
CHAPTER 1: CLASSICAL ENCRYPTION TECHNIQUES
Plaintext: This is the original intelligible message or data that is fed into the algorithm
as input.
Encryption algorithm: The encryption algorithm performs various substitutions and
transformations on the plaintext.
Secret key: The secret key is also input to the encryption algorithm. The key is a value
independent of the plaintext and of the algorithm. The algorithm will produce a
different output depending on the specific key being used at the time.
Ciphertext: This is the scrambled message produced as output. It depends on the
plaintext and the secret key.
Decryption algorithm: This is essentially the encryption algorithm run in reverse. It
takes the ciphertext and the secret key and produces the original plaintext.
A source produces a message in plaintext, X = [X1, X2, …. XM]. The M elements of X are letters in
some finite alphabet. Traditionally, the alphabet usually consisted of the 26 capital letters.
For encryption, a key of the form K = [K1, K2, …., KJ] is generated. If the key is generated at the
message source, then it must also be provided to the destination by means of some secure channel.
Alternatively, a third party could generate the key and securely deliver it to both source and
destination.
With the message X and the encryption key K as input, the encryption algorithm forms the ciphertext
Y = [Y1, Y2, ….., YN]. We can write this as
Y = E(K, X)
This notation indicates that Y is produced by using encryption algorithm E as a function of the
plaintext X, with the specific function determined by the value of the key K.
The intended receiver, in possession of the key, is able to invert the transformation:
X = D(K, Y)
Cryptography
Cryptanalysis
There are two general approaches to attacking a conventional encryption scheme:
Cryptanalysis: Cryptanalytic attacks rely on the nature of the algorithm plus perhaps
some knowledge of the general characteristics of the plaintext.
Brute-force attack: The attacker tries every possible key on a piece of ciphertext until an
intelligible translation into plaintext is obtained. On average, half of all possible keys must
be tried to achieve success.
The various types of cryptanalytic attacks based on the amount of information known to the
cryptanalyst is given below.
The cost of breaking the cipher exceeds the value of the encrypted information.
The time required to break the cipher exceeds the useful lifetime of the
information.
Substitution Techniques:
The two basic building blocks of all encryption techniques are substitution and
transposition.
1. Caesar Cipher:
The Caesar cipher involves replacing each letter of the alphabet with the letter
standing three places further down the alphabet. For example,
C = E (3,p) = (p + 3) mod 26
2. Monoalphabetic Ciphers:
If the "cipher" line can be any permutation of the 26 alphabetic characters,then there
are 26! possible keys. This is referred to as a monoalphabetic substitution cipher, because a
single cipher alphabet (mapping from plain alphabet to cipher alphabet) is used per message.
If the cryptanalyst knows the nature of the plaintext (e.g., non compressed English
text), then the analyst can exploit the regularities of the language. the relative frequency of
the letters can be determined and compared to a standard frequency distribution for English
3. Playfair Cipher:
The Playfair algorithm is based on the use of a 5 x 5 matrix of letters constructed using a
keyword.
I/J
Repeating plaintext letters that are in the same pair are separated with a filler letter,
such as x, so that balloon would be treated as ba lx lo on.
Two plaintext letters that fall in the same row of the matrix are each replaced by the
letter to the right, with the first element of the row circularly following the last. For
example, ar is encrypted as RM.
Two plaintext letters that fall in the same column are each replaced by the letter beneath,
with the top element of the column circularly following the last. mu is encrypted as
CM.
Otherwise, each plaintext letter in a pair is replaced by the letter that lies in its own row
and the column occupied by the other plaintext letter. Thus, hs becomes BP andea
becomes IM (or JM, as the encipherer wishes).
4. Hill Cipher
This encryption algorithm takes m successive plaintext letters and substitutes for them m ciphertext
letters. The substitution is determined by m linear equations in which each character is assigned a
numerical value (a = 0, b = 1, c, z = 25). For m = 3, the system can be described as
c1 = (k11p1 + k21p2 + k31p3) mod 26
c2 = (k12p1 + k22p2 + k32p3) mod 26
c3 = (k13p1 + k23p2 + k33p3) mod 26
where C and P are row vectors of length 3 representing the plaintext and ciphertext, and K is a 3 * 3
matrix representing the encryption key. Operations are performed mod 26.
For example, consider the plaintext “paymoremoney” and use the encryption key
The first three letters of the plaintext “pay” are represented by the vector (15 0 24).
C = PK mod 26
Same procedure is repeated for next set of letters “mor” , “emo”, “ney”. We get the cipher texts as
“MWB”, “KAS”, “PDH”
So Plaintext “paymoremoney” is encrypted as RRLMWBKASPDH
Decryption requires using the inverse of the matrix K.
P = CK-1 mod 26
Polyalphabetic Ciphers
One of the way to improve on the simple monoalphabetic technique is to use different monoalphabetic
substitutions as one proceeds through the plaintext message.
The general name for this approach is polyalphabetic substitution cipher. All these techniques have
the following features in common:
1. A set of related monoalphabetic substitution rules is used.
2. A key determines which particular rule is chosen for a given transformation.
Vigenere Cipher
One of the simplest, polyalphabetic ciphers is the Vigenère cipher.
To encrypt a message, a key is needed that is as long as the message. Usually, the key is a
repeating keyword. For example, if the keyword is deceptive, the message "we are discovered
save yourself" is encrypted as follows:
key: deceptivedeceptivedeceptive
plaintext: wearediscoveredsaveyourself
ciphertext: ZICVTWQNGRZGVTWAVZHCQYGLMGJ
Decryption is equally simple. The key letter again identifies the row. The position of
the ciphertext letter in that row determines the column, and the plaintext letter is at the top of
that column.
The strength of this cipher is that there are multiple ciphertext letters for each plaintext
letter, one for each unique letter of the keyword. Thus, the letter frequency information is
obscured.
The periodic nature of the keyword can be eliminated by using a nonrepeating keyword
that is as long as the message itself. Vigenère proposed what is referred to as an autokey
system, in which a keyword is concatenated with the plaintext itself to provide a running key.
For our example,
key: deceptivewearediscoveredsav
plaintext: wearediscoveredsaveyourself
ciphertext: ZICVTWQNGKZEIIGASXSTSLVVWLA
Even this scheme is vulnerable to cryptanalysis. Because the key and the plaintext share
the same frequency distribution of letters, a statistical technique can be applied.
Vernam Cipher
The ultimate defense against such a cryptanalysis is to choose a keyword that is as long as the plaintext
and has no statistical relationship to it. Such a system was introduced by an AT&T engineer named
Gilbert Vernam in 1918.
Mary M Dsouza , Asst.Prof , Dept of ISE , AIT,Bangalore Page 9
Cryptography (18CS744)
Thus, the ciphertext is generated by performing the bitwise XOR of the plaintext and the key. Because
of the properties of the XOR, decryption simply involves the same bitwise operation:
One-Time Pad:
The key is to be used to encrypt and decrypt a single message, and then is discarded.
Each new message requires a new key of the same length as the new message. Such a scheme,
known as a one-time pad, is unbreakable.
The one-time pad offers complete security but, in practice, has two fundamental difficulties:
Feistel cipher is the execution of two or more simple ciphers in sequence in such a way
that the final result or product is cryptographically stronger than any of the component ciphers.
Diffusion is the statistical structure of the plaintext is dissipated into long-range statistics of the
ciphertext. This is achieved by having each plaintext digit affect the valueof many ciphertext digits;
generally this is equivalent to having each ciphertext digit be affected by many plaintext digits.
Confusion seeks to make the relationship between the statistics of the ciphertext and the value of
the encryption key as complex as possible, again to thwart attempts to discover the key.
The inputs to the encryption algorithm are a plaintext block of length 2w bits and akey K.
The plaintext block is divided into two halves, L0 and R0.
The two halves of the data pass through n rounds of processing and then combine toproduce
the ciphertext block.
Each round i has as inputs Li-1 and Ri-1, derived from the previous round, as well as asubkey
Ki, derived from the overall K.
In general, the subkeys Ki are different from K and from each other.
A substitution is performed on the left half of the data. This is done by applying around
function F to the right half of the data and then taking the exclusive-OR of the output of that
function and the left half of the data. Following this substitution, a permutation is performed that
Mary M Dsouza , Asst.Prof , Dept of ISE , AIT,Bangalore Page 11
Cryptography (18CS744)
The exact realization of a Feistel network depends on the choice of the following parameters and
design features:
Block size: Larger block sizes mean greater security, but reduced encryption/decryption speed for
a given algorithm.
Key size: Larger key size means greater security but may decrease encryption/decryptionspeed.
The greater security is achieved by greater resistance to brute-force attacks and greater confusion.
Number of rounds: The essence of the Feistel cipher is that a single round offers inadequate
security but that multiple rounds offer increasing security. A typical size is 16 rounds.
Subkey generation algorithm: Greater complexity in this algorithm should lead to greater
difficulty of cryptanalysis.
Round function: Again, greater complexity generally means greater resistance to cryptanalysis.
The process of decryption with a Feistel cipher is essentially the same as the encryption
process. The rule is as follows: Use the ciphertext as input to the algorithm,but use the subkeys
Ki in reverse order. That is, use Kn in the first round, Kn-1 in the second round, and so on until K1
is used in the last round.
Now we would like to show that the output of the first round of the decryption process is
equal to a 32-bit swap of the input to the sixteenth round of the encryption process. First, consider
the encryption process. We see that
LE16 = RE15
[A x B] x C = A x [B x C]D
xD=0
Ex0=E
Thus, we have LD1 = RE15 and RD1 = LE15. Therefore, the output of the firstround of the
decryption process is LE15||RE15, which is the 32-bit swap of the input to the sixteenth round of
the encryption. This correspondence holds all the way through the 16 iterations, as is easily shown.
We can cast this process in general terms. For the ith iteration of the encryption algorithm,
LEi = REi-1
Rearranging terms,
REi-1 = LEi
The most widely used encryption scheme is based on the Data Encryption Standard (DES)
adopted in 1977 by the National Institute of Standards and Technology (NIST).
The algorithm itself is referred to as the Data Encryption Algorithm (DEA). For DES, data
are encrypted in 64-bit blocks using a 56-bit key. The algorithm transforms 64-bit input in a series
of steps into a 64-bit output. The same steps, with the same key, are used to reverse the encryption.
DES Encryption
As with any encryption scheme, there are two inputs to the encryption function: the
plaintext to be encrypted and the key. In this case, the plaintext must be 64 bits in length and the
key is 56 bits in length.
Looking at the left-hand side of the figure, the processing of the plaintext proceedsin three
phases.
1. The 64-bit plaintext passes through an initial permutation (IP) that rearranges the
bits to produce the permuted input. This is followed by a phase consisting of 16 rounds
of the same function, which involves both permutationand substitution functions.
2. The output of the last (sixteenth) round consists of 64 bits that are a function ofthe input
plaintext and the key. The left and right halves of the output are swapped to produce
the preoutput.
3. Finally, the preoutput is passed through a permutation (IP-1) that is the inverse of the
initial permutation function, to produce the 64-bit ciphertext. With the exception of the
initial and final permutations, DES has the exact structure of a Feistel cipher
The right-hand portion shows the way in which the 56-bit key is used. Initially, thekey is
passed through a permutation function. Then, for each of the 16 rounds, a subkey (Ki) is produced
by the combination of a left circular shift and a permutation. The permutation function is the same
for each round, but a different subkey is produced because of the repeated shifts of the key bits.
The left and right halves of each 64-bit intermediate value are treated as separate 32-
bit quantities, labeled L (left) and R (right).
the overall processing at each round can be summarized in the following formulas:
Li = Ri-1
The round key Ki is 48 bits. The R input is 32 bits. This R input is first expanded to 48
bits by using a table that defines a permutation plus an expansion that involves
duplication of 16 of the R bits.
The resulting 48 bits are XORed with Ki. This 48-bit result passes through a substitution
function that produces a 32-bit output.
The substitution consists of a set of eight S-boxes, each of which accepts 6 bits as input
and produces 4 bits as output.
The first and last bits of the input to box Si form a 2-bit binary number to select one of
four substitutions defined by the four rows in the table for Si. The middle four bits select
one of the sixteen columns.
The decimal value in the cell selected by the row and column is then converted to its
4-bit representation to produce the output. For example, in S1 for input 011001, the
row is 01 (row 1) and the column is 1100 (column 12). The value in row 1, column 12
is 9, so the output is 1001.
K EY GENERATION :
Returning to Figures 3.5 and 3.6, we see that a 64-bit key is used as input to the
algorithm.
The bits of the key are numbered from 1 through 64;every eighth bit is ignored, as
indicated by the lack of shading in Table 3.4a.
The key is first subjected to a permutation governed by a table labeled Permuted
Choice One (Table 3.4b).
The resulting 56-bit key is then treated as two 28-bit quantities, labeled C0 and D0. At
each round, Ci-1 and Di-1 are separately subjected to a circular left shift or (rotation)
of 1 or 2 bits,as governed by Table 3.4d.
These shifted values serve as input to the next round. They also serve as input to the
part labeled Permuted Choice Two (Table 3.4c), which produces a 48-bit output that
Timing Attacks
A timing attack is one in which information about the key or the plaintext is obtained
by observing how long it takes a given implementation to perform decryptions on various
ciphertexts. This is a long way from knowing the actual key, but it is an intriguing first
step.
Differential Cryptanalysis
Consider the original plaintext block m to consist of two halves m0, m1. Each round
of DES maps the right-hand input into the left-hand output and sets the right-hand output
to be a function of the left-hand input and the subkey for this round. So, at each round, only
one new 32-bit block is created. If we label each new block
In differential cryptanalysis, we start with two messages, m and m', with a known
XOR difference m = m⊕ m', and consider the difference between the intermediate
message halves: mi = mi⊕ mi' Then we have:
Linear Cryptanalysis
Key scheduling
A final area of block cipher design, and one that has received less attention than
S-box design, is the key schedule algorithm. With any Feistel block cipher, the
key schedule is used to generate a subkey for each round.
Would like to select subkeys to maximize the difficulty of deducing individual
subkeys and the difficulty of working back to the main key. The key schedule
should guarantee key/ciphertext Strict Avalanche Criterion and Bit Independence
Criterion.