Unit II
Unit II
Unit II
Modern Block Ciphers
2 CSE-AVCCE
Block vs Stream Ciphers
Block ciphers process messages in blocks, each of which is
then en/decrypted
like a substitution on very big characters 64-bits or more
stream ciphers process messages a bit or byte at a time when
en/decrypting
many current ciphers are block ciphers
3 CSE-AVCCE
Block vs Stream Ciphers
4 CSE-AVCCE
SIMPLIFIED DATA ENCRYPTION STANDARD (S-DES)
5 CSE-AVCCE
Encryption algorithm involves 5 functions
Initial permutation (IP)
A complex function (Round function) involves both permutation
and substitution operations (fk )
Swapping ( SW )
Complex function (fk )
Inverse of initial permutation (IP-1)
6 CSE-AVCCE
7 CSE-AVCCE
S-DES key generation
8 CSE-AVCCE
S-DES
Encryption
9 CSE-AVCCE
Permutation Boxes – P Box
10 CSE-AVCCE
S-Box
00 01 10 11
S0 00 01 00 11 10
01 11 10 01 00
10 00 10 01 11
11 11 01 11 10
11 CSE-AVCCE
Example
Plaintext : 10111101
Key : 1010000010
Assignment 2
Perform encryption using SDES
Plain text : 1 1 0 0 1 1 0 0
Key : 1 0 1 0 1 0 1 1 0 1
12 CSE-AVCCE
Claude Shannon and Substitution-
Permutation Ciphers
Claude Shannon introduced idea of substitution-permutation
(S-P) networks in 1949 paper
form basis of modern block ciphers
S-P nets are based on the two primitive cryptographic
operations seen before:
substitution (S-box)
permutation (P-box)
13 CSE-AVCCE
Principles of Confusion and Diffusion
plaintext ciphertext plaintext
Encryption Decryption
Key KA Key KB
• Terms courtesy of Claude Shannon, father of
Information Theory
• “Confusion” = Substitution
• a -> b
• Caesar cipher
• “Diffusion” = Transposition or Permutation
• abcd -> dacb
14 • CSE-AVCCE
DES
Principles of Confusion and Diffusion
• “Confusion” : a classical Substitution Cipher
Courtesy:
Andreas
Steffen
Courtesy:
Andreas
Steffen
17 CSE-AVCCE
Feistel Cipher Structure
Horst Feistel devised the Feistel cipher
The Feistel cipher structure is based on Shannon's proposal
of 1945, is the structure used by many significant symmetric
block ciphers currently in use.
Feistel proposed the use of a cipher that alternates
substitutions and permutations
18 CSE-AVCCE
Feistel Cipher Structure
Figure depicts the structure proposed by Feistel.
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
19 CSE-AVCCE
Feistel Cipher
Encryption
20 CSE-AVCCE
Fiestel
Encryption
and
Decryption
21 CSE-AVCCE
Feistel Cipher Design Principles
Block size
increasing size improves security, but slows cipher
Key size
increasing size improves security, makes exhaustive key searching
harder, but may slow cipher
Number of rounds
increasing number improves security, but slows cipher
Round function
greater complexity can make analysis harder, but slows cipher
22 CSE-AVCCE
DATA ENCRYPTION STANDARD (DES)
History
25 CSE-AVCCE
Encryption
[1]
26 CSE-AVCCE
Initial Permutation IP
First step of the data computation
IP reorders the input data bits
even bits to LH half, odd bits to RH half
quite regular in structure
27 CSE-AVCCE
Encryption
29 CSE-AVCCE
30 CSE-AVCCE
DES Round Structure
31 CSE-AVCCE
Encryption (Round)
(Key Generation)
32 CSE-AVCCE [1]
Substitution Boxes S
• 8 S-boxes
• Each S-Box maps 6 to 4 bits
• outer bits 1 & 6 (row bits) select the row
• inner bits 2-5 (col bits) select the column
• For example, in S1, for input 011001,
• the row is 01 (row 1)
• the column is 1100 (column 12).
• The value in row 1, column 12 is 9
• The output is 1001.
• result is 8 X 4 bits, or 32 bits
33 CSE-AVCCE
Substitution Boxes S
so the 8 s-boxes
Si implement the 48-bit to
32-bit contraction
output symbol substitution
34 CSE-AVCCE
Encryption (Round) (cont.)
S-box
Example : 010001
1,6 th bit refers row – 01 – 1st row
Middle 4 bits refers column – 1000 – 8th
column
35 CSE-AVCCE [1]
Encryption (Round) (cont.)
S-box
Example : 010001
1,6 th bit refers row – 01 – 1st row
[1]
36 CSE-AVCCE Middle 4 bits refers column – 1000 – 8th column
Permutation Box P
S1 S2 S3 S4 S5 S6 S7 S8
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
31 32
32
16 7 20 21 29 12 28 17 1 15 23 26 5 18 31 10 2 8 24 14 32 27 3 9 19 13 30 6 22 11 44 25
25
37 CSE-AVCCE
DES Round in Full
Right Half i-1 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
32 1 2 3 4 5 4 5 6 7 8 9 8 9 10 11 12 13 12 13 14 15 16 17 16 17 18 19 20 21 20 21 22 23 24 25 24 25 26 27 28 29 28 29 30 31 32 1
Round Key i
+
O 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
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
input symbol input symbol input symbol input symbol input symbol input symbol input symbol input symbol
control
control
control
control
control
control
control
control
S1 S2 S3 S4 S5 S6 S7 S8
output symbol output symbol output symbol output symbol output symbol output symbol output symbol output symbol
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
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
16 7 20 21 29 12 28 17 1 15 23 26 5 18 31 10 2 8 24 14 32 27 3 9 19 13 30 6 22 11 4 25
+
O 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
38 CSE-AVCCE
1
Right Half i
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
Key Generation
(Encryption)
39 CSE-AVCCE [1]
DES Key Schedule
64-bit key with parity bits
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
permuted
choice 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
56-bit key 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
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
Left
Shift
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 1 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 29
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
permuted
choice 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
48-bit subkey 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
40 CSE-AVCCE
41 CSE-AVCCE
42 CSE-AVCCE
DES Example
43 CSE-AVCCE
Strength of DES
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 change in many bits of the ciphertext.
Key Size
56-bit keys have 256 , brute force search looks hard.
44 CSE-AVCCE
Strength of DES
DES exhibits a strong avalanche
effect.
45 CSE-AVCCE
Avalanche in DES
K1
original
P2
46 CSE-AVCCE
Block Cipher design Principles
i) Design of function F
a) Design criteria for F
b) S-Box design
ii) Number of Rounds
iii) Key Schedule Algorithm
47 CSE-AVCCE
i) Design of function F
The heart of a Fiestel block cipher is the function [Link] DES, the function
relies on the use of S-Boxes
a) Design Criteria for F
Strict Avalanche Criterion(SAC) which states that any output bit j of an
S-Box should change with the probability ½ when any single input bit i
is inverted for all i,j
Bit independence Criterion which states that output bit j and k should
change independently when any single input bit i is inverted for all i, j
and k
48 CSE-AVCCE
Each row of an S-box (determined by a fixed value of the leftmost
and rightmost input bits) should include all 16 possible output bit
combinations.
If two inputs to an S-box differ in exactly one bit, the outputs must
differ in atleast two bits.
If two inputs to an S- box differ in the two middle bits exactly,
the outputs must differ in at least two bits.
If two inputs to an Sbox differ in their first two bits and are identical in
their last two bits, the two outputs must not be the same.
49 CSE-AVCCE
b) S-Box Design
51 CSE-AVCCE
Block Cipher modes of operation
52 CSE-AVCCE
Different modes of Operation
53 CSE-AVCCE
Electronic Code Book (ECB)
Message is broken into independent blocks.
For a given key ,there is a unique cipher text for every 64 bit
block of plain text
In a gigantic code book there is an entry for every possible 64
bit plain text pattern, showing its corresponding cipher text
Each block is encoded independently of the other blocks
Ci = DESK1 (Pi)
uses: secure transmission of single values
54 CSE-AVCCE
Electronic Code Book (ECB)
55 CSE-AVCCE
Advantages and Limitations of ECB
56 CSE-AVCCE
P blocks : 000000 011111 001111 000011 011111 000111 011111
57 CSE-AVCCE
Cipher Block Chaining (CBC)
58 CSE-AVCCE
Cipher Block Chaining (CBC)
59 CSE-AVCCE
Advantages and Limitations of CBC
60 CSE-AVCCE
Cipher Feed Back (CFB)
61 CSE-AVCCE
Cipher FeedBack (CFB)
62 CSE-AVCCE
Advantages and Limitations of CFB
appropriate when data arrives in bits/bytes
most common stream mode
limitation is need to stall while do block encryption after
every n-bits
note that the block cipher is used in encryption mode at
both ends
errors propagate for several blocks after the error
63 CSE-AVCCE
Output FeedBack (OFB)
Output of the encryption function is fedback to the shift register in
OFB
64 CSE-AVCCE
Output FeedBack (OFB)
65 CSE-AVCCE
Counter (CTR)
a “new” mode, though proposed early on
similar to OFB but encrypts counter value rather than
any feedback value
must have a different key & counter value for every
plaintext block (never reused)
Ci = Pi XOR Oi
66 CSE-AVCCE
Counter (CTR)
67 CSE-AVCCE
Advantages of CTR
Efficiency
E and D can be done in parallel on multiple blocks
Other cases depends on previous output
Preprocessing
the execution of Encryption algorithm doesn’t depend on
input of P / C
If sufficient memory and security is available we can prepare
the output of Encryption boxes
Hence if Plaintext is presented, the only computation is series
of XORS. Greatly enhances throughput
68 CSE-AVCCE
random access
if we need the Plaintext of 10th block – particular 10th
Cipher block is Decrypted and get the Plaintext
provable security (good as other modes)
69 CSE-AVCCE
Double DES
C= EK2(EK1(P))
70 CSE-AVCCE
Triple DES ( 3 keys )
71 CSE-AVCCE
Triple DES with 2 keys
72 CSE-AVCCE
Advanced Encryption Standard
(AES)
73 CSE-AVCCE
Origins
clear a replacement for DES was needed
can use Triple-DES – but slow with small blocks
US NIST issued call for ciphers in 1997
15 candidates accepted in Jun 98
5 were shortlisted in Aug-99
Rijndael was selected as the AES in Oct-2000
74 CSE-AVCCE
AES Requirements
private key symmetric block cipher
128-bit data, 128/192/256-bit keys
stronger & faster than Triple-DES
provide full specification & design details
NIST have released all submissions & unclassified
analyses
75 CSE-AVCCE
AES Evaluation Criteria
initial criteria:
76 CSE-AVCCE
AES Shortlist
after testing and evaluation, shortlist in Aug-99:
MARS (IBM) - complex, fast, high security margin
RC6 (USA) - v. simple, v. fast, low security margin
Rijndael (Belgium) - clean, fast, good security margin
Serpent (Euro) - slow, clean, v. high security margin
Twofish (USA) - complex, v. fast, high security margin
then subject to further analysis & comment
saw contrast between algorithms with
few complex rounds verses many simple rounds
which refined existing ciphers verses new proposals
77 CSE-AVCCE
The AES Cipher - Rijndael
designed by Rijmen-Daemen in Belgium
has 128/192/256 bit keys, 128 bit data
an iterative rather than feistel cipher
treats data in 4 groups of 4 bytes
operates an entire block in every round
designed to be:
resistant against known attacks
speed and code compactness on many CPUs
design simplicity
78 CSE-AVCCE
Rijndael
processes data as 4 groups of 4 bytes (state)
has 9/11/13 rounds in which state undergoes:
byte substitution (1 S-box used on every byte)
shift rows (permute bytes between groups/columns)
mix columns (subs using matrix multipy of groups)
add round key (XOR state with key material)
initial XOR key material & incomplete last round
all operations can be combined into XOR and table lookups -
hence very fast & efficient
79 CSE-AVCCE
Rijndael
80 CSE-AVCCE
Byte Substitution
a simple substitution of each byte
each byte of state is replaced by byte in row (left 4-
bits) & column (right 4-bits)
eg. byte {95} is replaced by row 9 col 5 byte
which is the value {2A}
81 CSE-AVCCE
Shift Rows
a circular byte shift in each row
1st row is unchanged
2nd row does 1 byte circular shift to left
3rd row does 2 byte circular shift to left
4th row does 3 byte circular shift to left
decrypt does shifts to right
82 CSE-AVCCE
Mix Columns
each column is processed separately
each byte is replaced by a value dependent on all 4
bytes in the column
83 CSE-AVCCE
Add Round Key
XOR state with 128-bits of the round key
again processed by column (though effectively a series
of byte operations)
inverse for decryption is identical since XOR is own
inverse, just with correct round key
designed to be as simple as possible
84 CSE-AVCCE
AES Round
85 CSE-AVCCE
AES Key Expansion
takes 128-bit (16-byte) key
start by copying key into first 4 words
then loop creating words that depend on values in
previous & 4 places back
in 3 of 4 cases just XOR these together
every 4th has S-box + rotate + XOR constant of previous
before XOR together
designed to resist known attacks
86 CSE-AVCCE
AES Decryption
AES decryption is not identical to encryption since
steps done in reverse
87 CSE-AVCCE
RC4 algorithm
88 CSE-AVCCE
RC4 – Stream Cipher Diagram
89 CSE-AVCCE
RC4
It is a stream cipher designed by Ronald Rivest
It is a byte oriented stream cipher
Here a byte of plain text is XORed with a byte of key to
produce a byte of cipher text
State
RC4 is based on the concept of a state
At each moment a state of 256 byte is active from
which one of the byte is randomly selected to serve as
the key for encryption
90 CSE-AVCCE
Initialization
It is done in 2 steps
In the first step, the state is initialized to the values
s[0]=0, s[1]=1, s[2]=2,……s[255]=255
A key array k[0], k[1],k[2]……..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
91 CSE-AVCCE
92 CSE-AVCCE
In the second step ,the initialized step goes through a
permutation ( swapping the elements ) based on the values
of the bytes in k[i].
After this step, the state bytes are completely shuffled
93 CSE-AVCCE
Key stream generation
First the state is permuted based on the values of state
elements and values of 2 variables i and j
The following code is repeated for each byte of plain text to
create a new key element in the key stream
94 CSE-AVCCE
Encryption and Decryption
After K has been created the plain text byte is encrypted with
k to create the cipher text byte
95 CSE-AVCCE
96 CSE-AVCCE
Example contd.
97 CSE-AVCCE
Example contd.
98 CSE-AVCCE
Example contd.
99 CSE-AVCCE
Example contd.
100 CSE-AVCCE
Example contd.
101 CSE-AVCCE
Example contd.
102 CSE-AVCCE
103 CSE-AVCCE
Key Generation
Key - 1 0 1 0 0 0 0 0 1 0
1 2 3 4 5 6 7 8 9 10
1 0 0 0 0 0 1 1 0 0
1 0 0 0 0 0 1 1 0 0
LS-1 : 0 0 0 0 1 1 1 0 0 0
1 2 3 4 5 6 7 8 9 10
Step – 3 Permute P8
(Rearrange the bits in LS-1)
1 0 1 0 0 1 0 0 --------------------K1
CSE - AVCCE
Step-4 Left shift 2 times
LS-1 0 0 0 0 1 1 1 0 0 0
1st time 0 0 0 1 0 1 0 0 0 1
2nd time 0 0 1 0 0 0 0 0 1 1
1 2 3 4 5 6 7 8 9 10
Step-5 Permute P8
0 1 0 0 0 0 1 1 -----------------------------------------K2
ENCRYPTION
Plain text : 1 0 1 1 1 1 0 1
1 2 3 4 5 6 7 8
IP 0 1 1 1 1 1 1 0
0 1 1 1 1 1 1 0
LH RH
E/P: 0 1 1 1 1 1 0 1
E/P - 0 1 1 1 1 1 0 1
K1 - 1 0 1 0 0 1 0 0
XOR - 1 1 0 1 1 0 0 1
Step 5: S-BOX
1 1 0 1 1 0 0 1
XOR
S0 S1
Check in S0 matrix
1 1 0 1
Check in S1 matrix
1 0 0 1
Output of S – Boxes
1 1 1 0
1 2 3 4
Step 6 : Permute P4
P4 - 1 0 1 1
CSE - AVCCE
Step 7: XOR with LH
P4 - 1 0 1 1
LH - 0 1 1 1
XOR- 1 1 0 0
SWAPPING
1 1 0 0 1 1 1 0
LH RH
1 1 1 0 1 1 0 0
LH RH
RH - 1 1 0 0
CSE - AVCCE
Cryptography and Network Security
K1 K4
K2 K3
K5
K6
K8
K7
K9
K10
4 CSE-AVCCE
Key Hierarchy
typically
have a hierarchy of keys
session key
temporary key
used for encryption of data between users
for one logical session then discarded
master key
used to encrypt session keys
shared by user & key distribution center
Key Hierarchy
I. Key Distribution Scenario
A Key Distribution Scenario
User A wishes to establish a logical connection with B
8 CSE-AVCCE
Steps inolved
1. A issues a request to the KDC for a session key to protect a logical
connection to B.
[The message includes the identity of A and B and a unique identifier,
N1, for this transaction, which we refer to
as a nonce- random number identifying each transaction]
2. The KDC responds with a message encrypted using Ka
The one-time session key, Ks, to be used for the session
original request message, including the nonce, to enable A to match
this response
In addition, the message includes two items intended for B:
● The one-time session key, Ks to be used for the session
● An identifier of A (e.g., its network address), IDA
These items are encrypted with Kb
9 CSE-AVCCE
3. A stores the session key for use in the upcoming session
and forwards to B the information EKb, [Ks || IDA]).
- B now stores the session key (Ks),
- knows that the other party is A (from IDA), and
- knows that the information originated at the KDC
(because it is encrypted using Kb).
At this point, a session key has been securely delivered to
A and B, and they may begin their protected exchange.
However, two additional steps are desirable:
10 CSE-AVCCE
4. Using the new session key, 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 (e.g., adding
one).
These steps assure B that the original message it received
(step 3) was not a replay.
Steps 1,2,3 performs key distribution
steps 4 and 5 perform an authentication function.
11 CSE-AVCCE
II. Hierarchical Key Control
For very large networks, single KDC is not enough
12 CSE-AVCCE
III. A Transparent Key Control Scheme
13 CSE-AVCCE
This scheme is useful for providing end-to-end encryption
at a network level to the end users.
The approach assumes that communication makes use of a
14 CSE-AVCCE
Steps Involved
1. Host A wishes to set up a connection to host B, it transmits a connection-
request packet
2. The SSM saves that packet and applies to the KDC for permission to establish
the connection
The communication between the SSM and the KDC is encrypted using a master
key shared only by this SSM and the KDC.
3. If the KDC approves the connection request, it generates the session key and
delivers it to the two appropriate SSMs
4. The requesting SSM can now release the connection request packet, and a
connection is set up between the two end systems
All user data exchanged between the two end systems are encrypted by their
respective SSMs using the one-time session key.
15 CSE-AVCCE
IV. Decentralized key Control
16 CSE-AVCCE
Steps Involved
Session key may be established in the following way
17 CSE-AVCCE
V. Controlling the Key Usage
18 CSE-AVCCE
Control Vector Encryption and Decryption
19 CSE-AVCCE