Formal Security Analysis of Cryptographic Protocol Code - - PowerPoint PPT Presentation

formal security analysis of cryptographic protocol code
SMART_READER_LITE
LIVE PREVIEW

Formal Security Analysis of Cryptographic Protocol Code - - PowerPoint PPT Presentation

Formal Security Analysis of Cryptographic Protocol Code Karthikeyan Bhargavan INRIA Karthikeyan.Bhargavan@inria.fr IIT Delhi, Fall 2010 Lecture 2: A


slide-1
SLIDE 1

Formal ¡Security ¡Analysis ¡of ¡ Cryptographic ¡Protocol ¡Code ¡ ¡

Karthikeyan ¡Bhargavan ¡ INRIA ¡ Karthikeyan.Bhargavan@inria.fr ¡ IIT ¡Delhi, ¡Fall ¡2010 ¡

slide-2
SLIDE 2

Lecture ¡2: ¡ A ¡Cryptographic ¡Library ¡in ¡F# ¡

IntroducDon ¡

slide-3
SLIDE 3

Abstract ¡ Abstract ¡

A ¡Secure ¡Web ¡ApplicaDon ¡

Networking ¡ (Windows) ¡ Cryptographic ¡ Protocol ¡ (HTTPS/TLS) ¡ Web ¡Browser ¡ ¡ (Firefox+JS) ¡

Secure ¡Connec*on ¡ Insecure ¡Network ¡

Networking ¡ (Linux) ¡ Cryptographic ¡ Protocol ¡ (HTTPS/TLS) ¡ Web ¡Server ¡ ¡ (Apache+SQL) ¡

Online ¡Banking ¡Procedure ¡

