Symmetric key cryptography

Similar documents
1 Data Encryption Algorithm

Lecture 4 Data Encryption Standard (DES)

Network Security. Chapter 3 Symmetric Cryptography. Symmetric Encryption. Modes of Encryption. Symmetric Block Ciphers - Modes of Encryption ECB (1)

Cryptography and Network Security Block Cipher

Cryptography and Network Security Prof. D. Mukhopadhyay Department of Computer Science and Engineering Indian Institute of Technology, Kharagpur

How To Attack A Block Cipher With A Key Key (Dk) And A Key (K) On A 2Dns) On An Ipa (Ipa) On The Ipa 2Ds (Ipb) On Pcode)

Cryptography and Network Security

The Advanced Encryption Standard (AES)

Overview of Cryptographic Tools for Data Security. Murat Kantarcioglu


CSCE 465 Computer & Network Security

How To Encrypt With A 64 Bit Block Cipher

Cryptography and Network Security. Prof. D. Mukhopadhyay. Department of Computer Science and Engineering. Indian Institute of Technology, Kharagpur

EXAM questions for the course TTM Information Security May Part 1

Network Security - ISA 656 Introduction to Cryptography

Advanced Encryption Standard by Example. 1.0 Preface. 2.0 Terminology. Written By: Adam Berent V.1.7

Cryptography and Network Security Chapter 3

Advanced Encryption Standard by Example. 1.0 Preface. 2.0 Terminology. Written By: Adam Berent V.1.5

Table of Contents. Bibliografische Informationen digitalisiert durch

Network Security. Abusayeed Saifullah. CS 5600 Computer Networks. These slides are adapted from Kurose and Ross 8-1

lundi 1 octobre 2012 In a set of N elements, by picking at random N elements, we have with high probability a collision two elements are equal

Dr. Jinyuan (Stella) Sun Dept. of Electrical Engineering and Computer Science University of Tennessee Fall 2010

Modes of Operation of Block Ciphers

A Secure Software Implementation of Nonlinear Advanced Encryption Standard

CS 758: Cryptography / Network Security

The Advanced Encryption Standard: Four Years On

Cryptography: Motivation. Data Structures and Algorithms Cryptography. Secret Writing Methods. Many areas have sensitive information, e.g.

Network Security: Secret Key Cryptography

Cryptography and Network Security Prof. D. Mukhopadhyay Department of Computer Science and Engineering Indian Institute of Technology, Kharagpur

Overview of Symmetric Encryption

AES Cipher Modes with EFM32

MAC. SKE in Practice. Lecture 5

Part I. Universität Klagenfurt - IWAS Multimedia Kommunikation (VK) M. Euchner; Mai Siemens AG 2001, ICN M NT

SeChat: An AES Encrypted Chat

Error oracle attacks and CBC encryption. Chris Mitchell ISG, RHUL

Chair for Network Architectures and Services Department of Informatics TU München Prof. Carle. Network Security. Chapter 13

Block encryption. CS-4920: Lecture 7 Secret key cryptography. Determining the plaintext ciphertext mapping. CS4920-Lecture 7 4/1/2015

Network Security. Modes of Operation. Steven M. Bellovin February 3,

Implementation of Full -Parallelism AES Encryption and Decryption

Secret File Sharing Techniques using AES algorithm. C. Navya Latha Garima Agarwal Anila Kumar GVN

SAMPLE EXAM QUESTIONS MODULE EE5552 NETWORK SECURITY AND ENCRYPTION ECE, SCHOOL OF ENGINEERING AND DESIGN BRUNEL UNIVERSITY UXBRIDGE MIDDLESEX, UK

IT Networks & Security CERT Luncheon Series: Cryptography

CIS 6930 Emerging Topics in Network Security. Topic 2. Network Security Primitives

Talk announcement please consider attending!

Ky Vu DeVry University, Atlanta Georgia College of Arts & Science

Evaluation of the RC4 Algorithm for Data Encryption

F3 Symmetric Encryption

Network Security: Cryptography CS/SS G513 S.K. Sahay

CS155. Cryptography Overview

Outline. Transport Layer Security (TLS) Security Protocols (bmevihim132)

Network Security Technology Network Management

CRC Press has granted the following specific permissions for the electronic version of this book:

Introduction. Where Is The Threat? Encryption Methods for Protecting Data. BOSaNOVA, Inc. Phone: Web:

WINTER SCHOOL ON COMPUTER SECURITY. Prof. Eli Biham

AN IMPLEMENTATION OF HYBRID ENCRYPTION-DECRYPTION (RSA WITH AES AND SHA256) FOR USE IN DATA EXCHANGE BETWEEN CLIENT APPLICATIONS AND WEB SERVICES

