CCS Unit-2
CCS Unit-2
SEM-05
COMPUTER AND COMMUNICATION
ENGINEERING
UNIT – II
1|P a ge
Downloaded by Varsha R ([email protected])
lOMoARcPSD|28867284
2|P a ge
Downloaded by Varsha R ([email protected])
lOMoARcPSD|28867284
3|P a ge
Downloaded by Varsha R ([email protected])
lOMoARcPSD|28867284
4|P a ge
Downloaded by Varsha R ([email protected])
lOMoARcPSD|28867284
To increase the complexity of the round function, the avalanche effect is also included in the round
function, as the change of a single bit in plain text would produce a mischievous output due to the
presence of avalanche effect.
Key schedule algorithm – In Feistel Block cipher structure, each round would generate a sub-key for
increasing the complexity of cryptanalysis. The Avalanche effect makes it more complex in deriving
sub-key. Decryption must be done very carefully to get the actual output as the avalanche effect is
present in it.
Strength of DES:
Data encryption standard (DES) is a symmetric key block cipher algorithm. The algorithm is based on
Feistel network. The algorithm uses a 56-bit key to encrypt data in 64-bit blocks.
There are mainly two categories of concerns about the strength of Data encryption standard. They are:
Concerns about the particular algorithm used.
Concerns about the usage of key of size 56-bit.
The first concern regarding the algorithm used addresses the possibility of cryptanalysis by making use
of the DES algorithm characteristics. A more severe concern is about the length of secret key used.
Differential and linear cryptanalysis:
For most of its life, the prime concern with DES has been its vulnerability to brute-force attack
because of its relatively short (56 bits) key length. However, there has also been interest in finding
cryptanalytic attacks on DES. With the increasing popularity of block ciphers with longer key lengths,
including triple DES, brute-force attacks have become increasingly impractical. Thus, there has been
increased emphasis on cryptanalytic attacks on DES and other symmetric block ciphers. In this section,
we provide a brief overview of the two most powerful and promising approaches: differential
cryptanalysis and linear cryptanalysis.
Differential Cryptanalysis Attack - The differential cryptanalysis attack is complex; [BIHA93] provides
a complete description. The rationale behind differential cryptanalysis 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. Here, we provide a brief overview so that you can get the flavor of the attack. We
begin with a change in notation for DES. 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 mi (2 … i … 17), then the
intermediate message halves are related as follows:
The overall strategy of differential cryptanalysis is based on these considerations for a single round. The
procedure is to begin with two plaintext messages m and m¿ with a given difference and trace through a
probable pattern of differences after each round to yield a probable difference for the ciphertext.
Actually, there are two probable patterns of differences for the two 32-bit halves: (¢m17 || ¢m16). Next,
we submit m and m¿ for encryption to determine the actual difference under the unknown key and
compare the result to the probable difference. If there is a match,
5|P a ge
Downloaded by Varsha R ([email protected])
lOMoARcPSD|28867284
A replacement for DES was needed as its key size was too small. With increasing computing power, it
was considered vulnerable against exhaustive key search attack. Triple DES was designed to overcome
this drawback but it was found slow. The features of AES are as follows −
Symmetric key symmetric block cipher
128-bit data, 128/192/256-bit keys
Stronger and faster than Triple-DES
Provide full specification and design details
Software implementable in C and Java
Operation of AES: AES is an iterative rather than Feistel cipher. It is based on ‘substitution–
permutation network’. It comprises of a series of linked operations, some of which involve replacing
inputs by specific outputs (substitutions) and others involve shuffling bits around (permutations).
Interestingly, AES performs all its computations on bytes rather than bits. Hence, AES treats the 128
bits of a plaintext block as 16 bytes. These 16 bytes are arranged in four columns and four rows for
processing as a matrix. Unlike DES, the number of rounds in AES is variable and depends on the length
of the key. AES uses 10 rounds for 128-bit keys, 12 rounds for 192-bit keys and 14 rounds for 256-bit
keys. Each of these rounds uses a different 128-bit round key, which is calculated from the original AES
key.
RC4 – Key distribution.
RC4 is a stream cipher and variable length key algorithm. This algorithm encrypts one byte at a time (or
larger units on a time). A key input is pseudorandom bit generator that produces a stream 8-bit number
that is unpredictable without knowledge of input key, The output of the generator is called key-stream,
is combined one byte at a time with the plaintext stream cipher using X-OR operation.
Key-Generation Algorithm – A variable-length key from 1 to 256 byte is used to initialize a 256-byte state
vector S, with elements S[0] to S[255]. For encryption and decryption, a byte k is generated from S by
selecting one of the 255 entries in a systematic fashion, then the entries in S are permuted again.
6|P a ge
Downloaded by Varsha R ([email protected])
lOMoARcPSD|28867284
7|P a ge
Downloaded by Varsha R ([email protected])
lOMoARcPSD|28867284
8|P a ge
Downloaded by Varsha R ([email protected])
lOMoARcPSD|28867284
In each step, r1, r2, and r have the same values in the Euclidean algorithm. The variables r1 and r2
are initialized to the values of a and b, respectively. The variables s1 and s2 are initialized to 1 and 0,
respectively. The variables t1 and t2 are initialized to 0 and 1, respectively. The calculations of r, s, and t
are similar, with one warning. Although r is the remainder of dividing r1 by r2, there is no such
relationship between the other two sets. There is only one quotient, q, which is calculated as r1 by r2 and
used for the other two calculations.
9|P a ge
Downloaded by Varsha R ([email protected])
lOMoARcPSD|28867284
10 | P a g e
Downloaded by Varsha R ([email protected])
lOMoARcPSD|28867284
2.1.4.2 Matrices:
Definitions: A matrix is a rectangular array of l x m elements, in which l is the number of rows and m
is the number of columns. A matrix is normally denoted with a boldface uppercase letter such as A.
The element aij is located in the ith row and jth column.
If a matrix has only one row (l x 1), it is called a row matrix; if it has only one column
(mx1), it is called a column matrix. In a square matrix, in which there is the same number of
rows and columns (l = m), the elements a11, a22, …. , amm make the main diagonal. An additive
identity matrix, denotedas 0, is a matrix with all rows and columns set to 0’s. An identity matrix,
denoted as I, is a square matrix with 1s on the main diagonal and 0s elsewhere.
Operations and Relations
In linear algebra, one relation (equality) and four operations (addition, subtraction, multiplication, and
scalar multiplication) are defined for matrices.
Equality
Two matrices are equal if they have the same number of rows and columns and the
corresponding elements are equal. In other words, A = B if we have aij = bij for all i’s and j’s.
Addition and Subtraction
Two matrices can be added if they have the same number of columns and rows. This
addition is shown as C = A + B. In this case, the resulting matrix C has also the same
number of rows and columns as A or B. Each element of C is the sum of the two
corresponding elements of A and B: cij = aij + bij. Subtraction is the same except that each
element of B is subtracted from the corresponding element of A: dij = aij - bij.
Multiplication
We can multiply two matrices of different sizes if the number of columns of the first matrix
is the same as the number of rows of the second matrix. If A is an l x m matrix and B is an m
x p matrix, the product of the two is a matrix C of size l x p. If each element of matrix A is
called aij, each element of matrix B is called bjk, then each element of matrix C, cik, can be
calculated as:
cik = ∑ 𝐚𝐢𝐣 𝐱 𝐛𝐣𝐤 = ai1 x b1j + ai2 x b2j + ……+ aim x bmj
Scalar Multiplication
We can also multiply a matrix by a number (called a scalar). If A is an l x m matrix and x is a
scalar, C = xA is a matrix of size l x m, in which cij = x x aij.
2.1.4.3 Determinant
The determinant of a square matrix A of size m x m denoted as det (A) is a scalar calculated
recursively as shown below:
If m = 1, det (A) = a11
If m > 1, det (A) = ∑(−𝟏)𝐢+𝐣 𝐱 𝐚𝐢𝐣 𝐱 det (Aij)
Inverses
Matrices have both additive and multiplicative inverses.
Additive Inverse
The additive inverse of matrix A is another matrix B such that A + B = 0. In other words, we
have bij = - aij for all values of i and j. Normally the additive inverse of A is defined by -A.
Multiplicative Inverse
The multiplicative inverse is defined only for square matrices. The multiplicative inverse
of a square matrix A is a square matrix B such that A x B = B x A = I. Normally the
multiplicative inverse of A is defined by A-1. The multiplicative inverse exists only
if the (A) has a multiplicative inverse in the corresponding set. Since no integer has a
multiplicative inverse in Z, there is no multiplicative inverse of a matrix in Z. However,
matrices with real elements have matrices only if det (A) ≠ 0.
Congruence
11 | P a g e
Downloaded by Varsha R ([email protected])
lOMoARcPSD|28867284
Two matrices are congruent modulo n, written as A ≡ B (mod n), if they have the same
number of rows and columns and all corresponding elements are congruent modulo n. In
other words, A ≡ B (mod n) if aij ≡ bij (mod n) for all i’s and j’s.
2.1.4.4 Groups:
⚫ Fundamental elements of modern algebra.
GROUPS:{G, .}
• It is a set of elements or “numbers” with binary operation, denoted by .
• The elements in a Group obeys the properties:
• A1: Closure: if a and b belong to G, then a . B is also in G.
• A2: Associative law: (a.b).c = a.(b.c).
• A3: Has identity e: e . a = a . e = a.
• A4: Has inverses a : -1
a . a-1 = e.
• A5: If commutative a . b = b . a then it forms an abelian group.
• Finite group- It contains finite number of elements.
• Order of a group- Represents number of elements in a group. Otherwise the group is
infinite.
• CYCLIC GROUP- A group is cyclic if every element of G is a power ak. Where k is an
integer and a is an element in Group G.
• Eg: a3=a .a. a.
2.1.4.5 Rings:
• A set of “numbers” with two binary operations (addition and multiplication).{R, +, x}
• R is an abelian group with addition operation (+) (A1-A5) identity-0, inverse as –a.
• Multiplication properties:
– M1: Has closure-if a,b€R, then a.b also €R.
– M2: Is associative-a(bc)=(ab)c.
– M3: Distributive over Addition: a(b+c) = ab + ac.
– M4: If multiplication operation is commutative, it forms a commutative ring
(ab=ba).
– M5: Multiplicative identity- a.1=1.a=a.
– M6: No zero divisors, ab=0, then a=0 or b=0.
2.1.4.6 Field{F,+,x}:
• a set of elements with two binary operations addition and multiplication.
• The following axioms are obeyed:
• A1: Closure: if a and b belong to F, then a . B is also in F.
• A2: Associative law: (a.b).c = a.(b.c).
• A3: Has identity e: e . a = a . e = a.
• A4: Has inverses a-1: a . a-1 = e.
• A5: If commutative a . b = b . a.
• M1: Has closure-if a,b€R, then a.b also €R.
• M2: Is associative-a(bc)=(ab)c.
• M3: Distributive over Addition: a(b+c) = ab + ac.
• M4: If multiplication operation is commutative, it forms a commutative field (ab=ba).
• M5: Multiplicative identity- a.1=1.a=a.
• M6: No zero divisors, ab=0, then a=0 or b=0.
• M7: Multiplicative inverse: aa-1=a-1a=1.
2.1.4.7 Finite fields:
• A field is a set of elements with two custom-defined arithmetic operations: most
commonly, addition and multiplication.
• A field is called finite if it has a finite number of elements. The most commonly used
finite fields in cryptography are the field Fp (where p is a prime number)
• Also known as Galois fields and it is denoted as GF(pn). and in particular often use the
12 | P a g e
Downloaded by Varsha R ([email protected])
lOMoARcPSD|28867284
fields:
• GF(p)
• GF(2n)
• GF(p) is the set of integers {0,1, … , p-1} with arithmetic operations modulo prime p
and these form a finite field.
• Since it has multiplicative inverses, hence arithmetic is “well-behaved” and can do
addition, subtraction, multiplication, and division without leaving the field GF(p)
13 | P a g e
Downloaded by Varsha R ([email protected])
lOMoARcPSD|28867284
14 | P a g e
Downloaded by Varsha R ([email protected])
lOMoARcPSD|28867284
0 1 2 3 0 1 2 3
01 0 3 2 00 1 2 3
13 2 1 0 12 0 1 3
15 | P a g e
Downloaded by Varsha R ([email protected])
lOMoARcPSD|28867284
S0 20 2 1 3 S1 23 0 1 0
33 1 3 2 32 1 0 3
16 | P a g e
Downloaded by Varsha R ([email protected])
lOMoARcPSD|28867284
17 | P a g e
Downloaded by Varsha R ([email protected])
lOMoARcPSD|28867284
18 | P a g e
Downloaded by Varsha R ([email protected])
lOMoARcPSD|28867284
19 | P a g e
Downloaded by Varsha R ([email protected])
lOMoARcPSD|28867284
We can use Triple-DES with Three-Keys to avoid even impractical attacks as,
C = EK3(DK2(EK1(P)))
A number of Internet-based applications have adopted three-key 3DES, including PGP and S/MIME.
20 | P a g e
Downloaded by Varsha R ([email protected])
lOMoARcPSD|28867284
21 | P a g e
Downloaded by Varsha R ([email protected])
lOMoARcPSD|28867284
22 | P a g e
Downloaded by Varsha R ([email protected])
lOMoARcPSD|28867284
23 | P a g e
Downloaded by Varsha R ([email protected])
lOMoARcPSD|28867284
use it as input to the same algorithm. The input to the first round is RE16 || LE16, which is equal to the
32-bit swap of the output of the sixteenth round of the encryption process.
Now we will see how 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,
LE16 = RE15
RE16 = LE15 F (RE15, K16) On the decryption
side, LD1 =RD0 = LE16 =RE15
RD1 = LD0 F (RD0, K16)
= RE16 F (RE15, K16)
= [LE15 F (RE15, K16)] F (RE15, K16)
= LE15 Therefore, LD1 = RE15 RD1 = LE15
In general, for the ith iteration of the encryption
algorithm, LEi = REi-1 REi = LEi-1
F (REi-1, Ki)
Finally, the output of the last round of the decryption process is RE0 || LE0. A 32-bit swap recovers the
original plaintext.
A block cipher processes the data blocks of fixed size. Usually, the size of a message is larger than the
block size. Hence, the long message is divided into a series of sequential message blocks, and the
cipher operates on these blocks one at a time.
2.8.1 Electronic Code Book (ECB) Mode:
This mode is a most straightforward way of processing a series of sequentially listed message blocks.
Operation:
The user takes the first block of plaintext and encrypts it with the key to produce the first block
of ciphertext.
He then takes the second block of plaintext and follows the same process with same key and so
on so forth.
The ECB mode is deterministic, that is, if plaintext block P1, P2,…, Pm are encrypted twice under
the same key, the output ciphertext blocks will be the same.
In fact, for a given key technically we can create a codebook of ciphertexts for all possible
plaintext blocks. Encryption would then entail only looking up for required plaintext and select the
corresponding ciphertext. Thus, the operation is analogous to the assignment of code words in a
codebook, and hence gets an official name − Electronic Codebook mode of operation (ECB). It is
illustrated as follows:
25 | P a g e
Downloaded by Varsha R ([email protected])
lOMoARcPSD|28867284
26 | P a g e
Downloaded by Varsha R ([email protected])
lOMoARcPSD|28867284
and XOR them with ‘s’ bit plaintext message block to generate ciphertext block.
Feed ciphertext block into top register by shifting already present data to the left and
continue the operation till all plaintext blocks are processed.
Essentially, the previous ciphertext block is encrypted with the key, and then the result is
XORed to the current plaintext block.
Similar steps are followed for decryption. Pre-decided IV is initially loaded at the start of
decryption.
27 | P a g e
Downloaded by Varsha R ([email protected])
lOMoARcPSD|28867284
28 | P a g e
Downloaded by Varsha R ([email protected])
lOMoARcPSD|28867284
29 | P a g e
Downloaded by Varsha R ([email protected])
lOMoARcPSD|28867284
30 | P a g e
Downloaded by Varsha R ([email protected])
lOMoARcPSD|28867284
The final round contains only 3 transformations, and there is a initial single transformation (Add
Round Key) before the first round, which can be considered Round 0. Each transformation takes one
or more 4 x 4 matrices as input and produces a 4 x 4 matrix as output. Figure 5.1 shows that the
output of each round is a 4 x 4 matrix, with the output of the final round being the ciphertext. Also,
the key expansion function generates N + 1 round keys, each of which is a distinct 4 x 4 matrix. Each
round key served as one of the inputs to the Add Round Key transformation in each round.
2.9.1.2 Substitute Bytes:
The Substitute bytes stage uses an S-box to perform a byte-by-byte substitution of the block.
There is a single 8-bit wide S-box used on every byte. This S-box is a permutation of all 256 8-bit
values, constructed using a transformation which treats the values as polynomials in GF(28) – however
it is fixed, so really only need to know the table when implementing. Decryption requires the inverse
of the table.
The table was designed to be resistant to known cryptanalytic attacks. Specifically, the Rijndael
developers sought a design that has a low correlation between input bits and output bits, with the
property that the output cannot be described as a simple mathematical function of the input, with no
fixed points and no “opposite fixed points”.
32 | P a g e
Downloaded by Varsha R ([email protected])
lOMoARcPSD|28867284
inverse mix columns step be applied to the round keys first – this makes the decryption key schedule
a little more complex with this construction, but allows the use of same h/w or s/w for the data
en/decrypt computation.
RC4 is a stream cipher and variable length key algorithm. This algorithm encrypts one byte at a time.
A key input is pseudorandom bit generator that produces a stream 8-bit number that is unpredictable
without knowledge of input key, The output of the generator is called key-stream, is combined one
byte at a time with the plaintext stream cipher using X-OR operation.
34 | P a g e
Downloaded by Varsha R ([email protected])
lOMoARcPSD|28867284
2.11.1 State
RC4 is based on the concept of a state.
S[0] S[1] S[2]...........S[255]
2.11.2 The RC4 Stream Cipher:
• RC4 was designed by Ron Rivest in 1987 for RSA Security.
• It was kept as a trade secret until leaked out in 1994.
• One of the most popular stream cipher.
• RC4 is Simple and fast.
• It is used in the SSL/TLS standards (for secure Web communication), IEEE 802.11 wireless
LAN standard, Microsoft Point-to-Point Encryption, and many others.
2.11.3 Key Scheduling Algorithm:
Initialization: Initialization is done in two steps:
In the first step, the state is initialized to values 0,1,…,255. A key array K[0],K[1]…,K[255]
is also created. If the secret key has exactly 256 bytes, the bytes are copied to the K array
otherwise the bytes are repeated until the K array is filled.
for (i=0to255)
{
S[i]=i
K[i]=key[imodKeylength]
In the second step, the initialized state goes through a permutation based on the value of the
bytes in K[i]. The key byte is used only in this step to define which elements are to be
swapped. The state bytes are shuffled after this step.
j=0
for (i=0to255)
{
j=(j+S[i]+K[i])
mod256
swap(S[i],S[j])
}
i=j=0
Key Stream Generation: The keys in the key stream, the K’s are generated one by one. First
the state is permuted on the values of state elements and the values of two individual
variables i and j. second the values of two state elements in positions i and j are used to
define the index of the state element that serves as K. The following code is used:
i=(i+l)mo
d256
j=(j+S[i])
mod256
swap(S[i],
S[j])
k=(S[i]+S[j])
mod256
keystreamByt
e=S[k]
The output i.e. keystream Byte is a single byte that can be XORed with plaintext to encrypt or
XORed with ciphertext to decrypt.
2.11.44 Security of RC4:
• The keystream generated by RC4 is biased.
• The first few bytes are strongly non-random and cannot leak information about the
input key.
35 | P a g e
Downloaded by Varsha R ([email protected])
lOMoARcPSD|28867284
36 | P a g e
Downloaded by Varsha R ([email protected])
lOMoARcPSD|28867284
37 | P a g e
Downloaded by Varsha R ([email protected])
lOMoARcPSD|28867284
At this point, a session key has been securely delivered to A and B, and they may begin their
protected exchange. Two additional steps are desirable:
4. Using the new session key for encryption B sends a nonce N2 to A.
5. Also using Ks, A responds with f(N2), where f is a function that performs some transformation on
N2 (eg. adding one). These steps assure B that the original message it received (step 3) was not a
replay. Note that the actual key distribution involves only steps 1 through 3 but that steps 4 and 5, as
well as 3, perform an authentication function.
38 | P a g e
Downloaded by Varsha R ([email protected])