Cryptography The language of cryptography Alices K encryption

  • Slides: 46
Download presentation
Cryptography

Cryptography

The language of cryptography Alice’s K encryption A key plaintext encryption algorithm Bob’s K

The language of cryptography Alice’s K encryption A key plaintext encryption algorithm Bob’s K decryption B key ciphertext decryption plaintext algorithm symmetric key crypto: sender, receiver keys identical public-key crypto: encryption key public, decryption key secret (private) 8: Network Security 8 -2

Symmetric key cryptography substitution cipher: substituting one thing for another – monoalphabetic cipher: substitute

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? : q brute force (how hard? ) q other? 8: Network Security 8 -3

Symmetric key cryptography K plaintext message, m K A-B encryption ciphertext algorithm K (m)

Symmetric key cryptography K plaintext message, m K A-B encryption ciphertext algorithm K (m) A-B decryption plaintext algorithm m=K A-B (K (m)) A-B symmetric key crypto: Bob and Alice share know same (symmetric) key: K A-B • e. g. , key is knowing substitution pattern in mono alphabetic substitution cipher • Q: how do Bob and Alice agree on key value? 8: Network Security 8 -4

Symmetric key crypto: DES: Data Encryption Standard • US encryption standard [NIST 1993] •

Symmetric key crypto: DES: Data Encryption Standard • US encryption standard [NIST 1993] • 56 -bit symmetric key, 64 -bit plaintext input • How secure is DES? – DES Challenge: 56 -bit-key-encrypted phrase (“Strong cryptography makes the world a safer place”) decrypted (brute force) in 4 months – no known “backdoor” decryption approach • making DES more secure: – use three keys sequentially (3 -DES) on each datum – use cipher-block chaining 8: Network Security 8 -5

Symmetric key crypto: DES operation initial permutation 16 identical “rounds” of function application, each

Symmetric key crypto: DES operation initial permutation 16 identical “rounds” of function application, each using different 48 bits of key final permutation 8: Network Security 8 -6

AES: Advanced Encryption Standard • new (Nov. 2001) symmetric-key NIST standard, replacing DES •

AES: Advanced Encryption Standard • new (Nov. 2001) symmetric-key NIST standard, replacing DES • processes data in 128 bit blocks • 128, 192, or 256 bit keys • brute force decryption (try each key) taking 1 sec on DES, takes 149 trillion years for AES 8: Network Security 8 -7

Block Cipher loop for n rounds 64 -bit input 8 bits T 1 8

Block Cipher loop for n rounds 64 -bit input 8 bits T 1 8 bits • one pass through: one input bit affects eight output bits 8 bits T 2 8 bits T 3 8 bits T 4 T 5 T 6 8 bits T 7 T 8 8 bits 8 bits 64 -bit scrambler 64 -bit output r multiple passes: each input bit afects all output bits r block ciphers: DES, 3 DES, AES 8: Network Security 8 -8

Cipher Block Chaining • cipher block: if input block repeated, will produce same cipher

Cipher Block Chaining • cipher block: if input block repeated, will produce same cipher text: t=1 … t=17 m(1) = “HTTP/1. 1” block cipher c(1) m(17) = “HTTP/1. 1” block cipher c(17) = “k 329 a. M 02” r cipher block chaining: XOR ith input block, m(i), with previous block of cipher text, c(i-1) m m c(0) transmitted to receiver in clear what happens in “HTTP/1. 1” scenario from above? m(i) c(i-1) + block cipher c(i) 8: Network Security 8 -9

Public key cryptography symmetric key crypto • requires sender, receiver know shared secret key

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”)? public key cryptography r radically different approach [Diffie-Hellman 76, RSA 78] r sender, receiver do not share secret key r public encryption key known to all r private decryption key known only to receiver 8: Network Security 8 -10

Public key cryptography + Bob’s public B key K K plaintext message, m encryption

Public key cryptography + Bob’s public B key K K plaintext message, m encryption ciphertext algorithm + K (m) B 8: Network Security - Bob’s private B key decryption plaintext algorithm message m = K -(K +(m)) B B 8 -11