A: ¡Web ¡applicaDon ¡code ¡ ¡ ¡ ¡ ¡ ¡100,000 ¡lines ¡(in ¡F#) ¡ D: ¡Client ¡and ¡Bank ¡share ¡ ¡ ¡ ¡ ¡ ¡ ¡100 ¡lines ¡of ¡data ¡ P: ¡Security-­‑related ¡code ¡ ¡ ¡ ¡ ¡ ¡10,000 ¡lines ¡(in ¡F#) ¡ L: ¡System ¡libraries ¡ ¡ ¡ ¡ ¡1,000,000 ¡lines ¡(in ¡C) ¡

Client ¡ Bank ¡

O: ¡Unknown ¡Opponent ¡

Web ¡Session ¡ 3 ¡

slide-4
SLIDE 4

TLS: ¡Transport ¡Layer ¡Protocol ¡ ¡A ¡Protocol ¡for ¡Secure ¡Sessions ¡

NegoDaDon ¡ Key ¡agreement ¡ (RSA, ¡no ¡client ¡auth) ¡ ConfirmaDon ¡ ApplicaDon ¡

Firefox ¡Client ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡Apache ¡Server ¡ (Mozilla ¡NSS) ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡(OpenSSL) ¡

ClientHello ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ServerHello ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡CerDficate ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ServerHelloDone ¡ ClientKeyExchange ¡ [ChangeCipherSpec] ¡ Finished ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡[ChangeCipherSpec] ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡Finished ¡ ApplicaDon ¡Data ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ApplicaDon ¡Data ¡

(Protected ¡by ¡Record ¡Protocol) ¡

slide-5
SLIDE 5

Example: ¡Encrypted ¡Message ¡

data ¡ data ¡fragment ¡ mac ¡ header ¡ encrypted ¡fragment ¡and ¡mac ¡ data ¡fragment ¡

Message ¡Structure: ¡

C ¡ ¡S ¡: ¡{m,[m]ak}ek ¡

Cryptographic ¡Processing: ¡

slide-6
SLIDE 6

Example: ¡Server ¡Code ¡Fragment ¡

let recv (connid:ConnectionId) = let conn = getConnection connid in let conn, input = recvRecord conn in let conn, msg = verifyPayload conn CT_application_data input in let id,entity = connid in log tr (Recv (id,entity,msg)); storeConnection connid conn; msg let verifyPayload(conn:Connection)(ct:ContentType)(input:bytes) let (bct, bver, blen, ciphertext) = parseRecord input in let rct, rver, rlen = getAbstractValues bct bver blen in let ver = conn.crt_version in if rver = ver then let connst = conn.read in let connst, plaintext = decrypt ver connst ciphertext in let payload, recvmac = parsePlaintext ver connst plaintext in let len = bytes_of_int 2 (length payload) in let bseq = bytes_of_seq connst.seq_num in let maced = append5 bseq bct bver len payload in let conn = updateConnection_read conn connst in checkContentType ct rct payload; if hmacVerify connst maced recvmac then(conn,payload) else failwith "bad record mac" else failwith "bad version"

Message ¡Parsing ¡ Security ¡event: ¡ message ¡accepted! ¡ MAC ¡verificaDon ¡

data ¡ data ¡fragment ¡ mac ¡ header ¡ encrypted ¡fragment ¡and ¡mac ¡ data ¡fragment ¡

Message ¡Structure: ¡

C ¡ ¡S ¡: ¡{m,[m]ak}ek ¡

Cryptographic ¡Processing: ¡

DecrypDon ¡

Full ¡ImplementaDon ¡of ¡TLS ¡ is ¡10,000 ¡lines ¡of ¡ML ¡

slide-7
SLIDE 7

Cryptography ¡

Greek ¡origin: ¡ ¡kryptos ¡= ¡”secret”, ¡gráph= ¡"wriEng” ¡ ¡ ¡ ¡ ¡A ¡collecEon ¡of ¡mathemaEcal ¡funcEons ¡for ¡hiding ¡ informaEon ¡and ¡algorithms ¡for ¡compuEng ¡them. ¡ ¡ AddiDonal ¡Reading ¡

– Wikipedia: ¡hap://en.wikipedia.org/wiki/Cryptography ¡ – Secrets ¡and ¡Lies, ¡Bruce ¡Schneier, ¡2000 ¡ – Handbook ¡of ¡Applied ¡Cryptography, ¡Menezes, ¡ Oorschot, ¡Vanstone, ¡2001 ¡

slide-8
SLIDE 8

Lecture ¡2: ¡ A ¡Cryptographic ¡Library ¡in ¡F# ¡

Hash ¡FuncDons ¡

slide-9
SLIDE 9

Hash ¡FuncDon ¡ ¡

  • A ¡funcDon ¡from ¡byte[] ¡to ¡byte[20] ¡

– Example: ¡MD4, ¡MD5, ¡SHA-­‑1, ¡SHA-­‑3 ¡

Desired ¡mathemaDcal ¡properDes: ¡

  • Computability: ¡efficient ¡algorithm ¡
  • Preimage ¡resistance: ¡ ¡

¡ ¡given ¡h(m), ¡it ¡is ¡hard ¡to ¡find ¡m ¡

  • Collision ¡resistance: ¡

¡ ¡ ¡hard ¡to ¡find ¡m1, ¡m2, ¡such ¡that ¡h(m1) ¡= ¡h(m2) ¡ ¡ ¡ ¡ ¡

slide-10
SLIDE 10

A ¡Note ¡about ¡Hardness ¡

  • Cryptographers ¡assume ¡that ¡the ¡ ¡

adversary/opponent/aaacker ¡is ¡a ¡ ¡ probabilisDc ¡polynomial-­‑Dme ¡turing ¡machine. ¡

– Ohen ¡called ¡a ¡PPT ¡adversary ¡

  • Hard ¡implies ¡that ¡the ¡probability ¡that ¡an ¡

adversary ¡will ¡be ¡able ¡to ¡find ¡a ¡hash ¡funcDon ¡ preimage ¡or ¡collision ¡is ¡negligible ¡ ¡

  • For ¡simplicity, ¡we ¡ohen ¡assume ¡that ¡these ¡aaacks ¡

are ¡impossible, ¡not ¡just ¡improbable ¡ ¡

slide-11
SLIDE 11

A ¡Protocol ¡using ¡a ¡Hash ¡FuncDon ¡

Protocol: ¡ ¡C ¡-­‑> ¡S ¡: ¡m, ¡(sha1 ¡passwordC ¡m) ¡ ImplementaEon: ¡ ¡ ¡ ¡ ¡ ¡ ¡When ¡S ¡receives ¡a ¡message ¡from ¡C, ¡ ¡ ¡1. ¡S ¡extracts ¡the ¡message ¡m ¡and ¡hash ¡h, ¡ ¡2. ¡S ¡retrieves ¡the ¡password ¡for ¡C: ¡passwordC, ¡ ¡3. ¡S ¡verifies ¡that ¡h ¡= ¡sha1 ¡passwordC ¡m ¡ ¡4. ¡If ¡the ¡test ¡fails, ¡S ¡rejects ¡the ¡message ¡ ¡5. ¡Otherwise, ¡it ¡accepts ¡the ¡message ¡m ¡from ¡C. ¡

slide-12
SLIDE 12

Security ¡Goals ¡

Protocol: ¡ ¡C ¡-­‑> ¡S ¡: ¡m, ¡sha1 ¡passwordC ¡m ¡ Security ¡Goal: ¡ ¡ ¡ ¡Assume ¡that ¡passwordC ¡is ¡known ¡only ¡to ¡C ¡and ¡S. ¡ ¡ ¡When ¡S ¡accepts ¡a ¡message ¡m ¡from ¡C, ¡ ¡ ¡ ¡Message ¡Integrity: ¡S ¡can ¡be ¡sure ¡that ¡the ¡message ¡sent ¡ by ¡C ¡was ¡indeed ¡m ¡and ¡not ¡m’. ¡ ¡Sender ¡Authen*ca*on: ¡S ¡can ¡be ¡sure ¡that ¡the ¡message ¡ was ¡indeed ¡sent ¡by ¡C ¡and ¡not ¡by ¡C’. ¡ ¡

slide-13
SLIDE 13

Aaempted ¡Aaacks ¡

Protocol: ¡ ¡C ¡-­‑> ¡S ¡: ¡m, ¡sha1 ¡passwordC ¡m ¡ APack: ¡Suppose ¡an ¡aaacker ¡C’ ¡intercepts ¡this ¡message. ¡

  • 1. ¡Suppose ¡C’ ¡modifies ¡m ¡to ¡m’ ¡without ¡modifying ¡the ¡hash. ¡

Then ¡S ¡will ¡reject ¡the ¡message ¡since ¡the ¡test ¡ sha1 ¡passwordC ¡m ¡= ¡sha1 ¡passwordC ¡m’ ¡must ¡fail. ¡ ¡ ¡[Collision ¡Resistance] ¡

  • 2. Suppose ¡C’ ¡also ¡modifies ¡the ¡hash ¡to ¡sha1(passwordC’,m’). ¡ ¡

Then ¡S ¡will ¡accept ¡the ¡message ¡from ¡C’ ¡and ¡not ¡from ¡C. ¡ ¡The ¡aaacker ¡C’ ¡cannot ¡modify ¡the ¡hash ¡to ¡ ¡ sha1 ¡passwordC ¡m’ ¡since ¡he ¡does ¡not ¡know ¡ ¡passwordC ¡

slide-14
SLIDE 14

Password-­‑recovery ¡Aaacks ¡

Protocol: ¡ ¡C ¡-­‑> ¡S ¡: ¡m, ¡sha1 ¡passwordC ¡m ¡ The ¡security ¡of ¡the ¡protocol ¡depends ¡on ¡passwordC ¡ ¡Can ¡an ¡aaacker ¡recover ¡passwordC ¡from ¡the ¡hash ¡above? ¡

  • No. ¡[Preimage ¡Resistance] ¡
  • 3. ¡DicDonary ¡aaack: ¡What ¡if ¡the ¡aaacker ¡were ¡to ¡

enumerate ¡all ¡probably ¡passwords? ¡ ¡He ¡could ¡then ¡test ¡his ¡guesses ¡by ¡checking ¡if ¡ ¡ sha1 ¡guess ¡m ¡= ¡sha1 ¡passwordC ¡m ¡ ¡When ¡a ¡guess ¡succeeds, ¡he ¡has ¡the ¡answer. ¡ ¡ ¡

slide-15
SLIDE 15

Crypto: ¡A ¡Crypto ¡Library ¡in ¡F# ¡

  • A ¡funcDon ¡from ¡byte ¡arrays ¡to ¡byte ¡arrays ¡
  • Result ¡is ¡a ¡fixed-­‑length ¡array ¡(40 ¡bytes) ¡
  • No ¡inversion ¡funcDon! ¡
slide-16
SLIDE 16

Data: ¡Extended ¡with ¡ConcatenaDon ¡

  • InverDble ¡concatenaDon ¡of ¡bytestrings ¡

– Inserts ¡the ¡length ¡of ¡first ¡bytestring ¡in ¡result ¡

  • iconcat(concat ¡b1 ¡b2) ¡= ¡(b1,b2) ¡
slide-17
SLIDE 17

Exercises ¡

  • Modify ¡the ¡client ¡server ¡applicaDon ¡to ¡use ¡

passwords ¡and ¡SHA-­‑1 ¡hashes ¡

– Pick ¡a ¡fixed ¡4 ¡character ¡password ¡

  • Aaempt ¡aaacks ¡1 ¡and ¡2. ¡Do ¡they ¡fail? ¡
  • [Extra] ¡Aaempt ¡aaack ¡3. ¡Does ¡it ¡succeed? ¡ ¡
slide-18
SLIDE 18

Lecture ¡2: ¡ A ¡Cryptographic ¡Library ¡in ¡F# ¡

Message ¡AuthenDcaDon ¡Codes ¡

slide-19
SLIDE 19

Message ¡AuthenDcaDon ¡Code ¡ ¡

  • A ¡MAC ¡is ¡a ¡Keyed ¡Hash ¡FuncDon ¡

– Takes ¡a ¡byte[] ¡message ¡and ¡a ¡byte[32] ¡key ¡and ¡returns ¡a ¡ byte[20] ¡MAC ¡ – The ¡key ¡is ¡generated ¡uniformly ¡at ¡random ¡by ¡a ¡pseudo-­‑ random ¡number ¡generator ¡(PRNG) ¡ – Example: ¡HMAC-­‑SHA1, ¡HMAC-­‑MD5, ¡VMAC, ¡CBC-­‑MAC ¡

  • AddiEonal ¡MathemaEcal ¡ProperEes: ¡ ¡

Unforgeability: ¡Given ¡(m1,MAC ¡k ¡m1),…,(mj,MAC ¡k ¡mj) ¡ it ¡is ¡sDll ¡hard ¡to ¡compute ¡MAC ¡k ¡n ¡for ¡a ¡new ¡n, ¡ ¡ without ¡knowing ¡k ¡

slide-20
SLIDE 20

A ¡Protocol ¡using ¡MACs ¡

Protocol: ¡ ¡C ¡-­‑> ¡S ¡: ¡m, ¡hmacsha1 ¡keyCS ¡m ¡ ImplementaEon: ¡ ¡ ¡ ¡ ¡ ¡ ¡When ¡S ¡receives ¡a ¡message ¡from ¡C, ¡ ¡ ¡1. ¡S ¡extracts ¡the ¡message ¡m ¡and ¡hash ¡h, ¡ ¡2. ¡S ¡retrieves ¡the ¡key ¡shared ¡with ¡C: ¡keyCS, ¡ ¡3. ¡S ¡verifies ¡that ¡h ¡= ¡hmacsha1 ¡keyCS ¡m ¡ ¡4. ¡If ¡the ¡test ¡fails, ¡S ¡rejects ¡the ¡message ¡ ¡5. ¡Otherwise, ¡it ¡accepts ¡the ¡message ¡m ¡from ¡C. ¡

slide-21
SLIDE 21

Security ¡Goals ¡

Protocol: ¡ ¡C ¡-­‑> ¡S ¡: ¡m, ¡hmacsha1 ¡keyCS ¡m ¡ Security ¡Goal: ¡ ¡ ¡ ¡Assume ¡that ¡keyCS ¡is ¡known ¡only ¡to ¡C ¡and ¡S. ¡ ¡ ¡When ¡S ¡accepts ¡a ¡message ¡m ¡from ¡C, ¡ ¡ ¡ ¡Message ¡Integrity: ¡S ¡can ¡be ¡sure ¡that ¡the ¡message ¡sent ¡ by ¡C ¡was ¡indeed ¡m ¡and ¡not ¡m’. ¡ ¡Sender ¡Authen*ca*on: ¡S ¡can ¡be ¡sure ¡that ¡the ¡message ¡ was ¡indeed ¡sent ¡by ¡C ¡and ¡not ¡by ¡C’. ¡ ¡

slide-22
SLIDE 22

Aaempted ¡Aaacks ¡

Protocol: ¡ ¡C ¡-­‑> ¡S ¡: ¡m, ¡hmacsha1 ¡keyCS ¡m ¡ APack: ¡Suppose ¡an ¡aaacker ¡C’ ¡intercepts ¡this ¡message ¡ and ¡modifies ¡m ¡to ¡m’ ¡

  • 1. If ¡C’ ¡leaves ¡MAC ¡unchanged, ¡ ¡

then ¡S ¡will ¡reject ¡the ¡message. ¡

  • 2. If ¡C’ ¡modifies ¡MAC ¡to ¡hmacsha1 ¡keyC’S ¡m’, ¡ ¡

then ¡S ¡will ¡accept ¡the ¡message ¡from ¡C’, ¡not ¡from ¡C. ¡

slide-23
SLIDE 23

Aaempted ¡Aaacks ¡

Protocol: ¡ ¡C ¡-­‑> ¡S ¡: ¡m, ¡hmacsha1 ¡keyCS ¡m ¡

  • 3. ¡C’ ¡aaempts ¡to ¡obtain ¡hmacsha1 ¡keyCS ¡m’ ¡ ¡

But ¡it ¡cannot ¡[Unforgeability] ¡

  • 4. ¡C’ ¡aaempts ¡to ¡obtain ¡keyCS ¡by ¡a ¡dicDonary ¡aaack. ¡

It ¡generates ¡all ¡32 ¡byte ¡keys. ¡ But ¡this ¡cannot ¡work, ¡they’re ¡too ¡many. ¡

slide-24
SLIDE 24

Crypto: ¡A ¡Crypto ¡Library ¡in ¡F# ¡

  • A ¡type ¡of ¡cryptographic ¡keys ¡
  • A ¡key ¡generaDon ¡funcDon ¡using ¡a ¡

cryptographically ¡strong ¡pseudorandom ¡ number ¡generator ¡

  • A ¡MAC ¡funcDon ¡from ¡key ¡and ¡byte[] ¡to ¡byte[] ¡
slide-25
SLIDE 25

Exercises ¡

  • Modify ¡the ¡client ¡server ¡applicaDon ¡to ¡use ¡

keys ¡and ¡HMAC-­‑SHA-­‑1 ¡MACs ¡

– Generate ¡a ¡fixed ¡key ¡for ¡client ¡and ¡server ¡

  • Aaempt ¡aaacks ¡1 ¡and ¡2. ¡Do ¡they ¡fail? ¡
slide-26
SLIDE 26

Lecture ¡2: ¡ A ¡Cryptographic ¡Library ¡in ¡F# ¡

Symmetric ¡EncrypDon ¡

slide-27
SLIDE 27

Symmetric ¡EncrypDon ¡

  • A ¡funcDon ¡that ¡uses ¡a ¡key ¡to ¡encode ¡a ¡bytestring ¡so ¡that ¡it ¡

may ¡later ¡be ¡decoded ¡only ¡using ¡the ¡same ¡key ¡

– Takes ¡a ¡byte[] ¡message ¡and ¡a ¡byte[32] ¡key ¡and ¡returns ¡a ¡byte[] ¡ message ¡of ¡a ¡similar ¡size ¡ – The ¡key ¡is ¡generated ¡uniformly ¡at ¡random ¡by ¡a ¡pseudo-­‑random ¡ number ¡generator ¡(PRNG) ¡ – Example: ¡AES, ¡Blowfish, ¡IDEA ¡

  • MathemaEcal ¡ProperEes: ¡ ¡

Determinis*c ¡decryp*on: ¡decrypt ¡k ¡(encrypt ¡k ¡m) ¡= ¡m ¡ ¡ Secrecy: ¡Given ¡(encrypt ¡k ¡m1) ¡ ¡ it ¡is ¡hard ¡to ¡obtain ¡m1 ¡without ¡knowing ¡k ¡

slide-28
SLIDE 28

A ¡Protocol ¡using ¡Symmetric ¡EncrypDon ¡

Protocol: ¡ ¡C ¡-­‑> ¡S ¡: ¡aes ¡keyCS ¡m ¡ ImplementaEon: ¡ ¡ ¡ ¡When ¡S ¡receives ¡a ¡message ¡c ¡from ¡C, ¡ ¡ ¡1. ¡S ¡retrieves ¡the ¡key ¡shared ¡with ¡C: ¡keyCS ¡ ¡2. ¡S ¡computes ¡m ¡= ¡aes_decrypt ¡keyCS ¡c ¡ ¡3. ¡S ¡accepts ¡the ¡message ¡m ¡from ¡C. ¡

slide-29
SLIDE 29

Security ¡Goals ¡

Protocol: ¡ ¡C ¡-­‑> ¡S ¡: ¡aes ¡keyCS ¡m ¡ Security ¡Goal: ¡ ¡ ¡ ¡Assume ¡that ¡keyCS ¡is ¡known ¡only ¡to ¡C ¡and ¡S. ¡ ¡ ¡Assume ¡that ¡C ¡generates ¡a ¡fresh ¡pseudorandom ¡ bytestring ¡m ¡and ¡sends ¡it. ¡ ¡Message ¡Secrecy: ¡C ¡and ¡S ¡can ¡be ¡sure ¡that ¡the ¡ message ¡m ¡is ¡known ¡only ¡to ¡C ¡and ¡S. ¡

slide-30
SLIDE 30

Aaempted ¡Aaacks ¡

Protocol: ¡ ¡C ¡-­‑> ¡S ¡: ¡aes ¡keyCS ¡m ¡ APack: ¡Suppose ¡an ¡aaacker ¡C’ ¡intercepts ¡this ¡message. ¡

  • 1. C ¡aaempts ¡to ¡recover ¡the ¡secret ¡m ¡

But ¡it ¡cannot, ¡since ¡it ¡does ¡not ¡know ¡keyCS ¡[Secrecy] ¡

  • 2. Suppose ¡the ¡message ¡m ¡is ¡a ¡single ¡bit. ¡

C ¡can ¡guess ¡whether ¡two ¡messages ¡contain ¡the ¡ same ¡bit ¡or ¡not. ¡

– Message ¡1: ¡aes ¡keyCS ¡0 ¡ – Message ¡2: ¡aes ¡keyCS ¡1 ¡ – Message ¡3: ¡aes ¡keyCS ¡0 ¡

slide-31
SLIDE 31

Crypto: ¡A ¡Crypto ¡Library ¡in ¡F# ¡

  • A ¡key ¡generaDon ¡funcDon ¡using ¡a ¡

cryptographically ¡strong ¡pseudorandom ¡ number ¡generator ¡

  • EncrypDon ¡funcDon ¡from ¡key, ¡byte[] ¡to ¡byte[] ¡
  • DecrypDon ¡funcDon ¡from ¡key, ¡byte[] ¡to ¡byte[] ¡

– aes_decrypt ¡k ¡(aes_encrypt ¡k ¡m) ¡= ¡m ¡

slide-32
SLIDE 32

Otway-­‑Rees ¡Protocol ¡

A ¡wishes ¡to ¡establish ¡a ¡key ¡for ¡use ¡with ¡B ¡ A, ¡B, ¡already ¡have ¡keys ¡shared ¡with ¡S ¡

  • 1. A ¡sends ¡request ¡to ¡B ¡(NA) ¡
  • 2. B ¡forwards ¡A ¡and ¡B’s ¡requests ¡to ¡S ¡
  • 3. S ¡replies ¡to ¡B ¡with ¡new ¡key ¡KAB ¡
  • 4. B ¡forwards ¡the ¡key ¡to ¡A ¡

Can ¡you ¡find ¡any ¡aaacks? ¡

slide-33
SLIDE 33

Lecture ¡2: ¡ A ¡Cryptographic ¡Library ¡in ¡F# ¡

Public-­‑Key ¡Cryptography ¡

slide-34
SLIDE 34

Public ¡and ¡Private ¡Key ¡GeneraDon ¡

  • FuncDons ¡that ¡generate ¡pairs ¡of ¡keys ¡such ¡that ¡
  • ne ¡key ¡is ¡known ¡to ¡everybody ¡and ¡the ¡other ¡is ¡

known ¡only ¡to ¡one ¡parDcipant. ¡

– Example: ¡RSA, ¡Diffie-­‑Hellman ¡

  • MathemaEcal ¡ProperEes: ¡ ¡

Private-­‑key ¡Secrecy: ¡Suppose ¡(pk,sk) ¡are ¡a ¡key-­‑

  • pair. ¡Then, ¡given ¡pk, ¡it ¡is ¡hard ¡to ¡compute ¡sk ¡
slide-35
SLIDE 35

Public-­‑key ¡EncrypDon ¡

  • FuncDons ¡that ¡uses ¡a ¡public ¡key ¡to ¡encode ¡a ¡

message ¡such ¡that ¡it ¡can ¡only ¡be ¡decoded ¡with ¡ the ¡corresponding ¡private ¡key ¡ ¡

– Example: ¡RSA, ¡DSA, ¡ElGamal ¡

  • MathemaEcal ¡ProperEes: ¡ ¡

Secrecy: ¡Given ¡(encrypt ¡pk ¡m) ¡and ¡pk, ¡ it ¡is ¡hard ¡to ¡compute ¡m ¡without ¡known ¡sk ¡ (where ¡pk ¡and ¡sk ¡form ¡a ¡key-­‑pair) ¡ ¡

slide-36
SLIDE 36

Digital ¡Signatures ¡

  • FuncDons ¡that ¡uses ¡a ¡private ¡key ¡to ¡compute ¡a ¡

message ¡signature ¡that ¡is ¡unforgeable ¡

– Example: ¡RSA-­‑SHA1, ¡ECDSA, ¡ElGamal ¡signature ¡

  • MathemaEcal ¡ProperEes: ¡ ¡

Unforgeability: ¡Given ¡pk ¡and ¡(m1,sign ¡sk ¡m1),…,(mk,sign ¡ sk ¡mk), ¡where ¡pk ¡and ¡sk ¡form ¡a ¡key-­‑pair, ¡ it ¡is ¡sDll ¡hard ¡to ¡compute ¡sign ¡sk ¡n ¡for ¡a ¡new ¡n ¡ ¡ (without ¡knowing ¡sk) ¡ Non-­‑repudia*on: ¡Given ¡(sign ¡sk ¡m), ¡one ¡can ¡prove ¡that ¡ the ¡owner ¡of ¡sk ¡signed ¡m ¡

slide-37
SLIDE 37

Needham-­‑Schroeder ¡Protocol ¡

  • A ¡-­‑> ¡B: ¡rsa ¡pkB ¡(request, ¡A) ¡
  • B ¡-­‑> ¡A: ¡rsa ¡pkA ¡(request, ¡response) ¡
  • A ¡-­‑> ¡B: ¡rsa ¡pkB ¡(response) ¡

Security ¡Goal: ¡ ¡ ¡ ¡ ¡At ¡the ¡end ¡of ¡the ¡exchange, ¡A ¡and ¡B ¡both ¡ agree ¡on ¡the ¡values ¡A, ¡B, ¡request, ¡response ¡

slide-38
SLIDE 38

Aaack ¡on ¡Needham ¡Schroeder ¡

  • A ¡-­‑> ¡C: ¡rsa ¡pkC ¡(request, ¡A) ¡
  • C ¡-­‑> ¡B: ¡rsa ¡pkB ¡(request, ¡A) ¡ ¡ ¡

– C ¡forwards ¡request ¡to ¡B, ¡but ¡pretends ¡to ¡be ¡A ¡

  • B ¡-­‑> ¡C: ¡rsa ¡pkA ¡(request, ¡response) ¡
  • C ¡-­‑> ¡A: ¡rsa ¡pkA ¡(request, ¡response) ¡

– C ¡forwards ¡the ¡response ¡to ¡A ¡

  • A ¡-­‑> ¡C: ¡rsa ¡pkC ¡(response) ¡

– C ¡obtains ¡response ¡from ¡B, ¡it ¡may ¡be ¡a ¡secret! ¡ – B ¡thinks ¡he ¡is ¡speaking ¡to ¡A, ¡but ¡is ¡speaking ¡to ¡C! ¡

slide-39
SLIDE 39

Needham-­‑Schroeder-­‑Lowe ¡Protocol ¡

  • A ¡-­‑> ¡B: ¡rsa ¡pkB ¡(request, ¡A) ¡
  • B ¡-­‑> ¡A: ¡rsa ¡pkA ¡(request, ¡response,B) ¡
  • A ¡-­‑> ¡B: ¡rsa ¡pkB ¡(response) ¡

Now, ¡C’s ¡aPack ¡fails: ¡ ¡B ¡-­‑> ¡C: ¡rsa ¡pkA ¡(request, ¡response,B) ¡ ¡C ¡-­‑> ¡A: ¡rsa ¡pkA ¡(request, ¡response,B) ¡

– C ¡cannot ¡hide ¡from ¡A ¡that ¡the ¡message ¡is ¡from ¡B ¡

slide-40
SLIDE 40

Crypto: ¡A ¡Crypto ¡Library ¡in ¡F# ¡

  • A ¡key ¡generaDon ¡funcDon ¡using ¡RSA ¡exponents ¡
  • EncrypDon ¡and ¡decrypDon ¡funcDons ¡
  • Signature ¡and ¡verificaDon ¡funcDons ¡
slide-41
SLIDE 41

Exercises ¡

  • Implement ¡the ¡Needham-­‑Schroeder ¡protocol ¡

in ¡F# ¡using ¡the ¡libraries ¡above ¡

  • Implement ¡the ¡aaack ¡on ¡Needham-­‑Schroeder ¡
  • Implement ¡Needham-­‑Schroeder-­‑Lowe ¡

– Does ¡the ¡aaack ¡sDll ¡work? ¡