Unit-1-Ii CNS (2023-24) (Updated)
Unit-1-Ii CNS (2023-24) (Updated)
1.1.Introduction:
A block cipher is an encryption/decryption scheme in which a block of plaintext is treated as
a whole and used to produce a ciphertext block of equal length.
Many block ciphers have a Feistel structure. Such a structure consists of a number of identical
rounds of processing. In each round, a substitution is performed on one half of the data
being processed, followed by a permutation that interchanges the two halves. The original
key is expanded so that a differe nt key is used for each round.
The Data Encryption Standard (DES) has been the most widely used encryption algorithm until
recently. It exhibits the classic Feistel structure. DES uses a 64-bit block and a 56-bit
key.
1.2. Stream Ciphers and Block Ciphers :
A stream cipher is one that encrypts a digital data stream one bit or one byte at a time.
Examples of classical stream ciphers are the auto keyed Vigenère cipher and the Vernam
cipher.
A block cipher is one in which a block of plaintext is treated as a w hole and used to produce
a ciphertext block of equal length.
Typically, a block size of 64 or 128 bits is used. As with a stream cipher, the two users share
a symmetric encryption key
2.3.1 FEISTEL CIPHER STRUCTURE: The left-hand side of Figure depicts the structure proposed by
Feistel. The inputs to the encryption algorithm are a plaintext block of length 2w bits and a key. 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 to produce the ciphertext block. Each round i has as inputs Li-1 and Ri-
1 derived from the previous round, as well as a subkey Ki derived from the overall K. In general, the
subkeys Ki are different from K and from each other.
All rounds have the same structure. A substitution is performed on the left half of the data.
This is done by applying a round 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. The round function has the same
general structure for each round but is parameterized by the round subkey Ki.
Permutation is performed that consists of the interchange of the two halves of the data. This
structure is a particular form of the substitution-permutation network (SPN) proposed by Shannon.
The exact realization of a Feistel network depends on the choice of the following parameters
and design features:
CSE
Block size: Larger block sizes mean greater security (all other things being equal) but
reduced encryption/decryption speed for a given algori thm. The greater security is achieved
by greater diffusion. Traditionally, a block size of 64 bits has been considered a reasonable
tradeoff and was nearly universal in block cipher design. However, the new AES uses a 128-
bit block size.
Key size: Larger key size means greater security but may decrease encryption/
decryption speed. The greater security is achieved by greater resistance to brute -force
attacks and greater confusion. Key sizes of 64 bits or less are now widely considered to be
inadequ ate, and 128 bits has become a common size.
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.
DES (and most of the other major symmetric ciphers) is based on a cipher known as the Feistel
block cipher. This was a block cipher developed by the IBM cryptography researcher Horst Feistel in
the early
70’s. It consists of a number of rounds where each round contains bit -shuffling, non-linear
substitutions (S-boxes) and exclusive OR operations. Most symmetric encry ption schemes today are
based on this structure (known as a Feistel network).
Overall
structure
DES (and most of the other major symmetric ciphers) is based on a cipher known as the Feistel
block cipher.
Looking at the left-hand side of the figure, we can see that the processing of the plaintext proceeds in
three phases.
First, 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 sixteen rounds of the same function, which involves
both permutation and substitution functions. The output of the last (sixteenth) round consists
of 64 bits that are a function of the input plaintext and the key. The left and right halves of the
output are swapped to produce the preoutput.
Finally, the preoutput is passed through a permutation that is the inverse of the initial
permutation function, to produce the 64-bit cipher text. With the exception of the initial and
final permutations, DES has the exact structure of a Feistel cipher,
The right-hand portion of below shows the way in which the 56-bit key is used. Initially, the key is
passed through a permutation function. Then, for each of the sixteen 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.
CSE
SACET
CSE
Initial Permutation: The initial permutation and its inverse are defined b y tables, as shown in Tables
(a) and (b), respectively. The tables are to be interpreted as follows. The input to a table consists of 64
bits numbered from 1 to 64. The 64 entries in the permutation table contain a permutation of the
numbers from 1 to 64. Each entry i n the permutation table indicates the position of a numbered
input bit in the output, which also consists of 64 bits.
CSE
CSE
To see that these two permutation functions are indeed the inverse of each other, consider the following
64-bit input M:
DETAILS OF SINGLE
ROUND
Below figure shows the internal structure of a single round. Again, begin by focusing on the left-hand
side of the diagram. The left and right halves of each 64-bit intermediate value are treated as separate
32-bit quantities, labeled L (left) and R (right). As in any classic Feistel cipher, the overall processing at
each round can be summarized in the following formulas:
CSE
The round key K i 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 (Table
3.2c). The resulting 48 bits are XORed with K i . This 48-bit result passes through a substitution function
that produces a 32-bit output, which is permuted as defined by Table (d). The role of the S-boxes in
the function F is illustrated in Figure 3.7. The substitution consists of a set of eight S-boxes, each of
which accepts 6 bits as input and produces 4 bits as output. These transformations are defined in Table
3.3, which is interpreted as follows: 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 th e table for. 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. Each row of an S -box defines a general
reversible substitution. Figure 3.2 may be useful in understanding the mapping. The figure shows the
substitution for row 0 of box S1 . The operation of the S-boxes is worth further comment. Ignore for
the moment the contribution of the key ( Ki). If you examine the expansion table, you see that the 32
bits of input are split into groups of 4 bits and then become groups of 6 bits by taking the outer bits
from the two adjacent groups. For example, if part of the input word is
... efgh ijkl mnop
...
This becomes ... defghi hijklm lmnopq
...
CSE
The outer two bits of each group select one of four po ssible substitutions (one row of an S-box). Then
a
4-bit output value is substituted for the particular 4-bit input (the middle four input bits). The 32-bit
output from the eight S-boxes is then permuted, so that on the next round, the output from
each S -box immediately affects as many others as possible.
Substitution Boxes S: Have eight S-boxes which map 6 to 4 bits. Each S-box is actually 4 little 4 bit
boxes. Outer bits 1 & 6 (row bits) select one rows. inner bits 2-5 (col bits) are substituted. Result is 8
lots of 4 bits, or 32 bits. Row selection depends on both data & key
KEY GENERATION:
Returning to above all figures, 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, labelled 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 l
abeled Permuted Choice Two (Table 3.4c), which produces a 48-bit output that serves as input to the
Function F(Ri-1 , Ki).
DES DECRYPTION:
Whatever process we following in the encryption that process is used for decryption also but
the order of key is changed on input message (cipher text).
Reverse order of keys are K 16 , K15 ,……,
K1 .
The Avalanche
Effect:
A desirable property of any encryption algorithm is that a small change in either the plaintext
or the key should produce a significant change in the ciphertext.
In particular, a change in one bit of the plaintext or one bit of the key should produce a ch ange
in many bits of the ciphertext.
This is referred to as the avalanche effect.
TH E STRENGTH OF
DES:
With a key length of 56 bits, there are 256 possible keys, which is approximately 7.2 x 1016 .
A brute-force attack appears impractical. Assuming that, on average, half the key space has
to be searched, a single machine performing one DES encryption per microsecond would
take more than a thousand years to break the cipher. Diffie and Hellman postulated that
the technology existed to build a parallel machine with 1 million encryption devices, each
of which
CSE
could perform one encryption per microsecond. This would bring the average search
time down to about 10 hours.
The Nature of the DES Algorithm:
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
cipher texts.
A timing attack exploits the fact that an encryption or decryption algorithm often takes slightly
different amounts of time on different inputs.
DES appears to be fairly resistant to a successful timing attack.
Number of Rounds:
The greater the number of rounds, the more difficult it is to perform cryptanalysis, even for
a relatively weak F.
In general, the criterion should be that the number of rounds is chosen so that
known cryptanalytic efforts require greater effort than a simple brute -force key search
attack. This criterion was certainly used in the design of DES.
Design of Function F:
The heart of a Feistel block cipher is the function F, which provides the element of confusion
in a Feistel cipher. Thus, it must be difficult to “unscramble” the substitution performed by F.
F must be nonlinear. The more nonlinear F, the more difficult any type of cryptanalysis
will be.
With any Feistel block cipher, the key is used to generate one subkey for each round.
In general, we would like to select subkeys to maximize the difficulty of deducing
individual subkeys and the difficulty of working back to the main key.
AES does not use a Feistel structure. Instead, each full round consists of four
separate functions: byte substitution, permutation, arithmetic operations over a
finite field, and XOR with a key.
Rijndael was designed to have the following characteristics:
Resistance against all known attacks
Speed and code compactness on a wide range of platforms
Design simplicity
AES parameters:
Key size(words/bytes/bits) 4/16/128 6/24/192 8/32/256
Number of rounds 10 12 14
Inner Workings of a
Round
The algorithm begins with an Add round key stage followed by 9 rounds of four stages and
a
tenth round of three stages. This applies for both encryption and decryption with the
exception that each stage of a round the decryption algorithm is the inverse of its
counterpart in the encryption algorithm. The four stages are as follows:
1. Substitute
bytes
2. Shift rows
3. Mix
Columns
4. Add Round Key
The tenth round simply leaves out the Mix Columns stage. The first nine rounds of the
decryption
algorithm consist of the
following:
1. Inverse Shift
rows
2. Inverse Substitute
bytes
3. Inverse Add Round
Key
4. Inverse Mix
Columns
Again, the tenth round simply leaves out the Inverse Mix Columns stage. Each of these
stages
will now be considered in more
detail.
CSE
Substitute Byt es
This stage (known as SubBytes) is simply a table lookup using a 16×16 matrix of byte values
called an s-box. This matrix consists of all the possible combinations of an 8 -bit sequence (28
= 16 × 16
= 256). However, the s -box is not just a random permutation of these values and there is a
well - defined method for creating the s -box tables. The designers of Rijndael showed how
this was done unlike the s -boxes in DES for which no rationale
was given.
Again the matrix that gets operated upon throughout the encryption is known as state. We
will be concerned with how this matrix is effected in each round. For this particular round
each byte is mapped into a new byte in the following wa y: the leftmost nibble of the byte is
used to specify a particular row of the s -box and the rightmost nibble specifies a column. For
example, the byte
{95} (curly brackets represent hex values in FIPS PUB 197) selects row 9 column 5 which turns
out
to contain the value
{2A}.
This is then used to update the state matrix. Figure 7.3 depicts this
idea.
SACET
The Inverse substitute byte transformation makes use of an inverse s -box. In this case what
is desired is to select the value {2A} and get the value {95}. Table 7.4 shows the two s -boxes
and it can be verified that this is in fact the case.
In addition, the s -box has no fixed points (s -box(a) = a) and no opposite fixed points (s -
box(a) = ) where is the bitwise compliment of a.
Performs the circular shifts in the opposite direction for each of the last three rows, with a
one- byte circular right shift for the second row and soon.
AddRoundKey Transformation :
In the forward add round key transformation, called AddRoundKey, the 128 bits of
State are bitwise XORed with the 128 bits of the round key.
The inverse add round key transformation is identical to the forward add round key
transformation, because the XOR operation is its own inverse.
CSE
w4=w0 ⊕ w3
w5=w1 ⊕ w4
w6=w2 ⊕w5
w7=w3 ⊕w6
The simplest mode is the electronic codebook (ECB) mode, in which plaintext is handled one
block at a time and each block of plaintext is encrypted using the same key (Figure a & b). The term
codebook is used because, for a given key, there is a unique ciphertext for every b -bit block of
plaintext. For a message longer than b bits, the procedure is simply to break the message into b -bit
blocks, padding the last block if necessary. Decryption is performed one block at a time, always using
the same key. In Figure, the plaintext (padded as necessary) consists of a sequence of b -bit blocks, P1,
P2,..., PN; the corresponding sequence of ciphertext blocks is C1, C2,..., CN.
Figure. Electronic Codebook (ECB) Mode
The ECB method is ideal for a short amount of data, such as an encryption key. Thus, if you
want to transmit a DES key securely, ECB is the appropriate mode to use. The most significant
characteristic of ECB is that the same b-bit block of plaintext, if it appears more than once in the
message, always produces the same ciphertext.
For lengthy messages, the ECB mode may not be secure. If the message is highly structured,
it may be possible for a cryptanalyst to exploit these re gularities. For example, if it is known that
the message always starts out with certain predefined fields, then the cryptanalyst may have a
number of known plaintext-ciphertext pairs to work with. If the message has repetitive elements,
with a period of repetition a multiple of b bits, then these elements can be identified by the analyst.
This may help in the analysis or may provide an opportunity for substituting or rearranging blocks.
To overcome the security deficiencies of ECB, we would like a technique in which the same
plaintext block, if repeated, produces different cipher text blocks. A simple way to satisfy this
requirement is the cipher block chaining (CBC) mode.
In this scheme, the input to the encryption algorithm is the XOR of the current plaintext block
and the preceding cipher text block; the same key is used for each block. In effect, we have chained
together the processing of the sequence of plaintext blocks. The input to the encryption function for
each plaintext block bears no fixed relationship to the plaintext block. Therefore, repeating patterns
of b bits are not exposed.
The DES scheme is essentially a block cipher technique that uses b -bit blocks. However, it
is possible to convert DES into a stream cipher, using either the cipher feedback (CFB) or the output
feedback mode. Figure depicts the CFB scheme . In the figure, it is assumed that the unit of
transmission is s bits; a common value is s = 8. As with CBC, the units of plaintext are chained together,
so that the cipher text of any plaintext unit is a function of all the preceding plaintext. In this ca se,
rather than units of b bits, the plaintext is divided into segments of s bits.
First, consider encryption. The input to the encryption function is a b -bit shift register that is
initially set to some initialization vector (IV). The leftmost (most significant) s bits of the output of the
encryption function are XORed with the first segment of plaintext P 1 to produce the first unit of
ciphertext C, which is then transmitted. In addition, the contents of the shift register are shifted left
by s bits and C is placed in the rightmost (least significant) s bits of the shift register. This process
continues until all plaintext units have been encrypted.
For decryption, the same scheme is used, except that the received ciphertext unit is XORed with
the output of the encryption function to produce the plaintext unit.
Therefore,
P1 = C1 ⊕ Ss [E(K, IV)]
SACET
The output feedback (OFB) mode is similar in structure to that of CFB, as illustrated in Figure. As can
be seen, it is the output of the encryption function that is fed back to the shift register in OFB,
whereas in CFB the ciphertext unit is fed back to the shift register. One advantage of the OFB method
is that bit errors in transmission do not propagate. For example, if a bit error occurs in C1 only the
recovered value of is P1 affected; subsequent plaintext units are not corrupted. With CFB, C1 also
serves as input to the shift register and therefore causes additional corruption downstream. The
disadvantage of OFB is that it is more vulnerable to a message stream modification attack than is CFB.
Counter Mode:
In CTR mode a counter, equal to the plaintext block size is used. The only requirement is that the
counter value must be different for each plaintext block that is encrypted. Typically, the counter is
initialized to some value and then incremented by 1 for each subsequent block. For encryption, the
counter is encrypted and then XORed with the plaintext block to produce the ciphertext block; there is
no chaining. For decryption, the same sequence of counter values is used, with each encrypted
counter XORed with a ciphertext block to recover the corresponding plaintext block.
Advantages:
1. Hardware efficiency
2. Software efficiency
3. Preprocessing
4. Random access
5. Provable security
6. Simplicity
Figure. Counter (CTR) Mode