Skip to content

Commit 0cec60d

Browse files
committed
adapts DH model to allow messages encrypted under shared key
1 parent d95ea0f commit 0cec60d

File tree

1 file changed

+106
-32
lines changed

1 file changed

+106
-32
lines changed

dh/model/dh.spthy

Lines changed: 106 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,26 @@
1-
theory DhOld
1+
theory Dh
22
begin
33

4-
builtins: diffie-hellman
5-
6-
functions: sign/2, pk/1, verify/2, extract/1, true/0
4+
builtins: diffie-hellman, symmetric-encryption
75

6+
functions: sign/2, pk/1, verify/2, extract/1, true/0, kdf1/1, kdf2/1
87
equations: extract(sign(m, k)) = m
9-
108
equations: verify(sign(m, k), pk(k)) = true
119

1210

1311
/* format = transparent constructor used for the messages */
14-
functions: format/5, ex1/1, ex2/1, ex3/1, ex4/1, ex5/1
12+
functions: format2/2, ex21/1, ex22/1
13+
equations:
14+
ex21(format2(x1,x2)) = x1,
15+
ex22(format2(x1,x2)) = x2
1516

17+
functions: format5/5, ex51/1, ex52/1, ex53/1, ex54/1, ex55/1
1618
equations:
17-
ex1(format(x1,x2,x3,x4,x5)) = x1,
18-
ex2(format(x1,x2,x3,x4,x5)) = x2,
19-
ex3(format(x1,x2,x3,x4,x5)) = x3,
20-
ex4(format(x1,x2,x3,x4,x5)) = x4,
21-
ex5(format(x1,x2,x3,x4,x5)) = x5
19+
ex51(format5(x1,x2,x3,x4,x5)) = x1,
20+
ex52(format5(x1,x2,x3,x4,x5)) = x2,
21+
ex53(format5(x1,x2,x3,x4,x5)) = x3,
22+
ex54(format5(x1,x2,x3,x4,x5)) = x4,
23+
ex55(format5(x1,x2,x3,x4,x5)) = x5
2224

2325

2426
/* -------------------- */
@@ -61,21 +63,50 @@ rule Alice_send:
6163

