Authenticated Encryption and Cryptographic Network Protocols David Brumley Carnegie Mellon University.

Slides:



Advertisements
Similar presentations
Cryptography and Network Security Chapter 16
Advertisements

Web security: SSL and TLS
MAC Raushan. DES simple fiestel network 3131 PlainText Blocks 2*4=8bits 31 f f =0011 xor 0011=0000 = 0 f(r,k)=(2*r+k^2)%8 f(1,5)=(2*1+5^2)%8=3 xor 3 3.
Spring 2012: CS419 Computer Security Vinod Ganapathy SSL, etc.
Internet and Intranet Protocols and Applications Lecture 9a: Secure Sockets Layer (SSL) March, 2004 Arthur Goldberg Computer Science Department New York.
1 Lecture 17: SSL/TLS history, architecture basic handshake session initiation/resumption key computation negotiating cipher suites application: SET.
Lecture 6: Web security: SSL
Cryptography and Network Security
Secure Socket Layer.
SSL CS772 Fall Secure Socket layer Design Goals: SSLv2) SSL should work well with the main web protocols such as HTTP. Confidentiality is the top.
Socket Layer Security. In this Presentation: need for web security SSL/TLS transport layer security protocols HTTPS secure shell (SSH)
Working Connection Computer and Network Security - SSL, IPsec, Firewalls – (Chapter 17, 18, 19, and 23)
7-1 Chapter 7 – Web Security Use your mentality Wake up to reality —From the song, "I've Got You under My Skin“ by Cole Porter.
Chapter 7 Web Security MSc. NGUYEN CAO DAT Dr. TRAN VAN HOAI.
Cryptography: Review Day David Brumley Carnegie Mellon University.
Dan Boneh Authenticated Encryption Active attacks on CPA-secure encryption Online Cryptography Course Dan Boneh.
Authenticated Encryption and Cryptographic Network Protocols David Brumley Carnegie Mellon University.
WEP 1 WEP WEP 2 WEP  WEP == Wired Equivalent Privacy  The stated goal of WEP is to make wireless LAN as secure as a wired LAN  According to Tanenbaum:
Mar 19, 2002Mårten Trolin1 This lecture On the assignment Certificates and key management SSL/TLS –Introduction –Phases –Commands.
Cryptography and Network Security Chapter 17
1 Message Integrity CS255 Winter ‘06. 2 Message Integrity Goal: provide message integrity. No confidentiality. –ex: Protecting public binaries on disk.
How cryptography is used to secure web services Josh Benaloh Cryptographer Microsoft Research.
Chapter 8 Web Security.
Active attacks on CPA-secure encryption
Dan Boneh Authenticated Encryption Definitions Online Cryptography Course Dan Boneh.
Dan Boneh Authenticated Encryption Chosen ciphertext attacks Online Cryptography Course Dan Boneh.
Dan Boneh Authenticated Encryption Case study: TLS Online Cryptography Course Dan Boneh.
Announcement Final exam: Wed, June 9, 9:30-11:18 Scope: materials after RSA (but you need to know RSA) Open books, open notes. Calculators allowed. 1.
Secure Socket Layer (SSL)
Behzad Akbari Spring 2012 (These slides are based on lecture slides by Lawrie Brown)
Cosc 4765 SSL/TLS and VPN. SSL and TLS We can apply this generally, but also from a prospective of web services. Multi-layered: –S-http (secure http),
How cryptography is used to secure web services Josh Benaloh Cryptographer Microsoft Research.
Network Security Essentials Chapter 5
Cryptography and Network Security (CS435) Part Fourteen (Web Security)
Web Security : Secure Socket Layer Secure Electronic Transaction.
CMSC 414 Computer and Network Security Lecture 5 Jonathan Katz.
Dan Boneh Using block ciphers Modes of operation: many time key (CBC) Online Cryptography Course Dan Boneh Example applications: 1. File systems: Same.
Class 3 Cryptography Refresher II CIS 755: Advanced Computer Security Spring 2014 Eugene Vasserman
1 Certificates, SSL, and One time passwords Fall 2010 David Brumley.
SMUCSE 5349/7349 SSL/TLS. SMUCSE 5349/7349 Layers of Security.
Cryptography: Review Day David Brumley Carnegie Mellon University.
Web Security Web now widely used by business, government, individuals but Internet & Web are vulnerable have a variety of threats – integrity – confidentiality.
Gold Coast Campus School of Information Technology 2003/16216/3112INT Network Security 1Copyright © Griffith University, INT / 3112INT Network.
Message Authentication Codes (MACs) and Hashes David Brumley Carnegie Mellon University Credits: Many slides from Dan Boneh’s June 2012.
Dan Boneh Odds and ends Deterministic Encryption Online Cryptography Course Dan Boneh.
CSCE 715: Network Systems Security Chin-Tser Huang University of South Carolina.
Dan Boneh Authenticated Encryption CBC paddings attacks Online Cryptography Course Dan Boneh.
Dan Boneh Authenticated Encryption Constructions from ciphers and MACs Online Cryptography Course Dan Boneh.
CSEN 1001 Computer and Network Security Amr El Mougy Mouaz ElAbsawi.
@Yuan Xue CS 285 Network Security Secure Socket Layer Yuan Xue Fall 2013.
Cryptography CSS 329 Lecture 13:SSL.
Network security Presentation AFZAAL AHMAD ABDUL RAZAQ AHMAD SHAKIR MUHAMMD ADNAN WEB SECURITY, THREADS & SSL.
Computer and Network Security
Cryptography and Network Security
Secure Sockets Layer (SSL)
Authenticated encryption
BINF 711 Amr El Mougy Sherif Ismail
Originally by Yu Yang and Lilly Wang Modified by T. A. Yang
CSE 4095 Transport Layer Security TLS, Part II
PRPs and PRFs CS255: Winter 2017
Cryptography Lecture 9.
Topic 11: Authenticated Encryption + CCA-Security
Cryptography and Network Security
Cryptography and Network Security
SSL (Secure Socket Layer)
Cryptography Lecture 11.
Cryptography and Network Security
Presentation transcript:

