Cryptography The language of

Alice’s Bob’s K A K decryption key B key plaintext encryption ciphertext decryption plaintext algorithm 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 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 K A-B A-B plaintext encryption ciphertext decryption plaintext message, m algorithm algorithm K (m) m = K ( K (m)) A-B A-B 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

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

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 • 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 64-bit input

8bits 8bits 8bits 8bits 8bits 8bits 8bits 8bits loop for n rounds T T T T1 2 3 T4 T5 T6 T7 8

8 bits 8 bits 8 bits 8 bits 8 bits 8 bits 8 bits 8 bits • one pass 64-bit through: one input bit affects eight output bits 64-bit output r multiple passes: each input bit afects all output bits r block ciphers: DES, 3DES, AES

8: Network Security 8-8 Cipher Block Chaining

• cipher block: if input m(1) = “HTTP/1.1” c(1) = “k329aM02” t=1 block block repeated, will cipher … produce same cipher m(17) = “HTTP/1.1” c(17) = “k329aM02” t=17 block text: cipher r cipher block chaining: XOR ith input block, m(i), with previous block of cipher m(i) text, c(i-1) m c(0) transmitted to c(i-1) + receiver in clear m what happens in block “HTTP/1.1” scenario cipher from above? c(i)

8: Network Security 8-9 Public key cryptography symmetric key crypto public key cryptography • requires sender, receiver r radically different approach [Diffie-Hellman76, RSA78] know shared secret key r sender, receiver do not • Q: how to agree on key in share secret key first place (particularly if r public encryption key known to all never “met”)? r private decryption key known only to receiver

8-10 8: Network Security Public key cryptography

+ K Bob’s public B key K - Bob’s private B key

plaintext encryption ciphertext decryption plaintext algorithm + algorithm message, m K (m) message B m = K - (K + (m)) B B

8: Network Security 8-11 Public key encryption algorithms

Requirements:

+ - 1 . need KB ( ) and K B ( .) such that - +

K B (KB (m)) = m + 2 given public key KB , it should be

impossible to- compute private key KB

RSA: Rivest, Shamir, Adleman algorithm

8: Network Security 8-12 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

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 + K B B

8-13 RSA: Encryption, decryption

0. Given (n,b) and (n,a) as computed above

1. To encrypt bit pattern, m, compute e e x = m mod n (i.e., remainder when m is divided by n)

2. To decrypt received bit pattern, c, compute d d m = x mod n (i.e., remainder when c is divided by n)

