Download presentation
Presentation is loading. Please wait.
Published byFrankie Maxon Modified over 9 years ago
1
SECURITY AND VERIFICATION Lecture 4: Cryptography proofs in context Tamara Rezk INDES TEAM, INRIA January 24 th, 2012
2
QUESTIONS OF TODAY What can fail when encryption is put in larger program contexts? How to automatically verify it?
3
What can fail when encryption is put in larger program contexts? Security relying on CPA ? 1. x:= E (s,y) 2. k e, k d := G e (); k’ e, k’ d := G e (); y:= E (x, k e ); x’:= D (y, k’ d ) 3. k e, k d := G e (); y:= E (x, k e ); y’:= E (k d, k e ) 4. k e, k d := G e (); k’ e, k’ d := G e (); if (y=0) then {k e := k’ e } else {skip} ; y’= E (x, k e )
4
What can fail when encryption is put in larger program contexts? Security relying on CPA ? 1. x:= E (s,y) The program is not secure if y is not an encryption key generated by the generation function.
5
What can fail when encryption is put in larger program contexts? Security relying on CPA ? k e, k d := G e (); k’ e, k’ d := G e (); y:= E (x, k e ); x’:= D (y, k’ d ) The program is not secure if a different decryption key does not match the encryption key.
6
What can fail when encryption is put in larger program contexts? Security relying on CPA ? k e, k d := G e (); y:= E (x, k e ); y’:= E (k d, k e ) The CPA property does not state anything in case that the adversary is given the decryption key, even if this one is encrypted. This is called a key cycle. A key cycle occurs when there is an encryption of the decryption key with the corresponding encryption key. A longer key cycle: E ( E (k d, k’ e ), k e )
7
What can fail when encryption is put in larger program contexts? Security relying on CPA ? k e, k d := G e (); k’ e, k’ d := G e (); if (y=0) then {k e := k’ e } else {skip} ; y’= E (x, k e ) If y can hold the value 0 then the encryption keys are swaped. In this case a decryption x= D (u’, k d ) may fail.
8
What can fail when encryption is put in larger program contexts? Security relying on CPA ? Even if we use encryption schemes that are proved to be Resistent to chosen plaintext attacks, we need to check: Keys are correctely genereated Decryption key is not leaked to the adversary There are no key cycles No accidental leak of private information to the adversary No mix of different encryption schemes
9
What can fail when encryption is put in larger program contexts? Security relying on CPA We will state formally the security property desired and we will see an automatic verification method: Property: computational non-interference Method (static) : a type system
10
Computational Non-Interference for V (CNI) CNI = b:={0,1} ; I if (b=0) then { B 0 } else { B 1 }; P ; A The adversary does not have access to variables in B i, neither to b. It has access to variables V in I
11
Computational Non-Interference for V (CNI) CNI = b:={0,1} ; I if (b=0) then { B 0 } else { B 1 }; P ; A i I only writes variables in V. B i only writes variables outside V. A program P is CNI for variables V if for all I, B i, the advantage of A is negligible on a security parameter.
12
CNI = b:={0,1} I if (b=0) then {x:=1} else {x:={0,1}}; g:=x; A ; The program “g:=x “ is not CNI (the adversary cannot see x, but can see g).
13
CNI = b:={0,1} I P[A] ; The program is CNI if the adversary and the program P do not have b.
14
Types A type T contains a data type t and a security level l T:= t(l) l := L | H with L ≤ H t:= DATA | ENC T k | KE T k | KD T k k := K | K1 | K2 | …
15
Typing rules A typing rule is of the form: constrains ----------------------------------- F ├ commmand : l constrains ----------------------------------- F ├ expression: t(l) where F is a mapping from variables to types
16
Typing rules Typing rules for expressions: ----------------------------------- F ├ v: DATA (L) ----------------------------------- F ├ x: F(x) F ├ ei : DATA(li) l = U li ----------------------------------- F ├ op (e1,…, en) : DATA (l)
17
Typing rules Typing rules for a value expression (VAL): ----------------------------------- F ├ v: DATA (L) Values are always typed as public and DATA. For example: F ├ 0: DATA (L)
18
Typing rules Typing rules for a variable expression (VAR): ----------------------------------- F ├ x: F(x) Variables are typed according to map F. If F(y) = ENC DATA(L) K (L) then F ├ y: ENC DATA(L) K (L)
19
Typing rules Typing rules for an operation expression (OP): F ├ ei : DATA(li) l = U li ----------------------------------- F ├ op (e1,…, en) : DATA (l) Operations on expressions are always of type DATA. The security level is the join of the security levels of the parameters. For example: If F(y) = DATA (H ) then F ├ y + 3 : DATA (H) If F(y) = ENC DATA(L) K (L) then y + 3 is not typable
20
Typing rules Typing rule for assignment command (AS): F(x) = t(l) F ├ e : t(l’) l’ ≤ l ----------------------------------- F ├ x:= e : l The typing rule prevents explicit information leakage. For example, if F(x) = DATA (L) and F(y) = DATA (H) then x := y is not typable but y:=x is F ├ y: = x : H
21
Typing rules Typing rule for assignment command: F(x) = t(l) F ├ e : t(l’) l’ ≤ l ----------------------------------- F ├ x:= e : l The typing rule also prevents a violation of the data type wrt cryptographic types. For example, if F(x) = DATA (L) and F(y) = KE DATA(L) K (L) then neither x := y or y:=x are typable
22
Typing rules Typing rule for assignment command: F(x) = t(l) F ├ e : t(l’) l’ ≤ l ----------------------------------- F ├ x:= e : l Notice that in this rule there is NO INFORMATION FLOW from high (H) to low (L).
23
Typing rules Typing rule for if command (IF): F ├ e : DATA(l) F ├ P1 : l1 F ├ P2 : l2 l≤ l1 ∩ l2 ---------------------------------- F ├ if e then P1 else P2 : l The typing rule prevents implicit flows of information. For example: if F(y) = DATA(H) and F(x) = DATA(L) then if y=1 then x:=1 else x:=0 is not typable.
24
Typing rules Typing rule for if command (WHILE): F ├ e : DATA(l) F ├ P : l1 l≤ l1 ---------------------------------- F ├ while e P : l The typing rule prevents implicit flows of information. For example: if F(y) = DATA(H) and F(x) = DATA(L) then F ├ while x=1 (y:= y + 1) : L
25
Typing rules Typing rule for probabilistic function command (PROBFUN): F(xi) = DATA(li) l = ∩ li F ├ yi : DATA(li’) li ≤ l ---------------------------------- F ├ x1, x2.. := f(y1,y2, …) : l Probabilistic function {0,1} has no parameters and is trivially typable F ├ x : = {0,1} : F(x) If F(ke) = KE T K (L) and F(kd) = KD T K (L) then ke, kd:= G e () is not typable
26
Typing rules Typing rule for sequence (SEQ): F ├ c1 :l F ├ c2:l’ ---------------------------------- F ├ c1; c2: l ∩ l’ Sequence is typable if all subcommands are typable.
27
F(y) = t’(l’) ----------------- l’’ ≤ l’ t’= DATA F ├ y: t’(l’) F(x) = t(l)F(x) = t’(l’’ ) -------------------------- OP F ├ y+1 : t’(l’) ---------------- AS -------------------------------------- AS F ├ x:=1 :l F ├ y:=x+1:l’ --------------------------------------------------------------- SEQ F ├ x:= 1; y:= x + 1 : l1 To see that program is typable solve the constrains: l1= l ∩ l’ F(x) = t(l) and F(x) = t’(l’’ ) F(y) = t’(l’) and t’= DATA l≤ l’ A N EXAMPLE Typing derivation
28
Typing rules Typing rule for sequence: F ├ c1 :l F ├ c2:l’ ---------------------------------- F ├ c1; c2: l ∩ l’ Sequence is typable if all subcommands are typable.
29
Typing rules Typing rule for key generation (GEN): F (ke) = KE T K (L) F (kd) = KD T K (H) ---------------------------------- F ├ ke, kd: = G e () : L Notice that the type T must coincide as well as key label K for the corresponding pair of keys.
30
Typing rules F (ke) = KE T K (L) F (kd) = KD T K (H) ------------------------------GEN F ├ ke, kd: = G e () : L A key generation command can also be typed by the PROBFUN typing rule, if the types for ke and kd are DATA: F (ke) = DATA (L) F (kd) = DATA (H) ------------------------------PROBFUN F ├ ke, kd: = G e () : L
31
Typing rules F (ke) = KE t(H) K (L) F (x) = ENC t(H) K (L) F(y) = t(H) ------------------------------ENC F ├ x:= E (y,ke) : L Notice that in this rule there IS INFORMATION FLOW from high (H) to low (L). But if the encryption scheme is CPA then it is “secure” to have it.
32
Typing rules F (ke) = KE t(H) K (L) F (x) = ENC t(H) K (L) F(y) = t(H) ------------------------------ENC F ├ x:= E (y,ke) : L If there is no flow of information, encryption can still be typable by PROBFUN: F (ke) = DATA(L) F (x) = DATA(L) F(y) = t(L) ------------------------------PROBFUN F ├ x:= E (y,ke) : L
33
Theorem If 1. program P is typable with F, F ├ P: l 2. all encryption schemes used in P are CPA 3. each key label K in F is used for at most one key generation command typed with GEN then P is CNI for the set of L variables. We will prove this using games.
34
Lemma If 1. program P is typable with F, F ├ P: l 2. neither rule ENC or GEN are used to type P then P is CNI for the set of L variables. Furthermore Pr[CNI(P) ; g=b] = 1/2 The theorem is a generalization of this lemma. It is useful for the proof of the theorem. We will prove this lemma using games.
35
Lemma If 1. program P is typable with F, F ├ P: l 2. neither rule ENC or GEN are used to type P then P is CNI for the set of L variables. The proof is by structural induction on P, using the game based technique.
36
Proof CNI = b:={0,1} ; I if (b=0) then { B 0 } else { B 1 }; P ; A We will prove it for base cases: when P is a single command.
37
Proof CNI = b:={0,1} ; I if (b=0) then { B 0 } else { B 1 }; x:=e ; A Two cases to analyze: either F(x) = t(L) or F(x) = t(H).
38
Proof CNI = b:={0,1} ; I if (b=0) then { B 0 } else { B 1 }; x:=e ; A If F(x) = t(H), then by moving the command to B i, by subexpression elimination, we obtain a valid CNI command.
39
Proof CNI1 = b:={0,1} ; I if (b=0) then { B 0; x:=e } else { B 1; x:=e }; A If F(x) = t(H), then by moving the command to B i, by subexpression elimination, we obtain a valid CNI command.
40
Proof CNI1 = b:={0,1} ; I if (b=0) then { B 0; x:=e } else { B 1; x:=e }; A Since the adversary does not have access to variables in B i, we can apply deadcode
41
Proof CNI2 = b:={0,1} ; I A Since the adversary does not have access to variables in B i, we can apply deadcode and CNI1≈ g CNI2 By semantics probability of the adversary of guessing b is ½. End of the case for F(x) = t(H).
42
Proof CNI = b:={0,1} ; I if (b=0) then { B 0 } else { B 1 }; x:=e ; A Two cases to analyze: either F(x) = t(L) or F(x) = t(H).
43
Proof CNI = b:={0,1} ; I if (b=0) then { B 0 } else { B 1 }; x:=e ; A If F(x) = t(L), and because by assignment rule there is no flow from high to low, we know that e contains low variables. Then by moving the command to I, by swap (code motion), we obtain a valid CNI command.
44
Proof CNI1 = b:={0,1} ; I ; x:=e if (b=0) then { B 0 } else { B 1 }; A Since the adversary does not have access to variables in B i, we can apply deadcode
45
Proof CNI2 = b:={0,1} ; I A Since the adversary does not have access to variables in B i, we can apply deadcode and CNI1≈ g CNI2 By semantics probability of the adversary of guessing b is ½. End of the case for F(x) = t(L).
46
Proof CNI = b:={0,1} ; I if (b=0) then { B 0 } else { B 1 }; if e then P1 else P2 ; A If it is typed as L, by the expression typing rules variables in e are L. Hence, for each execution of CNI the value of e is determined by command I. We will do two transformations: one for when the value of e is true and one for false (the case false is analog).
47
Proof CNI1 = b:={0,1} ; I if (b=0) then { B 0 } else { B 1 }; P1 ; A If the value of e is true then the CNI program is equivalent to CNI1. By inductive hypothesis we conclude.
48
Proof CNI1 = b:={0,1} ; I if (b=0) then { B 0 } else { B 1 }; P1 ; A If the value of e is true then the CNI program is equivalent to CNI1. By inductive hypothesis we conclude. Other cases as exercise.
49
Theorem If 1. program P is typable with F, F ├ P: l 2. all encryption schemes used in P are CPA 3. each key label K in F is used for at most one key generation command typed with GEN then P is CNI for the set of L variables. We will prove this using games.
50
Proof sketch We eliminate one key label at the time to obtain P\K. P\K only encrypts 0s for each message m encrypted in P. We show that P\K can be typable without encryption rules. We replace in P, encryption by call to the CPA oracle E. We obtain P* that encrypts either m or 0. CPA(P*) = b:={0,1};ke,kd:= G(); b1:={0,1}; I; if b1 then B0 else B1; P*; A ; if b1=g1 then g:=1 else g:=0
51
Proof sketch If P is x:= E (y,ke) then P* is x0:= 0; x1:=y; E ; x:= c and P\K is x:= E (0,ke)
52
READING Slides, Notes, Bibliography Slides and exercises: www-sop.inria.fr/members/Tamara.Rezk/teaching Semantics and Program Analysis of Computationally Secure Information Flow - Laud Cryptographically sound implementations for typed information-flow security – Fournet, Rezk
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.