刘振 上海交通大学 计算机科学与工程系 电信群楼3-509

Slides:



Advertisements
Similar presentations
“Advanced Encryption Standard” & “Modes of Operation”
Advertisements

Modern Symmetric-Key Ciphers
CS 483 – SD SECTION BY DR. DANIYAL ALGHAZZAWI (3) Information Security.
1 CIS 5371 Cryptography 5b. Pseudorandom Objects in Practice Block Ciphers.
The Advanced Encryption Standard (AES) Simplified.
Symmetric Encryption Example: DES Weichao Wang. 2 Overview of the DES A block cipher: – encrypts blocks of 64 bits using a 64 bit key – outputs 64 bits.
Cryptography1 CPSC 3730 Cryptography Chapter 6 Triple DES, Block Cipher Modes of Operation.
CPSC415 Biometrics and Cryptography1 Conventional Cryptography (Symmetric Ciphers)
Block Ciphers 1 Block Ciphers Block Ciphers 2 Block Ciphers  Modern version of a codebook cipher  In effect, a block cipher algorithm yields a huge.
1 Overview of the DES A block cipher: –encrypts blocks of 64 bits using a 64 bit key –outputs 64 bits of ciphertext A product cipher –basic unit is the.
RC4 1 RC4 RC4 2 RC4  Invented by Ron Rivest o “RC” is “Ron’s Code” or “Rivest Cipher”  A stream cipher  Generate keystream byte at a step o Efficient.
Kemal AkkayaWireless & Network Security 1 Department of Computer Science Southern Illinois University Carbondale CS 591 – Wireless & Network Security Lecture.
Chapter 3 – Block Ciphers and the Data Encryption Standard Jen-Chang Liu, 2004 Adopted from lecture slides by Lawrie Brown.
Introduction to Symmetric Block Cipher Jing Deng Based on Prof. Rick Han’s Lecture Slides Dr. Andreas Steffen’s Security Tutorial.
CS Network Security Lecture 2 Prof. Katz. 9/7/2000Lecture 2 - Data Encryption2 DES – Data Encryption Standard Private key. Encrypts by series of.
Lecture 23 Symmetric Encryption
Symmetric Encryption and Message Confidentiality
Lecture 3: Cryptographic Tools modified from slides of Lawrie Brown.
Cryptography and Network Security Chapter 6. Multiple Encryption & DES  clear a replacement for DES was needed theoretical attacks that can break it.
Chapter 20 Symmetric Encryption and Message Confidentiality.
Chapter 20 Symmetric Encryption and Message Confidentiality.
Cracking DES Cryptosystem A cryptosystem is made of these parts: Two parties who want to communicate over an insecure channel An encryption algorithm that.
Classical Crypto By: Luong-Sorin VA, IMIT Dith Nimol, IMIT.
3DES and Block Cipher Modes of Operation CSE 651: Introduction to Network Security.
Multiple Encryption & DES  clearly a replacement for DES was needed Vulnerable to brute-force key search attacks Vulnerable to brute-force key search.
Dr. Reuven Aviv, Nov 2008 Conventional Encryption 1 Conventional Encryption & Message Confidentiality Acknowledgements for slides Henric Johnson Blekinge.
Part 1  Cryptography 1 Chapter 3: Symmetric Key Crypto.
TE/CS 536 Network Security Spring 2005 – Lecture 8 Security of symmetric algorithms.
Presented by: Dr. Munam Ali Shah
Lecture 23 Symmetric Encryption
1 The Data Encryption Standard. 2 Outline 4.1 Introduction 4.4 DES 4.5 Modes of Operation 4.6 Breaking DES 4.7 Meet-in-the-Middle Attacks.
Lecture 3 Page 1 CS 236 Online Introduction to Cryptography CS 236 On-Line MS Program Networks and Systems Security Peter Reiher.
1 CPCS425: Information Security (Topic 5) Topic 5  Symmetrical Cryptography  Understand the principles of modern symmetric (conventional) cryptography.
CPIS 312 Chapter Three: Symmetric KEY CRYPTO By Dr. Daniyal Alghazzawi 2011 Term 2.
Block Cipher Modes Last Updated: Aug 25, ECB Mode Electronic Code Book Divide the plaintext into fixed-size blocks Encrypt/Decrypt each block independently.
Modes of Operation block ciphers encrypt fixed size blocks – eg. DES encrypts 64-bit blocks with 56-bit key need some way to en/decrypt arbitrary amounts.
CS480 Cryptography and Information Security
Computer and Network Security
Provides Confidentiality
Data Security B. R. Chandavarkar Asst. Prof., CSE Dept., NITK, Surathkal. brc.nitk.ac.in.
(Data Encryption Standard)
6b. Practical Constructions of Symmetric-Key Primitives.
Chapter-2 Classical Encryption Techniques.
Cryptography CS 555 Topic 15: Stream Ciphers.
Cryptography.
Outline Desirable characteristics of ciphers Stream and block ciphers
Outline Desirable characteristics of ciphers Uses of cryptography
Lecture 3: Symmetric Key Encryption
NET 311 Information Security
Cryptography after DES
Block Cipher Modes CS 465 Make a chart for the mode comparisons
رمزنگاري متقارن بهروز ترك‏لاداني 1.
Topic 5: Constructing Secure Encryption Schemes
مروري برالگوريتمهاي رمز متقارن(كليد پنهان)
AES Objectives ❏ To review a short history of AES
PART VII Security.
Some of this slide set is from Section 2,
Block Ciphers and the Data Encryption Standard (DES)
Symmetric-Key Encryption
Block vs Stream Ciphers
ADVANCED ENCRYPTION STANDARDADVANCED ENCRYPTION STANDARD
Chapter -3 ADVANCED ENCRYPTION STANDARD & BLOCK CIPHER OPERATION
RC4 RC
Block Ciphers: DES and AES
SYMMETRIC ENCRYPTION.
Block Ciphers (Crypto 2)
Review of Cryptography: Symmetric and Asymmetric Crypto Advanced Network Security Peter Reiher August, 2014.
Secret-Key Encryption
Presentation transcript:

刘振 上海交通大学 计算机科学与工程系 电信群楼3-509 liuzhen@sjtu.edu.cn 网络安全技术 刘振 上海交通大学 计算机科学与工程系 电信群楼3-509 liuzhen@sjtu.edu.cn

Symmetric Key Encryption

Crypto – a brief introduction Cryptology  The art and science of making and breaking “secret codes” Cryptography  making “secret codes” ychrpyaprtgo C = M  K Cryptanalysis  breaking “secret codes” ychrpyaprtgo is cracked to ______________, QED. Crypto  all of the above (and more) More on non-repudiation (signature), authentication, identification, zero-knowledge, commitment, and more… Any reference books?... Bruce Schneier, HAC

A cipher or cryptosystem is used for encrypting/decrypting a plaintext/ciphertext Receiver / B / Bob Sender / A / Alice ciphertext plaintext encryption decryption key key eavesdropper plaintext key cryptanalysis

Cryptanalysis Basic assumption Objective of an attacker Known as Kerckhoffs Principle The system is completely known to the attacker Only the key is secret Crypto algorithms are not secret No “security through obscurity” Objective of an attacker Identify secret key used to encrypt a ciphertext (OR) recover the plaintext of a ciphertext without the secret key

1. IRXUVFRUHDAGVHYHABHDUVDIR 2. VSRQJHEREVTXDUHSDQWU Examples of (Classical) Symmetric Key Encryption Algorithms – Classical Cryptography Ciphertexts: 1. IRXUVFRUHDAGVHYHABHDUVDIR 2. VSRQJHEREVTXDUHSDQWU a b c d e f g h i j k l m n o p q r s t u v w x y z D E F G H I J K L M N O P Q R S T U V W X Y Z A B C

Simple Substitution: each plaintext letter is substituted by a distinct ciphertext letter EIMBULJIWLNYANJMVLIURAHIWAI A B C D E F G H I J K L M N O P Q R S T U V W X Y Z DEPARTMENTOFCOMPUTERSCIENCE What’s the ciphertext of “solutionstofinalexam”?

An example of simple substitution…

An Example Ciphertext (encrypted using simple substitution) PBFPVYFBQXZTYFPBFEQJHDXXQVAPTPQJKTOYQWIPBVWLXTOXBTFXQWAXBVCXQWAXFQJVWLEQNTOZQGGQLFXQWAKVWLXQWAEBIPBFXFQVXGTVJVWLBTPQWAEBFPBFHCVLXBQUFEVWLXGDPEQVPQGVPPBFTIXPFHXZHVFAGFOTHFEFBQUFTDHZBQPOTHXTYFTODXQHFTDPTOGHFQPBQWAQJJTODXQHFOQPWTBDHHIXQVAPBFZQHCFWPFHPBFIPBQWKFABVYYDZBOTHPBQPQJTQOTOGHFQAPBFEQJHDXXQVAVXEBQPEFZBVFOJIWFFACFCCFHQWAUVWFLQHGFXVAFXQHFUFHILTTAVWAFFAWTEVOITDHFHFQAITIXPFHXAFQHEFZQWGFLVWPTOFFA