Authenticated Encryption and Cryptographic Network Protocols David Brumley Carnegie Mellon University

Some Straw Men 2

TCP/IP (highly abstracted) packet Destination Machine TCP/IP Stack Webserver (port = 80) dest=80data Bob (port = 25) 3 Source

Encrypted with CBC and random IV encrypted packets with key k Destination Machine Webserver (port = 80) dest=80msg a Bob (port = 25) msg b k k IV 1, dest=25msg b IV 2, 4 Source

Example Tampering Attack Encrypted with CBC and random IV encrypted packets with key k Destination Machine Webserver (port = 80) dest=80msg a Eve (port = 25) msg b k IV 1, dest=25msg a IV 2, Eve can change destination (easy with CBC and rand IV) 5 k Source

Example Tampering Attack Encrypted with CBC and random IV encrypted packets with key k Destination Machine Webserver (port = 80) dest=80msg a Eve (port = 25) msg b k IV 1, dest=1026msg a IV 2, Active Attacker Eve can change destination (easy with CBC and rand IV) 6 k Source

How? 7 dest=80msg a IV 1, dest=1026msg a IV 2, CBC encryption: D(k, c[0]) ⨁ IV 1 = “dest=80” Attack: IV 2 = IV 1 ⨁ ⨁ xor out “80” and xor in “1026” Eve

An Attack Using Only Network Access 8 Example: Remote terminal app where each keystroke encrypted with CTR mode IP HdrTCP Hdrcd Alice Bob 16 bit checksum keystroke ack if valid checksum, else nothing

An Attack Using Only Network Access {checksum(hdr, d) = t ⨁ checksum(hdr, d⨁s) } ⇒ Even can find d for many realistic checksums * 9 Example: Remote terminal app where each keystroke encrypted with CTR mode IP HdrTCP Hdrcd Alice Bob IP HdrTCP Hdrt cs d Eve 16 bit checksum keystroke ack if valid checksum, else nothing for all t and s * potentially not for TCP checksum

The Story So Far Confidentiality: semantic security against a CPA attack – Examples: Using CBC with a PRP, AES Integrity: security against existential forgery – Examples: CBC-MAC, NMAC, PMAC, HMAC Now: security against tampering – Integrity + Confidentiality! 10

