Network Security HIT Shimrit Tzur-David 1
Goals: 2 Network Security Understand principles of network security: cryptography and its many uses beyond confidentiality authentication message integrity key distribution Security in practice: firewalls security in application, transport, network, link layers
What is Network Security? Confidentiality: only sender, intended receiver should understand message contents sender encrypts message receiver decrypts message Authentication: sender, receiver want to confirm identity of each other Message Integrity: sender, receiver want to ensure message not altered (in transit, or afterwards) without detection Access and Availability: services must be accessible and 3 available to users
Friends and Enemies: Alice, Bob, Trudy Well-known in network security world Bob, Alice (lovers!) want to communicate securely Trudy (intruder) may intercept, delete, add messages Alice channel data, control messages Bob data secure sender secure receiver data Trudy 4
Who might Bob, Alice be? Web browser/server for electronic transactions (e.g., on-line purchases) On-line banking client/server DNS servers Routers exchanging routing table updates 5
There are Bad Guys Out There! Q: What can a bad guy do? A: a lot! eavesdrop: intercept messages actively insert messages into connection impersonation: can fake (spoof) source address in packet (or any field in packet) hijacking: take over ongoing connection by removing sender or receiver, inserting himself in place denial of service: prevent service from being used by others (e.g., by overloading resources) 6
7 Notations cryptography - the principles and methods of transforming an intelligible message into one that is unintelligible, and then retransforming that message back to its original form. plaintext - the original intelligible message ciphertext - the transformed message cipher - an algorithm for transforming an intelligible message into one that is unintelligible by transposition and/or substitution methods key - some critical information used by the cipher, known only to the sender & receiver
8 Notations Cont. encipher (encode) - the process of converting plaintext to ciphertext using a cipher and a key decipher (decode) - the process of converting ciphertext back into plaintext using a cipher and a key cryptanalysis - the study of principles and methods of transforming an unintelligible message back into an intelligible message without knowledge of the key. Also called code-breaking cryptology - both cryptography and cryptanalysis code - an algorithm for transforming an intelligible message into an unintelligible one using a code-book
Notations Cont. C = E K (P) - the encryption of the plaintext P using key K gives the ciphertext C. P = D K (C) - the decryption of C to get the plaintext D K (E K (P)) = P E and D are mathematical functions of two parameters: the key and the message. 9
The Language of Cryptography K A Alice s encryption key Bob s decryption K B key plaintext encryption algorithm ciphertext decryption algorithm plaintext 10 symmetric key crypto: sender, receiver keys identical public-key crypto: encryption key public, decryption key secret (private)
Symmetric Key Cryptography K A-B K A-B plaintext message, m encryption algorithm ciphertext K (m) A-B decryption algorithm plaintext K (m) A-B m = K ( ) A-B symmetric key crypto: Bob and Alice share know same (symmetric) key: KA-B e.g., key is knowing substitution pattern in mono alphabetic substitution cipher 11
Symmetric Key Cryptography substitution cipher: substituting one thing for another monoalphabetic cipher: substitute one letter for another plaintext: abcdefghijklmnopqrstuvwxyz ciphertext: mnbvcxzasdfghjklpoiuytrewq E.g.: Plaintext: bob. i love you. alice ciphertext: nkn. s gktc wky. mgsbc Q: How hard to break this simple cipher?: brute force (how hard?) other? 12
Monoalphabetic Substitution There are 26! possible keys is in use. A computer would take ~10 10 years to try all the keys. Nevertheless, given a surprisingly small amount of ciphertext, the cipher can be broken easily. The basic attack takes advantage of the statistical properties of natural languages. In English, e is the most common letter, followed by t, o, a, n, i, etc. The most common two-letter combinations are th, in, er, re, and an. The most common three-letter combinations are the, ing, and, and ion. 13
Transposition Ciphers Substitution ciphers preserve the order of the plaintext symbols. Transposition ciphers, in contrast, reorder the letters but do not disguise them. The columnar transposition: 14
The Columnar Transposition The cipher is keyed by a word or phrase not containing any repeated letters. In the example, MEGABUCK is the key. The purpose of the key is to number the columns, column 1 being under the key letter closest to the start of the alphabet, and so on. The plaintext is written horizontally, in rows, padded to fill the matrix if need be. The ciphertext is read out by columns, starting with the column whose key letter is the lowest. 15
Breaking Transposition Cipher Step 1: The cryptanalyst must be aware that he is dealing with a transposition cipher. By looking at the frequency of E, T, A, O, I, N, etc., it is easy to see if they fit the normal pattern for plaintext. Step 2: Make a guess at the number of columns the plaintext phrase milliondollars occurs somewhere in the message Step 3: Order the columns 16 By frequency
One-Time Pads Unbreakable cipher Choose a random bit string as the key. Convert the plaintext into a bit string Compute the XOR of these two strings, bit by bit. The resulting ciphertext cannot be broken. The reason derives from information theory: there is simply no information in the message because all possible plaintexts of the given length are equally likely. 17
Public Key Cryptography symmetric key crypto requires sender, receiver know shared secret key Q: how to agree on key in first place (particularly if never met )? 18 public key cryptography radically different approach [Diffie- Hellman76, RSA78] sender, receiver do not share secret key public encryption key known to all private decryption key known only to receiver
Public Key Cryptography K B + K B - Bob s public key Bob s private key plaintext message, m encryption algorithm ciphertext + K (m) B decryption algorithm plaintext message - + m = K (K (m)) B B 19
Public Key Encryption Algorithms Requirements: 20 1 2 + B - + need K and K such that given public key K B, it should be impossible to compute - private key K RSA: Rivest, Shamir, Adelson algorithm - B K (K (m)) = m B B B +
RSA: Choosing keys 21 1. Choose two large prime numbers p, q. (e.g., 1024 bits each) 2. Compute n = pq, z = (p-1)(q-1) 3. Choose e (with e<n) that has no common factors with z. (e, z are relatively prime ). 4. Choose d such that ed-1 is exactly divisible by z. (in other words: ed mod z = 1 ). 5. Public key is (n,e). Private key is (n,d). K B + K B -
RSA: Encryption, Decryption 0. Given (n,e) and (n,d) as computed above 1. To encrypt bit pattern, m, compute c = m e e mod n (i.e., remainder when m is divided by n) 2. To decrypt received bit pattern, c, compute m = c d mod n (i.e., remainder when c d is divided by n) Magic happens! m = (m e d mod n) mod n c 22
RSA Example: Bob chooses p=5, q=7. Then n=35, z=24. e=5 (so e, z relatively prime). d=29 (so ed-1 exactly divisible by z). encrypt: letter m m e c = m e mod n l 12 248832 17 decrypt: c c d m = c d mod n 17 481968572106750915091411825223071697 12 letter l 23
RSA: Why is that Useful number theory result: If p,q prime and n = pq, then: y ymod (p-1)(q-1) x mod n = x mod n e (m mod n) d mod n = m ed mod n ed mod (p-1)(q-1) = m mod n (using number theory result above) 1 = m mod n (since we chose ed to be divisible by (p-1)(q-1) with remainder 1 ) 24 = m
RSA: Another Important Property The following property will be very useful later: - + K (K (m)) = m B B use public key first, followed by private key = + - B B K (K (m)) use private key first, followed by public key Result is the same! 25
Authentication Goal: Bob wants Alice to prove her identity to him Protocol ap1.0: Alice says I am Alice I am Alice Failure scenario?? 26
Authentication Goal: Bob wants Alice to prove her identity to him Protocol ap1.0: Alice says I am Alice I am Alice in a network, Bob can not see Alice, so Trudy simply declares herself to be Alice 27
Authentication: Another Try Protocol ap2.0: Alice says I am Alice in an IP packet containing her source IP address Alice s IP address I am Alice Failure scenario?? 28
Authentication: another try Protocol ap2.0: Alice says I am Alice in an IP packet containing her source IP address Alice s IP address I am Alice Trudy can create a packet spoofing Alice s address 29
Authentication: another try Protocol ap3.0: Alice says I am Alice and sends her secret password to prove it. Alice s IP addr Alice s password I m Alice Alice s IP addr OK Failure scenario?? 30
Authentication: another try Protocol ap3.0: Alice says I am Alice and sends her secret password to prove it. Alice s IP addr Alice s password I m Alice Alice s IP addr OK playback attack: Trudy records Alice s packet and later plays it back to Bob Alice s IP addr Alice s password I m Alice 31
Authentication: yet another try Protocol ap3.1: Alice says I am Alice and sends her encrypted secret password to prove it. Alice s IP addr encrypted password I m Alice Alice s IP addr OK Failure scenario?? 32
Authentication: another try Protocol ap3.1: Alice says I am Alice and sends her encrypted secret password to prove it. Alice s IP addr encrypted password I m Alice Alice s IP addr OK record and playback still works! Alice s IP addr encrypted password I m Alice 33
Authentication: Yet Another Try Goal: avoid playback attack Nonce: number (R) used only once in-a-lifetime ap4.0: to prove Alice live, Bob sends Alice nonce, R. Alice must return R, encrypted with shared secret key I am Alice R 34 Failures, drawbacks? K (R) A-B Alice is live, and only Alice knows key to encrypt nonce, so it must be Alice!
Authentication: ap5.0 ap4.0 requires shared symmetric key Can we authenticate using public key techniques? ap5.0: use nonce, public key cryptography R I am Alice - K A (R) send me your public key + K A Bob computes + - K A(K (R)) = R A and knows only Alice could have the private key, that encrypted R such that + - K A (K (R)) = R A 35
ap5.0: Security Hole Man (woman) in the middle attack: Trudy poses as Alice (to Bob) and as Bob (to Alice) - + m = K (K (m)) A A 36 I am Alice R - K (R) A + K A Send me your public key + K (m) A Trudy gets - + m = K (K (m)) sends T m to T Alice encrypted with Alice s public key I am Alice R - K (R) T Send me your public key + K (m) T + K T
ap5.0: Security Hole Man (woman) in the middle attack: Trudy poses as Alice (to Bob) and as Bob (to Alice) Difficult to detect: Bob receives everything that Alice sends, and vice versa. (e.g., so Bob, Alice can meet one week later and recall conversation) problem is that Trudy receives all messages as well! 37
Message Integrity: Digital Signatures Cryptographic technique analogous to handwritten signatures. Sender (Bob) digitally signs document, establishing he is the document s owner/creator. verifiable, non-forgeable: recipient (Alice) can prove to someone that Bob, and no one else (including Alice), must have signed document 38
Digital Signatures Simple digital signature for message m: Bob signs m by encrypting with his private key - - K B, creating signed message, K B (m) Bob s message, m Dear Alice Oh, how I have missed you. I think of you all the time! (blah blah blah), Bob K B - Public key encryption algorithm Bob s private key K B - (m) Bob s message, m, signed (encrypted) with his private key 39
40 Digital Signatures Cont. Suppose Alice receives msg m, digital signature K- B (m) Alice verifies m signed by Bob by applying Bob s + - + - public key K B to K B (m) then checks K B (K B (m) ) = m. + - If K B (K B (m) ) = m, whoever signed m must have used Bob s private key. Alice thus verifies that: Bob signed m. No one else signed m. Bob signed m and not m. Non-repudiation: Alice can take m, and signature K B (m) to court and prove that Bob signed m. -
Message Digests Computationally expensive to public-key-encrypt long messages Goal: fixed-length, easyto-compute digital fingerprint Apply hash function H to m, get fixed size message digest, H(m). 41 large message m H: Hash Function H(m) Hash function properties: many-to-1 produces fixed-size msg digest (fingerprint) given message digest x, computationally infeasible to find m such that x = H(m)
Internet Checksum: Poor Crypto Hash Function Internet checksum has some properties of hash function: produces fixed length digest (16-bit sum) of message is many-to-one But given message with given hash value, it is easy to find another message with same hash value: message ASCII format message ASCII format I O U 1 0 0. 9 9 B O B 49 4F 55 31 30 30 2E 39 39 42 D2 42 I O U 9 0 0. 1 9 B O B 49 4F 55 39 30 30 2E 31 39 42 D2 42 42 B2 C1 D2 AC different messages but identical checksums! B2 C1 D2 AC
Digital Signature = Signed Msg Digest Bob sends digitally signed message: 43 large message m H: Hash function Bob s private key K B - H(m) digital signature (encrypt) encrypted msg digest - + K B (H(m)) Alice verifies signature and integrity of digitally signed message: large message m H: Hash function H(m) Bob s public key K B + equal? encrypted msg digest - K B (H(m)) digital signature (decrypt) H(m)