Question: how secure is Simple Substitution? Let’s do some analysis…

Each permutation is a potential candidate of the secret key A secret key (in Simple Substitution) is a random permutation of the alphabetic characters. E.g. Each permutation is a potential candidate of the secret key Question: how many distinct permutations are there? (in other words, how many distinct secret keys are in the key space?)

26! Total number of possible permutations 26! = 403,291,461,126,605,635,584,000,000 (27 digits)  288 Maybe… write a computer program to try all the possible keys exhaustively… (so-called Brute-force Attack) Calculation: suppose we have one million 3GHz PCs which can try 3 billion permutations per second, the machines will take 4,263 years to try all the 26! permutations… Not so efficient Question: any better cracking algorithm?

Statistical Attack / Character Frequency Attack An interesting observation on simple substitution: the relative letter frequencies do not change during encryption letters in an alphabet are not equally common in English, e and t are by far the most common letters Probability distribution of the 26 English letters (Beker and Piper, 1982) letter probability A .082 N .067 B .015 O .075 C .028 P .019 D .043 Q .001 E .127 R .060 F .022 S .063 G .020 T .091 H .061 U I .070 V .010 J .002 W .023 K .008 X L .040 Y M .024 Z

Basic Approach of Statistic Attack: Identify possible encryptions of letter ‘e’ (the most common English letter) Identify possible diagrams starting/finishing with letter ‘e’ Use trigrams (e.g. find ‘the’) Identify word boundaries Iterate the above for the 2nd most common English letter and so on.

Ciphertext frequency counts: PBFPVYFBQXZTYFPBFEQJHDXXQVAPTPQJKTOYQWIPBVWLXTOXBTFXQWAXBVCXQWAXFQJVWLEQNTOZQGGQLFXQWAKVWLXQWAEBIPBFXFQVXGTVJVWLBTPQWAEBFPBFHCVLXBQUFEVWLXGDPEQVPQGVPPBFTIXPFHXZHVFAGFOTHFEFBQUFTDHZBQPOTHXTYFTODXQHFTDPTOGHFQPBQWAQJJTODXQHFOQPWTBDHHIXQVAPBFZQHCFWPFHPBFIPBQWKFABVYYDZBOTHPBQPQJTQOTOGHFQAPBFEQJHDXXQVAVXEBQPEFZBVFOJIWFFACFCCFHQWAUVWFLQHGFXVAFXQHFUFHILTTAVWAFFAWTEVOITDHFHFQAITIXPFHXAFQHEFZQWGFLVWPTOFFA Ciphertext frequency counts: A B C D E F G H I J K L M N O P Q R S T U V W X Y Z 21 26 6 10 12 51 25 9 3 1 15 28 42 27 4 24 22 8

Question: How to build a symmetric key cryptosystem which is secure against statistical attack?

One-time Pad Encryption Encryption: Plaintext  Key = Ciphertext e=000 h=001 i=010 k=011 l=100 r=101 s=110 t=111 h e i l t r 001 000 010 100 111 101 Plaintext: Key: 111 101 110 100 000 001 s r l h t Ciphertext: 简单替换密码不安全的一个原因就是他的密钥是简单的重复使用的,会被从中分析出信息。这个是最坏的情况。 与之相反的“最好”的情况就是密钥只用一次。这就是一次一密。 假设只有8个字符,每个字符用三bit表示就行了。 每个字母三bit,明文多长,密钥就需要多长

Pad must be random, used only once Pad has the same size as message e=000 h=001 i=010 k=011 l=100 r=101 s=110 t=111 Decryption: Ciphertext  Key = Plaintext s r l h t 110 101 100 001 111 Ciphertext: Key: 111 101 110 100 000 001 010 h e i l t r Plaintext: Pad must be random, used only once Pad has the same size as message