6264
rule Alice_recvAndSend:
6365
let
64-
msgIn = format('0', B, A, 'g'^x, Y)
65-
mOut = format('1', A, B, Y, 'g'^x)
66-
key = Y^x
66+
msgIn = format5('0', B, A, 'g'^~x, Y)
67+
mOut = format5('1', A, B, Y, 'g'^~x)
68+
key = Y^~x
6769
in
68-
[ St_Alice_1(ridA, A, B, skA, skB, x),
70+
[ St_Alice_1(ridA, A, B, skA, skB, ~x),
6971
In(sign(msgIn, skB)) ]
7072
--[ IN_ALICE(Y, msgIn),
7173
Secret(A, B, key),
7274
Running('R', 'I', <A, B, key>),
73-
Commit('I', 'R', <A, B, key>)
75+
Commit('I', 'R', <A, B, key>),
76+
AliceHsDone(key)
7477
]->
75-
[ St_Alice_2(ridA, A, B, skA, skB, x, Y),
78+
[ St_Alice_2(ridA, A, B, skA, skB, ~x, Y),
7679
Out(sign(mOut, skA)) ]
7780

7881

82+
rule Alice_sendMsg:
83+
let
84+
key = kdf1(Y^~x)
85+
mOut = format2('2', senc(msgIn, key))
86+
in
87+
[ St_Alice_2(ridA, A, B, skA, skB, ~x, Y),
88+
In(msgIn) ]
89+
--[ AliceSendLoop(Y^~x),
90+
AliceSendTransMsg(msgIn, key),
91+
OutFormat2(mOut) ]->
92+
[ St_Alice_2(ridA, A, B, skA, skB, ~x, Y),
93+
Out(mOut) ]
94+
95+
96+
rule Alice_recvMsg:
97+
let
98+
key = kdf2(Y^~x)
99+
mIn = format2('2', senc(msgOut, key))
100+
in
101+
[ St_Alice_2(ridA, A, B, skA, skB, ~x, Y),
102+
In(mIn) ]
103+
--[ AliceRecvLoop(Y^~x),
104+
AliceRecvTransMsg(msgOut, key),
105+
InFormat2(mIn) ]->
106+
[ St_Alice_2(ridA, A, B, skA, skB, ~x, Y),
107+
Out(msgOut) ]
108+
109+
79110

80111
/* Bob role */
81112
rule Bob_init: // technically an env rule
@@ -86,7 +117,7 @@ rule Bob_init: // technically an env rule
86117

87118
rule Bob_recvAndSend:
88119
let
89-
mOut = format('0', B, A, X, 'g'^~y)
120+
mOut = format5('0', B, A, X, 'g'^~y)
90121
key = X^~y
91122
in
92123
[ Setup_Bob(ridB, B, A, skB, skA),
@@ -101,29 +132,72 @@ rule Bob_recvAndSend:
101132

102133
rule Bob_recv:
103134
let
104-
msgIn = format('1', A, B, 'g'^y, X)
105-
key = X^y
135+
msgIn = format5('1', A, B, 'g'^~y, X)
136+
key = X^~y
106137
in
107-
[ St_Bob_1(ridB, B, A, skB, skA, y, X),
138+
[ St_Bob_1(ridB, B, A, skB, skA, ~y, X),
108139
In(sign(msgIn, skA)) ]
109140
--[ Commit('R', 'I', <A, B, key>),
110-
Secret(A, B, key) ]->
111-
[ St_Bob_2(ridB, B, A, skB, skA, y, X) ]
141+
Secret(A, B, key),
142+
BobHsDone(key) ]->
143+
[ St_Bob_2(ridB, B, A, skB, skA, ~y, X) ]
144+
145+
146+
rule Bob_recvMsg:
147+
let
148+
key = kdf1(X^~y)
149+
mIn = format2('2', senc(msgOut, key))
150+
in
151+
[ St_Bob_2(ridB, B, A, skB, skA, ~y, X),
152+
In(mIn) ]
153+
--[ BobRecvLoop(X^~y),
154+
BobRecvTransMsg(msgOut, key),
155+
BobRecvTransMsgIden(A, B, msgOut, key),
156+
InFormat2(mIn) ]->
157+
[ St_Bob_2(ridB, B, A, skB, skA, ~y, X),
158+
Out(msgOut) ]
159+
160+
161+
rule Bob_sendMsg:
162+
let
163+
key = kdf2(X^~y)
164+
mOut = format2('2', senc(msgIn, key))
165+
in
166+
[ St_Bob_2(ridB, B, A, skB, skA, ~y, X),
167+
In(msgIn) ]
168+
--[ BobSendLoop(X^~y),
169+
BobSendTransMsg(msgIn, key),
170+
OutFormat2(mOut) ]->
171+
[ St_Bob_2(ridB, B, A, skB, skA, ~y, X),
172+
Out(mOut) ]
173+
112174

113175

114176
/* ------------------------- */
115177
/* Lemmas and properties */
116178
/* ------------------------- */
117179
/* source lemma */
118-
lemma types [sources]:
119-
" (All y m #i.
120-
IN_ALICE(y , m) @ i
121-
==>
122-
( (Ex #j. KU(y) @ j & j < i)
123-
| (Ex #j. OUT_BOB( m ) @ j )
124-
)
125-
)
126-
"
180+
lemma sources [sources]:
181+
" (All payload key #i.
182+
BobRecvTransMsg(payload, key)@i ==>
183+
(Ex #j. AliceSendTransMsg(payload, key)@j & #j < #i) |
184+
(Ex #j #k. KU(key)@j & #j < #i & KU(payload)@k & #k < #i))
185+
&
186+
(All payload key #i.
187+
AliceRecvTransMsg(payload, key)@i ==>
188+
(Ex #j. BobSendTransMsg(payload, key)@j & #j < #i) |
189+
(Ex #j #k. KU(key)@j & #j < #i & KU(payload)@k & #k < #i))
190+
&
191+
(All x1 x2 #i.
192+
InFormat2(format2(x1, x2))@i ==>
193+
(Ex #j. OutFormat2(format2(x1, x2))@j) |
194+
(Ex #j #k. KU(x1)@j & #j < #i & KU(x2)@k & #k < #i))
195+
&
196+
(All key m #i.
197+
IN_ALICE(key, m) @ i ==>
198+
( (Ex #j. KU(key) @ j & j < i)
199+
| (Ex #j. OUT_BOB( m ) @ j )))
200+
"
127201

128202

129203
/* Executability check */

0 commit comments

Comments
 (0)