Verified protocol implementations in F*

Slides:



Advertisements
Similar presentations
Probabilistic Public Key Encryption with Equality Test Duncan S. Wong Department of Computer Science City University of Hong Kong Joint work with Guomin.
Advertisements

MAC Raushan. DES simple fiestel network 3131 PlainText Blocks 2*4=8bits 31 f f =0011 xor 0011=0000 = 0 f(r,k)=(2*r+k^2)%8 f(1,5)=(2*1+5^2)%8=3 xor 3 3.
SECURITY AND VERIFICATION Lecture 4: Cryptography proofs in context Tamara Rezk INDES TEAM, INRIA January 24 th, 2012.
Last Class: The Problem BobAlice Eve Private Message Eavesdropping.
CS555Topic 191 Cryptography CS 555 Topic 19: Formalization of Public Key Encrpytion.
1 Cryptanalysis-tolerant CPA crypt. ● Suppose E, E’ are two encryption schemes which on of them is CPA - secure  E.g., a standard and a proprietary, a.
Security Definitions in Computational Cryptography
1 Introduction CSE 5351: Introduction to cryptography Reading assignment: Chapter 1 of Katz & Lindell.
S EMANTICALLY - SECURE FUNCTIONAL ENCRYPTION : P OSSIBILITY RESULTS, IMPOSSIBILITY RESULTS AND THE QUEST FOR A GENERAL DEFINITION Adam O’Neill, Georgetown.
CS 395T Computational Soundness of Formal Models.
Asymmetric Cryptography part 1 & 2 Haya Shulman Many thanks to Amir Herzberg who donated some of the slides from
Overview of Cryptography Anupam Datta CMU Fall A: Foundations of Security and Privacy.
Cryptography (continued). Enabling Alice and Bob to Communicate Securely m m m Alice Eve Bob m.
CMSC 414 Computer and Network Security Lecture 22 Jonathan Katz.
Hybrid Signcryption with Outsider Security
1 CIS 5371 Cryptography 9. Data Integrity Techniques.
Feb 19, 2002Mårten Trolin1 Previous lecture Practical things about the course. Example of cryptosystem — substitution cipher. Symmetric vs. asymmetric.
1 CS 194: Distributed Systems Security Scott Shenker and Ion Stoica Computer Science Division Department of Electrical Engineering and Computer Sciences.
Dan Boneh Authenticated Encryption Case study: TLS Online Cryptography Course Dan Boneh.
Rennes, 15/10/2014 Cristina Onete Message authenticity: Digital Signatures.
Cryptography Lecture 8 Stefan Dziembowski
Lecture 11: Strong Passwords
1 Lect. 13 : Public Key Encryption RSA ElGamal. 2 Shamir Rivest Adleman RSA Public Key Systems  RSA is the first public key cryptosystem  Proposed in.
Lecture 3.4: Public Key Cryptography IV CS 436/636/736 Spring 2013 Nitesh Saxena.
Basic Cryptography 1. What is cryptography? Cryptography is a mathematical method of protecting information –Cryptography is part of, but not equal to,
Kerberos Named after a mythological three-headed dog that guards the underworld of Hades, Kerberos is a network authentication protocol that was designed.
CS555Spring 2012/Topic 111 Cryptography CS 555 Topic 11: Encryption Modes and CCA Security.
Cryptography Lecture 2 Arpita Patra. Summary of Last Class  Introduction  Secure Communication in Symmetric Key setting >> SKE is the required primitive.
1 Reasoning about Concrete Security in Protocol Proofs A. Datta, J.Y. Halpern, J.C. Mitchell, R. Pucella, A. Roy.
14.1 Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Chapter 14 Entity Authentication.
Merkle trees Introduced by Ralph Merkle, 1979 An authentication scheme
Secure Computation Lecture Arpita Patra. Recap >> Improving the complexity of GMW > Step I: Offline: O(n 2 c AND ) OTs; Online: i.t., no crypto.
CS555Spring 2012/Topic 81 Cryptography CS 555 Topic 8: Pseudorandom Functions and CPA Security.
Dos and Don’ts of Client Authentication on the Web Kevin Fu, Emil Sit, Kendra Smith, Nick Feamster Presented: Jesus F. Morales.
EE 122: Lecture 24 (Security) Ion Stoica December 4, 2001.
Cryptography Lecture 9 Arpita Patra © Arpita Patra.
Dan Boneh Authenticated Encryption CBC paddings attacks Online Cryptography Course Dan Boneh.
Cryptography Lecture 10 Arpita Patra © Arpita Patra.
Cryptography Lecture 3 Arpita Patra © Arpita Patra.
6.033 Quiz3 Review Spring How can we achieve security? Authenticate agent’s identity Verify the integrity of the request Check the agent’s authorization.
SECURITY. Security Threats, Policies, and Mechanisms There are four types of security threats to consider 1. Interception 2 Interruption 3. Modification.
Cryptography Lecture 6 Arpita Patra. Quick Recall and Today’s Roadmap >> MAC for fixed-length messages >> Domain Extension for MAC >> Authenticated Encryption:
Cryptography CS 555 Topic 34: SSL/TLS.
Authenticated encryption
Basic Network Encryption
Modern symmetric-key Encryption
Topic 24: Finding Prime Numbers, RSA
Secrecy of (fixed-length) stream ciphers
Digital signatures.
Efficient Public-Key Distance Bounding
Digital Signature Schemes and the Random Oracle Model
Cryptography Lecture 26.
Topic 11: Authenticated Encryption + CCA-Security
Semantic Security and Indistinguishability in the Quantum World
Cryptography Lecture 12.
Topic 30: El-Gamal Encryption
پروتكلهاي احرازاصالت Authentication protocols
Cryptography Lecture 6.
Topic 7: Pseudorandom Functions and CPA-Security
Soundness of Formal Encryption in the Presence of Key Cycles
CDK4: Chapter 7 CDK5: Chapter 11 TvS: Chapter 9
Protocol ap1.0: Alice says “I am Alice”
Cryptography Lecture 12 Arpita Patra © Arpita Patra.
CDK: Chapter 7 TvS: Chapter 9
Cryptography Lecture 9.
Cryptography Lecture 12.
Basic Network Encryption
The power of Pairings towards standard model security
Cryptography Lecture 22.
Cryptography Lecture 25.
Presentation transcript:

