-
Notifications
You must be signed in to change notification settings - Fork 1
/
scimp_backwards_secrecy_sas.pv
328 lines (258 loc) · 11.3 KB
/
scimp_backwards_secrecy_sas.pv
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
(*
Formal analysis of the Silent Cirlce Instant Messaging Protocol (SCIMP).
Author: Sebastian Verschoor
Email: [email protected]
Last modified: <2015-10-08 14:54:01>
The key material of Alice and Bob was compromised. To mitigate and let
the protocol "self-heal", they re-negotiate the keys. By confirming the
SAS again, they can be sure of the authenticity and secrecy of their
new key material.
The description for the protocol was taken from the protocol description at:
https://github.com/SilentCircle/silent-text/tree/master/Documentation
A more informal description is given at:
https://silentcircle.com/scimp-protocol
Proverif version used: 1.90 (retrieved at 2015-07-06)
(*** Short protocol description ***
Initiator Alice (A)
Responder Bob (B)
ECDHE-exchange using a fixed base point G
Alice and Bob share the cached secret cs (compromised)
"=>" represents communication missed by the adversary
A : skI := random()
pkI := skI * G
A -> B: commit = (#pkI, MAC(cs, (#pkI, "Initiator")))
B: skR := random()
pkR := skR * G
A <- B: dh1 = (pkR, MAC(cs, (#pkR, "Responder")))
A : validate hcsr (= MAC in dh1); or abort
kdk2 := MAC(MAC(htotal, Z), (CONSTS, context, cs))
where htotal = #(commit, dh1, pkI)
Z = skI * pkR
context = (A, B, htotal)
extract from kdk2 and session variables:
ksnd, krcv, maci, macr, sasi, cs1, isnd, ircv
A -> B: dh2 = (pkI, maci)
B: validate pkI with #pkI of commit; or abort
validate hcsi (= MAC in commit); or abort
kdk2 := MAC(MAC(htotal, Z), (CONSTS, context, NULL))
where htotal = #(commit, dh1, pkI)
Z = skR * pkI
context = (A, B, htotal)
extract from kdk2 and session variables:
krcv, ksnd, macr, maci, sasr, cs1, ircv, isnd
A <- B: commit = macr
A <=> B: confirm sas; or abort
*)
(*** Types ***)
type mac_key.
type secret_key.
type nonce.
type point.
type scalar.
type identity.
fun mk2bs(mac_key) : bitstring [data, typeConverter].
fun bs2mk(bitstring) : mac_key [data, typeConverter].
fun sk2bs(secret_key) : bitstring [data, typeConverter].
fun bs2sk(bitstring) : secret_key [data, typeConverter].
fun pt2bs(point) : bitstring [data, typeConverter].
fun bs2n (bitstring) : nonce [data, typeConverter].
fun sk2mk(secret_key) : mac_key [data, typeConverter].
fun mk2sk(mac_key) : secret_key [data, typeConverter].
(*** Functions ***)
fun increment(bitstring) : bitstring [data].
fun splitFst(bitstring) : bitstring.
fun splitSnd(bitstring) : bitstring.
reduc forall x:bitstring;
unsplit(splitFst(x), splitSnd(x)) = x.
fun getCS(identity, identity) : bitstring [private].
equation forall x:identity, y:identity;
getCS(x, y) = getCS(y, x).
(* Cryptographic functions *)
fun hash(bitstring) : bitstring.
(* Message authentication code (MAC) *)
fun mac(mac_key, bitstring) : bitstring.
(* Key derivation function (KDF) *)
reduc forall key:mac_key, context:bitstring, label:bitstring;
kdf(key, label, context) = mac(key, (label, context)).
(* Symmetric encryption/decryption *)
fun sym_enc(secret_key, nonce, bitstring) : bitstring.
fun sym_dec(secret_key, nonce, bitstring) : bitstring.
equation forall k:secret_key, n:nonce, m:bitstring;
sym_dec(k, n, sym_enc(k, n, m)) = m.
equation forall k:secret_key, n:nonce, m:bitstring;
sym_enc(k, n, sym_dec(k, n, m)) = m.
(* Authenticated Encryption with Additional Data *)
letfun aead_enc(k:secret_key, n:nonce, header:bitstring, plaintext:bitstring) =
let tag = mac(sk2mk(k), (n, header, plaintext)) in
sym_enc(k, n, (plaintext, tag)).
letfun aead_dec(k:secret_key, n:nonce, header:bitstring, ciphertext:bitstring) =
let (plaintext:bitstring, tag:bitstring) = sym_dec(k, n, ciphertext) in
let (=tag) = mac(sk2mk(k), (n, header, plaintext)) in
plaintext.
(* Diffie-Hellman-Merkle key exchange
* Proverif does not care about the underlying group, so there is no need to
* encode ECDH any different.
*)
const Base : point [data].
fun mult(scalar, point) : point.
equation forall x:scalar, y:scalar;
mult(x, mult(y, Base)) = mult(y, mult(x, Base)).
(*** Communication channels ***)
(* Public channel over which the protocol is executed. Usually the internet. *)
free ch:channel.
(*** Constants ***)
const Null : bitstring [data]. (* NULL *)
const OK : bitstring [data]. (* SAS confirmation *)
(* String constants *)
const InitStr : bitstring [data]. (* "Initiator" *)
const RespStr : bitstring [data]. (* "Responder" *)
const MasterStr : bitstring [data]. (* "MasterSecret" *)
const AlgId : bitstring [data]. (* "SCimp-ENHANCE" *)
(* Labels for key derivation *)
const InitMasterLabel : bitstring [data]. (* "InitiatorMasterKey" *)
const RespMasterLabel : bitstring [data]. (* "ResponderMasterKey" *)
const InitMACLabel : bitstring [data]. (* "InitiatorMACkey" *)
const RespMACLabel : bitstring [data]. (* "ResponderMACkey" *)
const SasLabel : bitstring [data]. (* "SAS" *)
const CsLabel : bitstring [data]. (* "RetainedSecret" *)
const InitIndexLabel : bitstring [data]. (* "InitiatorInitialIndex" *)
const RespIndexLabel : bitstring [data]. (* "ResponderInitialIndex" *)
const MsgKeyLabel : bitstring [data]. (* "MessageKey" *)
(*** Queries ***)
(* Hint for the prover *)
not attacker(new ski).
not attacker(new skr).
(* Queries for confidentiality *)
free ksndInitFlag, krcvInitFlag, isndInitFlag, ircvInitFlag,
ksndRespFlag, krcvRespFlag, isndRespFlag, ircvRespFlag,
cs1InitFlag, cs1RespFlag, csInitFlag, csRespFlag : bitstring [private].
query attacker(ksndInitFlag); attacker(krcvInitFlag);
attacker(isndInitFlag); attacker(ircvInitFlag);
attacker(ksndRespFlag); attacker(krcvRespFlag);
attacker(isndRespFlag); attacker(ircvRespFlag);
attacker(cs1InitFlag); attacker(cs1RespFlag).
(* Queries for authenticity *)
event beginInit(identity, identity, bitstring, bitstring, bitstring, bitstring, bitstring).
event acceptInit(identity, identity, bitstring, bitstring, bitstring, bitstring, bitstring).
event beginResp(identity, identity, bitstring, bitstring, bitstring, bitstring, bitstring).
event acceptResp(identity, identity, bitstring, bitstring, bitstring, bitstring, bitstring).
query x:identity, y:identity, ki:bitstring, kr:bitstring,
ii:bitstring, ir:bitstring, cs1:bitstring;
inj-event(acceptInit(x, y, ki, kr, ii, ir, cs1))
==> inj-event(beginInit(x, y, ki, kr, ii, ir, cs1)).
query x:identity, y:identity, ki:bitstring, kr:bitstring,
ii:bitstring, ir:bitstring, cs1:bitstring;
inj-event(acceptResp(x, y, ki, kr, ii, ir, cs1))
==> inj-event(beginResp(x, y, ki, kr, ii, ir, cs1)).
(* Query reachability: check for typos. This should result in
not attacker(....HasTypo[]) is false. *)
free initHasTypo, respHasTypo : bitstring [private].
query attacker(initHasTypo); attacker(respHasTypo).
(*** Processes ***)
(* Role of the initiator *)
let processInitiator(init:identity, resp:identity, cs:bitstring, phone:channel) =
(* Commit *)
new ski : scalar;
let pki = mult(ski, Base) in
let hpki = hash(pt2bs(pki)) in
let hcsi = mac(bs2mk(cs), hash((pki, InitStr))) in
let commit = (hpki, hcsi) in
out(ch, commit);
(* DH1 *)
in(ch, dh1:bitstring);
let (pkr:point, hcsr:bitstring) = dh1 in
if hcsr = mac(bs2mk(cs), hash((pkr, RespStr))) then
(* DH2 *)
let z = mult(ski, pkr) in
let htotal = hash((commit, dh1, pki)) in
let kdk = bs2mk(mac(bs2mk(htotal), pt2bs(z))) in
let context = (init, resp, htotal) in
let sessId = hash((init, resp)) in
let kdk2 = bs2mk(mac(kdk, (MasterStr, AlgId, context, cs))) in
let maci = kdf(kdk2, InitMACLabel, context) in
out(ch, (pki, maci));
(* Confirm *)
in(ch, macr:bitstring);
let ksnd = kdf(kdk2, InitMasterLabel, context) in
let krcv = kdf(kdk2, RespMasterLabel, sessId) in
let sas = kdf(kdk2, SasLabel, context) in
let cs1 = kdf(kdk2, CsLabel, context) in
let isnd = kdf(kdk2, InitIndexLabel, sessId) in
let ircv = kdf(kdk2, RespIndexLabel, sessId) in
let (=macr) = kdf(kdk2, RespMACLabel, context) in
event beginInit(init, resp, ksnd, krcv, isnd, ircv, cs1);
(* Confirm the SAS *)
out(phone, sas);
in(phone, (=sas, ok:bitstring));
event acceptResp(init, resp, ksnd, krcv, isnd, ircv, cs1);
(* Publish secret values to test secrecy of generated key material *)
out(ch, sym_enc(bs2sk(ksnd), bs2n(Null), ksndInitFlag));
out(ch, sym_enc(bs2sk(krcv), bs2n(Null), krcvInitFlag));
out(ch, sym_enc(bs2sk(isnd), bs2n(Null), isndInitFlag));
out(ch, sym_enc(bs2sk(ircv), bs2n(Null), ircvInitFlag));
out(ch, sym_enc(bs2sk(cs1), bs2n(Null), cs1InitFlag))
(* Check for typos *)
; out(ch, initHasTypo)
.
(* Role of the responder *)
let processResponder(init:identity, resp:identity, cs:bitstring, phone:channel) =
(* Commit *)
in(ch, commit:bitstring);
let (hpki:bitstring, hcsi:bitstring) = commit in
(* DH1 *)
new skr : scalar;
let pkr = mult(skr, Base) in
let hpkr = hash(pt2bs(pkr)) in
let hcsr = mac(bs2mk(cs), hash((pkr, RespStr))) in
let dh1 = (pkr, hcsr) in
out(ch, dh1);
(* DH2 *)
in(ch, (pki:point, maci:bitstring));
let (=hpki) = hash(pt2bs(pki)) in
if hcsi = mac(bs2mk(cs), hash((pki, InitStr))) then
(* Confirm *)
let z = mult(skr, pki) in
let htotal = hash((commit, dh1, pki)) in
let kdk = bs2mk(mac(bs2mk(htotal), pt2bs(z))) in
let context = (init, resp, htotal) in
let sessId = hash((init, resp)) in
let kdk2 = bs2mk(mac(kdk, (MasterStr, AlgId, context, cs))) in
let ksnd = kdf(kdk2, RespMasterLabel, sessId) in
let krcv = kdf(kdk2, InitMasterLabel, context) in
let sas = kdf(kdk2, SasLabel, context) in
let cs1 = kdf(kdk2, CsLabel, context) in
let (=maci) = kdf(kdk2, InitMACLabel, context) in
let macr = kdf(kdk2, RespMACLabel, context) in
let isnd = kdf(kdk2, RespIndexLabel, sessId) in
let ircv = kdf(kdk2, InitIndexLabel, sessId) in
out(ch, macr);
event beginResp(init, resp, krcv, ksnd, ircv, isnd, cs1);
(* Confirm the SAS *)
in(phone, =sas);
out(phone, (sas, OK));
event acceptInit(init, resp, krcv, ksnd, ircv, isnd, cs1);
(* Publish secret values to test secrecy of generated key material *)
out(ch, sym_enc(bs2sk(ksnd), bs2n(Null), ksndRespFlag));
out(ch, sym_enc(bs2sk(krcv), bs2n(Null), krcvRespFlag));
out(ch, sym_enc(bs2sk(isnd), bs2n(Null), isndRespFlag));
out(ch, sym_enc(bs2sk(ircv), bs2n(Null), ircvRespFlag));
out(ch, sym_enc(bs2sk(cs1), bs2n(Null), cs1RespFlag))
(* Check for typos *)
; out(ch, respHasTypo)
.
(*** Main ***)
process
(* Allow arbitrary many protocol runs *)
!
(* Let the adversary decide who will rekey *)
in(ch, (init:identity, resp:identity));
(* Get their cached secret *)
let cs = getCS(init, resp) in
(* Compromised the cached secret *)
out(ch, cs);
(* Create a new phone channel *)
new phone : channel;
(* Allow eavesdropping on the phone channel *)
(! in(phone, x:bitstring); out(ch, x)) |
processInitiator(init, resp, cs, phone) |
processResponder(init, resp, cs, phone)