lecture 2: private key cryptography ii cs 436/636/736 spring 2015 nitesh saxena

63
Lecture 2: Private Key Cryptography II CS 436/636/736 Spring 2015 Nitesh Saxena

Upload: mervyn-mclaughlin

Post on 12-Jan-2016

221 views

Category:

Documents


3 download

TRANSCRIPT

Page 1: Lecture 2: Private Key Cryptography II CS 436/636/736 Spring 2015 Nitesh Saxena

Lecture 2: Private Key Cryptography II

CS 436/636/736 Spring 2015

Nitesh Saxena

Page 2: Lecture 2: Private Key Cryptography II CS 436/636/736 Spring 2015 Nitesh Saxena

Today’s fun/informative bit – The Smudge Attack

• See: http://www.usenix.org/event/woot10/tech/full_papers/Aviv.pdf

04/21/23Lecture 2.2 - Private Key

Cryptography II2

Page 3: Lecture 2: Private Key Cryptography II CS 436/636/736 Spring 2015 Nitesh Saxena

Course Administration

• Everything seems to be under control • Any questions?

• HW1 heads up– To be posted by coming Monday– Covers lecture 1, 2– 10-12 days for you to work on it

04/21/23Lecture 2.2 - Private Key

Cryptography II3

Page 4: Lecture 2: Private Key Cryptography II CS 436/636/736 Spring 2015 Nitesh Saxena

Outline of today’s lecture

•Block Ciphers•Data Encryption Standard (DES)•DES Security and Extensions•Block Cipher Modes of Encryption•AES (at home reading assignment)

04/21/23Lecture 2.2 - Private Key

Cryptography II4

Page 5: Lecture 2: Private Key Cryptography II CS 436/636/736 Spring 2015 Nitesh Saxena

Block Ciphers and Stream Ciphers

• Block ciphers partition plaintext into blocks and encrypt each block independently (with the same key) to produce ciphertext blocks.

• A stream cipher generates a keystream and encrypts by combining the keystream with the plaintext, usually with the bitwise XOR operation.

• We will focus mostly on Block Ciphers

04/21/23Lecture 2.2 - Private Key

Cryptography II5

Page 6: Lecture 2: Private Key Cryptography II CS 436/636/736 Spring 2015 Nitesh Saxena

DES – Data Encryption Standard

• Encrypts by series of substitution and transpositions.• Based on Feistel Structure• Worldwide standard for more than 25 years.• Designed by IBM (Lucifer) with later help from NSA.• No longer considered secure for highly sensitive applications.• Replacement standard AES (advanced encryption standard)

recently completed.

04/21/23Lecture 2.2 - Private Key

Cryptography II6

Page 7: Lecture 2: Private Key Cryptography II CS 436/636/736 Spring 2015 Nitesh Saxena

DES – Overview (Block Operation)

04/21/23Lecture 2.2 - Private Key

Cryptography II7

Page 8: Lecture 2: Private Key Cryptography II CS 436/636/736 Spring 2015 Nitesh Saxena

DES – Each Round

04/21/23 8Lecture 2.2 - Private Key

Cryptography II

Page 9: Lecture 2: Private Key Cryptography II CS 436/636/736 Spring 2015 Nitesh Saxena

DES – Function F

04/21/23Lecture 2.2 - Private Key

Cryptography II9

Page 10: Lecture 2: Private Key Cryptography II CS 436/636/736 Spring 2015 Nitesh Saxena

DES – Key Schedule (KS)

04/21/23Lecture 2.2 - Private Key

Cryptography II10

Page 11: Lecture 2: Private Key Cryptography II CS 436/636/736 Spring 2015 Nitesh Saxena

Operation Tables of DES: Key Schedule, PC-1, PC-2

04/21/23Lecture 2.2 - Private Key

Cryptography II11

Page 12: Lecture 2: Private Key Cryptography II CS 436/636/736 Spring 2015 Nitesh Saxena

Operation Tables (IP, IP-1, E and P)

04/21/23Lecture 2.2 - Private Key

Cryptography II12

Page 13: Lecture 2: Private Key Cryptography II CS 436/636/736 Spring 2015 Nitesh Saxena

S-boxes: S1 (as an example)0000

0001

0010

0011

0100

0101

0110

0111

1000

1001

1010

1011

1100

1101

1110

1111

00

01

10

11

04/21/23Lecture 2.2 - Private Key

Cryptography II13

14 4 13 1 2 15 11 8 3 10 6 12 5 9 0 70 15 7 4 14 2 13 1 10 6 12 11 9 5 3 84 1 14 8 13 6 2 11 15 12 9 7 3 10 5 015 12 8 2 4 9 1 7 5 11 3 14 10 0 6 13

Sj

)( 654321 bbbbbbS6543

21

:

:

bbbbcolumn

bbrow

Is the table entry from

01106)011001( dS

Page 14: Lecture 2: Private Key Cryptography II CS 436/636/736 Spring 2015 Nitesh Saxena

DES Decryption

• Same as the encryption algorithm with the “reversed” key schedule – NEXT!

04/21/23Lecture 2.2 - Private Key

Cryptography II14

Page 15: Lecture 2: Private Key Cryptography II CS 436/636/736 Spring 2015 Nitesh Saxena

x Plain text

0R0LInitial permutation (IP)

0R ),( 100 KRFL Round-1 (key K1)

),( 161515 KRFL 15R

Round-16 (key K16)

),( 161515 KRFL 15R

swap

yIP inverse

Cipher text

15R15L

Rounds 2-15

04/21/23 15Lecture 2.2 - Private Key

Cryptography II

Page 16: Lecture 2: Private Key Cryptography II CS 436/636/736 Spring 2015 Nitesh Saxena

),( 161515 KRFL 15R

yIP inverse

Cipher text

IP),( 161515 KRFL 15R

Round-1 (K16)

),(),( 1615161515 KRFKRFL 15R

15L15R

=

Since 0bbbb 0

en

cry

pt

decry

pt

04/21/23Lecture 2.2 - Private Key

Cryptography II16

Page 17: Lecture 2: Private Key Cryptography II CS 436/636/736 Spring 2015 Nitesh Saxena

DES Example

04/21/23Lecture 2.2 - Private Key

Cryptography II17

We choose a random plaintext block and a random key, and We choose a random plaintext block and a random key, and determine what the ciphertext block would be (all in determine what the ciphertext block would be (all in hexadecimal):hexadecimal):

Page 18: Lecture 2: Private Key Cryptography II CS 436/636/736 Spring 2015 Nitesh Saxena

Example (contd) -- encryption

04/21/23Lecture 2.2 - Private Key

Cryptography II18

Page 19: Lecture 2: Private Key Cryptography II CS 436/636/736 Spring 2015 Nitesh Saxena

Example (contd) -- decryption

04/21/23Lecture 2.2 - Private Key

Cryptography II19

Let us see how Bob, at the destination, can decipher the Let us see how Bob, at the destination, can decipher the ciphertext received from Alice using the same key. Table 6.16 ciphertext received from Alice using the same key. Table 6.16 shows some interesting points. shows some interesting points.

Page 20: Lecture 2: Private Key Cryptography II CS 436/636/736 Spring 2015 Nitesh Saxena

DES Security: Avalanche Effect

04/21/23Lecture 2.2 - Private Key

Cryptography II20

Page 21: Lecture 2: Private Key Cryptography II CS 436/636/736 Spring 2015 Nitesh Saxena

Further Reading

• Chapter 7.4 of HAC • Chapter 3 of Stallings

04/21/23Lecture 2.2 - Private Key

Cryptography II21

Page 22: Lecture 2: Private Key Cryptography II CS 436/636/736 Spring 2015 Nitesh Saxena

DES Security

• S-Box design not well understood • Has survived some recent sophisticated

attacks (differential cryptanalysis)• Key is too short. Hence is vulnerable to brute

force attack.• 1998 distributed attack took 3 months.• $1,000,000 machine will crack DES in 35

minutes – 1997 estimate. $10,000 – 2.5 days.

04/21/23Lecture 2.2 - Private Key

Cryptography II22

Page 23: Lecture 2: Private Key Cryptography II CS 436/636/736 Spring 2015 Nitesh Saxena

DES Cracking machine

04/21/23Lecture 2.2 - Private Key

Cryptography II23

Page 24: Lecture 2: Private Key Cryptography II CS 436/636/736 Spring 2015 Nitesh Saxena

Super-encryption.

• If key length is a concern, then instead of encrypting once, encrypt twice!!

C = EK2(EK1(P))

P = DK1(DK2(C))

• Does this result in a larger key space?• Encrypting with multiple keys is known as

super-encryption. • May not always be a good idea04/21/23

Lecture 2.2 - Private Key Cryptography II

24

Page 25: Lecture 2: Private Key Cryptography II CS 436/636/736 Spring 2015 Nitesh Saxena

Double DES

• Double DES is almost as easy to break as single DES (Needs more memory though)!

04/21/23Lecture 2.2 - Private Key

Cryptography II25

Page 26: Lecture 2: Private Key Cryptography II CS 436/636/736 Spring 2015 Nitesh Saxena

Double DES – Meet-in-the-middle Attack (due to Diffie-Hellman)

• Based on the observation that, if C = EK2(EK1(P))

ThenX = EK1(P) = DK2(C).

• Given a known (P, C) pair, encrypt P with all possible values of K and store result in table T.

• Next, decrypt C with all possible keys K and check result. If match occurs then check key pair with new known (P, C) pair. If match occurs, you have found the keys. Else continue as before.

• Process will terminate successfully.

04/21/23Lecture 2.2 - Private Key

Cryptography II26

Page 27: Lecture 2: Private Key Cryptography II CS 436/636/736 Spring 2015 Nitesh Saxena

Meet-in-the-middle Explanation

• The first match does not say anything as we have 264 ciphertexts and 2112 keys.

• On the average 2112 / 264 = 248 keys will produce same ciphertext.

• So there could be 248 possible candidates• We can use a second pair (P’,C’)• So, probability that false alarm will survive

two known (P, C) pairs is 248 / 264 = 2-16.• One can always check a third pair to further

reduce the chance of a false alarm.

04/21/23Lecture 2.2 - Private Key

Cryptography II27

Page 28: Lecture 2: Private Key Cryptography II CS 436/636/736 Spring 2015 Nitesh Saxena

Triple DES

28

Triple DES (2 keys) requires 2112 search. Is reasonably secure.

Triple DES (3 keys) requires 2112 as well Which one is better?

04/21/23Lecture 2.2 - Private Key

Cryptography II

Page 29: Lecture 2: Private Key Cryptography II CS 436/636/736 Spring 2015 Nitesh Saxena

Lecture 2.2 - Private Key Cryptography II

Block Cipher Encryption modes

• Electronic Code Book (ECB)• Cipher Block Chain (CBC)– Most popular one

• Cipher Feed Back (CFB)• Output Feed Back (OFB)

04/21/23 29

Page 30: Lecture 2: Private Key Cryptography II CS 436/636/736 Spring 2015 Nitesh Saxena

Lecture 2.2 - Private Key Cryptography II

Analysis

We will analyze each of the modes in terms of:•Security•Computational Efficiency (parallelizing encryption/decryption)•Transmission Errors•Integrity Protection

04/21/23 30

Page 31: Lecture 2: Private Key Cryptography II CS 436/636/736 Spring 2015 Nitesh Saxena

Lecture 2.2 - Private Key Cryptography II

Electronic Code Book (ECB) Mode• Although DES encrypts 64 bits (a block) at a time, it can

encrypt a long message (file) in Electronic Code Book (ECB) mode.

• Deterministic -- If same key is used then identical plaintext blocks map to identical ciphertext

04/21/23 31

Page 32: Lecture 2: Private Key Cryptography II CS 436/636/736 Spring 2015 Nitesh Saxena

Example – why ECB is bad?

04/21/23Lecture 2.2 - Private Key

Cryptography II32

Tux Tux encrypted with AES in ECB mode

Page 33: Lecture 2: Private Key Cryptography II CS 436/636/736 Spring 2015 Nitesh Saxena

Lecture 2.2 - Private Key Cryptography II

Cipher Block Chain (CBC) Mode

04/21/23 33

encryption

decryption

Page 34: Lecture 2: Private Key Cryptography II CS 436/636/736 Spring 2015 Nitesh Saxena

Lecture 2.2 - Private Key Cryptography II

CBC Traits

• Randomized encryption • IV – Initialization vector serves as the

randomness for first block computation; the ciphertext of the previous block serves as the randomness for the current block computation

• IV is a random value• IV is no secret; it is sent along with the

ciphertext blocks (it is part of the ciphertext)04/21/23 34

Page 35: Lecture 2: Private Key Cryptography II CS 436/636/736 Spring 2015 Nitesh Saxena

Example – why CBC is good?

04/21/23Lecture 2.2 - Private Key

Cryptography II35

Tux Tux encrypted with AES in CBC mode

Page 36: Lecture 2: Private Key Cryptography II CS 436/636/736 Spring 2015 Nitesh Saxena

Lecture 2.2 - Private Key Cryptography II

CBC – More Properties• What happens if k-th cipher block CK gets

corrupted in transmission.– With ECB – Only decrypted PK is affected.– With CBC?

• Only blocks PK and PK+1 are affected!!

• What if one plaintext block PK is changed?– With ECB only CK affected.– With CBC all subsequent ciphertext blocks will be

affected.• “Avalanche effect”

– This leads to an effective integrity protection mechanism (or message authentication code (MAC))

04/21/23 36

Page 37: Lecture 2: Private Key Cryptography II CS 436/636/736 Spring 2015 Nitesh Saxena

Cipher Feedback Mode (CFB)

04/21/23 37

Page 38: Lecture 2: Private Key Cryptography II CS 436/636/736 Spring 2015 Nitesh Saxena

Lecture 2.2 - Private Key Cryptography II

CFB Properties

• Randomized encryption – good for security (Tux won’t be visible after encryption!)

• Change in one plaintext bit is going to affect all subsequent ciphertext bits. So can be used for MAC.

• Change in ciphertext bit results in?

04/21/23 38

Page 39: Lecture 2: Private Key Cryptography II CS 436/636/736 Spring 2015 Nitesh Saxena

Output Feedback Mode (OFB)

04/21/23 39Lecture 2.2 - Private Key

Cryptography II

Page 40: Lecture 2: Private Key Cryptography II CS 436/636/736 Spring 2015 Nitesh Saxena

Lecture 2.2 - Private Key Cryptography II

OFB Properties

• Randomized encryption – good for security (Tux won’t be visible after encryption!)

• Bit errors in transmission do not propagate (except for the IV)

• Not good for authentication – no avalanche effect

04/21/23 40

Page 41: Lecture 2: Private Key Cryptography II CS 436/636/736 Spring 2015 Nitesh Saxena

Security of Block Cipher Modes• ECB is not even secure against eavesdroppers

(ciphertext only and known plaintext attacks)• CBC, CFB and OFB are secure against CPA attacks

(assuming 3-DES or AES is used in each block computation); automatically secure against eavesdropping attacks

• However, none is secure against CCA. Why?• Intuitively, this is because the ciphertext can be

“massaged” in a meaningful way -- see whiteboard (please take notes)

4104/21/23Lecture 2.2 - Private Key

Cryptography II

Page 42: Lecture 2: Private Key Cryptography II CS 436/636/736 Spring 2015 Nitesh Saxena

Summary of CCA Attacks• Assume adversary has eavesdropped upon a ciphertext

– (C0, C1, C2) -- corresponding to a plaintext (M1, M2). C0 is IV.

• Adversary is not allowed to query for (C0, C1, C2) itself • With CBC, adversary queries for (C0’, C1, C2) and

obtains (M1’, M2)• With CFB, he queries for (C0, C1, C2’) and obtains (M1,

M2’)• With OFB, he queries for (C0, C1’,C2)/(C0,C1, C2’)/(C0,

C1’,C2’) and obtains (M1’,M2)/(M1,M2’)/(M1’,M2’), respectively

4204/21/23Lecture 2.2 - Private Key

Cryptography II

Page 43: Lecture 2: Private Key Cryptography II CS 436/636/736 Spring 2015 Nitesh Saxena

How to achieve CCA security?• Prevent any massaging of the ciphertext• Intuitively, this can be achieved by using

integrity protection mechanisms (such as MACs), which we will study later

• The ciphertext is generated using CBC/CFB/OFB and a MAC is generated on this ciphertext

• Both ciphertext and the MAC is sent off• The other party decrypts only if MAC is valid04/21/23

Lecture 2.2 - Private Key Cryptography II

43

Page 44: Lecture 2: Private Key Cryptography II CS 436/636/736 Spring 2015 Nitesh Saxena

Advanced Encryption Standard (AES)

• National Institute of Science and Technology– DES is an aging standard that no longer addresses today’s needs for

strong encryption– Triple-DES: Endorsed by NIST as today’s defacto standard

• AES: The Advanced Encryption Standard– Finalized in 2001– Goal – To define Federal Information Processing Standard (FIPS) by

selecting a new powerful encryption algorithm suitable for encrypting government documents

– AES candidate algorithms were required to be:• Symmetric-key, supporting 128, 192, and 256 bit keys• Royalty-Free• Unclassified (i.e. public domain)• Available for worldwide export

Lecture 2.2 - Private Key Cryptography II

04/21/23 44

Page 45: Lecture 2: Private Key Cryptography II CS 436/636/736 Spring 2015 Nitesh Saxena

AES

• AES Round-3 Finalist Algorithms:– MARS

• Candidate offering from IBM– RC6

• Developed by Ron Rivest of RSA Labs, creator of the widely used RC4 algorithm

– Twofish• From Counterpane Internet Security, Inc.

– Serpent• Designed by Ross Anderson, Eli Biham and Lars Knudsen

– Rijndael: the winner!• Designed by Joan Daemen and Vincent Rijmen

Lecture 2.2 - Private Key Cryptography II

04/21/23 45

Page 46: Lecture 2: Private Key Cryptography II CS 436/636/736 Spring 2015 Nitesh Saxena

Other Symmetric Ciphers and their applications

• IDEA (used in PGP)• Blowfish (password hashing in OpenBSD)• RC4 (used in WEP), RC5• SAFER (used in Bluetooth)

Lecture 2.2 - Private Key Cryptography II

04/21/23 46

Page 47: Lecture 2: Private Key Cryptography II CS 436/636/736 Spring 2015 Nitesh Saxena

Some Questions• Double encryption in DES increases the key space

size from 2^56 to 2^112 – true or false?• Is known-plaintext an active or a passive attack?• Is chosen-ciphertext attack an active or a passive

attack?• Reverse Engineering is applied to what design of

systems – open or closed?• Alice needs to send a 64-bit long top-secret letter to

Bob. Which of the ciphers that we studied today should she use?

04/21/23Lecture 2.2 - Private Key

Cryptography II47

Page 48: Lecture 2: Private Key Cryptography II CS 436/636/736 Spring 2015 Nitesh Saxena

Some Questions• C=DES(K,P); where (P, C are 64-bit long blocks). What would

be DES(K,”PPPP”) in ECB mode? What it would be in CBC mode?

• ECB is secure for sending just one block of data: true or false?• Is it okay to re-use IV in CBC? Why/why not?• Alice needs to send a *long* top-secret message to Bob.

Which of the ciphers that we studied today can she use?• Is ECB secure against CPA?• Is CBC secure against CPA?• Is CBC secure against CCA?• Is OFB secure against CCA?

Lecture 2.2 - Private Key Cryptography II

04/21/23 48

Page 49: Lecture 2: Private Key Cryptography II CS 436/636/736 Spring 2015 Nitesh Saxena

AES: Rinjdael

At home reading assignment!

Lecture 2.2 - Private Key Cryptography II

04/21/23 49

Page 50: Lecture 2: Private Key Cryptography II CS 436/636/736 Spring 2015 Nitesh Saxena

Rijndael

• Joan Daemen (of Proton World International) and Vincent Rijmen (of Katholieke Universiteit Leuven).

• (pronounced “Rhine-doll”)• Allows only 128, 192, and 256-bit key sizes (unlike the other

candidates)• Variable block length of 128, 192, or 256 bits. All nine

combinations of key/block length possible.• A block is the smallest data size the algorithm will encrypt• Vast speed improvement over DES in both hardware and

software implementations– 8416 bytes/sec on a 20MHz 8051 (@ 12 CPI)– 8.8 Mbytes/sec on a 200MHz Pentium Pro

Lecture 2.2 - Private Key Cryptography II

04/21/23 50

Page 51: Lecture 2: Private Key Cryptography II CS 436/636/736 Spring 2015 Nitesh Saxena

Rijndael Structure• Rijndael consists of

– an initial Round Key addition;– Nr-1 Rounds;– a final round.

• In pseudo C code, this gives:

Rijndael(State,CipherKey) {

KeyExpansion(CipherKey,ExpandedKey) ; AddRoundKey(State,ExpandedKey); For( i=1 ; i<Nr ; i++ ) Round(State,ExpandedKey + Nb*i) ; FinalRound(State,ExpandedKey + Nb*Nr);

}

Lecture 2.2 - Private Key Cryptography II

04/21/23 51

Page 52: Lecture 2: Private Key Cryptography II CS 436/636/736 Spring 2015 Nitesh Saxena

Rijndael

Lecture 2.2 - Private Key Cryptography II

X R1

Key

R2 Rn-1 RnR3 YRn-2

K1 K2 Kn-1 KnK3 Kn-2

W KE Key Expansion

RoundKeys

Encryption Rounds r1 … rn

Key is expanded to a set of n round keysKey is expanded to a set of n round keys Input block X undergoes n rounds of operations (each Input block X undergoes n rounds of operations (each

operation is based on value of the nth round key), until it operation is based on value of the nth round key), until it reaches a final round.reaches a final round.

Strength relies on the fact that it’s difficult to obtain the Strength relies on the fact that it’s difficult to obtain the intermediate result (or intermediate result (or statestate) of round n from round n+1 ) of round n from round n+1 without the round key.without the round key.

04/21/23 52

Page 53: Lecture 2: Private Key Cryptography II CS 436/636/736 Spring 2015 Nitesh Saxena

Number of Rounds• Number of rounds (Nr) as a function of the block

(Nb) and key length (Nk) in 32 bit words.

Nr Nb = 4

Nb = 6

Nb = 8

Nk = 4

10 12 14

Nk = 6

12 12 14

Nk = 8

14 14 14

Lecture 2.2 - Private Key Cryptography II

04/21/23 53

Page 54: Lecture 2: Private Key Cryptography II CS 436/636/736 Spring 2015 Nitesh Saxena

Rijndael

Lecture 2.2 - Private Key Cryptography II

Detailed view of round i

Each round performs the following operations:Each round performs the following operations: Non-linear Layer: No linear relationship between the input Non-linear Layer: No linear relationship between the input

and output of a roundand output of a round Linear Mixing Layer: Guarantees high diffusion over Linear Mixing Layer: Guarantees high diffusion over

multiple roundsmultiple rounds Very small correlation between bytes of the round input Very small correlation between bytes of the round input

and the bytes of the outputand the bytes of the output Key Addition Layer: Bytes of theKey Addition Layer: Bytes of the input are simply XOR’ed input are simply XOR’ed

with the expanded round keywith the expanded round key

ByteSub ShiftRow MixColumn AddRoundKey

Ki

Result from round i-1

Pass toround i+1

04/21/23 5404/21/23

Page 55: Lecture 2: Private Key Cryptography II CS 436/636/736 Spring 2015 Nitesh Saxena

Rijndael

• Three layers provide strength against known types of cryptographic attacks: Rijndael provides “full diffusion” after only two rounds– Linear and differential cryptanalysis– Known-key and related-key attacks– Square attack– Interpolation attacks– Weak-keys

• Rijndael has been shown to be K-secure:– No key-recovery attacks faster than exhaustive search exist– No known symmetry properties in the round mapping– No weak keys– No related-key attacks: No two keys have a high number of expanded

round keys in commonLecture 2.2 - Private Key

Cryptography II04/21/23 55

Page 56: Lecture 2: Private Key Cryptography II CS 436/636/736 Spring 2015 Nitesh Saxena

Rijndael: ByteSub

Lecture 2.2 - Private Key Cryptography II

• Each byte at the input of a round undergoes a non-linear byte substitution according to the following: 1. First, taking the multiplicative inverse in GF(28). ‘00’ is mapped onto itself. 2. Then, applying an affine (over GF(2)) transformation.

Substitution (“S”)-box Affine Transform04/21/23 56

Page 57: Lecture 2: Private Key Cryptography II CS 436/636/736 Spring 2015 Nitesh Saxena

Rijndael: ShiftRow

Lecture 2.2 - Private Key Cryptography II

Depending on the block length, each “row” of the block is cyclically shifted according to the above table

04/21/23 57

Page 58: Lecture 2: Private Key Cryptography II CS 436/636/736 Spring 2015 Nitesh Saxena

Rijndael: MixColumn

Lecture 2.2 - Private Key Cryptography II

Each column is multiplied by a fixed polynomialC(x) = ’03’*X3 + ’01’*X2 + ’01’*X + ’02’

This corresponds to matrix multiplication b(x) = c(x) a(x):

04/21/23 58

Page 59: Lecture 2: Private Key Cryptography II CS 436/636/736 Spring 2015 Nitesh Saxena

Rijndael: Key Expansion and Addition

Lecture 2.2 - Private Key Cryptography II

Each word is simply XOR’ed with the expanded round key

KeyExpansion(int* Key[4*Nk], int* EKey[Nb*(Nr+1)]){ for(i = 0; i < Nk; i++) EKey[i] = (Key[4*i],Key[4*i+1],Key[4*i+2],Key[4*i+3]); for(i = Nk; i < Nb * (Nr + 1); i++) { temp = EKey[i - 1]; if (i % Nk == 0) temp = SubByte(RotByte(temp)) ^ Rcon[i / Nk]; EKey[i] = EKey[i - Nk] ^ temp; }}

Key Expansion algorithm:

04/21/23 59

Page 60: Lecture 2: Private Key Cryptography II CS 436/636/736 Spring 2015 Nitesh Saxena

Rijndael: Implementations

• Rijndael is well suited for software implementations on 8-bit processors (important for “Smart Cards”)– Operations focus on bytes and nibbles, not 32 or 64 bit integers– Layers such as ByteSub can be efficiently implemented using small tables

in ROM (e.g. < 256 bytes). – No special instructions are required to speed up operation

• For 32-bit implementations:– An entire round can be implemented via a fast table lookup routine on

machines with 32-bit or higher word lengths– Considerable parallelism exists in the algorithm

• Each layer operates in a parallel manner on bytes of the round state, all four component transforms act on individual parts of the block

• Although the Key expansion is complicated and cannot be parallelised, it only needs to be performed once until the two parties switch keys.

Lecture 2.2 - Private Key Cryptography II

04/21/23 60

Page 61: Lecture 2: Private Key Cryptography II CS 436/636/736 Spring 2015 Nitesh Saxena

Rijndael: Implementations

• Hardware Implementations– Performs very well in software, but in some cases more performance is

required (e.g. server and VPN applications).– Multiple S-Box engines, round-key EXORs, and byte shifts can all be

implemented efficiently in hardware when absolute speed is required– Small amount of hardware can vastly speed up 8-bit implementations

• Inverse Cipher– Except for the non-linear ByteSub step, each part of Rijndael has a

straightforward inverse and the operations simply need to be undone in the reverse order.

– Same code that encrypts a block can also decrypt the same block simply by changing certain tables and polynomials for each layer. The rest of the operation remains identical.

Lecture 2.2 - Private Key Cryptography II

04/21/23 61

Page 62: Lecture 2: Private Key Cryptography II CS 436/636/736 Spring 2015 Nitesh Saxena

Rijndael Future

• Rijndael is an extremely fast, state-of-the-art, highly secure algorithm

• Has efficient implementations in both hardware and software; it requires no special instructions to obtain good performance on any computing platform

• Despite being the chosen by NIST as the AES candidate winner, Rijndael is not yet automatically the new encryption standard– Triple-DES, still highly secure and supported by NIST, is expected

to be common for the foreseeable future.

Lecture 2.2 - Private Key Cryptography II

04/21/23 62

Page 63: Lecture 2: Private Key Cryptography II CS 436/636/736 Spring 2015 Nitesh Saxena

Further Reading

• Chapter 6 of Stallings – Modes of Operations; Chapter 5 for AES

• Chapter 7 of HAC – Modes of Operation

Lecture 2.2 - Private Key Cryptography II

04/21/23 63