Introduction to Modern Cryptography Lecture 3 (1) Finite Groups, Rings and Fields (2) AES - Advanced...

37
Introduction to Modern Cryptography Lecture 3 ( 1 ) Finite Groups, Rings and Fields ( 2 ) AES - Advanced Encryption
  • date post

    21-Dec-2015
  • Category

    Documents

  • view

    228
  • download

    0

Transcript of Introduction to Modern Cryptography Lecture 3 (1) Finite Groups, Rings and Fields (2) AES - Advanced...

Page 1: Introduction to Modern Cryptography Lecture 3 (1) Finite Groups, Rings and Fields (2) AES - Advanced Encryption Standard.

Introduction to Modern Cryptography

Lecture 3

(1) Finite Groups, Rings and Fields

(2) AES - Advanced Encryption Standard

Page 2: Introduction to Modern Cryptography Lecture 3 (1) Finite Groups, Rings and Fields (2) AES - Advanced Encryption Standard.

Review - Groups

Def (group): A set G with a binary operation + (addition) is called a commutative group if

1 a,bG, a+bG2 a,b,cG, (a+b)+c=a+

(b+c)3 a,bG, a+b=b+a

4 0G, aG, a+0=a5 aG, -aG, a+(-a)=0

+,0, and -aare only notations!

Page 3: Introduction to Modern Cryptography Lecture 3 (1) Finite Groups, Rings and Fields (2) AES - Advanced Encryption Standard.

Sub-groups

• Let (G, +) be a group, (H,+) is a sub-group of (G,+) if it is a group, and HG.

• Claim: Let (G, +) be a finite group, and HG. If H is closed under +, then (H,+) is a sub-group of (G,+).

• Examples• Lagrange theorem: if G is finite and (H,

+) is a sub-group of (G,+) then |H| divides |G|

Page 4: Introduction to Modern Cryptography Lecture 3 (1) Finite Groups, Rings and Fields (2) AES - Advanced Encryption Standard.

Order of Elements

• Let an denote a+…+a (n times)• We say that a is of order n if an = 0, and

for any m<n, am0• Examples• Euler theorem: In the multiplicative

group of Zm, every element is of order at most (m).

Page 5: Introduction to Modern Cryptography Lecture 3 (1) Finite Groups, Rings and Fields (2) AES - Advanced Encryption Standard.

Cyclic Groups• Claim: let G be a group and a be

an element of order n. The set <a>={1, a,…,an-1} is a sub-group

of G.• a is called the generator of <a>. • If G is generated by a, then G is

called cyclic, and a is called a primitive element of G.

• Theorem: for any prime p, the multiplicative group of Zp is cyclic

Page 6: Introduction to Modern Cryptography Lecture 3 (1) Finite Groups, Rings and Fields (2) AES - Advanced Encryption Standard.

Review - Rings

Def (ring): A set F with two binary operations + (addition) and · (multiplication)

is called a commutative ring with identity if

6 a,bF, a·bF7 a,b,cF, (a·b)·c=a·(b·c)

8 a,bF, a·b=b·a9 1F, aF, a·1=a

10 a,b,cF,a·(b+c)=a·b+a·c

1 a,bF, a+bF2 a,b,cF, (a+b)+c=a+(b+c)

3 a,bF, a+b=b+a4 0F, aF, a+0=a

5 aF, -aF, a+(-a)=0

+,·,0, 1 and-a are only notations!

Page 7: Introduction to Modern Cryptography Lecture 3 (1) Finite Groups, Rings and Fields (2) AES - Advanced Encryption Standard.

Review - Fields

Def (field): A set F with two binary operations + (addition) and · (multiplication)

is called a field if

6 a,bF, a·bF7 a,b,cF, (a·b)·c=a·(b·c)

8 a,bF, a·b=b·a9 1F, aF, a·1=a

10 a,b,cF,a·(b+c)=a·b+a·c

1 a,bF, a+bF2 a,b,cF, (a+b)+c=a+(b+c)

3 a,bF, a+b=b+a4 0F, aF, a+0=a

5 aF, -aF, a+(-a)=0

11 a0F, a-1F, a·a-1=1

+,·,0, 1,-a and a-1 are

only notations!

Page 8: Introduction to Modern Cryptography Lecture 3 (1) Finite Groups, Rings and Fields (2) AES - Advanced Encryption Standard.

Review - Fields