The lesson CPA security cannot guarantee secrecy under active attacks. Integrity Only ✓ Secure MAC Integrity + Secrecy ✗ Secure MAC + Secure Cipher Integrity + Secrecy ✓ Authenticated Encryption 11

Motivating Question: Which is Best? E(k E, m||tag) S(k I, m) m Encryption Key = K E ; MAC key = k I Option 1: SSL (MAC-then-encrypt) mtagm S(k I, c)E(k E, m) m Option 2: IPsec (Encrypt-then-MAC) mmtag S(k I, m)E(k E, m) m Option 3: SSH (Encrypt-and-MAC) mmtag 12

Authenticated Encryption 13

An authenticated encryption system (E,D) is a cipher where As usual: E: K × M × N ⟶ C but D: K × C × N ⟶ M ∪{ ⊥ } Security: the system must provide – Semantic security under CPA attack, and – ciphertext integrity. The attacker cannot create a new ciphertext that decrypts properly. reject ciphertext as invalid 14

Chal.Adv A. kKkK c m 1  M c 1  E(k,m 1 ) b=1 if D(k,c) ≠ ⊥ and c  { c 1, …, c q } b=0 otherwise b m2m2, …, m q c2c2, …, c q Def: (E,D) has ciphertext integrity iff for all “ efficient ” A: Adv CI [A,I] = Pr [Chal. outputs 1] < ε 15 Ciphertext Integrity For b ={0,1}, define EXP(0) and EXP(1) as:

Authenticated Encryption Def: cipher (E,D) provides authenticated encryption (AE) if it is (1) semantically secure under CPA, and (2) has ciphertext integrity Counter-example: CBC with rand. IV does not provide AE – D(k, ⋅ ) never outputs ⊥, hence adv. always wins ciphertext integrity game 16

Implication 1: Authenticity Attacker cannot fool Bob into thinking a message was sent from Alice AliceBob k k m 1, …, m q c i = E(k, m i ) c Cannot create valid c ∉ { c 1, …, c q } ⇒ if D(k,c) ≠ ⊥ Bob guaranteed message is from someone who knows k (but could be a replay) Eve 17

Implication 2 Authenticated encryption ⇒ Security against chosen ciphertext attack 18

Chosen Ciphertext Attacks 19

Chosen Ciphertext Attacks Def: A CCA adversary has the capability to get ciphertexts of their choosing decrypted. 20 AliceBob k Eve k VPN c = E(k,m) m Eve sees c and m c’ m’ Don’t want them to learn m’... or even just whether an ACK occurred.

The Lunchtime CCA Attack 21 Alice’s Computer Encryption Program k Encrypted File 1 It’s Lunchtime! Encrypted File 2

The Lunchtime CCA Attack 22 Alice’s Computer Encryption Program k Eve’s Encrypted File 1 Eve’s Encrypted File 2 Encrypted File 1 Encrypted File 2 Eve

802.11b WEP: how not to do it k k m CRC(m) PRG( IV || k ) ciphertext IV 23

Active attacks Fact: CRC is linear, i.e. ∀m,p: CRC( m p) = CRC(m) F(p) dest-port = 80 data CRC IV WEP ciphertext: attacker: …..... XX … F(XX) ⨁ IV dest-port = 25 data CRC’ XX = 25⨁80 Upon decryption CRC is valid, but ciphertext is changed !! 24

Chosen Ciphertext Security Adversaries Power: both CPA and CCA – Can obtain the encryption of arbitrary messages – Can decrypt ciphertexts of his choice Adversaries Goal: break semantic security 25

CCA Game Definition 26 Let ENC = (E,D) over (K,M,C). For b = {0,1}, define EXP(0) and EXP(1) b Chal. k  K Adv. b’  {0,1} m i,0, m i,1  M : |m i,0 | = |m i,1 | c i  E(k, m i,b ) for i=1,…,q: (1) CPA query: c i  C : c i ∉ {c 1, …, c i-1 } m i  D(k, c i ) (2) CCA query: Ex: could query a changed c i

