Block cipher, etc.

46 downloads 159 Views 96KB Size Report
bit l i t ti t dt bit. • An n-bit plaintext is encrypted to an n-bit ciphertext. P {0 1}. – P : { 0,1}n. – C : {0,1}n. – K : {0,1}s. – E: K ×P → C : E k. : a permutation on {0,1} n.
Computer Security CS 426 Lecture 4

Cryptography: Block Ciphers and Encryption Modes CS426

Fall 2010/Lecture 4

1

Why y Block Ciphers? p • One O thread th d off defeating d f ti frequency f analysis l i – Use different keys in different locations – Example: one-time pad, stream ciphers

• Another way to defeat frequency analysis – Make the unit of transformation larger, g , rather than encrypting letter by letter, encrypting block by block – Example: block cipher

CS426

Fall 2010/Lecture 4

2

Block Ciphers p • A An n-bit bit plaintext l i t t iis encrypted t d tto an n-bit bit ciphertext – – – – – – –

CS426

P : {0 {0,1} 1}n C : {0,1}n K : {0,1}s E: K ×P  C : Ek: a permutation on {0,1} n D: K ×C  P : Dk is Ek-1 Block size: n Key size: s

Fall 2010/Lecture 4

3

Ideal block cipher p • An ideal block cipher is a substitution cipher from {0 1}n to {0,1} t {0,1} {0 1}n i.e., i a Random R d P Permutation t ti (RP) • Total number of keys: 2n! – insecure when n is small – impractical when n is large (264!  22^71) • How much space is needed to represent the key?

• Solution: PseudoRandom Permutation (PRP) ( ) – Use a subset of the 2n! possible permutations

• A PRP cannot be distinguished from RP by any computationally bounded adversary Block ciphers aim at providing a PRP. CS426

Fall 2010/Lecture 4

4

Data Encryption yp Standard ((DES)) • Designed by IBM IBM, with modifications proposed by the National Security Agency • US national standard from 1977 to 2001 • De facto standard • Block size 64 bits; • Keyy size 56 bits • 16-rounds • Designed mostly for hardware implementations • Considered insecure now – vulnerable to brute-force attacks CS426

Fall 2010/Lecture 4

5

Attackingg Block Ciphers p • Types of attacks to consider – known plaintext: given several pairs of plaintexts and ciphertexts, recover the key (or decrypt another block encrypted under the same key) – how would chosen plaintext and chosen ciphertext work?

• Standard attacks – exhaustive keyy search – dictionary attack – differential cryptanalysis, linear cryptanalysis

• Side channel attacks. DES’ main DES’s i vulnerability l bilit is i short h t key k size. i CS426

Fall 2010/Lecture 4

6

Advanced Encryption yp Standard • In 1997 1997, NIST made a formal call for algorithms stipulating that the AES would specify an unclassified, publicly disclosed encryption algorithm, available royalty-free, worldwide. • Goal: replace DES for both government and private-sector encryption. encryption • The algorithm must implement symmetric key cryptography as a block cipher p and ((at a minimum)) support pp block sizes of 128-bits and key sizes of 128-, 192-, and 256-bits. • In 1998, NIST selected 15 AES candidate algorithms. • On October 2, 2000, NIST selected Rijndael (invented by Joan Daemen and Vincent Rijmen) to as the AES. CS426

Fall 2010/Lecture 4

7

AES Features • Designed to be efficient in both hardware and d software f across a variety i off platforms. l f • Not a Feistel Network • Block Bl k size: i 128 bit bits • Variable key size: 128, 192, or 256 bits. • Variable number of rounds (10 (10, 12 12, 14): – 10 if K = 128 bits – 12 if K = 192 bits – 14 if K = 256 bits

• No known weaknesses

CS426

Fall 2010/Lecture 4

8

Need for Encryption yp Modes • A block bl k cipher i h encrypts t only l one bl block k • Needs a way to extend it to encrypt an arbitrarily long message p is secure, • Want to ensure that if the block cipher then the encryption is secure • Aim at providing Semantic Security (Ciphertext indistinguishability) – ii.e., e if an adversary chooses two messages M0 and M1, and is given EK[Mb], where b is randomly chosen from {0,1}, the adversary has little advantage in guessing b CS426

Fall 2010/Lecture 4

9

Block Cipher p Encryption yp Modes: ECB • Message is broken into independent block; • Electronic Code Book (ECB): each block encrypted separately. • Encryption: ci = Ek(xi) • Decrytion: xi = Dk(ci)

CS426

Fall 2010/Lecture 4

10

Properties p of ECB • Deterministic: – the same data block gets encrypted the same way, • reveals patterns of data when a data block repeats

– when the same key is used, the same message is encrypted yp the same way y

• Usage: not recommended to encrypt more than one block of data • H How tto break b k th the S Semantic ti security it (Ci (Ciphertext h t t indistinguishability) of a block cipher with ECB? CS426

Fall 2010/Lecture 4

11

DES Encryption yp Modes: CBC • Cipher Ci h Block Bl k Chaining Ch i i (CBC): (CBC) – Uses a random Initial Vector (IV) – Next N t iinputt d depends d upon previous i output t t Encryption: Ci= Ek (MiCi-1), with C0=IV Decryption: Mi= Ci-1Dk(Ci), ) with C0=IV

IV

C0 CS426

M1

M2

M3







Ek

Ek

Ek

C1

C2

C3

Fall 2010/Lecture 4

12

Properties p of CBC • Randomized encryption: repeated text gets mapped to different encrypted data. – can be proven to provide semantic security assuming that the block cipher is PRP and that random IV’s are used d

• A ciphertext block depends on all preceding plaintext l i t t blocks; bl k reorder d affects ff t decryption d ti • Usage: chooses random IV and protects the integrity of IV

CS426

Fall 2010/Lecture 4

13

Encryption c yp o Modes:CTR odes:C • C Counter t M Mode d (CTR) (CTR): A way to t construct t t PRNG using a block cipher – Uses a random counter

– yi = Ek[counter+i] – Sender and receiver share: counter (does not need to be secret) and the secret key.

CS426

Fall 2010/Lecture 4

14

Properties p of CTR • Gives a stream cipher from a block cipher – subject bj t to t limitations li it ti off stream t ciphers i h ( h t are (what they?)

• Randomized encryption: – when starting counter is chosen randomly

• R Random d A Access: d decryption ti off a bl block k can b be done in random order, very useful for harddisk encryption encryption.

CS426

Fall 2010/Lecture 4

15

Readings g for This Lecture • Required reading from wikipedia • Block Cipher • Data Encryption Standard • Advanced Encryption Standard • Block cipher p modes of operation

CS426

Fall 2010/Lecture 4

16

Coming g Attractions … • C Cryptography: t h Cryptographic C t hi H Hash h Functions and Message A th ti ti Authentication

CS426

Fall 2010/Lecture 4

17