A field is a commutative ring with identity where each non-zero element has a multiplicative inverse

a0F, a-1F, a·a-1=1

Equivalently, (F,+) is a commutative (additive) group,and (F \ {0}, ·) is a commutative (multiplicative) group.

Page 9: Introduction to Modern Cryptography Lecture 3 (1) Finite Groups, Rings and Fields (2) AES - Advanced Encryption Standard.

Polynomials over Fields

Let f(x)= an·xn + an-1·x

n-1 + an-2·xn-2 + … + a1·x +

a0

be a polynomial of degree n in one variable x over a fieldF (namely an, an-1,…, a1, a0 F).

Theorem: The equation f(x)=0 has at most n solutions in F.

Remark: The theorem does not hold over rings with identity.

For example, in Z24 the equation 6·x = 0 has six solutions (0,4,8,12,16,20).

Page 10: Introduction to Modern Cryptography Lecture 3 (1) Finite Groups, Rings and Fields (2) AES - Advanced Encryption Standard.

Polynomial RemaindersLet f(x)= an·x

n + an-1·xn-1 + an-2·x

n-2 + … + a1·x + a0

g(x)= bm·xm + bm-1·xm-1 + bm-2·x

m-2 + … + b1·x + b0

be two polynomials over F such that m < n (or m=n).

Theorem: There is a unique polynomial r(x) of degree < m over F such that

f(x) = h(x) · g(x) + r(x).

Remark: r(x) is called the remainder of f(x) modulo g(x).Maple 8

Worksheet File

Page 11: Introduction to Modern Cryptography Lecture 3 (1) Finite Groups, Rings and Fields (2) AES - Advanced Encryption Standard.

Finite Fields

Def (finite field): A field (F,+,·) is called a finite field if the set F is finite .

Example: Zp denotes {0,1,...,p-1}. We define + and · as addition and multiplication modulo p, respectively.

One can prove that (Zp,+,·) is a field iff p is prime .

Q.: Are there any finite fields except (Zp,+,·)?

Page 12: Introduction to Modern Cryptography Lecture 3 (1) Finite Groups, Rings and Fields (2) AES - Advanced Encryption Standard.

The Characteristic of Finite Fields

Let (F,+,·) be a finite field.There is a positive integer n such that

1+…+1 = 0 (n times)

The mimimal such n is called the characteristic of F, char(F).

Thm: For any finite field F, char(F) is a prime number.

Page 13: Introduction to Modern Cryptography Lecture 3 (1) Finite Groups, Rings and Fields (2) AES - Advanced Encryption Standard.

Galois Fields GF(pk)