CCA Game Definition 27 Let ENC = (E,D) over (K,M,C). For b = {0,1}, define EXP(0) and EXP(1) b Chal. k  K Adv. b’  {0,1} m i,0, m i,1  M : |m i,0 | = |m i,1 | c i  E(k, m i,b ) for i=1,…,q: (1) CPA query: c i  C : c i ∉ {c 1, …, c i-1 } m i  D(k, c i ) (2) CCA query: ENC = (E,D) is CCA secure iff Adv[A,ENC] = |Pr[Exp(0) = 1] – Pr[Exp(1) = 1]| < ε

Example: CBC is not CCA Secure 28 Chal. k  K b Adv. m 0, m 1 : |m 0 | = |m 1 |=1 c  E(k, m b ) = (IV, c[0]) c’ = (IV⨁1, c[0]) D(k, c’) = m b ⨁1 b learns b

Thm: Let (E,D) be a cipher that provides AE. Then (E,D) is CCA secure ! In particular, for any q-query eff. A there exist eff. B 1, B 2 s.t. Adv CCA [A,E] ≤ 2q⋅Adv CI [B 1,E] + Adv CPA [B 2,E] 29 AE implies CCA security!

So What? Authenticated encryption assures security against: – A passive adversary (CPA security) – An active adversary that can even decrypt some ciphertexts (CCA security) Limitations: – Does not protect against replay – Assumes no other information other than message/ciphertext pairs can be learned. Timing attacks out of scope Power attacks out of scope... 30

AE Constructions Cipher + MAC = security 31

History Pre 2000: Crypto API’s provide separate MAC and encrypt primitives – Example: Microsoft Cryptographic Application Programming Interface (MS-CAPI) provided HMAC and CBC + IV – Every project had to combine primitives in their own way 2000: Authenticated Encryption – Bellare and Namprempre in Crypto, 2000 – Katz and Yung in FSE,

Motivating Question: Which is Best? Encryption Key = K E ; MAC key = k I E(k E, m||tag) S(k I, m) m Option 1: SSL (MAC-then-encrypt) mtagm S(k I, c)E(k E, m) m Option 2: IPsec (Encrypt-then-MAC) mmtag S(k I, m)E(k E, m) m Option 3: SSH (Encrypt-and-MAC) mmtag ✓ Always Correct 33

Theorems Let (E,D) by a CPA secure cipher and (S,V) a MAC secure against existential forgery. Then: 1.Encrypt-then-MAC always provides authenticated encryption 2.MAC-then-encrypt may be insecure against CCA attacks – however, when (E,D) is rand-CTR mode or rand- CBC, MAC-then-encrypt provides authenticated encryption 34

Standards GCM:CTR mode encryption then CW-MAC CCM:CBC-MAC then CTR mode (802.11i) EAX:CTR mode encryption then CMAC All are nonce-based. All support Authenticated Encryption with Associated Data (AEAD). 35 Associated Data Encrypted Data Authenticated

An example API (OpenSSL) int AES_GCM_Init(AES_GCM_CTX *ain, unsigned char * nonce, unsigned long noncelen, unsigned char * key, unsigned int klen ) int AES_GCM_EncryptUpdate(AES_GCM_CTX *a, unsigned char * aad, unsigned long aadlen, unsigned char * data, unsigned long datalen, unsigned char * out, unsigned long *outlen) 36

MAC Security -- an explanation Recall: MAC security required an attacker given (m, t) couldn’t find a different t’ such that (m,t’) is a valid MAC Why? Suppose not: (m, t) ⟶ (m, t’) Then Encrypt-then-MAC would not have Ciphertext Integrity !! Chal. k  K b Adv. m 0, m 1 c  E(k, m b ) = (c 0, t) c’ = (c 0, t’ ) ≠ c D(k, c’ ) = m b b (c 0, t) (c 0, t’) 37

Performance AE CipherCode SizeSpeed (MB/sec) Raw CipherRaw Speed AES/GCMLarge108AES/CTR139 AES/CCMsmaller61AES/CBC109 AES/EAXsmaller61AES/CMAC109 AES/OCB*small129HMAC/SHA * OCB mode may have patent issues. Speed extrapolated from Ted Kravitz’s results. From Crypto [Wei Dai]

