Internet-Technologien (CS262) Netzwerksicherheit: Anwendungen 22. Mai 2015 Christian Tschudin & Thomas Meyer Departement Mathematik und Informatik, Universität Basel Chapter 8 Security in Computer Networks (with changes CS262 UniBasel, 2015) A note on the use of these ppt slides: We re making these slides freely available to all (faculty, students, readers). They re in PowerPoint form so you can add, modify, and delete slides (including this one) and slide content to suit your needs. They obviously represent a lot of work on our part. In return for use, we only ask the following: If you use these slides (e.g., in a class) in substantially unaltered form, that you mention their source (after all, we d like people to use our book!) If you post any slides in substantially unaltered form on a www site, that you note that they are adapted from (or perhaps identical to) our slides, and note our copyright of this material. Thanks and enjoy! JFK/KWR All material copyright 1996-2010 J.F Kurose and K.W. Ross, All Rights Reserved Computer Networking: A Top Down Approach, International Version, 5 th edition. Jim Kurose, Keith Ross Pearson Addison-Wesley, March 2009. CS262 FS15 Netzwerksicherheit: Anwendungen 2
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 CS262 FS15 Netzwerksicherheit: Anwendungen 3 Secure e-mail Alice wants to send confidential e-mail, m, to Bob. m K S K S (. ) K S (m ) K S (m ) K S.( ) m K S + K B (. ) K+ B K+ B (K S ) + Internet - + K B (K S ) K B - K S -. K B ( ) Alice: generates random symmetric private key, K S encrypts message with K S (for efficiency) also encrypts K S with Bob s public key sends both K S (m) and K B (K S ) to Bob CS262 FS15 Netzwerksicherheit: Anwendungen 4
Secure e-mail Alice wants to send confidential e-mail, m, to Bob. m K S K S (. ) K S (m ) K S (m ) K S.( ) m K S + K B (. ) K+ B K+ B (K S ) + Internet - + K B (K S ) K B - K S -. K B ( ) Bob: uses his private key to decrypt and recover K S uses K S to decrypt K S (m) to recover m CS262 FS15 Netzwerksicherheit: Anwendungen 5 Secure e-mail (continued) Alice wants to provide sender authentication, message integrity m K A - H(.) K A ( ) -. K A - (H(m)) K- A (H(m)) K A + K+ A (. ) H(m ) + - Internet compare m m H(.) H(m ) Alice digitally signs message sends both message (in the clear) and digital signature CS262 FS15 Netzwerksicherheit: Anwendungen 6
Secure e-mail (continued) Alice wants to provide secrecy, sender authentication, message integrity. - m m K A H(.) K A ( ) -. K- A (H(m)) + K S K S.( ) K+ B (. ) K+ B Alice uses three keys: her private key, Bob s public key, newly created symmetric key K S + + K B (K S ) Internet CS262 FS15 Netzwerksicherheit: Anwendungen 7 Pretty Good Privacy (PGP), GPG Written by Phil Zimmerman (1991) De facto e-mail encryption scheme Available for your favorite mail client Similar to the designe showed before: message digests: MD5/SHA symmetric key encryption: CAST, 3DES, IDEA public key encryption: RSA No certification authority Users mutually sign their keys private key rings public key rings (stored in so called key servers on the web) CS262 FS15 Netzwerksicherheit: Anwendungen 8
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 CS262 FS15 Netzwerksicherheit: Anwendungen 9 SSL: Secure Sockets Layer widely deployed security protocol supported by almost all browsers, web servers https billions $/year over SSL original design: Netscape, 1993 variation TLS: transport layer security, RFC 2246 provides confidentiality integrity authentication original goals: Web e-commerce transactions encryption (especially credit-card numbers) Web-server authentication optional client authentication minimum hassle in doing business with new merchant available to all TCP applications secure socket interface CS262 FS15 Netzwerksicherheit: Anwendungen 10
SSL and TCP/IP Application TCP Socket TCP IP Normal Application Application SSL Socket SSL Sublayer TCP Socket TCP IP Application with SSL SSL provides application programming interface (API) to applications C and Java SSL libraries/classes readily available CS262 FS15 Netzwerksicherheit: Anwendungen 11 Could do something like PGP: m K A - H(.) K A ( ) -. K- A (H(m)) + K S (. ) K S m K S + K B (. ) K B + + K B + (K S ) Internet but want to send byte streams & interactive data want set of secret keys for entire connection want certificate exchange as part of protocol: handshake phase CS262 FS15 Netzwerksicherheit: Anwendungen 12
Toy SSL: a simple secure channel handshake: Alice and Bob use their certificates, private keys to authenticate each other and exchange shared secret key derivation: Alice and Bob use shared secret to derive set of keys data transfer: data to be transferred is broken up into series of records connection closure: special messages to securely close connection CS262 FS15 Netzwerksicherheit: Anwendungen 13 Toy SSL: A simple handshake MS = master secret EMS = encrypted master secret CS262 FS15 Netzwerksicherheit: Anwendungen 14
Toy SSL: Key derivation It is considered bad practice to use same key for more than one cryptographic operation use different keys for message authentication code (MAC) and encryption four keys: K c = encryption key for data sent from client to server M c = MAC key for data sent from client to server K s = encryption key for data sent from server to client M s = MAC key for data sent from server to client keys derived from key derivation function (KDF) takes master secret and (possibly) some additional random data and creates the keys CS262 FS15 Netzwerksicherheit: Anwendungen 15 Toy SSL: Data Records why not encrypt data in constant stream as we write it to TCP? where would we put the MAC? If at end, no message integrity until all data processed. E.g., with instant messaging, how can we do integrity check over all bytes sent before displaying? instead, break stream in series of records Each record carries a MAC Receiver can act on each record as it arrives issue: in record, receiver needs to distinguish MAC from data want to use variable-length records length data MAC CS262 FS15 Netzwerksicherheit: Anwendungen 16
Toy SSL: Sequence Numbers attacker can capture and replay the record, or can re-order records solution: put sequence number into MAC: MAC = MAC(M x, sequence data) Note: no sequence number field needed, it s now implicit attacker could still replay all of the records use random nonce CS262 FS15 Netzwerksicherheit: Anwendungen 17 Toy SSL: Control information truncation attack: attacker forges TCP connection close segment One or both sides thinks there is less data than there actually is. solution: record types, with one type for closure type 0 for data; type 1 for closure MAC = MAC(M x, sequence type data) length type data MAC CS262 FS15 Netzwerksicherheit: Anwendungen 18
Toy SSL: summary bob.com encrypted CS262 FS15 Netzwerksicherheit: Anwendungen 19 Toy SSL isn t complete how long are fields? which encryption protocols? want negotiation? allow client and server to support different encryption algorithms allow client and server to choose together specific algorithm before data transfer CS262 FS15 Netzwerksicherheit: Anwendungen 20
SSL Cipher Suite cipher suite public-key algorithm symmetric encryption algorithm MAC algorithm SSL supports several cipher suites negotiation: client, server agree on cipher suite client offers choice server picks one Common SSL symmetric ciphers DES Data Encryption Standard: block 3DES Triple strength: block RC2 Rivest Cipher 2: block RC4 Rivest Cipher 4: stream SSL Public key encryption RSA CS262 FS15 Netzwerksicherheit: Anwendungen 21 Real SSL: Handshake (1) Purpose 1. server authentication 2. negotiation: agree on crypto algorithms 3. establish keys 4. client authentication (optional) CS262 FS15 Netzwerksicherheit: Anwendungen 22
Real SSL: Handshake (2) 1. client sends list of algorithms it supports, along with random client nonce (28 bytes) 2. server chooses algorithms from list; sends back: choice + certificate + server nonce 3. client verifies certificate, extracts server s public key, generates pre_master_secret, encrypts with server s public key, sends to server 4. client and server independently compute encryption and MAC keys from pre_master_secret and nonces 5. client sends a MAC of all the handshake messages 6. server sends a MAC of all the handshake messages CS262 FS15 Netzwerksicherheit: Anwendungen 23 Real SSL: Handshaking (3) last 2 steps protect handshake from tampering client typically offers range of algorithms, some strong, some weak man-in-the middle could delete stronger algorithms from list last 2 steps prevent this Last two messages are encrypted CS262 FS15 Netzwerksicherheit: Anwendungen 24
Real SSL: Handshaking (4) why two random nonces? suppose Trudy sniffs all messages between Alice & Bob next day, Trudy sets up TCP connection with Bob, sends exact same sequence of records Bob (Amazon) thinks Alice made two separate orders for the same thing solution: Bob sends different random nonce for each connection. This causes encryption keys to be different on the two days Trudy s messages will fail Bob s integrity check CS262 FS15 Netzwerksicherheit: Anwendungen 25 SSL Record Protocol data data fragment MAC data fragment MAC record header encrypted data and MAC record header encrypted data and MAC record header: content type; version; length MAC: includes sequence number, MAC key M x fragment: each SSL fragment 2 14 bytes (~16 Kbytes) CS262 FS15 Netzwerksicherheit: Anwendungen 26
SSL Record Format 1 byte 2 bytes 3 bytes content type SSL version length data MAC data and MAC encrypted (symmetric algorithm) CS262 FS15 Netzwerksicherheit: Anwendungen 27 Real Connection Everything henceforth is encrypted TCP Fin follow CS262 FS15 Netzwerksicherheit: Anwendungen 28
General Lesson: 3 things needed We started with a toolbox of mechanisms: - encryption algorithms - hash function which permit to implement basic security services: - confidentiality - authenticity - non-repudation etc Mechanisms are not enough, we also need security protocols - to tie together the mechanims, prevent some attacks outside mechanisms (e.g. man-in-the-middle) - to enforce good practice (how to choose IVs, keys, etc) CS262 FS15 Netzwerksicherheit: Anwendungen 29 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 CS262 FS15 Netzwerksicherheit: Anwendungen 30
What is network-layer confidentiality? between two network entities: sending entity encrypts datagram payload, payload could be: TCP or UDP segment, ICMP message, OSPF message. all data sent from one entity to other would be hidden: web pages, e-mail, P2P file transfers, TCP SYN packets blanket coverage CS262 FS15 Netzwerksicherheit: Anwendungen 31 Virtual Private Networks (VPNs) institutions often want private networks for security. costly: separate routers, links, DNS infrastructure. VPN: institution s inter-office traffic is sent over public Internet instead encrypted before entering public Internet logically separate from other traffic e.g. home access to private Unibas network CS262 FS15 Netzwerksicherheit: Anwendungen 32
Virtual Private Network (VPN) Public Internet IP header IPsec header Secure payload laptop w/ IPsec salesperson in hotel Router w/ IPv4 and IPsec Router w/ IPv4 and IPsec headquarters branch office CS262 FS15 Netzwerksicherheit: Anwendungen 33 IPsec services data integrity origin authentication replay attack prevention confidentiality two protocols providing different service models: AH (Authentication Header) ESP (Encapsulation Security Protocol) CS262 FS15 Netzwerksicherheit: Anwendungen 34
IPsec Transport Mode IPsec IPsec IPsec datagram emitted and received by endsystem protects upper level protocols CS262 FS15 Netzwerksicherheit: Anwendungen 35 IPsec tunneling mode IPsec IPsec IPsec IPsec edge routers IPsecaware hosts IPsec-aware CS262 FS15 Netzwerksicherheit: Anwendungen 36
Two protocols Authentication Header (AH) protocol provides source authentication & data integrity but not confidentiality Encapsulation Security Protocol (ESP) provides source authentication, data integrity, and confidentiality more widely used than AH Four combinations are possible! CS262 FS15 Netzwerksicherheit: Anwendungen 37 Host mode with AH Host mode with ESP Tunnel mode with AH Tunnel mode with ESP most common and most important CS262 FS15 Netzwerksicherheit: Anwendungen 38
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 CS262 FS15 Netzwerksicherheit: Anwendungen 53 WEP Design Goals symmetric key crypto confidentiality end host authorization data integrity self-synchronizing: each packet separately encrypted given encrypted packet and key, can decrypt; can continue to decrypt packets when preceding packet was lost (unlike Cipher Block Chaining (CBC) in block ciphers) efficient can be implemented in hardware or software CS262 FS15 Netzwerksicherheit: Anwendungen 54
Review: Symmetric Stream Ciphers key keystream generator keystream combine each byte of keystream with byte of plaintext to get ciphertext m(i) = ith unit of message ks(i) = ith unit of keystream c(i) = ith unit of ciphertext c(i) = ks(i) m(i) ( = exclusive or) m(i) = ks(i) c(i) WEP uses RC4 CS262 FS15 Netzwerksicherheit: Anwendungen 55 Stream cipher and packet independence recall design goal: each packet separately encrypted if for frame n+1, use keystream from where we left off for frame n, then each frame is not separately encrypted need to know where we left off for packet n WEP approach: initialize keystream with key + new IV for each packet: Key+IV packet keystream generator keystream packet CS262 FS15 Netzwerksicherheit: Anwendungen 56
WEP encryption (1) sender calculates Integrity Check Value (ICV) over data four-byte hash/crc for data integrity each side has 104-bit shared key sender creates 24-bit initialization vector (IV), appends to key: gives 128-bit key sender also appends keyid (in 8-bit field) 128-bit key inputted into pseudo random number generator to get keystream data in frame + ICV is encrypted with RC4: Bytes of keystream are XORed with bytes of data & ICV IV & keyid are appended to encrypted data to create payload Payload inserted into 802.11 frame encrypted IV Key ID data ICV MAC payload CS262 FS15 Netzwerksicherheit: Anwendungen 57 WEP encryption (2) New IV for each frame CS262 FS15 Netzwerksicherheit: Anwendungen 58
WEP decryption overview encrypted IV Key ID data ICV MAC payload receiver extracts IV inputs IV, shared secret key into pseudo random generator, gets keystream XORs keystream with encrypted data to decrypt data + ICV verifies integrity of data with ICV note: message integrity approach used here is different from MAC (message authentication code) and signatures (using PKI). CS262 FS15 Netzwerksicherheit: Anwendungen 59 End-point authentication w/ nonce Nonce: number (R) used only once in-a-lifetime How: to prove Alice live, Bob sends Alice nonce, R. Alice must return R, encrypted with shared secret key I am Alice R K A-B (R) Alice is live, and only Alice knows key to encrypt nonce, so it must be Alice! CS262 FS15 Netzwerksicherheit: Anwendungen 60
WEP Authentication Not all APs do it, even if WEP is being used. AP indicates if authentication is necessary in beacon frame. Done before association. authentication request AP nonce (128 bytes) nonce encrypted shared key success if decrypted value equals nonce CS262 FS15 Netzwerksicherheit: Anwendungen 61 Breaking 802.11 WEP encryption security hole: 24-bit IV, one IV per frame IV s eventually reused IV transmitted in plaintext IV reuse detected attack: Trudy causes Alice to encrypt known plaintext d 1 d 2 d 3 d 4 IV Trudy sees: c i = d i XOR k i IV Trudy knows c i d i, so can compute k i IV IV IV Trudy knows encrypting key sequence k 1 k 2 k 3 Next time IV is used, Trudy can decrypt! CS262 FS15 Netzwerksicherheit: Anwendungen 62
802.11i: improved security numerous (stronger) forms of encryption possible provides key distribution uses authentication server separate from access point CS262 FS15 Netzwerksicherheit: Anwendungen 63 802.11i: four phases of operation STA: client station AP: access point wired network AS: Authentication server 1 Discovery of security capabilities 2 STA and AS mutually authenticate, together generate Master Key (MK). AP servers as pass through 3 STA derives Pairwise Master Key (PMK) 3 AS derives same PMK, sends to AP 4 STA, AP use PMK to derive Temporal Key (TK) used for message encryption, integrity CS262 FS15 Netzwerksicherheit: Anwendungen 64
EAP: extensible authentication protocol EAP: end-end client (mobile) to authentication server protocol EAP sent over separate links mobile-to-ap (EAP over LAN) AP to authentication server (RADIUS over UDP) wired network EAP TLS EAP EAP over LAN (EAPoL) IEEE 802.11 RADIUS UDP/IP CS262 FS15 Netzwerksicherheit: Anwendungen 65 Network Security (summary) basic techniques... cryptography (symmetric and public) message integrity end-point authentication. used in many different security scenarios secure email secure transport (SSL) IP sec 802.11 CS262 FS15 Netzwerksicherheit: Anwendungen 66