Authentication requirement Authentication function MAC Hash function Security of

CIS433/533 - Computer and Network Security Cryptography

The Advanced Encryption Standard (AES)

CLOUD COMPUTING SECURITY ARCHITECTURE - IMPLEMENTING DES ALGORITHM IN CLOUD FOR DATA SECURITY

Cryptography Lecture 8. Digital signatures, hash functions

IronKey Data Encryption Methods

Network Security. Security Attacks. Normal flow: Interruption: 孫 宏 民 Phone: 國 立 清 華 大 學 資 訊 工 程 系 資 訊 安 全 實 驗 室

Three attacks in SSL protocol and their solutions

Rijndael Encryption implementation on different platforms, with emphasis on performance

Lecture Note 8 ATTACKS ON CRYPTOSYSTEMS I. Sourav Mukhopadhyay

Computer Networks. Network Security 1. Professor Richard Harris School of Engineering and Advanced Technology

Message Authentication Codes

How To Understand And Understand The History Of Cryptography

Security (WEP, WPA\WPA2) 19/05/2009. Giulio Rossetti Unipi

Network Security. Computer Networking Lecture 08. March 19, HKU SPACE Community College. HKU SPACE CC CN Lecture 08 1/23

Cryptographic hash functions and MACs Solved Exercises for Cryptographic Hash Functions and MACs

Chapter 11 Security+ Guide to Network Security Fundamentals, Third Edition Basic Cryptography

Chapter 6 CDMA/802.11i

Developing and Investigation of a New Technique Combining Message Authentication and Encryption

7! Cryptographic Techniques! A Brief Introduction

Common Pitfalls in Cryptography for Software Developers. OWASP AppSec Israel July The OWASP Foundation

(C) Global Journal of Engineering Science and Research Management

Properties of Secure Network Communication

Network Security. Omer Rana

6 Data Encryption Standard (DES)

Keywords Web Service, security, DES, cryptography.

Secure File Multi Transfer Protocol Design

Modern Block Cipher Standards (AES) Debdeep Mukhopadhyay

IJESRT. [Padama, 2(5): May, 2013] ISSN:

CSC474/574 - Information Systems Security: Homework1 Solutions Sketch

Authentication and Encryption: How to order them? Motivation

Cyber Security Workshop Encryption Reference Manual

Symmetric Key cryptosystem

ARCHIVED PUBLICATION

SSL Firewalls

Security. Contents. S Wireless Personal, Local, Metropolitan, and Wide Area Networks 1

Network Security. Security. Security Services. Crytographic algorithms. privacy authenticity Message integrity. Public key (RSA) Message digest (MD5)

A NEW HASH ALGORITHM: Khichidi-1

Cryptography and Network Security Chapter 12

Key Hopping A Security Enhancement Scheme for IEEE WEP Standards

CSE/EE 461 Lecture 23

Pavithra.S, Vaishnavi.M, Vinothini.M, Umadevi.V

Security in Distributed Systems. Network Security

Cryptography and Network Security Department of Computer Science and Engineering Indian Institute of Technology Kharagpur

Enhancing Advanced Encryption Standard S-Box Generation Based on Round Key

Transcription:

The best system is to use a simple, well understood algorithm which relies on the security of a key rather than the algorithm itself. This means if anybody steals a key, you could just roll another and they have to start all over. -- Andrew Carol Symmetric key cryptography - preliminaries (operational and attacker models) - block ciphers (basics, DES, 3DES, AES) - block ciphers in practice (modes of operation) - a security flaw induced by CBC padding - stream ciphers Operational model of encryption x plaintext E E k (x) ciphertext D D k (E k (x)) = x k encryption key attacker k decryption key Ciphers in general attacker s goal: to systematically recover plaintext from ciphertext to deduce the (decryption) key erckhoff s assumption: attacker knows all details of E and D attacker doesn t know the (decryption) key 2

Attack models Ciphers in general ciphertext-only only data transmitted over the ciphertext channel is available to the attacker known-plaintext plaintext-ciphertext pairs are available to the attacker chosen-plaintext ciphertexts are available corresponding to plaintexts of the attacker s choice adaptive: choice of plaintexts may depend on previously obtained plaintextciphertext pairs chosen-ciphertext plaintext-ciphertext pairs are available for some number of ciphertexts of the attacker s choice adaptive: choice of ciphertexts may depend on previously obtained plaintext-ciphertext pairs related-key attack attacker has access to the encryption of plaintexts under both the unknown key and keys known to have certain relationship with the unknown key 3 Asymmetric- vs. symmetric-key encryption asymmetric-key encryption it is hard (computationally infeasible) to compute k from k k can be made public (public-key cryptography) symmetric-key encryption it is easy to compute k from k (and vice versa) often k = k two main types: stream ciphers and block ciphers stream ciphers pseudo-random pseudo-random bit bit stream stream generator generator plaintext...... seed ciphertext Ciphers in general block ciphers plaintext padding block block cipher cipher key ciphertext 4