Summary Encrypt-then-MAC Provides integrity of CT Plaintext integrity If cipher is malleable, we detect invalid CT MAC provides no information about PT since it’s over the encryption MAC-then-Encrypt No integrity of CT Plaintext integrity If cipher is malleable, can change message w/o detection MAC provides no information on PT since encrypted 39 Encrypt-and-MAC No integrity on CT Integrity of PT can be verified If cipher is malleable, contents of CT can be altered; should detect at PT level May reveal info about PT in the MAC (e.g., MAC of same messages are the same)

Wrapup Authenticated Encryption – Chosen Ciphertext Attack (CCA) and CCA-secure ciphers – AE game = CCA + CPA secure Encrypt-then-MAC always right – Don’t roll your own 40

41 Questions?

END

Case Study: TLS 43

Alice Public key Expiration Date Certificates bind a public key to a user 44

Alice Public key Expiration Date Certificate Authority (CA) binds certificate to person CA Signature Certificate parameters 45

Alice Alice Sends: User ID || public key || … 46

Alice Alice Generates and Gives: User ID || public key || … CA Computes: D=H( User ID || public key || …) Sig = Sign(D, CA private key) Gives Alice Sig 47

Alice Alice Generates and Gives: User ID || public key || … Certificate Authority (CA) CA Computes: D=H( User ID || public key || …) Sig = Sign(D, Serial, CA private key) Gives Alice Alice’s Certificate [User ID || public key || …] || CA Name || Serial || Sig || 48

X.509 Certificates 49

TLS and SSL Transport Layer Security (TLS) – Secure socket layer (SSL) predecessor – originally developed by Netscape – version 3 designed with public input – RFC 2246 Uses TCP to provide a reliable end-to-end service 50

Protocol Stack Telnet… IP TCP SSL Record Protocol Handshake Change Cipher Alert HTTP Application Layer SSL Transport Layer 51

Session Establishment Alice Bob.com 1. ClientHello Encrypt with symmetric cipher using shared secret 2. ServerHello 3. ClientKeyExchange Telnet… IP TCP SSL Record Protocol Handshake Change Cipher Alert HTTP supported MAC’s and ciphers 52

Protocol Record 53 Telnet… IP TCP SSL Record Protocol Handshake Change Cipher Alert HTTP Application Data Fragment... CompressMAC t Encrypt tthdr Prepend Hdr

Other Fields Change cipher: Re-initiate handshake protocol, e.g., to re- negotiate the keying material used for encryption Alert: Signal warning or fatal problem – Fatal: unexpected message, bad record mac, decompression failure, handshake failure, illegal parameter – Warning: close notify, no certificate, bad certificate, unsupported certificate, certificate revoked, certificate expired, certificate unknown Telnet… IP TCP SSL Record Protocol Handshake Change Cipher Alert HTTP 54

Detailed Protocol 55

TLS Crypto Unidirectional keys: k b⇾s, k s⇾b Stateful encryption: – Each side maintains two 64-bit counters: ctr b⇾s, ctr s⇾b – Init. to 0 when session started. ctr++ for every record. – Purpose: replay defense 56 Browser Server hdrrecord k b⇾s, k s⇾b

TLS Record Encryption TypeVersionLength Data... Tag Pad 57 (CBC AES-128, HMAC-SHA1) TLS Record k b⇾s = (k mac, k enc ) Browser side enc(k bs, data, ctr bs ) : step 1: tag ⟵ S( k mac, [ ++ctr b⇾s || header || data ] ) step 2: pad [ header || data || tag ] to AES block size step 3: CBC encrypt with k enc and new random IV step 4: prepend header

TLS Record Decryption 58 (CBC AES-128, HMAC-SHA1) Server side dec(k bs, record, ctr bs ) : step 1: CBC decrypt record using k enc step 2: check pad format, send bad_record_mac if invalid step 3: check tag on [ ++ctr b⇾s || header || data] send bad_record_mac if invalid Provides authenticated encryption (provided no other info. is leaked during decryption)

TLS Record Decryption 59 (CBC AES-128, HMAC-SHA1) Server side dec(k bs, record, ctr bs ) : step 1: CBC decrypt record using k enc step 2: check pad format, send decryption_failed if invalid step 3: check tag on [ ++ctr b⇾s || header || data] send bad_record_mac if invalid V1.1 Bug: Only difference is error messages