Verified protocol implementations in F* Alessandro Bruni

$ whoami # Alessandro Bruni – Computer Scientist Now: Postdoc researcher @ ITU (computer security, SW verification, theorem provers…) Before: Fall 2015: Garbage Collector @ Prolog Dev. Center 2012-2015: PhD @ DTU (computer sec., SW ver, ...) Contributed crypto examples to the FStar repo 2012: Research Eng. @ Siav SpA (process mining) Find me at: alessandrobruni.name / @hoheinzollern

Recap: F* & Refinement types F* = F# + Types on Steroids: Can express powerful properties on data, e.g.: val cons: n: nat -> l: ‘a list {n = List.length l} -> x: ‘a -> l’: ‘a list {n+1 = List.length l’} “Can we use refinement types for proving security of protocols?” = +

Heartbleed, openSSL

Source: XKCD

Source: XKCD

Could /that/ be prevented? Yes Yes! Like tons of similar vulnerabilities, using a strong typing discipline Option 2: val reply: len:nat -> msg:text{length msg = len}  -> resp:text{resp = msg} Hint: not a complete solution…

miTLS: A Verified Reference Implementation of TLS Uses F* dependent types to reason about the security of TLS Attacks discovered while verifying TLS: Alert 3SHAKE VHC SMACK Logjam SLOTH Quick morale: Automatic reasoning about program correctness helps to discover problems, otherwise unnoticed The more automatic checking, the better

Introducing: Security Games “the only winning move is not to play” Artificial setup: Attacker given access to an Oracle, who gives him lots of information (e.g. encrypts/decrypts messages for him) minus some important bits (e.g. encryption keys) Game follows a script: the attacker and the oracle both follow the rules of the game Security proof: If the attacker has no better strategy than purely random guesses then the protocol is secure

Eavesdropping security (EAV) Oracle (knows k) Eavesdropper m[0] m[1] , ( ) b = sample {0,1} encrypt(k, m[b]) guess b Eavesdropper wins the game if P(guess b) > ½ + ε

Uppin’ the Game: Chosen Plaintext Attacks (IND-CPA) , ( ) m[0] m[1] b = sample {0,1} encrypt(k, m[b]) guess b We give the attacker access to encrypt(k, -) before and after the interaction with the user Still, we should have P(guess b) < ½ + ε Encryption should never return the same value twice ;)

Integrity of Chosen Message Attacks (INT-CMA) Oracle (knows k) Attacker m t = sign(k, m) (m’, t’) t’ = sign(m’, k) Attacker can query the oracle for signatures, but each requested message m is logged along with its signature tag t The attacker wins the game if he can produce a new pair (m’, t’), where t’ = sign(k, m’), with probability > ε

Reasoning in F* Security games are recipes (programs?) Involve interaction between parties val send: string -> IO unit val recv: unit -> IO string Express verification conditions IND-CPA Encryption: val enc: k:key -> plain -> c:cipher{Encrypted k c} val dec: k:key -> c:cipher{Encrypted k c} -> plain INT-CMA Signatures: val mac: k:key -> t:text{Oracle k t} -> tag val verify: k:key -> t:text -> tag -> b:bool{b ==> Oracle k t} Are we missing something? where the predicate ENCrypted(k,p,c) in the refinements ensures that a well-typed program never attempts to decrypt a ciphertext not produced by ENC. The interface also includes a logical as- sumption, stating that a ciphertext is the correct encryption of at most one plaintext for a given key. Authenticated

Introducing: Probabilistic F* New construct: let n = sample {0,1} in n = 1 50% n = 0 50%

Negligible differences let mac k t = let m = hmac_sha1 k t in log := Entry k t m :: !log; m let verify k text tag = let m = hmac_sha1 k text in let verified = (m = tag) in let found = is_Some (List.find (fun (Entry k' text' tag’) -> k = k' && text = text') !log) in verified && found let mac k t = let m = hmac_sha1 k t in m let verify k text tag = let m = hmac_sha1 k text in let verified = (m = tag) in verified ≈ <ε Remember: val mac: k:key -> t:text{Oracle k t} -> tag val verify: k:key -> t:text -> tag -> b:bool{b ==> Oracle k t}

Example: RPC protocol A -> B: utf8 s, mac kAB s B -> A: utf8 t, mac kAB (s, t) assume forall k t . Oracle k (utf8 t) <==> Request t let client q =   assume Request(q)   ...   send mac k (utf8 q) let server q =   ...   if verify k (utf8 q) m     then assert Request(q)       process q

Demo

Conclusions We can build cryptographic proofs of correctness using dependent types Precisely reasoning about the correctness of programs (using types) helps discover problems (miTLS attacks) Interested in more crypto protocols? Explore /FStar/examples/crypto