Feistel and Coppersmith rule: Sixteen rounds and one hell of an avalanche. -- Stephan Eisvogel in de.comp.security Block ciphers: DES, 3DES, and AES - basics - operation of DES - cryptanalysis of DES - multiple encryption and the 3DES - AES Block ciphers an n bit block cipher is a function E: {0, 1} n x {0, 1} k {0, 1} n, such that for each {0, 1} k, E(X, ) = E (X) is an invertible mapping from {0, 1} n to {0, 1} n cannot be efficiently distinguished from a random permutation the inverse of E (X) is denoted by D (Y), where Y = E (X) k bit key n bit input E E n bit output Block cipher basics possible plaintexts permutation defined by possible ciphertexts possible plaintexts permutation defined by possible ciphertexts 6

Trade-offs in block size attacks based on small block size text dictionary attack plaintext-ciphertext pairs become known for a fixed key the larger the dictionary the greater the chance of locating a random ciphertext in it if n is small, then it is feasible to build large dictionaries matching ciphertext attacks if a dictionary of size about 2 n/2 have been created, and about 2 n/2 ciphertexts are subsequently given, then one expects to locate a ciphertext in the dictionary with high probability (birthday paradox) Block cipher basics larger block size is more secure disadvantages of large block size more costly to implement (in terms of gates or low level instructions) 7 Exhaustive key search and key size Block cipher basics given a small number of plaintext-ciphertext pairs encrypted under a key, can be recovered by exhaustive key search with 2 k-1 processing complexity (expected number of operations) input: (X, Y), (X, Y ), progress through the entire key space for each trial key, decrypt Y if the result is not X, then throw away if the result is X, then check the other pairs (X, Y ), if does not work for at least one pair, then throw away if worked for all pairs (X, Y), (X, Y ),, then output as the target key on average, the target key is found after searching half of the key space if the plaintexts are known to contain redundancy, then ciphertext-only exhaustive key search is possible with a relatively small number of ciphertexts 8

How to build a strong block cipher? Block cipher basics complex encryption function can be built by composing several simple operations which offer complementary but individually insufficient protection simple operations: elementary arithmetic operations logical operations (e.g., XOR) modular multiplication transpositions substitutions etc. let s combine two or more transformations in a manner that the resulting cipher is more secure than the individual components 9 Example: SP networks an SP (substitution-permutation) network is a product cipher composed of s each involving key controlled substitutions (nonlinear look-up tables) and permutations X 1 SS SS SS SS P P Block cipher basics SS SS SS SS P Y r 10

DES Data Encryption Standard (32) X Initial Initial Permutation Permutation F F (64) (32) (48) 1 input size: 64 output size: 64 key size: 56 16 rounds Feistel structure F F F F (48) 2 (48) ey Scheduler (56) Block ciphers / DES F F Initial Initial Permutation Permutation -1-1 Y (64) 3 (48) 16 11 DES round function F key injection S1 S1 S2 S2 S3 S3 S4 S4 S5 S5 S6 S6 S7 S7 S8 S8 P P Block ciphers / DES Si substitution box (S-box) P permutation box (P-box) 12

DES key scheduler (56) Permuted Permuted Choice Choice 1 1 (28) Left shift (28) (28) Left shift (28) 1 (48) Permuted Permuted Choice Choice 2 2 Left shift Left shift Block ciphers / DES 2 (48) Permuted Permuted Choice Choice 2 2 each key bit is used in around 14 out of 16 rounds 13 Feistel structure illustrated L 0 R 0 1 L 0 R 0 1 F F F F R 1 2 L 1 2 L 1 R 1 twisted ladder F L 2 R 2 untwisted ladder F L 2 R 2 3 F F Block ciphers / DES r L r-1 R r-1 F R r L r R r-1 L r-1 R r r F L r 14

