Unit Ii: Block Ciphers & Public Key Cryptography
Unit Ii: Block Ciphers & Public Key Cryptography
BLOCK CIPHERS
Data Encryption Standard-Block cipher principles-block cipher modes of operation-Advanced Encryption
Standard (AES)-Triple DES-Blowfish-RC5 algorithm.
Ki Ki
Pi Ci Ci Pi
Plaintext + Cyphertext + Plaintext
ENCRYPTION DECRYPTION
1. Stream Cipher and Block Cipher
Stream Cipher
Encrypts data stream ___________________at a time.
Examples of Stream Cipher
1. ___________ Cipher
2. ___________ Cipher
Bit Stream
Key generation
(K) algorithm
Ki
Pi
+ Cyphertext + Plaintext
1. Stream Cipher and Block Cipher
Block Cipher
Encrypts block of plaintext as whole and translate to ciphertext
Block Size is 64 or 128 bits bits
Ciphertext Plaintext
bits bits
1. Stream Cipher and Block Cipher
Block Cipher
Encrypts _______ of plaintext as _______ and translate to ______
Block Size is ___ or ___ bits bits
Key
(K)
Ciphertext Plaintext
bits bits
2. Feistel Cipher
Utilizing the Concept of Product Cipher
Product Cipher – Execute two or more Cipher produce product
of stronger component.
Two Components
1. Substitution
2. Permutation
Substitution – Each plaintext or group of plaintext are replaced
by ciphertext
Permutation – Sequence of plaintext elements are replaced by
changing the order of sequence
2. Feistel Cipher
Utilizing the Concept of __________
________ Cipher – Execute _____________produce product of
stronger component.
Two Components
1. __________
2. __________
_________ – Each plaintext or group of plaintext are ______ by
ciphertext
_________ – Sequence of plaintext elements are replaced by
_____________of sequence
3. Diffusion and Confusion
Diffusion
- Structure of plaintext is dissipated into long range statistics
of ciphertext
Confusion
- the relationship between ciphertext and key as complex as
possible.
3. Diffusion and Confusion
Match this
Feistel Substitution
Diffusion and Cipher
Confusion
Permutation
Data Encryption Standard (DES)
The mostly used encryption algorithm is DES.
Input – 64 bits
Output – 64 bits
The step used in Encryption is same as for Decryption but Key is reversed
for decryption.
Data Encryption Standard (DES)
History
Late 1960 IBM started project on computer cryptography led by Fiestel.
This project concluded at 1971 with the name LUCIFER and sold to Lloyds London for use in cash
dispensing system.
LUCIFER operates on blocks of 64 bits using key size 128 bit.
No of Rounds – 16 rounds
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
DES Encryption – Initial Permutation (IP)
Each permutation table indicates the position of numbered input to the
output
X= IP(M)
Now choose a value from S1 box with 1st Row and 12th column which is 9
So output is 1001
DES Encryption – Details of Single Round
S – Box (Substitution Box)
DES Encryption – Details of Single Round
Sample S – Box (Substitution Box)
14 4 13 1 2 15 11 8 3 10 6 12 5 9 0 7
0 15 7 4 14 2 13 1 10 6 12 11 9 5 3 8
4 1 14 8 13 6 2 11 15 12 9 7 3 10 5 0
S1
15 12 8 2 4 9 1 7 5 11 3 14 10 0 6 13
15 1 8 14 6 11 3 4 9 7 2 13 12 0 5 10
3 13 4 7 15 2 8 14 12 0 1 10 6 9 11 5
0 14 7 11 10 4 13 1 5 8 12 6 9 3 2 15
S2
13 8 10 1 3 15 4 2 11 6 7 12 0 5 14 9
DES Encryption – Details of Single Round
S – Box (Substitution Box)
DES Encryption – Details of Single Round
Permutation P
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
DES Encryption – Key Generation
64 bit key is used to input for the algorithm.
The bits of key are numbered from 1 to 64.
Every eighth bit is ignored.
(a) Input 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
57 58 59 60 61 62 63 64
DES Encryption – Key Generation
Now 56 bit input to Permuted Choice 1 (PC1)
(a) 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
The resulting 56 bits is treated as two halves with 28 bit labelled C0 and D0.
Each round separate circular left shift of 1 or 2 bits according below table.
(a) Schedule of Left Shifts
Round Number 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 Encryption – Key Generation
Now Shifted values are input to Permuted Choice 2 (PC2) which produce 4b bit
then this 48 bit is input to the Function (F)
(a) 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
DES Decryption
Decryption uses same algorithm as encryption except the keys are reversed.
The Strength of DES
The use of 56 bit Keys .
The length is 56 so there are 256 Possible keys approximately 7.2 X 1016 Keys.
However 1977 Diffie Hellman build parallel machine average time is reduced to 10 hours.
In 1998 announced DES had broken with special machine “DES Cracker”.
The nature of DES algorithm
Timing Attack
How long it takes the plaintext to perform Decryption of different ciphertext.
MULTIPLE ENCRYPTION
Due to vulnerability in DES,
Two approaches have been taken,
1. Design a new algorithm example AES
2. Preserves existing investment to use multiple encryption then Triple
DES.
Double DES
Given a plaintext P and two encryption keys K1 and K2, then ciphertext C
is generated
C=E(K2,E(K1,P))
Decryption
P=D(K1,D(K2,C))
DOUBLE DES
K1 K2
P C
Encryption
K2 K1
C P
Decryption
MEET IN THE MIDDLE ATTACK
It is based on
X= E(K1,P)=D(K2,C)
The attack proceeds as follows,
1. Given a known pair plaintext P, ciphertext C.
2. Encrypt the P for all possible 256 keys of K1.
3. Store these results in a table then sort by X
4. Decrypt the C by using all 256 possible values of K2.
5. Store these results in a table then sort.
6. Check for there is match then keys produce correct result.
To overcome this Triple DES is introduced
TRIPLE DES (3 DES)
Three stages of encryption with three different keys.
Algorithm used in Triple DES is Triple Data Encryption Algorithm (TDEA).
Two Versions of DES
Two Keys
Three Keys
Triple DES with Two Keys
Triple Des Follows Encrypt – Decrypt – Encrypt (EDE) sequence
C = E(K1,D(K2,E(K1,P)))
P = D(K1,E(K2,D(K1,C)))
Suppose
C = E(K1,D(K1,E(K1,P))) = E(K1,P)
P = D(K1,E(K2,D(K1,C))) = D(K1,C)
TRIPLE DES (3 DES) K1 (2 key)
Or
K1 K2 K1 K3 (3 key)
P C
Encryption
K1 (2 key)
Or
K1 K2 K1K3 (3 key)
C P
Decryption
TRIPLE DES (3 DES)
Triple DES with Three Key
Three Key DES is Defined as
E=(K3,D(K2,E(K1,P)))
BLOCK CIPHER MODES OF OPERATION
In general Block cipher takes fixed length block of text of length b bits and
key as input it produce b bit of ciphertext.
If Plaintext length is greater than b bits then block cipher breaking up block
into b bits block.
When multiple blocks are encrypted using same key some security issues
arise.
to apply Block cipher in a variety of application FIVE MODES OF
OPERATION are defined.
1. ECB – Electronic Code Book
2. CBC – Cipher Block Chaining Mode
3. CFB – Cipher Feedback Mode
4. OFB – Output Feedback Mode
Mode description Typical Application
Cipher Block Chaining (CBC) The input to the encryption algorithm • General-purpose
is the XOR of the next block of blockoriented
plaintext and the preceding block of transmission
ciphertext. • Authentication
Cipher Feedback (CFB) Input is processed s bits at a time. • General-purpose stream-
Preceding ciphertext is used as input oriented transmission
to the encryption algorithm to produce • Authentication
pseudorandom output, which is
XORed with plaintext to produce next
unit of ciphertext.
Output Feedback (OFB) Similar to CFB, except that the input • Stream-oriented
to the encryption algorithm is the transmission over noisy
preceding encryption output, and full channel (e.g., satellite
blocks are used. communication)
(a) Encryption
(b) Decryption
ECB – ELCTRONIC CODE BOOK
The simplest mode is ECB
ENCRYPTION
3. CFB – Cipher Feedback Mode
DECRYPTION
3. CFB – Cipher Feedback Mode
CFB I1 = IV I1 = IV
Ij = LSBb-s (Ij-1) || Cj-1 Ij = LSBb-s (Ij-1) || Cj-1
Oj = E(K,Ij) Oj = E(K,Ij)
Cj = Pj ⊕ MSBs(Oj) Pj = Cj ⊕ MSBs(Oj)
4. OFB – Output Feedback Mode
4. OFB – Output Feedback Mode
4. OFB – Output Feedback Mode
0 1 2 3 4 5 6 7 8 9 A B C D E F
0 63 7C 77 7B F2 6B 6F C5 30 01 67 2B FE D7 AB 76
1 CA 82 C9 7D FA 59 47 F0 AD D4 A2 AF 9C A4 72 C0
2 B7 FD 93 26 36 3F F7 CC 34 A5 E5 F1 71 D8 31 15
3 04 C7 23 C3 18 96 05 9A 07 12 80 E2 EB 27 B2 75
4 09 83 2C 1A 1B 6E 5A A0 52 3B D6 B3 29 E3 2F 84
5 53 D1 00 ED 20 FC B1 5B 6A CB BE 39 4A 4C 58 CF
6 D0 EF AA FB 43 4D 33 85 45 F9 02 7F 50 3C 9F A8
7 51 A3 40 8F 92 9D 38 F5 BC B6 DA 21 10 FF F3 D2
8 CD 0C 13 EC 5F 97 44 17 C4 A7 7E 3D 64 5D 19 73
9 60 81 4F DC 22 2A 90 88 46 EE B8 14 DE 5E 0B DB
A E0 32 3A 0A 49 06 24 5C C2 D3 AC 62 91 95 E4 79
B E7 C8 37 6D 8D D5 4E A9 6C 56 F4 EA 65 7A AE 08
C BA 78 25 2E 1C A6 B4 C6 E8 DD 74 1F 4B BD 8B 8A
D 70 3E B5 66 48 03 F6 0E 61 35 57 B9 86 C1 1D 9E
E E1 F8 98 11 69 D9 8E 94 9B 1E 87 E9 CE 55 28 DF
x F 8C A1 89 0D BF E6 42 68 41 99 2D 0F B0 54 BB 16
(a) S-box
Shift Rows Transformation
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-byte circular left shift is performed.
For the fourth row, a 3-byte circular left shift is performed.
87 F2 4D 97 87 F2 4D 97
EC 6E 4C 90 6E 4C 90 EC
46 E7 4A C3
4A C3 46 E7
A6 8C D8 95
8C D8 95 A6
Shift Rows Transformation
Mix Columns Transformation
• Each column is mapped into new value by matrix multiplication on
State
=
=
=
=
=
ADD Round Key
47 40 A3 4C AC 19 28 57
37 D4 70 9F 77 FA D1 5C
⊕
94 E4 3A 42 66 DC 29 00
ED A5 A6 BC F3 21 41 6A
=
EB 59 8B 1B
40 2E A1 C3
F2 38 13 42
1E 84 E7 D6
INPUTS FOR AES SINGLE ROUND
AES KEY EXPANSION
AES KEY EXPANSION
The function g consists of the following subfunctions.
RotWord performs a one-byte circular left shift on a word. This means
that an input word [B0, B1, B2, B3] is transformed into [B1, B2, B3, B0].
SubWord performs a byte substitution on each byte of its input word,
using the S-box.
The result of steps 1 and 2 is XORed with a round constant, Rcon[j].
RC5 Algorithm
In cryptography, RC5 is a symmetric-key block cipher notable for its
simplicity.
Designed by Ronald Rivest in 1994.
RC stands for "Rivest Cipher", or alternatively, "Ron's Code“.
Block Size - 32, 64 or 128 bits (64 suggested)
Key sizes 0 to 2040 bits (128 suggested)
Structure Feistel-like network
Rounds 1-255 (12 suggested originally)
Block Diagram
K ⊕ - XOR OPERATION
⊞ - ADDITION MOD
<<< - Left Shift
K
Blowfish Algorithm
Blowfish is a symmetric-key block cipher, designed in 1993 by Bruce
Schneier and included in a large number of cipher suites and encryption
products.
Blowfish provides a good encryption rate in software and no effective
cryptanalysis.
Schneier designed Blowfish as a general-purpose algorithm, intended as an
alternative to the aging DES
Free of the problems and constraints associated with other algorithms.
Key sizes - 32–448 bits
Block sizes - 64 bits
Structure - Feistel network
Rounds - 16
Block Diagram
Blowfish Algorithm
Every round r consists of 4 actions:
Action 1 XOR the left half (L) of the data with the r th P-array entry
Action 2 Use the XORed data as input for Blowfish's F-function
Action 3 XOR the F-function's output with the right half (R) of the data
Action 4 Swap L and R
The F-function splits the 32-bit input into four eight-bit quarters, and uses
the quarters as input to the S-boxes.
Decryption is exactly the same as encryption, except that P1, P2, …, P18
are used in the reverse order.
ASYMMETRIC CIPHERS
Y = E(PRa,X)
X= D(PUa,Y)
Principles of Public key Cryptosystems
Z = E(Pub,E(PRa,X))
X= D(PUa,D(PRb,Z))
Application Public Key Cryptosystems
Encryption/decryption: The sender encrypts a message with the recipient’s public key.
Digital signature: The sender “signs” a message with its private key.
Key exchange: Two sides cooperate to exchange a session key.
one-way function
A one-way function is one that maps a domain into a range such that every function value has a
unique inverse, with the condition that the calculation of the function is easy, whereas the
calculation of the inverse is infeasible:
Y = f(X) easy
X = f-1(Y) infeasible
trap-door one-way function
Easy to calculate in one direction and infeasible to calculate in the other direction unless certain
additional information is known.
Y = fk(X) easy, if k and X are known
X = fk-1(Y) easy, if k and Y are known
X = fk-1(Y) infeasible, if Y is known but k is not known
The RSA Algorithm
RSA Stands for Rivest-Shamir-Adleman
The mostly used, accepted and implemented general purpose public key
encryption.
Plaintext and Ciphertext are integers between 0 and n - 1 for some n.
Both sender and receiver must know the value of n.
The sender knows the value of e.
The receiver knows the value of d.
Public-key encryption algorithm with a public key of PU = {e, n} and a
private key of PR = {d, n}.
RSA ALGORITHM
Key Generation
Select p, q p and q both prime, p ≠ q
Calculate n = p * q
Calcuate ɸ(n) = (p - 1)(q - 1)
Select integer e gcd (ɸ(n), e) = 1; 1 < e < ɸ(n)
Calculate d d ≡ e-1 (mod ɸ(n))
Public key PU = {e, n}
Private key PR = {d, n}
Encryption using Public Key
Plaintext: M < n
Ciphertext: C = Me mod n
Alice and Bob share a prime Alice and Bob share a prime
number q and an integer α, number q and an integer α,
such that α < q and α is a such that α < q and α is a
primitive root of q primitive root of q
2 2 4 8 5 10 9 7 3 6 1
10
Diffie-Hellman key exchange Example
α=2
Sender
choose XA = 8 private key
Compute YA = αXA mod q public key
YA = 28 mod 11
YA = 3
Receiver
XB = 4
YB = 24 mod 11
YB = 5
Diffie-Hellman key exchange Example
User A XA = 8
YA = 3
User B XB = 4
YB = 5
Sender Receiver
K=(YB) XA mod q K= (YA) XB mod q
K=(5) 8 mod 11 K=(3) 4 mod 11
K= 4 K= 4
Successfully Exchanged
Man in the middle attack
Diffie-Hellman key exchange Practices
Users Alice and Bob use the Diffie-Hellman key exchange technique with a
common prime q = 83 and a primitive root α = 5.
i) If Alice has a private key XA = 6, what is Alice's public key YA ? (6)
ii) If Bob has a private key XB = 10, what is Bob's public key YB ? (6)
Elliptic Curve Cryptography(ECC)
Abelian Groups
An abelian group G, sometimes denoted by {G, . }, is a set of elements with a
binary operation, denoted by . .
If a group is said to be abelian group the following axioms are obeyed.
If a and b belong to G, then a . b is also in
(A1) Closure: G.
(A2) Associative: a . (b . c) = (a . b) . c for all a, b, c in G.
(A3) Identity There is an element e in G such that a . e
element: = e . a = a for all a in G.
(A4) Inverse element: For each a in G there is an element a′ in G
(A5) Commutative: such that a . a′ = a′ . a = e.
a . b = b . a for all a, b in G.
Elliptic Curve Cryptography(ECC)
Abelian Groups
An abelian group G, sometimes denoted by {G, . }, is a set of elements with a
binary operation, denoted by . .
If a group is said to be abelian group the following axioms are obeyed.
If a and b belong to G, then a . b is also in
(A1) Closure: G.
(A2) Associative: a . (b . c) = (a . b) . c for all a, b, c in G.
(A3) Identity There is an element e in G such that a . e
element: = e . a = a for all a in G.
(A4) Inverse element: For each a in G there is an element a′ in G
(A5) Commutative: such that a . a′ = a′ . a = e.
a . b = b . a for all a, b in G.
Elliptic Curve Cryptography(ECC)
Elliptic Curve
An elliptic curve is defined by an equation in two variables with coefficients.
For cryptography, the variables and coefficients are restricted to elements in a
finite field, which results in the definition of a finite abelian group.
Elliptic Curves over Real Numbers
Elliptic curves are not ellipses.
Cubic equations, similar to those used for calculating the circumference of an
ellipse.
Y2 = X3 + ax + b
Y = √X3 + ax + b
Elliptic Curve Examples
2 3
(a y x x
)
4
4 (P )
(P ) Q
Q
2
2
Q
Q
0
P
P 0
2
2
(P )
Q
4 4 (P )
Q
2 1 0 1 2 3 4 5
2 1 0 1 2 3 4 5
2 3
(b y x x
) 1
Elliptic Curves over Zp
Elliptic curve cryptography makes use of elliptic curves in which the variables
and coefficients are all restricted to elements of a finite field.
Two families
prime curves over Zp
binary curves over GF(2m )
Prime curve over Zp
The variables and coefficients all take on values in the set of integers from 0
through p - 1 and in which calculations are performed modulo p.
Binary Curve over GF(2m )
Binary curve defined over GF(2m), the variables and coefficients all take on
values in GF(2m) and in calculations are performed over GF(2m).
For elliptic curves over Zp, as with real numbers,
Y2 mod p= (X3 + ax + b) mod p
Elliptic Curves over GF(2 ) m
Finite field GF(2m) consists of 2m elements, together with addition and
multiplication operations that can be defined over polynomials.\
Y2 + xy = X3 + ax + b