Скачать презентацию Lecture 21 Secure Communications CPE 401 601 Computer Network Скачать презентацию Lecture 21 Secure Communications CPE 401 601 Computer Network

942c2cb9a0e9d7a8a42dd4b906e13c21.ppt

  • Количество слайдов: 47

Lecture 21 Secure Communications CPE 401/601 Computer Network Systems All material copyright 1996 -2009 Lecture 21 Secure Communications CPE 401/601 Computer Network Systems All material copyright 1996 -2009 J. F Kurose and K. W. Ross, All Rights Reserved slides are modified from Jim Kurose & Keith Ross

Chapter 8 roadmap 8. 1 What is network security? 8. 2 Principles of cryptography Chapter 8 roadmap 8. 1 What is network security? 8. 2 Principles of cryptography 8. 3 Message integrity 8. 4 Securing e-mail 8. 5 Securing TCP connections: SSL 8. 6 Network layer security: IPsec 8. 7 Securing wireless LANs 8. 8 Operational security: firewalls and IDS

SSL: Secure Sockets Layer r Widely deployed security protocol m m m Supported by SSL: Secure Sockets Layer r Widely deployed security protocol m m m Supported by almost all browsers and web servers https Tens of billions $ spent per year over SSL r Originally designed by Netscape in 1993 r Number of variations: m TLS: transport layer security, RFC 2246 r Provides m Confidentiality m Integrity m Authentication r Original goals: m Had Web e-commerce transactions in mind m Encryption (especially credit-card numbers) m Web-server authentication m Optional client authentication m Minimum hassle in doing business with new merchant r Available to all TCP applications m Secure socket interface 3

SSL and TCP/IP Application TCP Application SSL TCP IP IP Normal Application with SSL SSL and TCP/IP Application TCP Application SSL TCP IP IP Normal Application with SSL • SSL provides application programming interface (API) to applications • C and Java SSL libraries/classes readily available 4