Properties of Feistel ciphers round i maps (L i-1, R i-1 ) into (L i, R i ) as follows: L i = R i-1 R i = L i-1 F(R i-1, i ) a Feistel cipher is always invertible even if F is not invertible: R i-1 = L i L i-1 = R i F(R i-1, i ) = R i F(L i, i ) decryption can be achieved using the same r-round process with the round keys used in reverse order ( r through 1 ) L i R Block ciphers / DES L F(R, ) L F F i F F R 15 Complementation property of DES Y = DES (X) implies Y* = DES * (X*) where X* denotes the bitwise complement of X R* E E(R*) = E(R)* E(R)* * = E(R) * L i-1 * R i-1 * i * F(R i-1, i ) F Block ciphers / DES F S S( E(R) ) P P(S( E(R) )) = F(R, ) L i * R i * 16

Consequences of the complementation prop. Block ciphers / DES assume an attacker can mount a chosen-plaintext attack the attacker chooses a plaintext X, and obtains Y 1 = DES (X) and Y 2 = DES (X*) by the complementation property, the attacker knows that DES * (X) = Y 2 * the attacker then runs an exhaustive key search for each trial key, he computes Y = DES (X) if Y = Y 1, then is possibly the target key (should be further tested) if Y = Y 2 *, then * is possibly the target key (should be further tested) otherwise throw away both and * expected number of keys required before success is reduced from 2 55 to 2 54 still impractical as an attack 17 DES weak keys and semi-weak keys a weak key is a key such that DES (DES (X)) = X there are 4 DES weak keys: 0101 0101 0101 0101 FEFE FEFE FEFE FEFE 1F1F 1F1F 0E0E 0E0E E0E0 E0E0 F1F1 F1F1 a semi-weak key pair is a pair ( 1, 2 ) such that DES (DES 1 2 (X)) = X there are 6 pairs of DES semi-weak keys Block ciphers / DES why are these keys weak? for each weak key, there exist 2 32 fix points of DES, i.e., plaintext X such that DES (X) = X for 4 out of the 12 semi-weak keys, there exist 2 32 anti-fix points, i.e., plaintext X such that DES (X) = X* 18

Linear and differential cryptanalysis of DES Block ciphers / Cryptanalysis of DES linear cryptanalysis (LC) linear cryptanalysis is the most powerful attack against DES to date requires an enormous number (~2 43 ) known plaintext-ciphertext pairs infeasible in practical environments could work in a ciphertext only model if plaintexts are redundant (e.g., contain parity bits) differential cryptanalysis (DC) most general cryptanalytic tool to date against iterated block ciphers (including DES, FEAL, IDEA) primarily a chosen-plaintext attack in case of DES, it requires ~2 47 chosen plaintext-ciphertext pairs infeasible in practical environments DES was optimized against DC when it was designed it can, however, be improved with respect to LC (apparently the designers of DES was not aware of this attack at that time) 19 Multiple encryption and 3DES if a block cipher is susceptible to exhaustive key search (e.g., DES), then encryption of the same message more than once may increase security 1 2 Block ciphers / Multiple encryption keys may not be independent e.g., two-key 3DES: 1 = 3 a cipher may be either a block cipher or its corresponding decryption function e.g., 3DES-EDE (encryption-decryption-encryption) 20 X X E/D E/D E/D E/D M E/D E/D double encryption 1 2 3 A E/D E/D B triple encryption E/D E/D Y Y

Meet-in-the-middle attack on double enc. Block ciphers / Multiple encryption a naïve exhaustive key search attack on double encryption tries all 2 2k keys a known-plaintext meet-in-the-middle attack defeats double encryption using an order of 2 k operations and 2 k storage attack time is reduced at the cost of substantial space meet-in-the-middle attack: input: known plaintext-ciphertext pairs (X, Y), (X, Y ), compute M i = E i (X) for all possible key values 1 = i and store all (M i, i) pairs in a table compute M j = D j (Y) for all possible key values 2 = j and check for hits M j = M i against entries in the stored table M j need not be stored, it can be checked as it is generated each hit identifies a candidate solution key pair (i, j) using a second plaintext-ciphertext pair (X, Y ), discard false hits for an L cascade of random ciphers, the expected number of false key hits when t plaintext-ciphertext pairs are available is 2 Lk-tn, where n and k are the block and key sizes, resp. 21 AES Advanced Encryption Standard Block ciphers / AES (Rijndael) NIST selected Rijndael (designed by Joan Daemen and Vincent Rijmen) as a successor of DES (3DES) in November 2001 Rijndael parameters key size 128 192 256 input/output size 128 128 128 number of rounds 10 12 14 round key size 128 128 128 not Feistel structure decryption algorithm is different from encryption algorithm (optimized for encryption) single 8 bit to 8 bit S-box key injection (bitwise XOR) 22