Magic e d happens! m = (m mod n) 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 prime). d=29 (so ed-1 exactly divisible by z.

e e letter m m c = m mod n encrypt: l 12 1524832 17

d c c d letter decrypt: m = c mod n 17 481968572106750915091411825223071697 12 l

8: Network Security 8-15 e d RSA: Why is that m = (m mod n) 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 d ed (m mod n) mod n = m 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:

- + + - K K (m) = m = B( B ) K B (K B (m))

use public key use private key first, followed first, followed by private key 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 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: ü 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 49 4F 55 31 I O U 9 49 4F 55 39 0 0 . 9 30 30 2E 39 0 0 . 1 30 30 2E 31 9 B O B 39 42 4F 42 9 B O B 39 42 4F 42

B2 C1 D2 AC different messages B2 C1 D2 AC but identical checksums! 8: Network Security 8-19 Message Authentication Code

(shared secret) s H(m+s) H(.) (message) m m H(m+s) public m append compare Internet H(m+s) H(.) H(m+s)

s (shared secret)

8: Network Security 8-20 MACs in practice

• MD5 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 MD5 hash is equal to x • recent (2005) attacks on MD5 • 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, 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 encrypting with his private key KB, - creating “signed” message, KB(m)

- Bob’s private - Bob’s message, m K K (m) B key B !"#$%&'()" *+,-.%/"..#0"1% !"#$"%&$'$"()*$+,--*.$ public key /%01$'$2",34$%5$/%0$(66$2"*$ /1%.(02"3% 2,+*7$89:6("$:6("$:6("; encryption 4"2)$567"38%9(7:% algorithm :(.%6$(;#7"%<"5 *+,

8: Network Security 8-23 Digital Signatures (more)

> • suppose Alice receives msg m, digital signature KB(m) = • Alice verifies m signed by Bob by applying Bob’s public key KB > = > to KB(m) then checks KB(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 Bob sends digitally signed of digitally signed message: message: large message H: hash H(m) encrypted m function msg digest - KB(H(m)) Bob’s digital large private signature message Bob’s key - (encrypt) m digital K B public + signature key K encrypted H: hash B (decrypt) msg digest function - + KB(H(m)) H(m) H(m) equal ?

8-25 8: Network Security 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. • 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 (K ) digital CA B Bob’s + signature public + K B key K B (encrypt) CA private - certificate for Bob’s K identifying key CA Bob’s public key, information signed by CA

8-27 8: Network Security 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

- + digital Bob’s + K CA(K ) K B public B signature + key (decrypt) K B

CA + public K key CA

8-28 8: Network Security 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 ap1.0: Alice says “I am Alice”

“I am Alice” Failure scenario??

8: Network Security 8-30 Authentication

Goal: Bob wants Alice to “prove” her identity to him

Protocol ap1.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 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??

8: Network Security 8-32 Authentication: another try

Protocol ap2.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 ap3.0: Alice says “I am Alice” and sends her secret password to “prove” it.

Alice’s Alice’s “I’m Alice” IP addr password

Failure scenario?? Alice’s OK IP addr

8: Network Security 8-34 Authentication: another try

Protocol ap3.0: Alice says “I am Alice” and sends her secret password to “prove” it.

Alice’s Alice’s “I’m Alice” IP addr password playback attack: Trudy records Alice’s packet Alice’s OK IP addr and later plays it back to Bob

Alice’s Alice’s “I’m Alice” IP addr password

8: Network Security 8-35 Authentication: yet another try

Protocol ap3.1: Alice says “I am Alice” and sends her encrypted secret password to “prove” it.

encrypted Alice’s “I’m Alice” IP addr password

Failure scenario?? Alice’s OK IP addr

8: Network Security 8-36 Authentication: another try

Protocol ap3.1: Alice says “I am Alice” and sends her encrypted secret password to “prove” it.

encrypted Alice’s “I’m Alice” record IP addr password and playback Alice’s OK still works! IP addr

encrypted Alice’s “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 –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

K (R) Alice is live, and A-B only Alice knows key to encrypt nonce, so it must Failures, drawbacks? be Alice!

8: Network Security 8-38 Authentication: ap5.0 ap4.0 requires shared symmetric key • can we authenticate using public key techniques? ap5.0: use nonce, public key cryptography

“I am Alice” Bob computes R + - K (K (R)) = R K - (R) A A A and knows only Alice could have the private “send me your public key” + key, that encrypted R K such that A + - K (K (R)) = R A A

8: Network Security 8-39 ap5.0: security hole Man (woman) in the middle attack: Trudy poses as Alice (to Bob) and as Bob (to Alice)

I am Alice I am Alice R - K (R) T R - Send me your public key K (R) + A K T Send me your public+ key K A + K (m) Trudy gets T - + + m = K (K (m)) K (m) T T A sends m to Alice - + m = K (K (m)) encrypted with A A Alice’s public key

8-40 8: Network Security ap5.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-41 8: Network Security Secure e-mail q Alice wants to send confidential e-mail, m, to Bob.

KS

KS(m ) KS(m ) m KS( .) KS( .) m

+ Internet - KS + . - . KS KB( ) + + KB( ) KB(KS ) KB(KS )

K+B 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

KS(m ) KS(m ) m KS( .) KS( .) m

+ Internet - KS + . - . KS KB( ) + + KB( ) KB(KS ) KB(KS )

K+B KB-

Bob: q uses his private key to decrypt and recover KS 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.

+ KA- KA - - - KA(H(m)) KA(H(m)) + . H(m ) m H(. ) KA( .) KA( )

compare + Internet -

m H(. ) m 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.

KA- - - KA(H(m)) m H(. ) KA( .) KS

+ KS( .)

m + Internet + . KS KB( ) + KB(KS )

K+B

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 standard. ---BEGIN PGP SIGNED MESSAGE--- • uses symmetric key cryptography, Hash: SHA1 public key cryptography, hash function, and digital signature as Bob:My husband is out of town tonight.Passionately yours, described. Alice • provides secrecy, sender authentication, integrity. ---BEGIN PGP SIGNATURE--- Version: PGP 5.0 • inventor, Phil Zimmerman, was Charset: noconv target of 3-year federal yhHJRHhGJGhgg/12EpJ+lo8gE4vB3mqJ investigation. hFEvZP9t6n7G6m5Gw2 ---END PGP SIGNATURE---

8: Network Security 8-46