Cryptography and Network Security: Sixth Edition by William Stallings
Cryptography and Network Security: Sixth Edition by William Stallings
Cryptography and Network Security: Sixth Edition by William Stallings
and Network
Security
Sixth Edition
by William Stallings
Chapter 4
b = 7; g = 14; h = 63; m = 3; n = 2
7 | 14 and 7 | 63.
To show 7 (3 * 14 + 2 * 63),
we have (3 * 14 + 2 * 63) = 7(3 * 2 + 2 * 9),
and it is obvious that 7 | (7(3 * 2 + 2 * 9)).
Division Algorithm
• Given any positive integer n and any
nonnegative integer a, if we divide a by n we get
an integer quotient q and an integer remainder r
that obey the following relationship:
a = qn + r 0 ≤ r < n; q = [a/n]
Euclidean Algorithm
• One of the basic techniques
of number theory
• Procedure for determining
the greatest common divisor
of two positive integers
• Two integers are relatively
prime if their only common
positive integer factor is 1
Greatest Common Divisor (GCD)
• The greatest common divisor of a and b is the
largest integer that divides both a and b
• We can use the notation gcd(a,b) to mean the
greatest common divisor of a and b
• We also define gcd(0,0) = 0
• Positive integer c is said to be the gcd of a and b if:
• c is a divisor of a and b
• Any divisor of a and b is a divisor of c
11 mod 7 = 4; - 11 mod 7 = 3
Modular Arithmetic
• Congruent modulo n
– Two integers a and b are said to be congruent
modulo n if (a mod n) = (b mod n)
– This is written as a = b(mod n)2
– Note that if a = 0(mod n), then n | a
23 = 8 (mod 5) because 23 - 8 = 15 = 5 * 3
- 11 = 5 (mod 8) because - 11 - 5 = - 16 = 8 * (- 2)
81 = 0 (mod 27) because 81 - 0 = 81 = 27 * 3
Modular Arithmetic
• Modular arithmetic exhibits the following properties:
11 mod 8 = 3; 15 mod 8 = 7
[(11 mod 8) + (15 mod 8)] mod 8 = 10 mod 8 = 2
(11 + 15) mod 8 = 26 mod 8 = 2
[(11 mod 8) - (15 mod 8)] mod 8 = - 4 mod 8 = 4
(11 - 15) mod 8 = - 4 mod 8 = 4
[(11 mod 8) * (15 mod 8)] mod 8 = 21 mod 8 = 5
(11 * 15) mod 8 = 165 mod 8 = 5
Table 4.2(a) Arithmetic Modulo 8
Table 4.2(b) Multiplication Modulo 8
Table 4.2(c)
Additive
and
Multiplicative
Inverses
Modulo 8
Table 4.3
Properties of Modular Arithmetic for Integers in Zn
Table 4.4
Extended Euclidean Algorithm Example
For given integers a and b, find <d,x,y> satisfying: ax + by = d = gcd(a,b)
a
b
through M6
(M7) Multiplicative inverse:
For each a in F, except 0, there is an element a-1 in F such that aa-1 = (a-1 )a = 1
• In essence, a field is a set in which we can do addition, subtraction,
multiplication, and division without leaving the set. Division is defined
with the following rule: a /b = a (b-1 )
Familiar examples of fields are the rational numbers, the real numbers, and
the complex numbers. Note that the set of all integers is not a field,
because not every element of the set has a multiplicative inverse.
Group,
Ring,
and
Field
Finite Fields of the Form GF(p)
• Finite fields play a crucial role in many
cryptographic algorithms
• It can be shown that the order of a finite field
must be a power of a prime pn, where n is a
positive integer
• The only positive integers that are divisors of p are
p and 1
• The finite field of order pn is generally written
GF(pn )
• GF stands for Galois field, in honor of the
mathematician who first studied finite fields
Table 4.5(a) Arithmetic in GF(7)
Arithmetic
in GF(7)
Then:
f(x) + g(x) = x3 + 2x2 - x + 3
f(x) - g(x) = x3 + x + 1
f(x) * g(x) = x5 + 3x2 - 2x + 2
(a) Addition
Table 4.6(b) Arithmetic in GF(23)
(b) Multiplication
Table 4.6(c)
Arithmetic
in GF(23)
(a) Addition
(b) Multiplication
(a) Addition
(b) Multiplication
AES
Example
Key
Expansion
(Table is located on page 151
in textbook)
Table 5.4
AES
Example
If we view the
The key as a
transformations sequence of
These two
AddRoundKey words, then both
operations are
and AddRoundKey
linear with
InvMixColumns and
respect to the
do not alter the InvMixColumns
column input
sequence of operate on State
bytes in State one column at a
time
Equivalent
Inverse
Cipher
Implementation Aspects
• AES can be implemented very efficiently on an 8-bit
processor
• AddRoundKey is a bytewise XOR operation
• ShiftRows is a simple byte-shifting operation
• SubBytes operates at the byte level and only
requires a table of 256 bytes
• MixColumns requires matrix multiplication in the
field GF(28), which means that all operations are
carried out on bytes
Implementation Aspects
• Can efficiently implement on a 32-bit processor
• Redefine steps to use 32-bit words
• Can precompute 4 tables of 256-words
• Then each column in each round can be computed
using 4 table lookups + 4 XORs
• At a cost of 4Kb to store tables
• Designers believe this very efficient
implementation was a key factor in its selection
as the AES cipher
AES Rijndael Encryption Cipher
Overview
• Youtube Example
AES Rijndael Cipher - Visualization
• Example
• https://www.youtube.com/watch?v=nL1ApwEXrz0
Summary
• AES transformation
• Finite field arithmetic
functions
• AES structure
• Substitute bytes
– General structure
• ShiftRows
– Detailed structure
• MixColumns
• AES key expansion • AddRoundKey
– Key expansion
algorithm • AES implementation
– Rationale • Equivalent inverse
cipher
• Implementation
aspects