General structure of encryption/decryption plaintext plaintext round 1 add round key substitute bytes shift rows mix columns w[0..3] add round key inverse subs bytes inverse shift rows inverse mix columns round 10 Block ciphers / AES (Rijndael) round 10 round 9 add round key substitute bytes shift rows mix columns add round key substitute bytes shift rows add round key ciphertext w[4..7] expanded key w[36..39] w[40..43] add round key inverse subs bytes inverse shift rows inverse mix columns add round key inverse subs bytes inverse shift rows add round key ciphertext round 9 round 1 23 Shift row and mix column shift row s 00 s 01 s 02 s 03 s 00 s 01 s 02 s 03 s 10 s 11 s 12 s 13 LROT1 s 11 s 12 s 13 s 10 s 20 s 21 s 22 s 23 LROT2 s 22 s 23 s 20 s 21 s 30 s 31 s 32 s 33 LROT3 s 33 s 30 s 31 s 32 Block ciphers / AES (Rijndael) mix column s 00 s 01 s 02 s 03 s 10 s 11 s 12 s 13 s 20 s 21 s 22 s 23 s 30 s 31 s 32 s 33 2 3 1 1 1 2 3 1 1 1 2 3 3 1 1 2 x = multiplications and additions are performed over GF(2 8 ) s 00 s 01 s 02 s 03 s 10 s 11 s 12 s 13 s 20 s 21 s 22 s 23 s 30 s 31 s 32 s 33 24

ey expansion k 0 k 4 k 8 k 12 k 1 k 2 k 3 k 5 k 6 k 7 k 9 k 13 k 10 k 14 k 11 k 15 function g -rotate word - substitute bytes - XOR with round constant Block ciphers / AES (Rijndael) w 0 w 1 w 2 w 3 g g w 4 w 5 w 6 w 7 g g w 8 w 9 w 10 w 11 25 Summary block cipher basics trade-offs in block size trade-offs in key size, exhaustive key search product ciphers, SP networks DES operation properties (Feistel structure, complementation, weak keys) differential and linear cryptanalysis multiple encryption and the 3DES meet-in-the middle attack on 2DES AES operation 26

Using a block cipher in practice: modes of operation - ECB - CBC - CFB, OFB, CTR Block cipher modes of operation Block ciphers / Modes of operation ECB Electronic Codebook used to encipher a single plaintext block (e.g., a DES key) CBC Cipher Block Chaining repeated use of the encryption algorithm to encipher a message consisting of many blocks CFB Cipher Feedback used to encipher a stream of characters, dealing with each character as it comes OFB Output Feedback another method of stream encryption, used on noisy channels CTR Counter simplified OFB with certain advantages triple-inner-cbc and triple-outer-cbc possible modes of operation when multiple encryption is used 28

ECB mode encrypt P 1 P 2 P N E E E E Block ciphers / Modes of operation decrypt C 1 C 1 DD P 1 C 2 C 2 D D P 2 C N C N D D P N 29 Properties of ECB mode Block ciphers / Modes of operation identical plaintext blocks result in identical ciphertext blocks (under the same key of course) messages to be encrypted often have very regular formats repeating fragments, special headers, string of 0s, etc. are quite common blocks are encrypted independently of other blocks reordering ciphertext blocks result in correspondingly reordered plaintext blocks ciphertext blocks can be cut from one message and pasted in another, possibly without detection error propagation: one bit error in a ciphertext block affects only the corresponding plaintext block (results in garbage) overall: not recommended for messages longer than one block, or if keys are reused for more than one block 30

CBC mode encrypt P 1 P 2 P 3 P N IV C N-1 Block ciphers / Modes of operation E C 1 decrypt C 1 DD IV P 1 E E C 2 C 2 DD P 2 E E C 3 C 3 DD P 3 C N-1 E E C N C N DD P N 31 Properties of CBC mode Block ciphers / Modes of operation encrypting the same plaintexts under the same key, but different IVs result in different ciphertexts ciphertext block C j depends on P j and all preceding plaintext blocks rearranging ciphertext blocks affects decryption however, dependency on the preceding plaintext blocks is only via the previous ciphertext block C j-1 proper decryption of a correct ciphertext block needs a correct preceding ciphertext block only error propagation: one bit error in a ciphertext block C j has an effect on the j-th and (j1)-st plaintext block P j is complete garbage and P j1 has bit errors where C j had an attacker may cause predictable bit changes in the (j1)-st plaintext block error recovery: recovers from bit errors (self-synchronizing) cannot, however, recover from frame errors ( lost bits) 32