Questions: What are the current symmetric key cryptosystems? There are many… They can be categorized into two types: Stream Cipher Block Cipher 前面介绍了经典密码中的简单替换密码,不安全的,现在可不能用了。 也介绍了一种理想的密码,一次一密密码,安全,但不实用。

 Stream Ciphers Keystream Generator secret key keystream Plaintext Ciphertext Secret key length: 128 bits, 256 bits, etc. Maximum plaintext length: usually can be arbitrarily long. Security: Given a “long” segment of keystream (e.g. 240 bits), the secret key cannot be derived AND the subsequent segment of the keystream cannot be deducted. 流密码在一定程度上和一次一密密码很象。如果keystream不是由一个secret key通过生成器生成出来,而是真正的随机01串的话,这就是一次一密加密。 现在由secret key生成出来,就有了一定的信息泄漏。

RC4 A stream cipher Ron’s code version 4 (Ronald Rivest) Stream ciphers are generally faster than block ciphers RC4 Stage 1: RC4 initialization Stage 2: RC4 keystream generation

RC4 Initialization Setup: Initialization: byte key[N]; // secret key (e.g. N = 16, i.e. 128-bit key) byte K[256]; // keying material byte S[256]; // internal states Initialization: for i = 0 to 255 S[i] = i K[i] = key[i (mod N)] j = 0 j = (j + S[i] + K[i]) mod 256 swap(S[i], S[j]) i = j = 0 S[] is the permutation of 0,1,...,255

RC4 Keystream Generation To output a keystream byte, swap table elements and select a byte Keystream generation: i = (i + 1) mod 256 j = (j + S[i]) mod 256 swap(S[i], S[j]) t = (S[i] + S[j]) mod 256 KeyStreamByteSelected = S[t] Use the KeyStreamByteSelected to do XOR with one byte of plaintext, then iterate the keystream generation steps above for getting another byte of keystream Note: Some research results show that the first 256 bytes must be discarded, otherwise attacker may be able to recover the key.

Block Ciphers plaintext Block Cipher Ciphertext secret key A block cipher takes a block of plaintext and a secret key, produces a block of ciphertext. The key is reused for different plaintext blocks Typical block sizes: 64 bits, 128 bits, 192 bits, 256 bits Key sizes: 56 bits (DES), 128/192/256 bits (AES) Popular block ciphers: DES, 3DES, AES, Twofish, Serpent

(Iterated) Block Cipher Ciphertext obtained from plaintext by iterating a round function Input to round function consists of key and the output of previous round DES: 16 rounds of Feistel round function Block size: 64 bits Key size: 56 bits 轮函数

One Round of DES key Ki   key 32 28 28 expand shift shift 48 28 28 Li-1 Ri-1 32 28 28 expand shift shift One Round of DES 48 28 28 32 Ki  48 compress 48 S-boxes 28 28 32 P box 32 32  32 key Li Ri

Security of DES Security of DES depends solely on the internals of f Thirty years of intense analysis has revealed no “back door” The most effective attack today against DES is still the exhaustive key search (aka bruteforce attack)

Exhaustive Key Search Given a plaintext x and corresponding ciphertext y, every possible key would be tested until a key K is found such that E(K, x) = y Note: there may be more than one such key K. For DES, total number of keys = 256  7.21016 keys Assume at the speed of 106 encryptions per second, it would need more than 1000 years to break DES. Diffie and Hellman postulated in 1977 that a DES cracking machine with 106 processors, each could test 106 keys per second, could be built for about US$20M. This machine can break DES in about 10 hours.