Public key encryption algorithms Requirements: + 1 need KB (. ) and K (.

Public key encryption algorithms Requirements: + 1 need KB (. ) and K (. ) such that - - + B K B (KB (m)) = m + 2 given public key KB , it should be impossible to- compute private key K B RSA: Rivest, Shamir, Adleman algorithm 8: Network Security 8 -12

RSA: Choosing keys 1. Choose two large prime numbers p, q. (e. g. ,

RSA: Choosing keys 1. Choose two large prime numbers p, q. (e. g. , 1024 bits each) 2. Compute n = pq, z = phi(n)=(p-1)(q-1) 3. Choose e (with b<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 8 -13

RSA: Encryption, decryption 0. Given (n, b) and (n, a) as computed above 1.

RSA: Encryption, decryption 0. Given (n, b) and (n, a) as computed above 1. To encrypt bit pattern, m, compute e x = m mod n e (i. e. , remainder when m is divided by n) 2. To decrypt received bit pattern, c, compute d m = x mod n d (i. e. , remainder when c is divided by n) Magic e m = (m mod n) happens! d mod n x 8: Network Security 8 -14

RSA example: Bob chooses p=5, q=7. Then n=35, z=24. e=5 (so e, z relatively

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: decrypt: letter m l 12 c 17 c m e e c = m mod n 17 1524832 d d m = c mod n 48196857210675091411825223071697 8: Network Security 12 letter l 8 -15

RSA: Why is that e m = (m mod n) d mod n Useful

RSA: Why is that e m = (m mod n) d mod n Useful number theory result: If p, q prime and n = pq, then: y y mod (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 ) = m 8: Network Security 8 -16

RSA: another important property The following property will be very useful later: - +

RSA: another important property The following property will be very useful later: - + K B (KB (m)) = m use public key first, followed by private key = + - K B (m)) use private key first, followed by public key Result is the same! 8: Network Security 8 -17

Message Integrity Bob receives msg from Alice, wants to ensure: • message originally came

Message Integrity Bob receives msg from Alice, wants to ensure: • message originally came from Alice • message not changed since sent by Alice Cryptographic Hash: • takes input m, produces fixed length value, H(m) – e. g. , as in Internet checksum • computationally infeasible to find two different messages, x, y such that H(x) = H(y) – equivalently: given m = H(x), (x unknown), can not determine x. – note: Internet checksum fails this requirement! 8: Network Security 8 -18

Internet checksum: poor crypto hash function Internet checksum has some properties of hash function:

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 IOU 1 00. 9 9 BOB message IOU 9 00. 1 9 BOB ASCII format 49 4 F 55 31 30 30 2 E 39 39 42 4 F 42 B 2 C 1 D 2 AC ASCII format 49 4 F 55 39 30 30 2 E 31 39 42 4 F 42 B 2 C 1 D 2 AC different messages but identical checksums! 8: Network Security 8 -19

Message Authentication Code (shared secret) s H(. ) (message) m append H(. ) m

Message Authentication Code (shared secret) s H(. ) (message) m append H(. ) m H(m+s) public Internet H(m+s) m compare H(m+s) s (shared secret) 8: Network Security 8 -20

MACs in practice • MD 5 hash function widely used (RFC 1321) – computes

MACs in practice • MD 5 hash function widely used (RFC 1321) – computes 128 -bit MAC in 4 -step process. – arbitrary 128 -bit string x, appears difficult to construct msg m whose MD 5 hash is equal to x • recent (2005) attacks on MD 5 • SHA-1 is also used – US standard [NIST, FIPS PUB 180 -1] – 160 -bit MAC 8: Network Security 8 -21

Digital Signatures cryptographic technique analogous to hand-written signatures. • sender (Bob) digitally signs document,

Digital Signatures cryptographic technique analogous to hand-written signatures. • sender (Bob) digitally signs document, establishing he is document owner/creator. • verifiable, nonforgeable: recipient (Alice) can prove to someone that Bob, and no one else (including Alice), must have signed document 8: Network Security 8 -22

Digital Signatures simple digital signature for message m: - • Bob “signs” m by

Digital Signatures simple digital signature for message m: - • Bob “signs” m by encrypting with his private key KB, 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) Bob K B Bob’s private key public key encryption algorithm 8: Network Security K B(m) Bob’s message, m, signed (encrypted) with his private key 8 -23

Digital Signatures (more) • suppose Alice receives msg m, digital signature KB-(m) • Alice

Digital Signatures (more) • suppose Alice receives msg m, digital signature KB-(m) • Alice verifies m signed by Bob by applying Bob’s public key K+B to KB(m) then checks K+B(KB-(m) ) = m. + - • if KB(KB(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 KB(m) to court and prove that Bob signed m. 8: Network Security 8 -24

Digital signature = signed MAC Alice verifies signature and integrity of digitally signed message:

Digital signature = signed MAC Alice verifies signature and integrity of digitally signed message: Bob sends digitally signed message: large message m H: hash function Bob’s private key + encrypted msg digest H(m) digital signature (encrypt) - KB encrypted msg digest - KB(H(m)) large message m H: hash function KB(H(m)) Bob’s public key + KB digital signature (decrypt) H(m) equal ? 8: Network Security 8 -25

Public Key Certification public key problem: • When Alice obtains Bob’s public key (from

Public Key Certification public key problem: • When Alice obtains Bob’s public key (from web site, e-mail, diskette), how does she know it is Bob’s public key, not Trudy’s? solution: • trusted certification authority (CA) 8: Network Security 8 -26

Certification Authorities • Certification Authority (CA): binds public key to particular entity, E. •

Certification Authorities • Certification Authority (CA): binds public key to particular entity, E. • E registers its public key with CA. – E provides “proof of identity” to CA. – CA creates certificate binding E to its public key. – certificate containing E’s public key digitally signed by CA: CA says “This is E’s public key. ” + K CA(KB ) Bob’s public key Bob’s identifying information + KB digital signature (encrypt) CA private key - K CA + KB certificate for Bob’s public key, signed by CA 8: Network Security 8 -27

Certification Authorities • when Alice wants Bob’s public key: – gets Bob’s certificate (Bob

Certification Authorities • when Alice wants Bob’s public key: – gets Bob’s certificate (Bob or elsewhere). – apply CA’s public key to Bob’s certificate, get Bob’s public key + KB - + K CA(KB ) digital signature (decrypt) CA public key Bob’s public + key KB + K CA 8: Network Security 8 -28

A certificate contains: • Serial number (unique to issuer) • info about certificate owner,

A certificate contains: • Serial number (unique to issuer) • info about certificate owner, including algorithm and key value itself (not shown) r info about certificate issuer r valid dates r digital signature by issuer 8: Network Security 8 -29

Authentication Goal: Bob wants Alice to “prove” her identity to him Protocol ap 1.

Authentication Goal: Bob wants Alice to “prove” her identity to him Protocol ap 1. 0: Alice says “I am Alice” Failure scenario? ? 8: Network Security 8 -30

Authentication Goal: Bob wants Alice to “prove” her identity to him Protocol ap 1.

Authentication Goal: Bob wants Alice to “prove” her identity to him Protocol ap 1. 0: Alice says “I am Alice” in a network, Bob can not “see” Alice, so Trudy simply declares herself to be Alice “I am Alice” 8: Network Security 8 -31

Authentication: another try Protocol ap 2. 0: Alice says “I am Alice” in an

Authentication: another try Protocol ap 2. 0: Alice says “I am Alice” in an IP packet containing her source IP address Alice’s “I am Alice” IP address Failure scenario? ? 8: Network Security 8 -32

Authentication: another try Protocol ap 2. 0: Alice says “I am Alice” in an

Authentication: another try Protocol ap 2. 0: Alice says “I am Alice” in an IP packet containing her source IP address Trudy can create a packet “spoofing” Alice’s address Alice’s “I am Alice” IP address 8: Network Security 8 -33

Authentication: another try Protocol ap 3. 0: Alice says “I am Alice” and sends

Authentication: another try Protocol ap 3. 0: Alice says “I am Alice” and sends her secret password to “prove” it. Alice’s “I’m Alice” IP addr password Alice’s IP addr OK 8: Network Security Failure scenario? ? 8 -34

Authentication: another try Protocol ap 3. 0: Alice says “I am Alice” and sends

Authentication: another try Protocol ap 3. 0: Alice says “I am Alice” and sends her secret password to “prove” it. Alice’s “I’m Alice” IP addr password Alice’s IP addr OK playback attack: Trudy records Alice’s packet and later plays it back to Bob Alice’s “I’m Alice” IP addr password 8: Network Security 8 -35

Authentication: yet another try Protocol ap 3. 1: Alice says “I am Alice” and

Authentication: yet another try Protocol ap 3. 1: Alice says “I am Alice” and sends her encrypted secret password to “prove” it. Alice’s encrypted “I’m Alice” IP addr password Alice’s IP addr OK 8: Network Security Failure scenario? ? 8 -36

Authentication: another try Protocol ap 3. 1: Alice says “I am Alice” and sends

Authentication: another try Protocol ap 3. 1: Alice says “I am Alice” and sends her encrypted secret password to “prove” it. Alice’s encrypted “I’m Alice” IP addr password Alice’s IP addr OK record and playback still works! Alice’s encrypted “I’m Alice” IP addr password 8: Network Security 8 -37

Authentication: yet another try Goal: avoid playback attack Nonce: number (R) used only once

Authentication: yet another try Goal: avoid playback attack Nonce: number (R) used only once –in-a-lifetime ap 4. 0: to prove Alice “live”, Bob sends Alice nonce, R. Alice must return R, encrypted with shared secret key “I am Alice” R K (R) A-B Failures, drawbacks? 8: Network Security Alice is live, and only Alice knows key to encrypt nonce, so it must be Alice! 8 -38

Authentication: ap 5. 0 ap 4. 0 requires shared symmetric key • can we

Authentication: ap 5. 0 ap 4. 0 requires shared symmetric key • can we authenticate using public key techniques? ap 5. 0: use nonce, public key cryptography “I am Alice” R K (R) A “send me your public key” + K A 8: Network Security Bob computes + K (K (R)) = R A A and knows only Alice could have the private key, that encrypted R such that + K (K (R)) = R A A 8 -39

ap 5. 0: security hole Man (woman) in the middle attack: Trudy poses as

ap 5. 0: security hole Man (woman) in the middle attack: Trudy poses as Alice (to Bob) and as Bob (to Alice) I am Alice R K (R) T K (R) A Send me your public key + K T Send me your public key + K A - + m = K (K (m)) A A + K (m) A Trudy gets - + m = K (K (m)) sends T m to. TAlice + K (m) T encrypted with Alice’s public key 8: Network Security 8 -40

ap 5. 0: security hole Man (woman) in the middle attack: Trudy poses as

ap 5. 0: security hole Man (woman) in the middle attack: Trudy poses as Alice (to Bob) and as Bob (to Alice) Difficult to detect: q Bob receives everything that Alice sends, and vice versa. (e. g. , so Bob, Alice can meet one week later and recall conversation) q problem is that Trudy receives all messages as well! 8: Network Security 8 -41

Secure e-mail q Alice wants to send confidential e-mail, m, to Bob. KS m

Secure e-mail q Alice wants to send confidential e-mail, m, to Bob. KS m KS K (. ) KS(m ) S + . KB( ) K+ B + Internet + - KS + KB( ) KB(KS ) . KS( ) - m . KB- Alice: q generates random symmetric private key, KS. q encrypts message with KS (for efficiency) q also encrypts KS with Bob’s public key. q sends both KS(m) and KB(KS) to Bob. 8: Network Security 8 -42

Secure e-mail q Alice wants to send confidential e-mail, m, to Bob. KS m

Secure e-mail q Alice wants to send confidential e-mail, m, to Bob. KS m KS K (. ) KS(m ) S + . KB( ) K+ B + Internet + - KS + KB( ) KB(KS ) . KS( ) - m . KB- Bob: q uses his private key to decrypt and recover K S q uses KS to decrypt KS(m) to recover m 8: Network Security 8 -43

Secure e-mail (continued) • Alice wants to provide sender authentication message integrity. m H(.

Secure e-mail (continued) • Alice wants to provide sender authentication message integrity. m H(. ) KA- - . KA(H(m)) KA ( ) + KA+ Internet m - + . KA ( ) H(m ) compare m . H( ) H(m ) • Alice digitally signs message. • sends both message (in the clear) and digital signature. 8: Network Security 8 -44

Secure e-mail (continued) • Alice wants to provide secrecy, sender authentication, message integrity. m

Secure e-mail (continued) • Alice wants to provide secrecy, sender authentication, message integrity. m . H( ) KA- - - . KA(H(m)) KA ( ) + . KS( ) m KS KS + . KB( ) K+ B + Internet + KB(KS ) Alice uses three keys: her private key, Bob’s public key, newly created symmetric key 8: Network Security 8 -45

Pretty good privacy (PGP) • Internet e-mail encryption A PGP signed message: scheme, de-facto

Pretty good privacy (PGP) • Internet e-mail encryption A PGP signed message: scheme, de-facto standard. ---BEGIN PGP SIGNED MESSAGE-- • uses symmetric key cryptography, Hash: SHA 1 public key cryptography, hash function, and digital signature as Bob: My husband is out of town tonight. Passionately yours, described. Alice • provides secrecy, sender ---BEGIN PGP SIGNATURE--authentication, integrity. Version: PGP 5. 0 • inventor, Phil Zimmerman, was Charset: noconv yh. HJRHh. GJGhgg/12 Ep. J+lo 8 g. E 4 v. B 3 mq. Jh target of 3 -year federal FEv. ZP 9 t 6 n 7 G 6 m 5 Gw 2 investigation. ---END PGP SIGNATURE--- 8: Network Security 8 -46