Unit II Symmetric Ciphers: Prepared By: Suresh Thapa Vedas College, Jawalakhel, Lalitpur
Unit II Symmetric Ciphers: Prepared By: Suresh Thapa Vedas College, Jawalakhel, Lalitpur
Symmetric Ciphers
Prepared by: Suresh Thapa
Vedas College, Jawalakhel, Lalitpur
Feistel Cipher Structure
• In May 1973, and again in Aug 1974 the NBS (now NIST) called for
possible encryption algorithms for use in unclassified government
applications response was mostly disappointing, however IBM submitted
their Lucifer design following a period of redesign and comment it became
the Data Encryption Standard (DES)
• It was adopted as a (US) federal standard in Nov 76, published by NBS as a
hardware only scheme in Jan 77 and by ANSI for both hardware and
software standards in ANSI X3.92-1981 (also X3.106-1983 modes of use)
subsequently it has been widely adopted and is now published in many
standards around the world cf Australian Standard AS2805.5-1985
• One of the largest users of the DES is the banking industry, particularly with
EFT, and EFTPOS
• It is for this use that the DES has primarily been standardized, with ANSI
having twice reconfirmed its recommended use for 5 year periods - a further
extension is not expected however although the standard is public, the
design criteria used are classified and have yet to be released there has been
considerable controversy over the design, particularly in the choice of a 56-
bit key.
Data Encryption Standards (DES)
• Initial Permutation IP
– First step of the data computation
– IP reorders the input data bits
– Even bits to LH half and, odd bits to RH half
– Quite regular in structure
– Example
• IP (675a6967 5e5a6b5a) = (ffb2194d 004df6fb)
• DES Round Structure
– uses two 32-bit L & R halves
– as for any Feistel cipher can describe as:
• L i = R i–1
• R i = L i–1 xor F(R i–1, K i )
– takes 32-bit R half and 48-bit subkey and:
• expands R to 48-bits using perm E
• adds to subkey
• passes through 8 S-boxes to get 32-bit result
• finally permutes this using 32-bit perm P
Data Encryption Standards (DES)
Data Encryption Standards (DES)
• Substitution Boxes S
– have eight S-boxes which map 6 to 4 bits
– each S-box is actually 4 little 4 bit boxes
• outer bits 1 & 6 (row bits) select one rows
• inner bits 2-5 (col bits) are substituted
• result is 8 lots of 4 bits, or 32 bits
– row selection depends on both data & key
• feature known as autoclaving (autokeying)
– example: S(18 09 12 3d 11 17 38 39) = 5fd25e03
– forms subkeys used in each round consists of:
• initial permutation of the key (PC1) which selects 56-bits in two 28-bit halves
• 16 stages consisting of:
– selecting 24-bits from each half
– permuting them by PC2 for use in function f,
– rotating each half separately either 1 or 2 places depending on the key rotation schedule K
Data Encryption Standards (DES)
• DES Decryption
– decrypt must unwind steps of data computation
– with Feistel design, do encryption steps again
using subkeys in reverse order (SK16 … SK1)
– note that IP undoes final FP step of encryption
– 1st round with SK16 undoes 16th encrypt round
….
– 16th round with SK1 undoes 1st encrypt round
– then final FP undoes initial encryption IP
– thus recovering original data value
Data Encryption Standards (DES)
• Double DES
– The simplest form of multiple encryption has two
encryption stages and two keys).
– Given a plaintext P and two encryption keys K1 and
K2, ciphertext C is generated as
• C = E(K2, E(K1, P))
– Decryption requires that the keys be applied in
reverse order:
• P = D(K1, D(K2, C))
– For DES, this scheme apparently involves a key length
of 56 * 2 = 112 bits, and should result in a dramatic
increase in cryptographic strength.
Data Encryption Standards (DES)
• Double DES
Data Encryption Standards (DES)
• Triple DES
Data Encryption Standards (DES)
• Groups
– A group G, sometimes denoted by {G, ·} is a set of elements with a binary operation,
denoted by ·, that associates to each ordered pair (a, b) of elements in G an element
(a · b) in G, such that the following axioms are obeyed.]The operator · is generic and
can refer to addition, multiplication, or some other mathematical operation.
• (A1) Closure:
– If a and b belong to G, then a · b is also in G.
• (A2) Associative:
– a · (b · c) = (a · b) · c for all a, b, c in G.
• (A3) Identity element:
– There is an element e in G such that a · e = e · a = a for all a in G.
• (A4) Inverse element:
– For each a in G there is an element a' in G such that a · a' = a' · a = e.
– If a group has a finite number of elements, it is referred to as a finite group, and the
order of the group is equal to the number of elements in the group. Otherwise, the
group is an infinite group.
– A group is said to be abelian if it satisfies the following additional condition:
• (A5) Commutative:
– a · b = b · a for all a, b in G. The set of integers (positive, negative, and 0) under addition is an abelian group.
Finite Fields
• Cyclic Group
– We define exponentiation within a group as repeated
application of the group operator, so that a3 = a · a · a.
– Further, we define a0 = e, the identity element; and a-
n = (a')n.
• Ring
– A ring R, sometimes denoted by {R, +, x}, is a set of
elements with two binary operations, called addition and
multiplication, such that for all a, b, c in R the following
axioms are obeyed:
• (A1-A5) R is an abelian group with respect to addition; that is, R
satisfies axioms A1 through A5. For the case of an additive group,
we denote the identity element as 0 and the inverse of a as a.
• (M1) Closure under multiplication:
– If a and b belong to R, then ab is also in R.
• (M2) Associativity of multiplication:
– a(bc) = (ab)c for all a, b, c in R.
• (M3) Distributive laws:
– a(b + c) = ab + ac for all a, b, c in R. (a + b)c = ac + bc for all a, b, c in R.
Finite Fields
• Commutative Ring
– A ring is said to be commutative if it satisfies the
following additional condition:
– (M4) Commutativity of multiplication:
• ab = ba for all a, b in R.
– Let S be the set of even integers (positive,
negative, and 0) under the usual operations of
addition and multiplication. S is a commutative
ring. The set of all n-square matrices defined in
the preceding example is not a commutative ring.
Finite Fields
• Integral Domain
– we define an integral domain, which is a
commutative ring that obeys the following axioms:
– (M5) Multiplicative identity:
• There is an element 1 in R such that a1 = 1a = a for all a
in R. (M6) No zero divisors: If a, b in R and ab = 0, then
either a = 0 or b = 0.
– Let S be the set of integers, positive, negative, and
0, under the usual operations of addition and
multiplication. S is an integral domain.
Finite Fields
• Fields
– A field F, sometimes denoted by {F, +, x}, is a set of elements with two
binary operations, called addition and multiplication, such that for all a, b,
c in F the following axioms are obeyed:
– (A1 M6) F is an integral domain; that is, F satisfies axioms A1 through A5
and M1 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; in fact,
only the elements 1 and -1 have multiplicative inverses in the integers
Finite Fields
• Fields
– A field F, sometimes denoted by {F, +, x}, is a set of elements with
two binary operations, called addition and multiplication, such that
for all a, b, c in F the following axioms are obeyed:
– (A1 M6) F is an integral domain; that is, F satisfies axioms A1 through
A5 and M1 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
Finite Fields
Finite Fields
• Modular Arithmetic
– 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…………………….*(1)
– If a 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.
• For example: 11 mod 7=4 and -11 mod 7 = 3
– Two integers a and b are said to be congruent modulo n,
if (a mod n) = (b mod n).
• i.e. a ≡ b ( mod n)
Finite Fields
• Divisors
– We say that a nonzero b divides a if a = mb for
some m, where a, b, and m are integers. That is, b
divides a if there is no remainder on division. The
notation is commonly used to mean b divides a.
Also, if b|a, we say that b is a divisor of a.
– The following relations hold:
• If a|1, then a = ±1.
• If a|b and b|a, then a = ±b.
• Any b 0 divides 0.
• If b|g and b|h, then b|(mg + nh) for arbitrary integers m
and n.
Finite Fields
• Properties of Congruences
– Congruences have the following properties:
• a ≡ b (mod n) if n|(a-b).
• a ≡ b (mod n) implies b ≡ a (mod n)..
• a ≡ b (mod n) and b ≡ c (mod n) imply a ≡ c (mod n).
– To demonstrate the first point, if n|(a b), then (a b) = kn for some k.
So we can write a = b + kn. Therefore, (a mod n) = (reminder when b
+ kn is divided by n) = (reminder when b is divided by n) = (b mod n)
• Arithmetic Modulo 8
+ 0 1 2 3 4 5 6 7 * 0 1 2 3 4 5 6 7 W -w w-
0 0 1 2 3 4 5 6 7 0 0 0 0 0 0 0 0 0 0 0 -
1 1 2 3 4 5 6 7 0 1 0 1 2 3 4 5 6 7 1 7 1
2 2 3 4 5 6 7 0 1
2 0 2 4 6 0 2 4 6 2 6 -
3 3 4 5 6 7 0 1 2
3 0 3 6 1 4 7 2 5 3 5 3
4 4 5 6 7 0 1 2 3
5 5 6 7 0 1 2 3 4 4 0 4 0 4 0 4 0 4 4 4 -
6 6 7 0 1 2 3 4 5 5 0 5 2 7 4 1 6 3 5 3 5
7 7 0 1 2 3 4 5 6 6 0 6 4 2 0 6 4 2 6 2 -
7 0 7 6 5 4 3 2 1 7 1 7
• Arithmetic in GF(7)
+ 0 1 2 3 4 5 6 * 0 1 2 3 4 5 6 W -w w-
0 0 1 2 3 4 5 6 0 0 0 0 0 0 0 0 0 0 -
1 1 2 3 4 5 6 0 1 0 1 2 3 4 5 6 1 6 1
2 2 3 4 5 6 0 1
2 0 2 4 6 1 3 5 2 5 4
3 3 4 5 6 0 1 2
3 0 3 6 2 5 1 4 3 4 5
4 4 5 6 0 1 2 3
5 5 6 0 1 2 3 4 4 0 4 1 5 2 6 2 4 3 2
6 6 0 1 2 3 4 5 5 0 5 3 1 6 4 2 5 2 3
6 0 6 5 4 3 2 1 6 1 6
• Finding
the Multiplicative Inverse in GF(p)
– The Euclidean algorithm can be extended so that, in addition
to finding gcd(m, b), if the gcd is 1, the algorithm returns the
multiplicative inverse of b.
– EXTENDED EUCLID(m, b)
1. (A1, A2, A3) (1, 0, m); (B1, B2, B3) (0, 1, b)
2. if B3 = 0 return A3 = gcd(m, b); no inverse
3. if B3 = 1 return B3 = gcd(m, b); B2 = b -1 mod m
• Polynomial Arithmetic
– Ordinary polynomial arithmetic, using the basic rules
of algebra.
– Polynomial arithmetic in which the arithmetic on the
coefficients is performed modulo p; that is, the
coefficients are in GF(p).
– Polynomial arithmetic in which the coefficients are in
GF(p), and the polynomials are defined modulo a
polynomial m(x) whose highest power is some
integer n.
Finite Fields
•• Polynomial
Arithmetic
– A polynomial of degree n (integer n≥ 0) is an expression of the
form
f(x) = anxn + an-1xn-1 + …….. + a1x + a0 =
where the ai are elements of some designated set of numbers S,
called the coefficient set, and an ≠ 0.
– We say that such polynomials are defined over the coefficient set
S.
– As an example,
• let f(x) = x3 + x2 + 2 and g(x) = x2 - x + 1, where S is the set of integers. Then
f(x) + g(x) = x3 + 2x2 - x + 3
f(x) - g(x) = x3 + x + 1
f(x) * g(x) = x5 + 3x2 - 2x + 2
Finite Fields
• Polynomial Arithmetic
– Given polynomials f(x) of degree n and g(x) of degree (m), (n ≥ m), if
we divide f(x) by g(x), we get a quotient q(x) and a remainder r(x) that
obey the relationship
f(x) = q(x)g(x) + r(x)
with polynomial degrees:
Degree f(x) = n
Degree g(x) = m
Degree q(x) = n - m
Degree r(x) ≤ m - 1
– A polynomial f(x) over a field F is called irreducible if and only if f(x)
cannot be expressed as a product of two polynomials, both over F,
and both of degree lower than that of f(x). By analogy to integers, an
irreducible polynomial is also called a prime polynomial.
Finite Fields
• Encryption
– First of all 64 bit plain text is divided into 4 16-bit parts and they are taken as
an input in first round.
– At the end of the first encryption round four 16-bit values are produced
which are used as input to the second encryption round
– The process is repeated in each of the subsequent 8 encryption rounds
– Note that in 9th round we have to use only 4 key( K49, K50, K51,K52) and
have to perform different operation as guided in previous slide.
• Decryption
– The computational process used for decryption of the ciphertext is
essentially the same as that used for encryption
– The only difference is that each of the 52 16-bit key sub-blocks used for
decryption is the inverse of the key sub-block used during encryption
– Do remember that the sub blocks must be used in reverse order than of the
encryption round.
IDEA
• Applications of IDEA
– Today, there are hundreds of IDEA-based security solutions
available in many market areas, ranging from Financial
Services, and Broadcasting to Government
– The IDEA algorithm can easily be combined in any encryption
software. Data encryption can be used to protect data
transmission and storage.
– Typical fields are:
• Audio and video data for cable TV, video conferencing, distance
learning
• Sensitive financial and commercial data
• Email via public networks
• Smart cards
Block Cipher Mode of Operation
Block Cipher Mode of Operation
• Substitute Bytes
– This stage (known as SubBytes) is simply a table
lookup using a 16×16 matrix of byte values called an
s-box.
– This matrix consists of all the possible combinations
of an 8 bit sequence (28 = 16×16 = 256).
– However, the s-box is not just a random permutation
of these values and there is a well defined method for
creating the s-box tables
Advance Encryption System (AES)
• Substitute Bytes
Advance Encryption System (AES)
• Substitute Bytes
Advance Encryption System (AES)
• Construction of S-Box
– Initialize the S-box with the byte values in ascending sequence row by row. The first
row contains {00}, {01}, {02}, c , {0F}; the second row contains {10}, {11}, etc.; and so
on. Thus, the value of the byte at row y, column x is {yx}.
– Map each byte in the S-box to its multiplicative inverse in the finite field GF(28 ); the
value {00} is mapped to itself.
– Consider that each byte in the S-box consists of 8 bits labeled (b7, b6, b5, b4, b3,
b2, b1, b0). Apply the following transformation to each bit of each byte in the S-box:
• b′i = bi ⊕ b(i+4) mod 8 ⊕ b(i+5) mod 8 ⊕ b(i+6) mod 8 ⊕ b(i+7) mod 8 ⊕ ci
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.
– The inverse substitute byte transformation, called InvSubBytes, makes use of the
inverse S-box. The inverse S-box is constructed by applying the inverse of the
transformation followed by taking the multiplicative inverse in GF(28 ). The inverse
transformation is
• b′ i = b(i+2) mod 8 ⊕ b(i+5) mod 8 ⊕ b(i+7) mod 8 ⊕ di where byte d = {05}, or 00000101.
Advance Encryption System (AES)
• AES
– Refer to document provided for more detail
Thank You
End of Unit II
(Symmetric Ciphers)