Ccs Unit II Notes
Ccs Unit II Notes
Syllabus
Number theory – Algebraic Structures – Modular Arithmetic – Euclid‘s algorithm – Congruence
and matrices – Group, Rings, Fields, Finite Fields SYMMETRIC KEY CIPHERS: SDES –
Block Ciphers – DES, Strength of DES – Differential and linear cryptanalysis – Block cipher
design principles – Block cipher mode of operation – Evaluation criteria for AES –
Pseudorandom Number Generators – RC4 – Key distribution.
.
Algebraic structures:
Cryptography requires sets of integers and specific operations that are defined for those sets. The
combination of the set and the operations that are applied to the elements of the set is called an
algebraic structure. In this chapter, we will define three common algebraic structures:
Next, we define an integral domain, which is a commutative ring that obeys the following
axioms
Fields
A field F , sometimes denoted by {F,+,X}, is a set of elements with two binary
operations, called addition and subtraction , such that for all a,b,c , in F the following axioms
are obeyed
MODULAR ARITHMETIC
If is an integer and n is a positive integer, we define a mod n to be the remainder when a
is divided by n. The integer n is called the modulus. Thus, for any integer a, we can rewrite
Equation as follows:
Properties of Congruences
Congruences have the following properties:
A kind of integer arithmetic that reduces all numbers to one of a fixed set [0… n-1] for some
number n. Any integer outside this range is reduced to one in this range by taking the remainder
after division by n.
Modular arithmetic exhibits the following properties
Euclid‟s algorithm
One of the basic techniques of number theory is the EucliDEAN-IT algorithm, which is a
simple procedure for determining the greatest common divisor of two positive integers. First, we
need a simple definition: Two integers are relatively prime if their only common positive integer
factor is 1.
Phase 1
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.
Phase 2:
This is followed by a phase consisting of 16 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 pre
output.
Phase 3:
Finally, the pre output is passed through a permutation (IP-1) that is the inverse of the
initial permutation function, to produce the 64-bit ciphertext.
The right-hand portion of Figure shows the way in which the 56-bit key is used.
Operation on key:
Initially, the key 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.
Initial Permutation
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 in the
permutation table indicates the position of a numbered input bit in the output, which also consists
of 64 bits.
M1 M2 M3 M4 M5 M6 M7 M8
M9 M10 M11 M12 M13 M14 M15 M16
M17 M18 M19 M20 M21 M22 M23 M24
M25 M26 M27 M28 M29 M30 M31 M32
M33 M34 M35 M36 M37 M38 M39 M40
M41 M42 M43 M44 M45 M46 M47 M48
M49 M50 M51 M52 M53 M54 M55 M56
M57 M58 M59 M60 M61 M62 M63 M64
Inverse permutation Y = IP-1 (X) = IP-1(IP (M)), Therefore we can see that the original ordering of
the bits is restored.
Details of Single Round
The below figure 2.2 shows the internal structure of a single round. 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
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 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, which is then permuted.
Definition of S-Boxes
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 as shown in figure 5.3.
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.
Key Generation
The 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. The key is first subjected to a permutation governed by a
table labeled Permuted Choice One. 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. These shifted values serve as input to the next round. They also serve as input to
Permuted Choice 2, which produces a 48-bit output that serves as input to the function F(Ri-1,
Ki).
DES Key Schedule Calculation
1 2 3 4 5 6 7 8
9 10 11 12 13 14 15 16
17 18 19 20 21 22 23 24
25 26 27 28 29 30 31 32
33 34 35 36 37 38 39 40
41 42 43 44 45 46 47 48
49 50 51 52 53 54 55 56
57 58 59 60 61 62 63 64
(b) Permuted Choice One (PC-1)
57 49 41 33 25 17 9
1 58 50 42 34 26 18
10 2 59 51 43 35 27
19 11 3 60 52 44 36
63 55 47 39 31 23 15
7 62 54 46 38 30 22
14 6 61 53 45 37 29
21 13 5 28 20 12 4
(c) Permuted Choice Two (PC-2)
14 17 11 24 1 5 3 28
15 6 21 10 23 19 12 4
26 8 16 7 27 20 13 2
41 52 31 37 47 55 30 40
51 45 33 48 44 49 39 56
34 53 46 42 50 36 29 32
(d) Schedule of Left Shifts
Roundnumber:1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
Bits rotated : 1 1 2 2 2 2 2 2 1 2 2 2 2 2 2 1
DES Decryption:
As with any Feistel cipher, decryption uses the same algorithm as encryption, except that the
application of the subkeys is reversed. Additionally, the initial and final permutations are
reversed.
The Strength of DES
The strength of DES depends on two factors:key size and the nature of the algorithm.
3. 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.
Differential Cryptanalysis
Differential cryptanalysis is the first published attack that is capable of breaking DES in less
than 255 complexities. The need to strengthen DES against attacks using differential
cryptanalysis played a large part in the design of the S-boxes and the permutation P.
One of the most significant recent (public) advances in cryptanalysis
Powerful method to analyze block ciphers
Used to analyze most current block ciphers with varying degrees of success
Differential Cryptanalysis Attack:
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:
Let us suppose that there are many pairs of inputs to f with the same difference yield the
same output difference if the same subkey is used.
Therefore, if we know Δmi-1 and Δmiwith high probability, then we know Δmi+1 with high
probability. Furthermore, if a number of such differences are determined, it is feasible to
determine the subkey used in the function f.
Linear Cryptanalysis
This attack is based on the fact that linear equation can be framed to describe the
transformations.
The principle of linear crypt analysis is as follows
Length of CT and PT =n bits;key=mbit
Block of cipher text is c[1]c[2]…c[n];
Block of key is k[1]k[2]….k[m]
A[I,j,..k]= A[i] A[j] . A[k]
Can attack DES with 247 known plaintexts, still in practice infeasible
Find linear approximations with prob p != ½
P[i1,i2,...,ia](+)c[j1,j2,...,jb] = k[k1,k2,...,kc]Where ia,jb,kc are bit locations in p,c,k
Number of Rounds
When the greater the number of rounds, the more difficult it is to perform cryptanalysis,
even for a relatively weak F.
Then number of rounds is chosen so that known cryptanalytic efforts require greater
effort than a simple brute-force key search attack.
When round DES S= 16, a differential cryptanalysis attack is slightly less efficient than
brute force, the differential cryptanalysis attack requires 255 operations.
It makes it easy to judge the strength of an algorithm and to compare different algorithms.
Design of Function F
Uses: The ECB method is ideal for a short amount of data, such as an encryption key.
Disadvantage:
When ‘b’ -bit block of plaintext appears more than once in the message, it always
produces the same cipher text output.
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 regularities.
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 produce the first block of cipher text, an initialization vector (IV) is XORed with the
first block of plaintext.
On decryption, the IV is XORed with the output of the decryption algorithm to recover
the first block of plaintext.
Size of IV = Size of data Blocks
We can define CBC mode as
For maximum security, the IV should be protected against unauthorized changes. This
could be done by sending the IV using ECB encryption.
MODE 3: Cipher Feedback Mode:
We know that the DES is a block cipher.it is possible to convert block cipher into stream Cipher
using CFB mode
The advantages of CFB is that
Where
Let the size of a block be b. If the last block of plaintext contains u bits (indicated by *), with
u<b, the most significant u bits of the last output block ON are used for the XOR operation
The remaining b - u bits of the last output block are discarded.
The forward substitute byte transformation, called Sub Bytes, is a simple table
lookup. AES defines a 16 * 16 matrix of byte values, called an S-box , that contains a
permutation of all possible 256 8-bit values.
Each individual byte of State is mapped into a new byte in the following way: The
leftmost 4 bits of the byte are used as a row value and the rightmost 4 bits are used as a column
value. These row and column values serve as indexes into the S-box to select a unique8-bit
output value as shown in figure 2.17.
For example, the hexadecimal value {95} references row 9,column 5 of the S-box, which
contains the value {2A}. Accordingly, the value {95}is mapped into the value {2A}.
Fig 2.15 AES Byte level Operations
Here is an example of the SubBytes transformation:
Where ci is the ith bit of byte c with the value {63}; that is, (c7c6c5c4c3c2c1c0) = (01100011). The
prime ( ‘) indicates that the variable is to be updated by the value on the right.
The AES standard depicts this transformation in matrix form as follows.
In ordinary matrix multiplication, each element in the product matrix is the sum of
products of the elements of one row and one column. Each element in the product matrix
is the bitwise XOR of products of elements of one row and one column.
As an example, consider the input value {95}. The multiplicative inverse in GF(28) is
{95}-1 = {8A}, which is 10001010 in binary. Using above Equation
The result is {2A}, which should appear in row {09} column {05} of the S-box.
Type 2: Inverse Substitute Byte Transformation:
The inverse substitute byte transformation, called InvSubBytes, For example, that the
input {2A} produces the output {95}, and the input {95} to the S-box produces {2A}. The
inverse S-box is constructed by applying the inverse of the transformation is followed by taking
the multiplicative inverse in GF(28). The inverse transformation is
InvSubBytes is the inverse of Sub Bytes, label the matrices in sub Bytes and InvSubBytes
as X and Y, respectively, and the vector versions of constants c and d as C and D, respectively.
For some 8-bit vector B, becomes . We need to show that .
To multiply out, we must show . This becomes
We have demonstrated that YX equals the identity matrix, and the YC = D, so that YC D
equals the null vector.
Type 3: Shift Rows Transformation
The forward shift row transformation, called Shift Rows, is depicted in Figure 2.18a.
The first row of State is not altered. For the second row, a 1-byte circular left shift is performed.
For the third row, a 2-bytecircular left shift is performed. For the fourth row, a 3-byte circular
left shift is performed. The following is an example of Shift Rows
For the first equation, we have {02}.{87} =(0000 1110) (0001 1011) =(0001 0101) and
{03}. {6E} = {6E} ({02}. {6E}) = (0110 1110) (1101 1100) = (1011 0010)
then
The encryption was deemed more important than decryption for two reasons:
1. For the CFB and OFB cipher modes only encryption is used.
2. AES can be used to construct a message authentication code and for this, only encryption is
used.
Type 5: AddRoundKey Transformation
The first matrix is State, and the second matrix is the round key.
The inverses add round key transformation is identical to the forward add round key
transformation, because the XOR operation is its own inverse.
The Figure 2.20 is another view of a single round of AES, emphasizing the mechanisms and
inputs of each transformation.
Type 6: Key Expansion Algorithm
The AES key expansion algorithm takes as input a four-word (16-byte) key and produces
a linear array of 44 words (176 bytes). This is sufficient to provide a four word round key for the
initial AddRoundKey stage and each of the 10 rounds of the cipher.
Each added word w[i]depends on the immediately preceding word, w [i - 1], and the
word four positions back, w[i - 4]. In three out of four cases, a simple XOR is used. For a word
whose position in the w array is a multiple of 4, a more complex function is used.
Figure 2.21 illustrates the generation of the expanded key, using the symbol g to
represent that complex function. The function g consists of the following sub functions
1. RotWord performs a one-byte circular left shift on a word. This means that a input word [B0,
B1, B2, B3] is transformed into [B1, B2, B3, B0].
2. Sub Word performs a byte substitution on each byte of its input word, using theS-box.
3. The result of steps 1 and 2 is XORed with a round constant, Rcon[j].
The round constant is a word in which the three rightmost bytes are always 0.Thus, the
effect of an XOR of a word with Rcon is to only perform an XOR on the leftmost byte of the
word.
The round constant is different for each round and is defined as Rcon[j] = (RC[j], 0, 0, 0),
with RC[1] = 1, RC[j] = 2 # RC[j-1] and with multiplication defined over the field GF(28). The
values of RC[j] in hexadecimal are