Évariste Galois )1811-1832(

Theorem: For every prime power pk (k=1,2,…) there is a unique finite field containing pk elements. These fields are

denoted by GF(pk) .There are no finite fields with other cardinalities.

Remarks:.1For F=GF(pk), char(F)=p.

2 .GF(pk) and Zpk are not the

same!

Page 14: Introduction to Modern Cryptography Lecture 3 (1) Finite Groups, Rings and Fields (2) AES - Advanced Encryption Standard.

Polynomials over Finite FieldsPolynomial equations and factorizations in finitefields can be different than over the rationals.

Examples from an XMAPLE session:

Maple 8 Worksheet File

Page 15: Introduction to Modern Cryptography Lecture 3 (1) Finite Groups, Rings and Fields (2) AES - Advanced Encryption Standard.

Irreducible PolynomialsA polynomial is irreducible in GF(p) if it does not factor over GF(p). Otherwise it is reducible.

Examples:

The same polynomial is reducible in Z5 but irreducible in Z2.

Maple 8 Worksheet File

Page 16: Introduction to Modern Cryptography Lecture 3 (1) Finite Groups, Rings and Fields (2) AES - Advanced Encryption Standard.

Implementing GF(p^k) arithmetic

Theorem: Let f(x) be an irreducible polynomial

of degree k over Zp .

The finite field GF(pk) can be realized as the set

of degree k-1 polynomials over Zp, with addition

and multiplication done modulo f(x).

Page 17: Introduction to Modern Cryptography Lecture 3 (1) Finite Groups, Rings and Fields (2) AES - Advanced Encryption Standard.

Example: Implementing GF(2^k)

By the theorem the finite field GF(25) can be realized as

the set of degree 4 polynomials over Z2, with addition

and multiplication done modulo the irreducible polynomial

f(x)=x5+x4+x3+x+1.

The coefficients of polynomials over Z2 are 0 or 1.So a degree k polynomial can be written down by k+1 bits.For example, with k=4:

x3+x+1 )0,1,0,1,1(

x4+ x3+x+1 )1,1,0,1,1(

Page 18: Introduction to Modern Cryptography Lecture 3 (1) Finite Groups, Rings and Fields (2) AES - Advanced Encryption Standard.

Implementing GF(2^k)

Addition: bit-wise XOR (since 1+1=0)

x3+x+1 )0,1,0,1,1( +

x4+ x3+x )1,1,0,1,0(-------------------------------

x4 +1 )1,0,0,0,1(

Page 19: Introduction to Modern Cryptography Lecture 3 (1) Finite Groups, Rings and Fields (2) AES - Advanced Encryption Standard.

Multiplication: Polynomial multiplication, and then remainder modulo the defining polynomial f(x):

Implementing GF(2^k)

For small size finite field, a lookup table is the most efficientmethod for implementing multiplication.

( 1,1,0,1,1 )*(0,1,0,1,1)

= (1,1,0,0,1)

Page 20: Introduction to Modern Cryptography Lecture 3 (1) Finite Groups, Rings and Fields (2) AES - Advanced Encryption Standard.

Implementing GF(25) in XMAPLE

Irreducible polynomial

Maple 8 Worksheet File

Page 21: Introduction to Modern Cryptography Lecture 3 (1) Finite Groups, Rings and Fields (2) AES - Advanced Encryption Standard.

More GF(25) Operations in XMAPLEAddition: b+c

test primitive element

e <--inverse of a Multiplication: a*e

Loop forfinding primitiveelements

Maple 8 Worksheet File

Page 22: Introduction to Modern Cryptography Lecture 3 (1) Finite Groups, Rings and Fields (2) AES - Advanced Encryption Standard.

Back to Symmetric Block Ciphers

out in

DES AES

Page 23: Introduction to Modern Cryptography Lecture 3 (1) Finite Groups, Rings and Fields (2) AES - Advanced Encryption Standard.

Historic Note

DES (data encryption standard) is a symmetric block cipherusing 64 bit blocks and a 56 bit key.

Developed at IBM, approved by the US goverment (1976)as a standard. Size of key (56 bits) was apparently small enough to allow the NSA (US national security agency) tobreak it exhaustively even back in 70’s.

In the 90’s it became clear that DES is too weak for contemporary hardware & algorithmics. (Best attack, Matsui

“linear attack”, requires only 243 known plaintext/ciphertextpairs).

Page 24: Introduction to Modern Cryptography Lecture 3 (1) Finite Groups, Rings and Fields (2) AES - Advanced Encryption Standard.

Historic Note (cont.)

The US government NIST (national inst. of standards and technology) announced a call for an advanced encryption standard in 1997 .

This was an international open competition.Overall, 15 proposals were made and evaluated ,

and 6 were finalists. Out of those, a proposal namedRijndael, by Daemen and Rijmen (two Belgians) was chosen in February 2001 .

Page 25: Introduction to Modern Cryptography Lecture 3 (1) Finite Groups, Rings and Fields (2) AES - Advanced Encryption Standard.

AES - Advanced Encryption Standard

• Symmetric block cipher• Key lengthes: 128, 192, or 256 bits• Approved US standard (2001)

Page 26: Introduction to Modern Cryptography Lecture 3 (1) Finite Groups, Rings and Fields (2) AES - Advanced Encryption Standard.

AES Design Rationale

• Resistance to all known attacks.

• Speed and code compactness.

• Simplicity.

Page 27: Introduction to Modern Cryptography Lecture 3 (1) Finite Groups, Rings and Fields (2) AES - Advanced Encryption Standard.

AES Specifications• Input & output block length: 128 bits.

• State: 128 bits, arranged in a 4-by-4 matrix of bytes.

A0,0A0,1A0,2A0,3

A1,0A1,1A1,2A1,3

A2,0A2,1A2,2A2,3

A3,0A3,1A3,2A3,3

Each byte is viewedas an element in GF(28)

Input/Output: A0,0, A1,0, A2,0, A3,0, A0,1…,

Page 28: Introduction to Modern Cryptography Lecture 3 (1) Finite Groups, Rings and Fields (2) AES - Advanced Encryption Standard.

AES Specifications• Key length: 128, 196, 256 bits.

Cipher Key Layout: n = 128, 196, 256 bits, arranged in a 4-by-n/32 matrix of bytes.

K0,0K0,1K0,2K0,3K0,4K0,5

K1,0K1,1K1,2K1,3K1,4K1,5

K2,0K2,1K2,2K2,3K2,4K2,5

K3,0K3,1K3,2K3,3K3,4K3,5

Initial layout: K0,0, K1,0, K2,0, K3,0, K0,1…,

Page 29: Introduction to Modern Cryptography Lecture 3 (1) Finite Groups, Rings and Fields (2) AES - Advanced Encryption Standard.

AES Specifications

• High level code:

• AES)State,Key(– KeyExpansion)Key,ExpandKey(– AddRoundKey)State,ExpandKey[0](– For )i=1; i<R; i++( Round)State,ExpandKey[i](;– FinalRound)State,ExpandKey[R](;

Page 30: Introduction to Modern Cryptography Lecture 3 (1) Finite Groups, Rings and Fields (2) AES - Advanced Encryption Standard.

Encryption: Carried out in rounds

input block( 128 bits)

output block( 128 bits)

Secret key (128 bits)

Page 31: Introduction to Modern Cryptography Lecture 3 (1) Finite Groups, Rings and Fields (2) AES - Advanced Encryption Standard.

Rounds in AES128 bits AES uses 10 rounds, no shortcuts

known for 6 rounds

• The secret key is expanded from 128 bits to 10 round keys, 128 bits each.• Each round changes the state, then XORS the round key. (For longer keys, addOne round for every extra 32 bits)

Each rounds complicates things a little .Overall it seems infeasible to invert without the secret key (but easy given the key).

Page 32: Introduction to Modern Cryptography Lecture 3 (1) Finite Groups, Rings and Fields (2) AES - Advanced Encryption Standard.

AES Specifications: One Round

A0,0A0,1A0,2A0,3

A1,0A1,1A1,2A1,3

A2,0A2,1A2,2A2,3

A3,0A3,1A3,2A3,3

Transform the state by applying:

1. Substitution.2. Shift rows3. Mix columns

4. XOR round key

Page 33: Introduction to Modern Cryptography Lecture 3 (1) Finite Groups, Rings and Fields (2) AES - Advanced Encryption Standard.

Substitution operates on every Byteseparately: Ai,j <-- Ai,j

-1 (multiplicative inverse in GF(28)

which is highly non linear.)

Substitution (S-Box)

If Ai,j =0, don’t change Ai,j .

Clearly, the substitution is invertible.

Page 34: Introduction to Modern Cryptography Lecture 3 (1) Finite Groups, Rings and Fields (2) AES - Advanced Encryption Standard.

Cyclic Shift of Rows

A0,0A0,1A0,2A0,3

A1,3A1,0A1,1A1,2

A2,2A2,3A2,0A2,1

A3,1A3,2A3,3A3,0

no shift shift 1 position

shift 2 positions shift 3 positions

Clearly, the shift is invertible.

Page 35: Introduction to Modern Cryptography Lecture 3 (1) Finite Groups, Rings and Fields (2) AES - Advanced Encryption Standard.

Mixing Columns Every state column is considered as a Polynomial over GF(28)

Multiply with an invertible polynomial03 x3 + 01x2 + 01x + 02 (mod x4 + 1)

Inv = 0B x3 + 0D x2 +09 x + 0E

Round: Subbytes(State) ShiftRows(State)

MixColumns(State) AddRoundKey(State,ExpandedKey[i])

Page 36: Introduction to Modern Cryptography Lecture 3 (1) Finite Groups, Rings and Fields (2) AES - Advanced Encryption Standard.

Key Expansion

• Generate a “different key” per round• Need a 4 x 4 matrix of values )over GF)28((

per round• Based upon a non-linear transformation of

the original key.• Details available:• The Design of Rijndael, Joan Daemen and

Vincent Rijmen, Springer

Page 37: Introduction to Modern Cryptography Lecture 3 (1) Finite Groups, Rings and Fields (2) AES - Advanced Encryption Standard.

Breaking AES

Breaking 1 or 2 rounds is easy.

It is not known how to break 5 rounds.

Breaking the full 10 rounds AES efficiently( say 1 year on existing hardware, or in

less than 2128 operations) is considered impossible ! (a good, tough challenge…)