Integrity of the IV in CBC mode Block ciphers / Modes of operation the IV need not be secret, but its integrity should be protected malicious modification of the IV allows an attacker to make predictable changes to the first plaintext block recovered one solution is to send the IV in an encrypted form at the beginning of the CBC encrypted message 33 Padding Block ciphers / Modes of operation the length of the message may not be a multiple of the block size of the cipher one can add some extra bytes to the short end block until it reaches the correct size this is called padding usually the last byte indicates the number of padding bytes added this allows the receiver to remove the padding note: if the encrypted message must have the same size as the clear message, then no padding can be used encrypt the last ciphertext block again select m bits and XOR them to the remaining m bits of the clear message short end block padding 05 34

CFB mode encrypt decrypt initialized with IV initialized with IV Block ciphers / Modes of operation P i shift register E E select select s s bits bits C i C i shift register E E select select s s bits bits P i 35 Properties of CFB mode Block ciphers / Modes of operation encrypting the same plaintexts under the same key, but different IVs result in different ciphertexts the IV can be sent in clear ciphertext block C j depends on P j and all preceding plaintext blocks rearranging ciphertext blocks affects decryption proper decryption of a correct ciphertext block needs the preceding n/s ciphertext blocks to be correct error propagation: one bit error in a ciphertext block C j has an effect on the decryption of that and the next n/s ciphertext blocks (the error remains in the shift register for n/s steps) P j has bit errors where C j had, all the other erroneous plaintext blocks are garbage an attacker may cause predictable bit changes in the j-th plaintext block error recovery: self synchronizing, but requires n/s blocks to recover 36

OFB mode encrypt decrypt initialized with IV initialized with IV shift register shift register Block ciphers / Modes of operation P i E E select select s s bits bits C i C i E E select select s s bits bits P i 37 Properties of OFB mode Block ciphers / Modes of operation a different IV should be used for every new message, otherwise messages will be encrypted with the same key stream the IV can be sent in clear however, if the IV is modified by the attacker, then the cipher will never recover (unlike CFB) ciphertext block C j depends on P j only (does not depend on the preceding plaintext blocks) however, rearranging ciphertext blocks affects decryption feedback size should be equal to n (= n) cycle length is around 2 n-1 (< n) cycle length is around 2 n/2 error propagation: one bit error in a ciphertext block C j has an effect on the decryption of only that ciphertext block P j has bit errors where C j had an attacker may cause predictable bit changes in the j-th plaintext block error recovery: recovers from bit errors never recovers if bits are lost or the IV is modified 38

CTR mode encrypt decrypt counter i counter i Block ciphers / Modes of operation P i E E C i C i E E P i 39 Properties of CTR mode Block ciphers / Modes of operation similar to OFB cycle length depends on the size of the counter (typically 2 n ) the i-th block can be decrypted independently of the others parallelizable (unlike OFB) random access the values to be XORed with the plaintext can be pre-computed at least as secure as the other modes note1: in CFB, OFB, and CTR mode only the encryption algorithm is used (decryption is not needed) that is why Rijndael is optimized for encryption these modes shouldn t be used with public-key encryption algs. note2: the OFB and CTR modes essentially make a synchronous stream cipher out of a block cipher, whereas the CFB mode converts a block cipher into a self-synchronizing stream-cipher 40

A security flaw induced by CBC padding CBC encryption with padding P 1 P 2 P 3 P N padding pad. len. A security flaw induced by CBC padding IV C N-1 E E C 1 TLS padding last byte is the length n of the padding all padding bytes have the value n examples for correct padding: 0, 11, 222, 3333, verification of TLS padding: if the last byte is n, then verify if the last n1 bytes are all n E E C 2 E E C 3 E E C N 42

Side channel TLS record message format type version length A security flaw induced by CBC padding send a random message to a TLS server the server will drop the message with overwhelming probability either the padding is incorrect (the server responds with a DECRYPTION_FAILED alert) or the MAC is incorrect with very high probability (the server responds with BAD_RECORD_MAC alert) if the response is BAD_RECORD_MAC, then the padding was correct we get 1 bit of information! application data MAC padding p.len 43 Last byte oracle A security flaw induced by CBC padding assume we have an encrypted block y 1 y 2 y 8 = E (x 1 x 2 x 8 ) we want to compute x 8 (the last byte of x) idea: 1. choose a random block r 1 r 2 r 8 ; let i = 0 2. send r 1 r 2 r 7 (r 8 i)y 1 y 2 y 8 to the server (oracle) 3. if there s a padding error, then increment i and go back to step 2 4. if there s no padding error, then r x ends with 0 or 11 or 222 the most likely is that (r 8 i) x 8 = 0, and hence x 8 = r 8 i r 1 r 2 r 7 (r 8 i) IV D garbage y 1 y 2 y 8 D x 1 x 2 x 8 (r 1 x 1 )(r 2 x 2 )(r 8 i x 8 ) 44

