formal security analysis of cryptographic protocol code
play

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


  1. Formal ¡Security ¡Analysis ¡of ¡ Cryptographic ¡Protocol ¡Code ¡ ¡ Karthikeyan ¡Bhargavan ¡ INRIA ¡ Karthikeyan.Bhargavan@inria.fr ¡ IIT ¡Delhi, ¡Fall ¡2010 ¡

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

  3. A ¡Secure ¡Web ¡ApplicaDon ¡ Client ¡ Bank ¡ D : ¡Client ¡and ¡ Bank ¡ share ¡ Online ¡Banking ¡Procedure ¡ ¡ ¡ ¡ ¡ ¡ ¡100 ¡lines ¡of ¡data ¡ Abstract ¡ Web ¡Browser ¡ ¡ Web ¡Server ¡ ¡ A : ¡Web ¡applicaDon ¡code ¡ Web ¡Session ¡ (Firefox+JS) ¡ (Apache+SQL) ¡ ¡ ¡ ¡ ¡ ¡100,000 ¡lines ¡(in ¡F#) ¡ Cryptographic ¡ Cryptographic ¡ P : ¡Security-­‑related ¡code ¡ Secure ¡Connec*on ¡ Protocol ¡ Protocol ¡ ¡ ¡ ¡ ¡ ¡10,000 ¡lines ¡(in ¡F#) ¡ (HTTPS/TLS) ¡ (HTTPS/TLS) ¡ Abstract ¡ Networking ¡ Networking ¡ L : ¡System ¡libraries ¡ ¡ ¡ ¡ ¡1,000,000 ¡lines ¡(in ¡C) ¡ (Windows) ¡ (Linux) ¡ Insecure ¡Network ¡ O : ¡Unknown ¡Opponent ¡ 3 ¡

  4. TLS: ¡Transport ¡Layer ¡Protocol ¡ ¡ A ¡Protocol ¡for ¡Secure ¡Sessions ¡ Firefox ¡Client ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡Apache ¡Server ¡ (Mozilla ¡NSS) ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡(OpenSSL) ¡ NegoDaDon ¡ ClientHello ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ServerHello ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡CerDficate ¡ Key ¡agreement ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ServerHelloDone ¡ (RSA, ¡no ¡client ¡auth) ¡ ClientKeyExchange ¡ [ChangeCipherSpec] ¡ ConfirmaDon ¡ Finished ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡[ChangeCipherSpec] ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡Finished ¡ ApplicaDon ¡ ApplicaDon ¡Data ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ApplicaDon ¡Data ¡ (Protected ¡by ¡Record ¡Protocol) ¡

  5. Example: ¡Encrypted ¡Message ¡ Message ¡Structure: ¡ C ¡  ¡S ¡: ¡{m,[m] ak } ek ¡ Cryptographic ¡Processing: ¡ data ¡ data ¡fragment ¡ mac ¡ data ¡fragment ¡ header ¡ encrypted ¡fragment ¡and ¡mac ¡

  6. Example: ¡Server ¡Code ¡Fragment ¡ Message ¡Structure: ¡ let recv (connid:ConnectionId) = let conn = getConnection connid in C ¡  ¡S ¡: ¡{m,[m] ak } ek ¡ let conn, input = recvRecord conn in let conn, msg = verifyPayload conn CT_application_data input in let id,entity = connid in Cryptographic ¡Processing: ¡ Security ¡event: ¡ log tr (Recv (id,entity,msg)); message ¡accepted! ¡ storeConnection connid conn; msg data ¡ 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 data ¡fragment ¡ let ver = conn.crt_version in if rver = ver then Message ¡Parsing ¡ mac ¡ let connst = conn.read in data ¡fragment ¡ 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 DecrypDon ¡ header ¡ encrypted ¡fragment ¡and ¡mac ¡ 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 MAC ¡verificaDon ¡ checkContentType ct rct payload; Full ¡ImplementaDon ¡of ¡TLS ¡ if hmacVerify connst maced recvmac then(conn,payload) else failwith "bad record mac" is ¡10,000 ¡lines ¡of ¡ML ¡ else failwith "bad version"

  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 ¡

  8. Lecture ¡2: ¡ A ¡Cryptographic ¡Library ¡in ¡F# ¡ Hash ¡FuncDons ¡

  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) ¡ ¡ ¡ ¡ ¡

  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 ¡ ¡

  11. A ¡Protocol ¡using ¡a ¡Hash ¡FuncDon ¡ Protocol : ¡ ¡ C ¡-­‑> ¡S ¡: ¡m, ¡(sha1 ¡password C ¡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: ¡password C , ¡ ¡ 3. ¡S ¡verifies ¡that ¡h ¡= ¡sha1 ¡password C ¡m ¡ ¡4. ¡If ¡the ¡test ¡fails, ¡S ¡rejects ¡the ¡message ¡ ¡ 5. ¡Otherwise, ¡it ¡accepts ¡the ¡message ¡m ¡from ¡C. ¡

  12. Security ¡Goals ¡ Protocol : ¡ ¡ C ¡-­‑> ¡S ¡: ¡m, ¡sha1 ¡password C ¡m ¡ Security ¡Goal : ¡ ¡ ¡ ¡Assume ¡that ¡password C ¡ 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’. ¡ ¡

  13. Aaempted ¡Aaacks ¡ Protocol : ¡ ¡ C ¡-­‑> ¡S ¡: ¡m, ¡sha1 ¡password C ¡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 ¡password C ¡m ¡= ¡sha1 ¡password C ¡m’ ¡must ¡fail. ¡ ¡ ¡[ Collision ¡Resistance] ¡ 2. Suppose ¡C’ ¡also ¡modifies ¡the ¡hash ¡to ¡sha1(password C’ ,m’). ¡ ¡ Then ¡S ¡will ¡accept ¡the ¡message ¡from ¡C’ ¡and ¡not ¡from ¡C. ¡ ¡The ¡aaacker ¡C’ ¡cannot ¡modify ¡the ¡hash ¡to ¡ ¡ sha1 ¡password C ¡m’ ¡since ¡he ¡does ¡not ¡know ¡ ¡password C ¡

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend