block ciphers - university of...

28
Block Ciphers Ramki Thurimella

Upload: lenhu

Post on 09-May-2018

217 views

Category:

Documents


1 download

TRANSCRIPT

Block Ciphers

Ramki Thurimella

2

What is a block cipher?

� Encryption function for fixed-size blocks of data

� Currently 128 bits = 16 bytes

� Block cipher, unlike a hash function, is reversible

� sizeof(plaintext)=sizeof(ciphertext)—block size

denoted b

� Need a key to encrypt/decrypt. Common key sizes are 128 bits or 256 bits

3

Substitution Cipher

http://en.wikipedia.org/wiki/File:ROT13.png

ROT13 here stands

for left rotation by

13 positions

4

Substitution Cipher (cont.)

Example:

flee at once. we are discovered!

Enciphers to

SIAA ZQ LKBA. VA ZOA RFPBLUAOAR!

� Omit spaces, punctuation, and group into 5 characters, pad if necessary

SIAAZ QLKBA VAZOA RFPBL UAOAR

5

Permutation Cipher

� Divide the plaintext into block size b

� Create a random permutation of size b

� Permute the characters

� Cryptanalysis� How to discover what cipher is being used?

� Would have the exact same frequencies as plaintext

� Weaknesses� Key length = block length

� If |plaintext| is not a multiple of b, how is the last block encrypted?

� Make incremental progress (“chip away”) by trying different permutations and those that produce most digrams and trigrams

6

Modern Block Ciphers

� One of the most widely used types of cryptography algorithms

� Provide strong secrecy and/or authentication services

� Will study DES (Data Encryption Standard) in detail

7

Block vs Stream Ciphers

� Block ciphers process messages into blocks, each of which is then en/decrypted

� Like a substitution on very big characters

� 64-bits or more

� Stream ciphers process messages a bit or byte at a time when en/decrypting

� Block ciphers are more common currently

8

Block Cipher Principles

� Block ciphers look like an extremely large substitution ciphers

� Conceptually useful to imagine it as a table of 264 entries for a 64-bit block

� Most symmetric block ciphers are based on a Feistel Cipher Structure

9

Substitution-Permutation Ciphers

� in 1949 Shannon introduced idea of substitution-permutation (S-P) networks

� These form the basis of modern block ciphers

� S-P networks are based on the two primitive cryptographic operations we have seen before: � substitution (S-box)

� permutation (P-box)

� Provide confusion and diffusion respectively

10

Diffusion and Confusion

� Without diffusion, provided by P-Box, a small change in plaintext corresponds to an equal size change in ciphertext

� Without confusion, provided by S-Box, key is not sufficiently mixed with plaintext

� Key cannot be derived with good confusion:� Even if one has a large number of plaintext-ciphertext

(chosen-plaintext attack) pairs produced with the same key

� I.e. each bit of the ciphertext should depend on the entire key, and in different ways on different bits of the key

� In particular, changing one bit of the key should change the ciphertext completely

11

Avalanche Effect

� Desirable property of encryption algorithm

� DES exhibits strong avalanche

� where a change of one input or key bit results in changing approximately half output bits

12

Feistel Cipher Structure

� Horst Feistel devised the feistel cipher

� That implements Shannon’s substitution-permutation network

� Partitions input block into two halves

� Iterated multiple rounds

� Performs a substitution on left data half

� Uses a round function of right half & subkey

� Permutation swaps two halves

13

DES

http://dmst.aueb.gr/dds/secimp/crypto/indexw.htm

14

Feistel Cipher Structure

http://www.computer.org/cms/Computer.org/dl/trans/tc/2003/04/figures/t04734.gif

15

Feistel Cipher Design Principles

� block size

� increasing size improves security, but slows cipher

� key size

� increasing size improves security, makes exhaustive key searching harder, but slows cipher

� number of rounds

� increasing number improves security, but slows cipher

� subkey generation

� greater complexity can make analysis harder, but slows cipher

� round function

� greater complexity can make analysis harder, but slows cipher

� fast software en/decryption & ease of analysis

16

Data Encryption Standard (DES)

� Most widely used block cipher in world

� Adopted in 1977 by NBS (now NIST)� as FIPS PUB 46

� Encrypts 64-bit data using 56-bit key

� Popular in financial applications

� Considerable controversy over design � Choice of 56-bit key (vs Lucifer 128-bit)

� Public scrutiny showed that design was appropriate

17

DES History

� IBM developed Lucifer cipher� by team led by Feistel

� used 64-bit data blocks with 128-bit key

� Redeveloped as a commercial cipher with input from NSA and others

� In 1973 NBS issued request for proposals for a national cipher standard

� IBM submitted their revised Lucifer which was eventually accepted as the DES

18

DES Encryption

19

Initial Permutation IP

� First step of the data computation

� IP reorders the input data bits

� Regular in structure

� Example:IP(675a6967 5e5a6b5a) = (ffb2194d 004df6fb)

20

DES Round Structure

� Uses two 32-bit L & R halves

� Feistel cipher mathematically is:

Li = Ri–1

Ri = Li–1 xor F(Ri–1, Ki)

� Takes 32-bit R half and 48-bit subkey and:

� Expands R to 48-bits using Expansion Permutation E

� Adds to subkey

� Passes through 8 S-boxes to get 32-bit result

� Permutes this using 32-bit Permutation Function P

21

The Round Function F(R,K)

22

Substitution Boxes S

� 8 S-boxes

� Each S-Box mapps 6 to 4 bits

� outer bits 1 & 6 (row bits) select the row

� inner bits 2-5 (col bits) select the column

� For example, in S1, for input 011001,

� the row is 01 (row 1)

� the column is 1100 (column 12).

� The value in row 1, column 12 is 9

� The output is 1001.

� Result is 8 X 4 bits, or 32 bits

23

DES Decryption

� Decrypt must unwind steps of data computation

� For Feistel design, do encryption steps again

� Use subkeys in reverse order (SK16 … SK1)

� IP undoes FP step of encryption

� 1st round with SK16 undoes 16th encrypt round

� 16th round with SK1 undoes 1st encrypt round

� Final FP undoes initial encryption IP

24

Strength of DES – Key Size

� 56-bit keys have 256 = 7.2 x 1016 values

� Recent advances have shown that brute force is possible

� in 1997 on Internet in a few months

� in 1998 on dedicated hardware (EFF) in a few days

� in 1999 above combined in 22hrs!

25

Strength of DES – Timing Attacks

� Attacks actual implementation of cipher

� use knowledge of implementation to derive some/all subkey bits

� Use fact that calculations can take varying times depending on the value of the inputs

26

AES structure

http://www.infoq.com/articles/encrypt-internet-intel

27

Twofish

http://en.wikipedia.org/wiki/File:Twofishalgo.svg

28

Strength of DES – Analytic Attacks

� Now there are several analytic attacks on DES

� some utilize deep structure of the cipher � by gathering information about encryptions

� can eventually recover some/all of the sub-key bits

� if necessary then exhaustively search for the rest

� some statistical attacks

� include� differential cryptanalysis

� linear cryptanalysis

� related key attacks