CNS Module 1
CNS Module 1
MODULE 1
CHAPTER 1: CLASSICAL ENCRYPTION TECHNIQUES
ud
lo
A symmetric encryption scheme has five ingredients:
C
• 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
tu
Vidya.H.A,
Abhijith H V,Assistant
Dept. ofProfessor,
ISE, SVIT,Dept. of ISE, SVIT
Bengaluru Page 1
1. We need a strong encryption algorithm. At a minimum, we would like the
algorithm to be such that an opponent who knows the algorithm and has access to
one or more ciphertexts would be unable to decipher the ciphertext or figure out the
key.
2. Sender and receiver must have obtained copies of the secret key in a secure
fashion and must keep the key secure.
ud
lo
C
A source produces a message in plaintext, X = [X1, X2, …. XM]. The M elements of X are letters in
tu
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.
V
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)
ud
rearranged. The fundamental requirement is that no information be lost.
2. The number of keys used. If both sender and receiver use the same key, the system
is referred to as symmetric, single-key, secret-key, or conventional encryption. If
the sender and receiver use different keys, the system is referred to as asymmetric,
two-key, or public-key encryption.
lo
3. The way in which the plaintext is processed. A block cipher processes the
input one block of elements at a time, producing an output block for each
input block. A stream cipher processes the input elements continuously,
producing output one element at a time, as it goes along.
C
Cryptanalysis
There are two general approaches to attacking a conventional encryption scheme:
Cryptanalysis: Cryptanalytic attacks rely on the nature of the algorithm plus perhaps
tu
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.
V
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.
tu
• 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.
The Caesar cipher involves replacing each letter of the alphabet with the letter
standing three places further down the alphabet. For example,
ud
C = E (3,p) = (p + 3) mod 26
lo
1. The encryption and decryption algorithms are known.
2. There are only 25 keys to try.
3. The language of the plaintext is known and easily recognizable.
C
Below Figure shows the results of applying this strategy to the example ciphertext. In this
case, the plaintext leaps out as occupying the third line.
tu
V
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
ud
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.
lo I/J
C
• Repeating plaintext letters that are in the same pair are separated with a filler letter,
tu
• 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.
V
• 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).
ud
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
lo
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
V
The first three letters of the plaintext “pay” are represented by the vector (15 0 24).
C = PK mod 26
ud
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 lo
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
C
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.
tu
Vigenere Cipher
One of the simplest, polyalphabetic ciphers is the Vigenère cipher.
key: deceptivedeceptivedeceptive
plaintext: wearediscoveredsaveyourself
ciphertext: ZICVTWQNGRZGVTWAVZHCQYGLMGJ
ud
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
obscured. lo
letter, one for each unique letter of the keyword. Thus, the letter frequency information is
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
C
system, in which a keyword is concatenated with the plaintext itself to provide a running key.
For our example,
tu
key: deceptivewearediscoveredsav
plaintext: wearediscoveredsaveyourself
ciphertext: ZICVTWQNGKZEIIGASXSTSLVVWLA
Even this scheme is vulnerable to cryptanalysis. Because the key and the plaintext share
V
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.
Abhijith H V, Dept. of ISE, SVIT, Bengaluru Page 9
ud
The system can be expressed succinctly as follows
lo
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:
C
One-Time Pad:
The key is to be used to encrypt and decrypt a single message, and then is discarded.
tu
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:
V
ud
The Feistel Cipher
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.
• 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.
V
• 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
Abhijith H V, Dept. of ISE, SVIT, Bengaluru Page 11
consists of the interchange of the two halves of the data.
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.
ud
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.
lo
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.
ud
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
lo
On the decryption side, LD1
[A x B] x C = A x [B x C]D
V
xD=0
Ex0=E
LEi = REi-1
ud
Rearranging terms,
REi-1 = LEi
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
V
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
ud
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
lo
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.
C
Initial Permutation IP:
• 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
lo
Ri = Li-1 x F(Ri-1, Ki)
• The round key Ki is 48 bits. The R input is 32 bits. This R input is first expanded to 48
C
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
tu
four substitutions defined by the four rows in the table for Si. The middle four bits select
one of the sixteen columns.
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.
V
• 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.
V
ud
lo
C
tu
V
ud
lo
C
tu
A change in one bit of the plaintext or one bit of the key should produce a change
in many bits of the ciphertext. If the change were small, this might provide a way to reduce
the size of the plaintext or key space to be searched.
ud
performing one DES encryption per microsecond would take more thana thousand
years to break the cipher.
• If the message is just plain text in English, then the task of recognizing English
would have to be automated.
• If the text message has been compressed before encryption, then recognition is
lo
more difficult. And if the message is some more general type of data, such as a
numerical file, and this has been compressed, the problem becomes even more
difficult to automate.
• Thus, to supplement the brute-force approach, some degree of knowledge about
C
the expected plaintext is needed.
Timing Attacks
A timing attack is one in which information about the key or the plaintext is obtained
V
Differential Cryptanalysis
ud
is to observe the behavior of pairs of text blocks evolving along each round of the cipher,
instead of observing the evolution of a single text block.
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
lo
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
tu
ud
lo
C
tu
V
ud
intermediate rounds are correct. With that assumption, can make some deductions about
the key bits. This procedure must be repeated many times to determine all the key bits.
Linear Cryptanalysis
lo
linear approximations to describe the transformations performed in DES. This method can
find a DES key given 243 known plaintexts, as compared to 247 chosen plaintexts for
differential cryptanalysis. Although this is a minor improvement, because it may be easier
to acquire known plaintext rather than chosen plaintext, it still leaves linear cryptanalysis
C
infeasible as an attack on DES. Again, this attack uses structure not seen before. So far,
little work has been done by other groups to validate the linear cryptanalytic approach.
• Key scheduling.
ud
• If DES had 15 or fewer rounds, differential cryptanalysis would require less
effort than brute-force key search.
Key scheduling
• A final area of block cipher design, and one that has received less attention than
V
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.