Exhaustive Key Search In 1993, Michael Wiener presented a pipelined chip which tests 5107 DES keys per second. Each chip could cost US$10 and a frame of 5760 chips would cost about $100K. In 1998, DES cracker (nicknamed “Deep Crack” http://en.wikipedia.org/wiki/EFF_DES_cracker) was built by the Electronic Frontier Foundation (EFF). It performs 256 DES operations in 56 hours. Cost: US$250K (first piece), US$50K - $75K (duplicates). Software version of DES cracking effort can be found at http://www.distributed.net/des/ 目前采用分布式的破解,估计十几个小时甚至不到十小时。 所以,DES已经是不安全的。现在肯定是都不用了。目前主流的是AES。

What Should We Use Today? 3DES (or Triple DES) AES (or Rijndael) Other candidates Twofish RC6 Serpent

Triple DES and DESX What are the sizes of K1, K2, and K3? Triple DES: two 56-bit keys DESX: three keys C = K3  DES(K2 , M  K1) C M DES DES-1 DES K1 K2 K1 DES   C M K1 K2 K3 Similar security to DES using differential cryptanalysis and linear cryptanalysis, which are theoretical attacks But much harder to break using exhaustive key search than DES. What are the sizes of K1, K2, and K3?

Advanced Encryption Standard Replacement for DES AES competition (late 90’s) NSA openly involved Many strong algorithms were proposed and cryptanalyzed publicly Rijndael Algorithm was ultimately selected Pronounced like “Rain Doll” or “Rhine Doll” Iterated block cipher (like DES) Not using Feistel round function (unlike DES)

AES (Advanced Encryption Standard) Replacement of DES Block size: 128 bits Key length: 128, 192 or 256 bits (independent of block size) 10 to 14 rounds (depends on key length) Each round uses 4 functions (in 3 “layers”) ByteSub (nonlinear layer) ShiftRow (linear mixing layer) MixColumn (nonlinear layer) AddRoundKey (key addition layer)

Key Space The Key Space of a cipher is the set of all possible and distinct secret keys E.g. The key space of DES is all distinct 56-bit binary strings E.g. The size of the key space of simple substitution for case-insensitive English alphabet is 26! What’s the key space size of AES? What’s the key space size of one-time pad? What’s the key space size of RC4?

Multiple Blocks How to encrypt multiple blocks? Message (n bits) Ciphertext (n bits) DES secret key (k bits) How to encrypt multiple blocks? A new key for each block? As bad as (or worse than) the one-time pad! Encrypt each block independently? Make encryption depend on previous block(s), i.e., “chain” the blocks together? How to handle partial blocks?

Modes of Operation Many modes of operation  we discuss three Electronic Codebook (ECB) mode Obvious thing to do Encrypt each block independently There is a serious weakness Cipher Block Chaining (CBC) mode Chain the blocks together More secure than ECB Counter Mode (CTR) mode Acts like a stream cipher Popular for random access

ECB Mode Notations: C=E(K, P) P=D(K,C) Given plaintext P = P0,P1,…,Pm,… (in blocks) Obvious way of using a block cipher is to encrypt plaintext blocks independently Encrypt Decrypt C0 = E(K, P0), P0 = D(K, C0), C1 = E(K, P1), P1 = D(K, C1), C2 = E(K, P2),… P2 = D(K, C2),… P0 DES K C0 C1 Ci P1 Pi

ECB Cut and Paste Attack Suppose plaintext is Alice digs Bob. Trudy digs Tom. Assuming 64-bit blocks and 8-bit ASCII: P0 = “Alice di”, P1 = “gs Bob. ”, P2 = “Trudy di”, P3 = “gs Tom. ” Ciphertext: C0,C1,C2,C3 Trudy cuts and pastes: C0,C3,C2,C1 Decrypts as Alice digs Tom. Trudy digs Bob. 举个有趣一点的例子,银行转账的例子。

ECB Weakness Suppose Pi = Pj Then Ci = Cj and Trudy knows Pi = Pj This gives Trudy some information, even if she does not know Pi or Pj Is this a serious issue?

Alice Hates ECB Mode Alice’s uncompressed image, Alice ECB encrypted Why does this happen? Same plaintext block  same ciphertext!

CBC Mode C0 = E(K, IV  P0), P0 = IV  D(K, C0), Blocks are “chained” together A random initialization vector, or IV, is required to initialize CBC mode IV is random, but is not a secret Encryption Decryption C0 = E(K, IV  P0), P0 = IV  D(K, C0), C1 = E(K, C0  P1), P1 = C0  D(K, C1), C2 = E(K, C1  P2),… P2 = C1  D(K, C2),… DES P0 P1 C0 C1 IV K IV需要双方预先协调吗?

Alice Likes CBC Mode Alice’s uncompressed image, Alice CBC encrypted Why does this happen? Same plaintext yields different ciphertext!

Counter Mode (CTR) Use block cipher like stream cipher Encryption Decryption C0 = P0  E(K, IV), P0 = C0  E(K, IV), C1 = P1  E(K, IV+1), P1 = C1  E(K, IV+1), C2 = P2  E(K, IV+2),… P2 = C2  E(K, IV+2),… CTR is good for random access (both READ and WRITE) CBC is good for random READ only, but not WRITE IV DES K C0 Ci IV+1 IV+i  P0 P1 Pi C1

Summary Kerckhoffs Principle Simple Substitution Encryption and statistical attack One-time Pad Encryption Stream Cipher: RC4 Block Cipher: DES, AES Key Space Modes of Operation