Last byte oracle A security flaw induced by CBC padding assume we get that x r has a correct padding, but we don t know if it is 0 or 11 or 222 idea: 1. let j = 1 2. change r j and send r 1 r 2 r 8 y 1 y 2 y 8 to the server again 3. if the padding is still correct then the j-th byte was not a padding byte; increment j and go back to step 2 4. if the padding becomes incorrect then the j-th byte was the first padding byte; x j r j x j1 r j1 x 8 r 8 = (8-j) (8-j) and hence x j x j1 x 8 = r j (8-j) r j1 (8-j) r 8 (8-j) x = DE AD BE EF DE AD BE EF r = 01 23 45 67 DD AE BD EC r x = DF 8E FB 88 03 03 03 03 j r r x padding 1 00 23 45 67 DD AE BD EC DE 8E FB 88 03 03 03 03 O 2 00 22 45 67 DD AE BD EC DE 8F FB 88 03 03 03 03 O 3 00 22 44 67 DD AE BD EC DE 8F FA 88 03 03 03 03 O 4 00 22 44 66 DD AE BD EC DE 8F FA 89 03 03 03 03 O 5 00 22 44 66 DC AE BD EC DE 8F FA 89 02 03 03 03 ERROR x 5 x 6 x 7 x 8 = DD 03 AE 03 BD 03 EC 03 = DE AD BE EF 45 Block decryption oracle A security flaw induced by CBC padding assume we have an encrypted block y 1 y 2 y 8 = E (x 1 x 2 x 8 ) and we know the value of x j x j1 x 8 (using the last byte oracle) we want to compute x j-1 idea: 1. choose a random block r 1 r 2 r 8 such that r j = x j (9-j); r j1 = x j1 (9-j); r 8 = x 8 (9-j); 2. let i = 0 3. send r 1 r 2 r j-2 (r j-1 i)r j r 8 y 1 y 2 y 8 to the server (oracle) 4. if there s a padding error then increment i and go back to step 3 5. if there s no padding error then x j-1 r j-1 i = 9-j and hence x j-1 = r j-1 i (9-j) x = DE AD BE EF DE AD BE EF r = 01 23 45 67 DA A9 BA EB r x = DF 8E FB 88 04 04 04 04 i r r x padding 0 01 23 45 67 DA A9 BA EB DF 8E FB 88 04 04 04 04 ERROR 1 01 23 45 66 DA A9 BA EB DF 8E FB 89 04 04 04 04 ERROR 140 01 23 45 EB DA A9 BA EB DF 8E FB 04 04 04 04 04 O x 4 = 67 8C 04 = EF 46

Decryption oracle A security flaw induced by CBC padding assume we have a CBC encrypted message (C 1, C 2,, C N ) where C 1 = E (P 1 IV) C i = E (P i C i-1 ) (for 1 < i < N) C N = E ([P N pad plen] C N-1 ) we want to compute P 1, P 2, P N idea: decrypt C N using the block decryption oracle and XOR the result to C N-1 ; you get P N pad plen decrypt C i using the block decryption oracle and XOR the result to C i-1 ; you get P i decrypt C 1 using the block decryption oracle and XOR the result to IV; you get P 1 (if IV is secret you cannot get P 1 ) complexity of the whole attack: on average we need only ½*256*8*N = 1024*N oracle calls! 47 Application A security flaw induced by CBC padding vulnerable protocols: SSL, TLS, WTLS, IPsec, some notes: problems (and solutions) with TLS alert messages are encrypted BAD_RECORD_MAC and DECRYPTION_FAILED cannot be distinguished measure timing between oracle call and oracle response BAD_RECORD_MAC takes more time than DECRYPTION_FAILED BAD_RECORD_MAC and DECRYPTION_FAILED are fatal errors connection is closed after one oracle call a password can still be broken if it is sent periodically to a server using TLS (a different session is used each time the password is sent) 48

Example: IMAP over TLS A security flaw induced by CBC padding Outlook Express checks for new mail on the server periodically (every 5 minutes) each time the same password is sent for every folder XXXX LOGIN username password <0D><0A> it is possible to uncover the password using the attack as follows: client man-in-the-middle server X X X X L O G I N b u t t y a n k i s k a c s a DECRYPTION_FAILED t r 1 r 2 r 3 r 4 r 5 r 6 r 7 r 8 a n k i s k a DECRYPTION_FAILED 49 Fixes A security flaw induced by CBC padding randomize response time after an error occurred (measuring timing of alert messages won t work) use random padding bytes put the padding before the MAC! 50