Padding Oracles 60 Server side dec(k bs, record, ctr bs ) : step 1: CBC decrypt record using k enc step 2: check pad format, abort if invalid step 3: check tag, abort if invalid Two different types of errors: bad pad vs bad MAC Padding Attack: Attacker submits ciphertext and learns if last byte of plaintext are a valid pad

Credit: Brice Canvel Fixed in OpenSSL 0.9.7a In older TLS 1.0: padding oracle due to different alert messages. MAC errorpad error 61

TLS Padding Valid paddings: – 0x01 for 1 byte padding – 0x02 0x02 for 2 byte padding – 0x03 0x03 0x03 for 3 byte padding – TypeVersionLength Data... Tag Pad

Using a Padding Oracle with CBC Example: Attacker has ciphertext c = (c[0], c[1], c[2]) and wants m[1]. We’ll show you how to get last byte of m[1]. (Full break possible) 63 D(k,  ) m[0]m[1] m[2] || pad  D(k,  )  c[0]c[1]c[2]IV

Step 1: Throw Away c[2] 64 D(k,  ) m[0]m[1]  c[0]c[1]IV

Step 2: Guess and Check if Padding Valid 65 D(k,  ) m[0]m[1]  c[0]c[1]IV = last-byte ⨁ g ⨁ 0x01 if last-byte = g: valid pad otherwise: invalid pad ⨁ g ⨁ 0x01 Let g be our guess for the last byte of m[1] *note MAC will fail, but we get the byte.

Using a Padding Oracle Attack: submit ( IV, c’[0], c[1] ) to padding oracle ⇒ attacker learns if last byte = g Repeat with g = 0,1, …, 255 to learn last byte of m[1] Then use a (0x02, 0x02) pad to learn the next byte and so on … 66

Another TLS Bug Prior to 1.1 IV for CBC is predictable using chained IV – IV for next record is last ciphertext block of current record. – Not CPA secure (see block cipher lecture). BEAST attack is a practical implementation 67

Other Problems The TLS header leaks the length of TLS records Lengths can also be inferred by observing network traffic For many web applications, leaking lengths reveals sensitive info: In tax preparation sites, lengths indicate the type of return being filed which leaks information about the user’s income In healthcare sites, lengths leaks what page the user is viewing In Google maps, lengths leaks the location being requested No easy solution 68

Lesson 1.Encrypt-then-MAC would completely avoid many problem. – MAC is checked first and ciphertext discarded if invalid 2.MAC-then-CBC provides Authenticated Encryption, but padding oracle destroys it 69

Certificate Revocation What to do if your keys are compromised. 70

Certificate Revocation Alice Bob 1. ClientHello 2. ServerHello (send cert., e.g., pub key e) 1.Check CA signature on key Accept key What needs to happen here? 71

Certificate Revocation Alice Bob 1. ClientHello 2. ServerHello (send cert., e.g., pub key e)  Verification protocol Verification Authority 72

Certificate Verification Protocols Expiration Date Certificate Revocation Lists (CRL) and Certificate Revocation Trees (CRT) OCSP – Online Cert Status Protocol 73

Efficient Certificate Revocation Lists (kocher98) 74 Verification Authority  Alice VA creates CRL and signs using private key. Note key very powerful. Replica Signed CRL Query Replicas Note no private keys on server

Certificate Revocation Tree Generation C1C1 C2C2 C3C3 C4C4 C i-1 CiCi … Revoked cert C j sorted by serial hh h hh h VASig = Sign(H root, VA signing key) H1H1 H2H2 H3H3 H4H4 H5H5 H6H6 H root Verification Authority  75

Alice 1. Is Bob’s Cert C 2 revoked 2. [C 1, H 2, H 6, VASig] 3. Alice validates C 2 by: H’ root =H(H(C 1, C 2 ), H 2, H 6 ) H’ =?= H VA Sig valid? Size of Proof: O(log i) VA Replica Signed CRL 76

Online Cert Status Protocol Alice 1. Request(Bob’s Cert) 2. Check DB 3. Response( Sign(Bob’s Cert {OK,BAD}) VA Signing Key ) Verification Authority  Implemented in IE7 (Vista+), Firefox, Safari (by default Lion+), Opera, Chrome 77