Could do something like PGP: m . H( ) KA - . K A( Could do something like PGP: m . H( ) KA - . K A( ) - KA(H(m)) + . K S( ) m KS KS + . K B( ) K+ B + Internet + KB(KS ) • But want to send byte streams & interactive data • Want a set of secret keys for the entire connection • Want certificate exchange part of protocol: handshake phase 5

Toy SSL: a simple secure channel r Handshake: Alice and Bob use their certificates Toy SSL: a simple secure channel r Handshake: Alice and Bob use their certificates and private keys to authenticate each other and exchange shared secret r Key Derivation: Alice and Bob use shared secret to derive set of keys r Data Transfer: Data to be transferred is broken up into a series of records r Connection Closure: Special messages to securely close connection 6

Toy: A simple handshake hello certificate KB +(MS) = EMS r MS = master Toy: A simple handshake hello certificate KB +(MS) = EMS r MS = master secret r EMS = encrypted master secret 7

Toy: Key derivation r Considered bad to use same key for more than one Toy: Key derivation r Considered bad to use same key for more than one cryptographic operation m Use different keys for message authentication code (MAC) and encryption r Four keys: m Kc = encryption key for data sent from client to server m Mc = MAC key for data sent from client to server m Ks = encryption key for data sent from server to client m Ms = MAC key for data sent from server to client r Keys derived from key derivation function (KDF) m Takes master secret and (possibly) some additional random data and creates the keys 8

Toy: Data Records r Why not encrypt data in constant stream as we write Toy: Data Records r Why not encrypt data in constant stream as we write it to TCP? m m Where would we put the MAC? If at end, no message integrity until all data processed. For example, with instant messaging, how can we do integrity check over all bytes sent before displaying? r Instead, break stream in series of records m Each record carries a MAC m Receiver can act on each record as it arrives r Issue: in record, receiver needs to distinguish MAC from data m Want to use variable-length records length data MAC 9

Toy: Sequence Numbers r Attacker can capture and replay record or re-order records r Toy: Sequence Numbers r Attacker can capture and replay record or re-order records r Solution: put sequence number into MAC: m MAC = MAC(Mx, sequence||data) m Note: no sequence number field r Attacker could still replay all of the records m Use random nonce 10

Toy: Control information r Truncation attack: m attacker forges TCP connection close segment m Toy: Control information r Truncation attack: m attacker forges TCP connection close segment m One or both sides thinks there is less data than there actually is. r Solution: record types, with one type for closure m type 0 for data; type 1 for closure r MAC = MAC(Mx, sequence||type||data) length type data MAC 11

Toy SSL: summary hello ce certificate, non KB +(MS) = EMS type 0, seq Toy SSL: summary hello ce certificate, non KB +(MS) = EMS type 0, seq 1, data encrypted type 0, seq 2, data bob. com ta 1, da pe 0, seq ty type 0, seq 3, data type 1, seq 4, close type 1, seq 2 12

Toy SSL isn’t complete r How long are the fields? r What encryption protocols? Toy SSL isn’t complete r How long are the fields? r What encryption protocols? r No negotiation m Allow client and server to support different encryption algorithms m Allow client and server to choose together specific algorithm before data transfer 13

Most common symmetric ciphers in SSL r DES – Data Encryption Standard: block r Most common symmetric ciphers in SSL r DES – Data Encryption Standard: block r 3 DES – Two keys: block r RC 2 – Rivest Cipher 2: block r RC 4 – Rivest Cipher 4: stream Public key encryption r RSA 14

SSL Cipher Suite r Cipher Suite m Public-key algorithm m Symmetric encryption algorithm m SSL Cipher Suite r Cipher Suite m Public-key algorithm m Symmetric encryption algorithm m MAC algorithm r SSL supports a variety of cipher suites r Negotiation: client and server must agree on cipher suite r Client offers choice; server picks one 15

Real SSL: Handshake (1) Purpose 1. Server authentication 2. Negotiation: agree on crypto algorithms Real SSL: Handshake (1) Purpose 1. Server authentication 2. Negotiation: agree on crypto algorithms 3. Establish keys 4. Client authentication (optional) 16

Real SSL: Handshake (2) 1. 2. 3. 4. 5. 6. Client sends list of Real SSL: Handshake (2) 1. 2. 3. 4. 5. 6. Client sends list of algorithms it supports, along with client nonce Server chooses algorithms from list; sends back: choice + certificate + server nonce Client verifies certificate, extracts server’s public key, generates pre_master_secret, encrypts with server’s public key, sends to server Client and server independently compute encryption and MAC keys from pre_master_secret and nonces Client sends a MAC of all the handshake messages Server sends a MAC of all the handshake messages 17

Real SSL: Handshaking (3) Last 2 steps protect handshake from tampering r Client typically Real SSL: Handshaking (3) Last 2 steps protect handshake from tampering r Client typically offers range of algorithms, some strong, some weak r Man-in-the middle could delete the stronger algorithms from list r Last 2 steps prevent this m Last two messages are encrypted 18

Real SSL: Handshaking (4) r Why the two random nonces? r Suppose Trudy sniffs Real SSL: Handshaking (4) r Why the two random nonces? r Suppose Trudy sniffs all messages between Alice & Bob. r Next day, Trudy sets up TCP connection with Bob, sends the exact same sequence of records, . m Bob (Amazon) thinks Alice made two separate orders for the same thing. m Solution: Bob sends different random nonce for each connection. This causes encryption keys to be different on the two days. m Trudy’s messages will fail Bob’s integrity check. 19

SSL Record Protocol data fragment record header data fragment MAC encrypted data and MAC SSL Record Protocol data fragment record header data fragment MAC encrypted data and MAC record header: content type; version; length MAC: includes sequence number, MAC key Mx Fragment: each SSL fragment 224 bytes (~16 Kbytes) 20

SSL Record Format 1 byte content type 2 bytes 3 bytes SSL version length SSL Record Format 1 byte content type 2 bytes 3 bytes SSL version length data MAC Data and MAC encrypted (symmetric algo) 21

Real Connection handshake: Client. Hel lo er. Hello hake: Serv hands rtificate dshake: Ce Real Connection handshake: Client. Hel lo er. Hello hake: Serv hands rtificate dshake: Ce han ello. Done e: Server. H handshake: Client. Key Exchange Change. Cipher. Sp ec handshake: Finished Everything henceforth is encrypted r. Spec Change. Ciphe inished dshake: F han application_data application_d TCP Fin follow Alert: warning, close_ notify 22

Key derivation r Client nonce, server nonce, and pre-master secret input into pseudo random-number Key derivation r Client nonce, server nonce, and pre-master secret input into pseudo random-number generator. m Produces master secret r Master secret and new nonces inputed into another random-number generator: “key block” m Because of resumption: TBD r Key block sliced and diced: m client MAC key m server MAC key m client encryption key m server encryption key m client initialization vector (IV) m server initialization vector (IV) 23

Chapter 8 roadmap 8. 1 What is network security? 8. 2 Principles of cryptography Chapter 8 roadmap 8. 1 What is network security? 8. 2 Principles of cryptography 8. 3 Message integrity 8. 4 Securing e-mail 8. 5 Securing TCP connections: SSL 8. 6 Network layer security: IPsec 8. 7 Securing wireless LANs 8. 8 Operational security: firewalls and IDS

What is confidentiality at the network-layer? Between two network entities: r Sending entity encrypts What is confidentiality at the network-layer? Between two network entities: r Sending entity encrypts the payloads of datagrams. Payload could be: m TCP segment, UDP segment, ICMP message, OSPF message, and so on. r All data sent from one entity to the other would be hidden: m Web pages, e-mail, P 2 P file transfers, TCP SYN packets, and so on. r That is, “blanket coverage”. 25

Virtual Private Networks (VPNs) r Institutions often want private networks for security. m Costly! Virtual Private Networks (VPNs) r Institutions often want private networks for security. m Costly! Separate routers, links, DNS infrastructure. r With a VPN, institution’s inter-office traffic is sent over public Internet instead. m But inter-office traffic is encrypted before entering public Internet 26

Virtual Private Network (VPN) IP header IPsec header Secure payload IP er ad ec Virtual Private Network (VPN) IP header IPsec header Secure payload IP er ad ec IPs der a he IPsec heade r laptop w/ IPsec salesperson in hotel he Secur e payloa d Public Internet IP heade r re cu Se load y pa IP er ad pay Router w/ IPv 4 and IPsec he loa d Router w/ IPv 4 and IPsec ylo IP hea der pa ad headquarters branch office 27

IPsec services r Data integrity r Origin authentication r Replay attack prevention r Confidentiality IPsec services r Data integrity r Origin authentication r Replay attack prevention r Confidentiality r Two protocols providing different service models: m AH m ESP 28

IPsec Transport Mode IPsec r IPsec datagram emitted and received by end-system. r Protects IPsec Transport Mode IPsec r IPsec datagram emitted and received by end-system. r Protects upper level protocols 29

IPsec – tunneling mode (1) IPsec r End routers are IPsec aware. Hosts need IPsec – tunneling mode (1) IPsec r End routers are IPsec aware. Hosts need not be. 30

IPsec – tunneling mode (2) IPsec r Also tunneling mode. 31 IPsec – tunneling mode (2) IPsec r Also tunneling mode. 31

Two protocols r Authentication Header (AH) protocol m provides source authentication & data integrity Two protocols r Authentication Header (AH) protocol m provides source authentication & data integrity but not confidentiality r Encapsulation Security Protocol (ESP) m provides source authentication, data integrity, and confidentiality m more widely used than AH 32

Four combinations are possible! Host mode with AH Host mode with ESP Tunnel mode Four combinations are possible! Host mode with AH Host mode with ESP Tunnel mode with AH Tunnel mode with ESP Most common and most important 33

Security associations (SAs) r Before sending data, a virtual connection is established from sending Security associations (SAs) r Before sending data, a virtual connection is established from sending entity to receiving entity. r Called “security association (SA)” m SAs are simplex: for only one direction r Both sending and receiving entites maintain state information about the SA m m Recall that TCP endpoints also maintain state information. IP is connectionless; IPsec is connection-oriented! r How many SAs in VPN w/ headquarters, branch office, and n traveling salesperson? 34

Example SA from R 1 to R 2 Internet Headquarters 200. 168. 1. 100 Example SA from R 1 to R 2 Internet Headquarters 200. 168. 1. 100 R 1 172. 16. 1/24 SA Branch Office 193. 68. 2. 23 R 2 172. 16. 2/24 R 1 stores for SA r 32 -bit identifier for SA: Security Parameter Index (SPI) r the origin interface of the SA (200. 168. 1. 100) r destination interface of the SA (193. 68. 2. 23) r type of encryption to be used (for example, 3 DES with CBC) r encryption key r type of integrity check (for example, HMAC with MD 5) r authentication key 35

Security Association Database (SAD) r Endpoint holds state of its SAs in a SAD, Security Association Database (SAD) r Endpoint holds state of its SAs in a SAD, where it can locate them during processing. r With n salespersons, 2 + 2 n SAs in R 1’s SAD r When sending IPsec datagram, R 1 accesses SAD to determine how to process datagram. r When IPsec datagram arrives to R 2, R 2 examines SPI in IPsec datagram, indexes SAD with SPI, and processes datagram accordingly. 36

IPsec datagram Focus for now on tunnel mode with ESP “enchilada” authenticated encrypted new IPsec datagram Focus for now on tunnel mode with ESP “enchilada” authenticated encrypted new IP header ESP hdr SPI original IP hdr Seq # Original IP datagram payload padding ESP trl ESP auth pad next length header 37

What happens? Internet Headquarters 200. 168. 1. 100 SA Branch Office 193. 68. 2. What happens? Internet Headquarters 200. 168. 1. 100 SA Branch Office 193. 68. 2. 23 R 1 R 2 172. 16. 1/24 172. 16. 2/24 “enchilada” authenticated encrypted new IP header ESP hdr SPI original IP hdr Seq # Original IP datagram payload padding ESP trl ESP auth pad next length header 38

R 1 converts original datagram into IPsec datagram r Appends to back of original R 1 converts original datagram into IPsec datagram r Appends to back of original datagram (which includes r r r original header fields!) an “ESP trailer” field. Encrypts result using algorithm & key specified by SA. Appends to front of this encrypted quantity the “ESP header, creating “enchilada”. Creates authentication MAC over the whole enchilada, using algorithm and key specified in SA; Appends MAC to back of enchilada, forming payload; Creates brand new IP header, with all the classic IPv 4 header fields, which it appends before payload. 39

Inside the enchilada: “enchilada” authenticated encrypted new IP header ESP hdr SPI original IP Inside the enchilada: “enchilada” authenticated encrypted new IP header ESP hdr SPI original IP hdr Seq # Original IP datagram payload padding ESP trl ESP auth pad next length header r ESP trailer: Padding for block ciphers r ESP header: m SPI, so receiving entity knows what to do m Sequence number, to thwart replay attacks r MAC in ESP auth field is created with shared secret key 40

IPsec sequence numbers r For new SA, sender initializes seq. # to 0 r IPsec sequence numbers r For new SA, sender initializes seq. # to 0 r Each time datagram is sent on SA: m Sender increments seq # counter m Places value in seq # field r Goal: m Prevent attacker from sniffing and replaying a packet • Receipt of duplicate, authenticated IP packets may disrupt service r Method: m Destination checks for duplicates m But doesn’t keep track of ALL received packets; instead uses a window 41

Security Policy Database (SPD) r Policy: For a given datagram, sending entity needs to Security Policy Database (SPD) r Policy: For a given datagram, sending entity needs to know if it should use IPsec. r Needs also to know which SA to use m May use: source and destination IP address; protocol number. r Info in SPD indicates “what” to do with arriving datagram; r Info in the SAD indicates “how” to do it. 42

Summary: IPsec services r Suppose Trudy sits somewhere between R 1 and R 2. Summary: IPsec services r Suppose Trudy sits somewhere between R 1 and R 2. She doesn’t know the keys. m Will Trudy be able to see contents of original datagram? m How about source, dest IP address, transport protocol, application port? m Flip bits without detection? m Masquerade as R 1 using R 1’s IP address? m Replay a datagram? 43

Internet Key Exchange r In previous examples, we manually established IPsec SAs in IPsec Internet Key Exchange r In previous examples, we manually established IPsec SAs in IPsec endpoints: Example SA SPI: 12345 Source IP: 200. 168. 1. 100 Dest IP: 193. 68. 2. 23 Protocol: ESP Encryption algorithm: 3 DES-cbc HMAC algorithm: MD 5 Encryption key: 0 x 7 aeaca… HMAC key: 0 xc 0291 f… r Such manually keying is impractical for large VPN with, say, hundreds of sales people. r Instead use IPsec IKE (Internet Key Exchange) 44

IKE: PSK and PKI r Authentication (proof who you are) with either m pre-shared IKE: PSK and PKI r Authentication (proof who you are) with either m pre-shared secret (PSK) or m with PKI (pubic/private keys and certificates). r With PSK, both sides start with secret: m then run IKE to authenticate each other and to generate IPsec SAs (one in each direction), including encryption and authentication keys r With PKI, both sides start with public/private key pair and certificate. m run IKE to authenticate each other and obtain IPsec SAs (one in each direction). m Similar with handshake in SSL. 45

IKE Phases r IKE has two phases m Phase 1: Establish bi-directional IKE SA IKE Phases r IKE has two phases m Phase 1: Establish bi-directional IKE SA • Note: IKE SA different from IPsec SA • Also called ISAKMP security association m Phase 2: ISAKMP is used to securely negotiate the IPsec pair of SAs r Phase 1 has two modes: aggressive mode and main mode m Aggressive mode uses fewer messages m Main mode provides identity protection and is more flexible 46

Summary of IPsec r IKE message exchange for algorithms, secret r r keys, SPI Summary of IPsec r IKE message exchange for algorithms, secret r r keys, SPI numbers Either the AH or the ESP protocol (or both) The AH protocol provides integrity and source authentication The ESP protocol (with AH) additionally provides encryption IPsec peers can be two end systems, two routers/firewalls, or a router/firewall and an end system 47