Stream ciphers - general principles - one-time pad - LFSR based stream ciphers - RC4 General principles while block ciphers simultaneously encrypt groups of characters, stream ciphers encrypt individual characters may be better suited for real time applications stream ciphers are usually faster than block ciphers in hardware (but not necessarily in software) limited or no error propagation may be advantageous when transmission errors are probable Stream ciphers note: the distinction between stream ciphers and block ciphers is not definitive stream ciphers can be built out of block ciphers using CFB, OFB, or CTR modes a block cipher in ECB or CBC mode can be viewed as a stream cipher that operates on large characters 52

Synchronous stream ciphers p i ff k k σ i1 σ i i gg k k z i h Stream ciphers the key stream is generated independently of the plaintext and of the ciphertext properties: needs synchronization between the sender and the receiver if a character is inserted into or deleted from the ciphertext stream then synchronization is lost and the plaintext cannot be recovered additional techniques must be used to recover from loss of synch. insertion and deletion are easy to detect by the receiver no error propagation a ciphertext character that is modified during transmission affects only the decryption of that character an attacker can make changes to selected ciphertext characters and know exactly what effect these changes have on the plaintext (if h = XOR) c i 53 Self-synchronizing stream ciphers p i register gg k k z i h c i Stream ciphers the key stream is generated as a function of a fixed number of previous ciphertext characters properties: self-synchronizing since the size t of the register is fixed, a lost ciphertext character affects only the decryption of the next t ciphertext characters more difficult to detect insertion and deletion of ciphertext char s limited error propagation if a ciphertext character is modified, then decryption of the next t ciphertext characters may be incorrect modifications are easier to detect than in case of synch. stream ciphers ciphertext characters depend on all previous plaintext characters better diffusion of plaintext statistics 54

Vernam cipher and the one-time pad Vernam cipher c i = p i k i for i = 1, 2, where p i are the plaintext digits, k i are the key stream digits, c i are the ciphertext digits, and is the bitwise XOR operation Stream ciphers one-time pad a Vernam cipher where the key stream digits are generated independently and uniformly at random the one-time pad is unconditionally secure [Shannon, 1949] I(P; C) = H(P) - H(P C) = 0 a necessary condition for a symmetric key cipher to be unconditionally secure is that H() H(P) [Shannon, 1949] practically, the key must have as many bits as the compressed plaintext impractical because of key management problems 55 Linear feedback shift registers (LFSR) c 1 c 2 c L-1 c L L-1 L-1 L-2 L-2 1 1 0 0 output Stream ciphers where each c i {0, 1} and each can store 1 bit operation is controlled by a clock during each time unit the content of 0 is output the contents of a fixed subset of s are XORed the content of i is moved to i-1 (i = 1, 2,, L-1) and the result of the XOR operation is moved in L-1 (feedback) 56

Maximum length LFSR and linear complexity maximum length LFSR since the number of possible states of an LFSR is finite, the output stream it produces is always periodic an LFSR is maximum length LFSR, if it produces an output sequence with maximum possible period 2 L -1 (m-sequence) m-sequences have good statistical properties Stream ciphers linear complexity the linear complexity L(s n ) of a finite binary sequence s n is the length of the shortest LFSR that generates a sequence having s n as its first n elements Berlekamp-Massey algorithm: let s be a binary sequence of linear complexity L, and let t be a finite subsequence of s of length at least 2L the Berlekamp-Massey algorithm with input t determines an LFSR of length L that generates s an LFSR should not be used as a key stream generator, as the resulting stream cipher would be vulnerable to known-plaintext attacks 57 Stream ciphers based on LFSRs nonlinear combination generators LFSR LFSR 11 LFSR LFSR 2 f key stream Stream ciphers LFSR LFSR n 58

Stream ciphers based on LFSRs nonlinear filter generators c 1 c 2 c L-1 c L L-1 L-1 L-2 L-2 1 1 0 0 f Stream ciphers key stream 59 Stream ciphers based on LFSRs clock-controlled generators alternating step generator LFSR 2 clock LFSR 1 key stream LFSR 3 shrinking generator LFSR 1 a i Stream ciphers clock LFSR 2 b i if a i = 1 output b i else discard b i key stream 60

RC4 stream cipher Stream ciphers initialization (input: a seed of keylen bytes) for i = 0 to 255 do S[i] = i; T[i] = [i mod keylen]; initial permutation j = 0; for i = 0 to 255 do j = (j S[i] T[i]) mod 256; swap(s[i], S[j]); stream generation (output: a stream of pseudo-random bytes) i, j = 0; while true i = (i 1) mod 256; j = (j S[i]) mod 256; swap(s[i], S[j]); output S[(S[i] S[j]) mod 256]; 61