Symmetric encryption | Bài giảng Môn An toàn thông tin Trường đại học sư phạm kỹ thuật TP. Hồ Chí Minh

Modern Symmetric-Key Ciphers: Modern block ciphers; Modern stream ciphers; Encipherment Using Modern Symmetric-Key Ciphers; Use of Modern block ciphers; Use of Modern stream ciphers; Data Encryption Standard - DES. Double DES. Triple DES. Advanced Encryption Standard - AES. Tài liệu giúp bạn tham khảo, ôn tập và đạt kết quả cao. Mời bạn đọc đón xem!

24/09/2021
1
Lecturer: Nguyễn Thị Thanh Vân FIT - HCMUTE
Modern Symmetric-Key Ciphers
o Modern block ciphers
o Modern stream ciphers
Encipherment Using Modern Symmetric-Key Ciphers
o Use of Modern block ciphers
o Use of Modern stream ciphers
Data Encryption Standard - DES
o Double DES
o Triple DES
Advanced Encryption Standard - AES
24/09/2021 2
24/09/2021
2
24/09/2021
3
MODERN BLOCK CIPHERS
o Substitution or Transposition
o Block Ciphers as Permutation Groups
o Components of a Modern Block Cipher
o S-Boxes
o Product Ciphers
o Two Classes of Product Ciphers
o Attacks on Block Ciphers
MODERN STREAM CIPHERS
o Synchronous Stream Ciphers
o Nonsynchronous Stream Ciphers
24/09/2021 5
24/09/2021 6
Block
Cipher
Stream
Cipher
24/09/2021
4
A symmetric-key modern block cipher: Encryption &
Decryption
Modern block ciphers normally are keyed substitution
ciphers
the key allows only partial mapping from the possible
inputs to the possible outputs.
24/09/2021 7
A P-box (permutation box)
parallels the traditional
transposition cipher for
characters. It transposes bits.
Three types of P-boxes
24/09/2021 8
24/09/2021
5
Ex: The possible (6) mappings of a 3 × 3 P-box
Example of a permutation table for a straight P-box
24/09/2021 9
Example :
o Design 8 permutation table for a straight P-box thatmoves an 8 ×
the two middle bits (bits 4 and 5) in the input word two to the
ends (bits 1 and 8) in the output words. Relative positions of
other bits should not be changed.
Solution:
o We need a straight P-box with the table [4 1 2 3 6 7 8 5]. The
relative positions of input bits 1, 2, 3, 6, 7, and 8 have not been
changed, but the first output takes the fourth input and the eighth
output takes the fifth input.
24/09/2021 10
24/09/2021
6
A compression P-box is a P-box with n inputs and m
outputs where m < n.
Example of a 32 24 permutation table×
o Note that inputs 7, 8, 9, 15, 16, 23, 24, and 25 are blocked
Compression P-boxes are used when we need to
permute bits and the same time decrease the number of
bits for the next stage.
24/09/2021 11
An expansion P-box is a P-box with n inputs and m
outputs where m > n.
Example of a 12 16 permutation table×
o Note each of the inputs 1, 3, 9, and 12 is mapped to that 2 outputs.
The expansion P-boxes:
o used in modern block ciphers normally are keyless, where a
permutation table shows the rule for transposing bits.
o are used when we need to permute bits and the same time
increase the number of bits for the next stage.
24/09/2021 12
24/09/2021
7
A straight P-box is invertible.
o use a straight P-box in the encryption cipher and its inverse in
the decryption cipher.
Compression expansion P-boxes are not.and
Figure shows how to invert a permutation table
represented as a one-dimensional table.
Compression and expansion P-boxes are non-invertible
24/09/2021 14
24/09/2021
8
An S-box (substitution box) can be thought of as a
miniature substitution cipher.
An S-box is an m n substitution unit, where m and are × n
not necessarily the same.
Linear S-Boxes. The relationship between the inputs and
the outputs can be represented as a set of equations
24/09/2021
Linear S-Boxes
Ex: In an S-box with inputs and outputs, we have3 2
o S-box is linear:
o The relationship:
24/09/2021 16
24/09/2021
9
Invertibility S-boxes are substitution ciphers
o relationship between input and output is defined by a table or
mathematical relation.
An S-box may or may not invertible.
o In an invertible S-box, the number of input bits should be the
same a number of output bits.
Ex: A S-box tables
Input: 001 (r1,c2)
Output: 101
input 101 (r2,c2)
output 001
24/09/2021 17
It is an important component in most block ciphers
Properties:
24/09/2021 18
24/09/2021
10
Circular Shift is another component found in some
modern block ciphers
o It mixes the bits in a word and helps hide the patterns in the
original word
Ex: Circular shifting an 8-bit word to the left or right
A circular left-shift operation is the inverse of the circular
right-shift operation.
19
The swap operation is a special case of the circular shift
operation where k = n/2.
Ex: Swap operation on an 8-bit word
24/09/2021 20
24/09/2021
11
Both operations are found in some block ciphers
o The split: splits an n-bit word in the middle, creating two -equal
length words.
o The combine: concatenates two equal-length words to create an
n-bit word.
These two operations are inverses of each other and can
be used as a pair to cancel each other out.
24/09/2021 21
Product cipher is introduced by Shannon
o a complex cipher combining substitution, permutation, and other
components.
It have two important properties: diffusion and confusion.
o Diffusion: hide the relationship between the ciphertext the plaintext. &
=> frustrate adversary the who uses ciphertext statistics to find the
plaintext.
o Confusion: hide the relationship between the ciphertext & the key.
=> frustrate the adversary who tries to use the ciphertext to find the key.
24/09/2021 22
24/09/2021
12
Diffusion and confusion can be achieved using iterated
product ciphers where each iteration is a combination of
S-boxes, P-boxes, and other components.
The block cipher uses a key schedule or key generator
that creates different keys for each round from the cipher
key.
In an N-round cipher, the plaintext is encrypted N times
to create the ciphertext; the ciphertext is decrypted N
times to create the plaintext.
24/09/2021 23
3 transformations
happen at each round
o Key mixer
o S-boxes
o P-box
24/09/2021
24/09/2021
13
Diffusion and confusion in a block
cipher. Ex:
o changing a single bit in the plaintext
affects many bits in the ciphertext.
Diffusion. Round1
o XOR with K1
o S-box 4: affects bits 7 and 8
o P-box: bit7 -> bit2, bit8 -> bit4.
Round 2: ….
=> bit 8 has affected bits 1, 3, 6, and 7
Confusion:
o bits are affected by bit8 (K ); bit 1,3,6,7
1
2,3 (K ). => each bit in each round key
2
affects several bits in the ciphertext.
25
Modern block ciphers are all product ciphers, but are
divided into two classes.
Feistel ciphers
o Feistel designed a very intelligent and interesting cipher that has
been used for decades.
o A Feistel cipher can have three types of components: self-
invertible, invertible, and noninvertible.
Non-Feistel ciphers
o A non-Feistel cipher uses only invertible components.
o A component in the encryption cipher has the corresponding
component in the decryption cipher.
24/09/2021 26
24/09/2021
14
The first thought
o Mixer ((XOR, F(K)): self-invertible
o Same key: encryption and
decryption are inverses of each
other
Improvement
o Use left and right blocks
o the inputs to the function must be
exactly the same inencryption &
decryption.
Means: The right half of the plain-
text never changes. => 1 flaw
=> Attack can intercepting the
ciphertext and extracting the right half
Improvement.
increase the number of
rounds.
add a new element to each
round: a swapper. => it
allows us to swap the left
and right halves in each
round.
K K
1 2
are used in reverse
order in the encryption and
decryption
24/09/2021
24/09/2021
15
Attacks on traditional ciphers can also be used on
modern block ciphers, but today’s block ciphers resist
most of the attacks
Differential Cryptanalysis
o Eli Biham and Adi Shamir introduced the idea of differential
cryptanalysis. This is a chosen-plaintext attack
Linear Cryptanalysis
o Linear cryptanalysis was presented by Mitsuru Matsui in 1993.
The analysis uses known plaintext attacks.
24/09/2021 29
Using XOR: Without knowing the value of the key,
attack can easily find the relationship between plaintext
differences and ciphertext differences if by plaintext/
ciphertext difference P and C
1
P
2 1
C
2
.
The following proves:
Because:
x x = (00…0)
x (00…0) = x
=> So simple
24/09/2021 30
24/09/2021
16
Solution: add one S-box.
o prevents atacker from finding a
definite relationship btw P and C
SBut, attack can create
a probabilistic relationship:
Make table from information
about S-box input/output table
with P = X .
1
P
2 1
X
2
24/09/2021 31
3 linear equations between plaintext and
ciphertext bits
Solving for three unknowns, we get.
24/09/2021 32
This means: 3known-plaintext attacks can find the values of k , k , and k
0 1 2
In some modern block ciphers, some S-boxes are not totally nonlinear;
they can be approximated, probabilistically, by some linear functions.
24/09/2021
17
In a modern stream cipher, encryption and decryption are
done r bits at a time.
We have: are r-bit words.p
i
, c , k
i i
o a plaintext bit stream P = p ,
n
…p
2
p
1
o a ciphertext bit strea C = c
n
…c
2
c
1
,
o a key bit stream K = k
n
…k
2
k
1
,
2 types:
o Synchronous stream cipher
o Nonsynchronous stream cipher
24/09/2021 33
In a synchronous stream cipher the key is independent
of the plaintext or ciphertext.
Ex: Enc & Dec with stream cipher
24/09/2021 34
Use the XOR function and the given key to encrypt the word “Hi”.
key = FA F2
Hi =
FA F2 =
Hi encrypted =
24/09/2021
18
One-time pad: The simplest and the most secure type
o cannot guess the key or the plaintext and ciphertext statistics.
o no relationship between the plaintext and ciphertext, either.
o ? How can the sender and the receiver share a one-time pad key
=> this perfect and ideal cipher is very difficult to achieve
24/09/2021 35
The feedback shift register (FSR)
o can be implemented in either software or hardware
o A feedback shift register is made of a shift register and a feedback
The shift register: a sequence of m cells, b each cell holds
0
to b
m−1
,
a single bit receives value from b , give value to b: b
i i-1 i+1
The feedback function: defines how the values of cells are
combined to calculate b
m
A feedback shift register:
o linear or
o nonlinear.
24/09/2021 36
24/09/2021
19
Linear feedback shift register (LFSR)
o b
m
is a linear function of b , b
0 1
, …, b
m−1
Ex: Create a linear feedback shift register with 5 cells in
which
LSFR for Example
o c
i
=0 -> b not connected
i
o 3 connections
vulnerable to attacks mainly because of its linearity
24/09/2021 37
NonLinear feedback shift register (NLFSR)
o b
m
is a nonlinear function of b
0
, b
1
, …, b
m−1
Combination:
o A stream cipher can use a combination of linear and nonlinear
structures.
o Some LFSRs can be made with the maximum period and then
combined through a nonlinear function.
24/09/2021 38
24/09/2021
20
the key depends on either the plaintext or ciphertext.
24/09/2021 39
| 1/49

Preview text:

24/09/2021
Lecturer: Nguyễn Thị Thanh Vân – FIT - HCMUTE
 Modern Symmetric-Key Ciphers o Modern block ciphers o Modern stream ciphers
 Encipherment Using Modern Symmetric-Key Ciphers o Use of Modern block ciphers o Use of Modern stream ciphers
 Data Encryption Standard - DES o Double DES o Triple DES
 Advanced Encryption Standard - AES 24/09/2021 2 1 24/09/2021 2 24/09/2021  MODERN BLOCK CIPHERS o Substitution or Transposition o
Block Ciphers as Permutation Groups o
Components of a Modern Block Cipher o S-Boxes o Product Ciphers o
Two Classes of Product Ciphers o Attacks on Block Ciphers  MODERN STREAM CIPHERS o Synchronous Stream Ciphers o Nonsynchronous Stream Ciphers 24/09/2021 5 Stream Cipher Block Cipher 24/09/2021 6 3 24/09/2021
 A symmetric-key modern block cipher: Encryption & Decryption
 Modern block ciphers normally are keyed substitution ciphers
 the key allows only partial mapping from the possible
inputs to the possible outputs. 24/09/2021 7  A P-box (permutation box) parallels the traditional transposition cipher for
characters. It transposes bits.  Three types of P-boxes 24/09/2021 8 4 24/09/2021
 Ex: The possible (6) mappings of a 3 × 3 P-box
 Example of a permutation table for a straight P-box 24/09/2021 9  Example : o
Design an 8 × 8 permutation table for a straight P-box thatmoves
the two middle bits (bits 4 and 5) in the input word to the t wo
ends (bits 1 and 8) in the output words. Relative positions of
other bits should not be changed.  Solution: o
We need a straight P-box with the table [4 1 2 3 6 7 8 5]. The
relative positions of input bits 1, 2, 3, 6, 7, and 8 have not been
changed, but the first output takes the fourth input and the eighth output takes the fifth input. 24/09/2021 10 5 24/09/2021
 A compression P-box is a P-box with n inputs and m outputs where m < n.
 Example of a 32 × 24 permutation table o
Note that inputs 7, 8, 9, 15, 16, 23, 24, and 25 are blocked
 Compression P-boxes are used when we need to
permute bits and the same time decrease the number of bits for the next stage. 24/09/2021 11
 An expansion P-box is a P-box with n inputs and m outputs where m > n.
 Example of a 12 × 16 permutation table o Note that e
ach of the inputs 1, 3, 9, and 12 is mapped to 2 outputs.  The expansion P-boxes: o
used in modern block ciphers normally are keyless, where a
permutation table shows the rule for transposing bits. o
are used when we need to permute bits and the same time
increase the number of bits for the next stage. 24/09/2021 12 6 24/09/2021
 A straight P-box is invertible. o
use a straight P-box in the encryption cipher and its inverse in the decryption cipher.
 Compression and expansion P-boxes are not.
 Figure shows how to invert a permutation table
represented as a one-dimensional table.
 Compression and expansion P-boxes are non-invertible 24/09/2021 14 7 24/09/2021
 An S-box (substitution box) can be thought of as a miniature substitution cipher.
 An S-box is an m × n substitution unit, where m and n are not necessarily the same.
 Linear S-Boxes. The relationship between the inputs and
the outputs can be represented as a set of equations Linear S-Boxes 24/09/2021
 Ex: In an S-box with 3 inputs and 2 outputs, we have o S-box is linear: o The relationship: 24/09/2021 16 8 24/09/2021
 Invertibility S-boxes are substitution ciphers o
relationship between input and output is defined by a table or mathematical relation.
 An S-box may or may not invertible. o
In an invertible S-box, the number of input bits should be the same a number of output bits.  Ex: A S-box tables Input: 001 (r1,c2) Output: 101 input 101 (r2,c2) output 001 24/09/2021 17
 It is an important component in most block ciphers  Properties: 24/09/2021 18 9 24/09/2021
 Circular Shift is another component found in some modern block ciphers o
It mixes the bits in a word and helps hide the patterns in the original word
 Ex: Circular shifting an 8-bit word to the left or right
 A circular left-shift operation is the inverse of the circular right-shift operation. 19
 The swap operation is a special case of the circular shift operation where k = n/2.
 Ex: Swap operation on an 8-bit word 24/09/2021 20 10 24/09/2021
 Both operations are found in some block ciphers o
The split: splits an n-bit word in the middle, creating two equa - l length words. o
The combine: concatenates two equal-length words to create an n-bit word.
 These two operations are inverses of each other and can
be used as a pair to cancel each other out. 24/09/2021 21
 Product cipher is introduced by Shannon o
a complex cipher combining substitution, permutation, and other components.
 It have two important properties: diffusion and confusion. o
Diffusion: hide the relationship between the ciphertext & the plaintext. => frustrate the a
dversary who uses ciphertext statistics to find the plaintext. o
Confusion: hide the relationship between the ciphertext & the key.
=> frustrate the adversary who tries to use the ciphertext to find the key. 24/09/2021 22 11 24/09/2021
 Diffusion and confusion can be achieved using iterated
product ciphers where each iteration is a combination of
S-boxes, P-boxes, and other components.
 The block cipher uses a key schedule or key generator
that creates different keys for each round from the cipher key.
 In an N-round cipher, the plaintext is encrypted N times
to create the ciphertext; the ciphertext is decrypted N
times to create the plaintext. 24/09/2021 23  3 transformations happen at each round o Key mixer o S-boxes o P-box 24/09/2021 12 24/09/2021
 Diffusion and confusion in a block cipher. Ex: o
changing a single bit in the plaintext
affects many bits in the ciphertext.  Diffusion. Round1 o XOR with K1 o S-box 4: affects bits 7 and 8 o
P-box: bit7 -> bit2, bit8 -> bit4. Round 2: ….
=> bit 8 has affected bits 1, 3, 6, and 7  Confusion: o
bits 1,3,6,7 are affected by bit8 (K ); bit 1
2,3 (K ). => each bit in each round key 2 25
affects several bits in the ciphertext.
 Modern block ciphers are all product ciphers, but are divided into two classes.  Feistel ciphers o
Feistel designed a very intelligent and interesting cipher that has been used for decades. o
A Feistel cipher can have three types of components: self-
invertible, invertible, and noninvertible.  Non-Feistel ciphers o
A non-Feistel cipher uses only invertible components. o
A component in the encryption cipher has the corresponding
component in the decryption cipher. 24/09/2021 26 13 24/09/2021  The first thought o
Mixer ((XOR, F(K)): self-invertible o Same key: encryption and
decryption are inverses of each other  Improvement o Use left and right blocks o
the inputs to the function must be
exactly the same inencryption & decryption.
Means: The right half of the plain-
text never changes. => 1 flaw
=> Attack can intercepting the
ciphertext and extracting the right half Improvement.  increase the number of rounds.  add a new element to each round: a swapper. => it allows us to swap the left and right halves in each round.  K K are used in reverse 1 2 order in the encryption and decryption 24/09/2021 14 24/09/2021
 Attacks on traditional ciphers can also be used on
modern block ciphers, but today’s block ciphers resist most of the attacks  Differential Cryptanalysis o
Eli Biham and Adi Shamir introduced the idea of differential
cryptanalysis. This is a chosen-plaintext attack  Linear Cryptanalysis o
Linear cryptanalysis was presented by Mitsuru Matsui in 1993.
The analysis uses known plaintext attacks. 24/09/2021 29
 Using XOR: Without knowing the value of the key,
attack can easily find the relationship between plaintext
differences and ciphertext differences if by plaintext/
ciphertext difference P  P and C  C . 1 2 1 2  The following proves: Because: x ⊕ x = (00…0) x ⊕ (00…0) = x => So simple 24/09/2021 30 15 24/09/2021  Solution: add one S-box. o
prevents atacker from finding a
definite relationship btw P and C  SBut, attack can create a probabilistic relationship:
 Make table from information about S-box input/output table with P  P = X  X . 1 2 1 2 24/09/2021 31
 3 linear equations between plaintext and ciphertext bits
 Solving for three unknowns, we get.
 This means: 3known-plaintext attacks can find the values of k , k , and k 0 1 2
 In some modern block ciphers, some S-boxes are not totally nonlinear;
they can be approximated, probabilistically, by some linear functions. 24/09/2021 32 16 24/09/2021
 In a modern stream cipher, encryption and decryption are done r bits at a time.
 We have: p , c , k are r-bit words. i i i o
a plaintext bit stream P = p …p p , n 2 1 o
a ciphertext bit strea C = c …c c , n 2 1 o
a key bit stream K = k …k k n 2 1,  2 types: o Synchronous stream cipher o Nonsynchronous stream cipher 24/09/2021 33
 In a synchronous stream cipher the key is independent
of the plaintext or ciphertext.
 Ex: Enc & Dec with stream cipher
Use the XOR function and the given key to encrypt the word “Hi”. key = FA F2 Hi = FA F2 = Hi encrypted = 24/09/2021 34 17 24/09/2021
 One-time pad: The simplest and the most secure type o
cannot guess the key or the plaintext and ciphertext statistics. o
no relationship between the plaintext and ciphertext, either. o
? How can the sender and the receiver share a one-time pad key
=> this perfect and ideal cipher is very difficult to achieve 24/09/2021 35
 The feedback shift register (FSR) o
can be implemented in either software or hardware o
A feedback shift register is made of a shift register and a feedback
 The shift register: a sequence of m cells, b to b , e ach cell holds 0 m−1
a single bit: b receives value from b , give value to b i i-1 i+1
 The feedback function: defines how the values of cells are combined to calculate bm  A feedback shift register: o linear or o nonlinear. 24/09/2021 36 18 24/09/2021
 Linear feedback shift register (LFSR) o
b is a linear function of b , b , …, b m 0 1 m−1
 Ex: Create a linear feedback shift register with 5 cells in which  LSFR for Example o c =0 -> b not connected i i o 3 connections
 vulnerable to attacks mainly because of its linearity 24/09/2021 37
 NonLinear feedback shift register (NLFSR) o
b is a nonlinear function of b , b , …, b m 0 1 m−1  Combination: o
A stream cipher can use a combination of linear and nonlinear structures. o
Some LFSRs can be made with the maximum period and then
combined through a nonlinear function. 24/09/2021 38 19 24/09/2021
 the key depends on either the plaintext or ciphertext. 24/09/2021 39 20