-
Notifications
You must be signed in to change notification settings - Fork 1
/
scimp_progressive_enc.pv
572 lines (478 loc) · 20.4 KB
/
scimp_progressive_enc.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
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
(*
Formal analysis of the Silent Cirlce Instant Messaging Protocol (SCIMP).
Author: Sebastian Verschoor
Email: [email protected]
Last modified: <2015-10-11 23:48:34>
This file checks the secrecy and authenticity of the initial key negotiation,
where two honest participants do not yet share a cached secret. The key
negotiation will be done with Progressive Encryption.
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)
Server (S)
ECDHE-exchange using a fixed base point G
B: skB := random()
pkB := skB * G
idPkB := KDF(pkB, Const, nonce)
B -> S: B, pkB, idPkB
A -> S: B
S -> A: B, pkB, idPkB
A: sk0 := random()
pk0 := sk0 * G
Z0 := sk0 * pkB
expand/extract/enhance: ksnd, isnd
ct := enc(ksnd, isnd, msg)
skI := random()
pkI := skI * G
A -> B: pkstart = (options, idPkB, pk0, #pkI, ct)
B: Z0 := skB * pk0
expand/extract/enhance: krcv, ircv
pt := dec(krcv, ircv, ct)
skR := random()
pkR := skR * G
B -> A: dh1 = (pkR, MAC(NULL, (#pkR, "Responder")))
A: kdk2 := MAC(MAC(htotal, Z), (CONSTS, context, NULL))
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
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
B -> A: commit = macr
A <=> B: check (sasi = sasr); 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].
fun pt2mk(point) : mac_key [data, typeConverter].
fun id2bs(identity) : bitstring [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.
(* 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]. (* Confirmation of SAS *)
(* 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" *)
const LocatorLabel : bitstring [data]. (* "SCKey_ECC_Key" *)
const Compromised : identity [data].
(* Key table *)
table keys(identity, point, bitstring).
(*** Queries ***)
(* Prover hints *)
not attacker(new ski). not attacker(new skiC).
not attacker(new ski0). not attacker(new ski0C).
not attacker(new skr). not attacker(new skrC).
not attacker(new skr0). not attacker(new skr0C).
(* Queries for confidentiality *)
free ksndInitFlag, krcvInitFlag, isndInitFlag, ircvInitFlag,
ksndRespFlag, krcvRespFlag, isndRespFlag, ircvRespFlag,
ksnd0InitFlag, krcv0InitFlag, isnd0InitFlag, ircv0InitFlag,
ksnd0RespFlag, krcv0RespFlag, isnd0RespFlag, ircv0RespFlag,
cs1InitFlag, cs1RespFlag, msg0InitFlag, msg0RespFlag : bitstring [private].
query attacker(ksndInitFlag); attacker(krcvInitFlag);
attacker(isndInitFlag); attacker(ircvInitFlag);
attacker(ksndRespFlag); attacker(krcvRespFlag);
attacker(isndRespFlag); attacker(ircvRespFlag);
attacker(ksnd0InitFlag); attacker(krcv0InitFlag);
attacker(isnd0InitFlag); attacker(ircv0InitFlag);
attacker(ksnd0RespFlag); attacker(krcv0RespFlag);
attacker(isnd0RespFlag); attacker(ircv0RespFlag);
attacker(cs1InitFlag); attacker(cs1RespFlag);
attacker(msg0InitFlag); attacker(msg0RespFlag).
query attacker(new msg0).
query attacker(new msg0C).
(* Queries for authenticity *)
event beginInit(identity, identity,
bitstring, bitstring, bitstring, bitstring, bitstring,
bitstring, bitstring, bitstring, bitstring, bitstring).
event acceptInit(identity, identity,
bitstring, bitstring, bitstring, bitstring, bitstring,
bitstring, bitstring, bitstring, bitstring, bitstring).
event beginResp(identity, identity,
bitstring, bitstring, bitstring, bitstring, bitstring,
bitstring, bitstring, bitstring, bitstring, bitstring).
event acceptResp(identity, identity,
bitstring, bitstring, bitstring, bitstring, bitstring,
bitstring, bitstring, bitstring, bitstring, bitstring).
query x:identity, y:identity,
ki:bitstring, kr:bitstring, ii:bitstring, ir:bitstring, cs:bitstring,
ki0:bitstring, kr0:bitstring, ii0:bitstring, ir0:bitstring, msg:bitstring;
inj-event(acceptInit(x, y, ki, kr, ii, ir, cs, ki0, kr0, ii0, ir0, msg))
==> inj-event(beginInit(x, y, ki, kr, ii, ir, cs, ki0, kr0, ii0, ir0, msg)).
query x:identity, y:identity,
ki:bitstring, kr:bitstring, ii:bitstring, ir:bitstring, cs:bitstring,
ki0:bitstring, kr0:bitstring, ii0:bitstring, ir0:bitstring, msg:bitstring;
inj-event(acceptResp(x, y, ki, kr, ii, ir, cs, ki0, kr0, ii0, ir0, msg))
==> inj-event(beginResp(x, y, ki, kr, ii, ir, cs, ki0, kr0, ii0, ir0, msg)).
(* Query reachability: check for typos. This should result in
not attacker(....HasTypo[]) is false. *)
free initHasTypo, initCompHasTypo, respHasTypo, respCompHasTypo : bitstring [private].
query attacker(initHasTypo); attacker(initCompHasTypo);
attacker(respHasTypo); attacker(respCompHasTypo).
(*** Processes ***)
(* Role of the server (handing out keys) *)
let processGetKey =
in(ch, resp:identity);
get keys(=resp, pkResp, locResp) in
out(ch, (pkResp, locResp)).
(* Role of the server (key registration) *)
let processKeyRegistration =
in(ch, (id:identity, pubkey:point, locator:bitstring));
insert keys(id, pubkey, locator).
(* Role of the initiator *)
let processInitiator(init:identity, resp:identity, phone:channel) =
(* Get responder public key *)
out(ch, resp);
in(ch, (pkResp:point, locResp:bitstring));
(* PKStart *)
new msg0 : bitstring;
new ski0 : scalar;
let pki0 = mult(ski0, Base) in
let z0 = mult(ski0, pkResp) in
let kdk0 = bs2mk(mac(bs2mk(Null), pt2bs(z0))) in
let context0 = (init, resp) in
let sessId0 = hash(context0) in
let kdk20 = bs2mk(mac(kdk0, (MasterStr, AlgId, context0, Null))) in
let ksnd0 = kdf(kdk20, InitMasterLabel, context0) in
let krcv0 = kdf(kdk20, RespMasterLabel, sessId0) in
let isnd0 = kdf(kdk20, InitIndexLabel, sessId0) in
let ircv0 = kdf(kdk20, RespIndexLabel, sessId0) in
let k0 = bs2sk(splitFst(ksnd0)) in
let n0 = bs2n(splitSnd(ksnd0)) in
let ct0 = aead_enc(k0, n0, isnd0, msg0) in
new ski : scalar;
let pki = mult(ski, Base) in
let hpki = hash(pt2bs(pki)) in
let pkstart = (locResp, pki0, hpki, ct0) in
out(ch, pkstart);
(* DH1 *)
in(ch, dh1:bitstring);
let (pkr:point, hcsr:bitstring) = dh1 in
(* DH2 *)
let z = mult(ski, pkr) in
let htotal = hash((pkstart, 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, Null))) 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 (=macr) = kdf(kdk2, RespMACLabel, context) in
let isnd = kdf(kdk2, InitIndexLabel, sessId) in
let ircv = kdf(kdk2, RespIndexLabel, sessId) in
(* Start verification of initiator identity *)
event beginInit(init, resp,
ksnd, krcv, isnd, ircv, cs1,
ksnd0, krcv0, isnd0, ircv0, msg0);
(* Confirm the SAS *)
out(phone, sas);
in(phone, (=sas, ok:bitstring));
(* Accept the responder identity and corresponding key material *)
event acceptResp(init, resp,
ksnd, krcv, isnd, ircv, cs1,
ksnd0, krcv0, isnd0, ircv0, msg0);
(* 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));
out(ch, sym_enc(bs2sk(ksnd0), bs2n(Null), ksnd0InitFlag));
out(ch, sym_enc(bs2sk(krcv0), bs2n(Null), krcv0InitFlag));
out(ch, sym_enc(bs2sk(isnd0), bs2n(Null), isnd0InitFlag));
out(ch, sym_enc(bs2sk(ircv0), bs2n(Null), ircv0InitFlag));
out(ch, sym_enc(bs2sk(msg0), bs2n(Null), msg0InitFlag));
(* Check for typos *)
out(ch, initHasTypo)
.
(* Role of the responder *)
let processResponder(init:identity, resp:identity, phone:channel) =
(* Register public key *)
new skr0 : scalar;
let pkr0 = mult(skr0, Base) in
let locr0 = kdf(pt2mk(pkr0), LocatorLabel, id2bs(resp)) in
out(ch, (resp, pkr0, locr0));
(* PKStart *)
in(ch, pkstart:bitstring);
let (=locr0, pki0:point, hpki:bitstring, ct:bitstring) = pkstart in
let z0 = mult(skr0, pki0) in
let kdk0 = bs2mk(mac(bs2mk(Null), pt2bs(z0))) in
let context0 = (init, resp) in
let sessId0 = hash(context0) in
let kdk20 = bs2mk(mac(kdk0, (MasterStr, AlgId, context0, Null))) in
let ksnd0 = kdf(kdk20, RespMasterLabel, sessId0) in
let krcv0 = kdf(kdk20, InitMasterLabel, context0) in
let isnd0 = kdf(kdk20, RespIndexLabel, sessId0) in
let ircv0 = kdf(kdk20, InitIndexLabel, sessId0) in
let k0 = bs2sk(splitFst(krcv0)) in
let n0 = bs2n(splitSnd(krcv0)) in
let pt0 = aead_dec(k0, n0, ircv0, ct) in
(* DH1 *)
new skr : scalar;
let pkr = mult(skr, Base) in
let hpkr = hash(pt2bs(pkr)) in
let hcsr = mac(bs2mk(Null), (hpkr, RespStr)) in
let dh1 = (pkr, hcsr) in
out(ch, dh1);
(* DH2 *)
in(ch, (pki:point, maci:bitstring));
let (=hpki) = hash(pt2bs(pki)) in
(* Confirm *)
let z = mult(skr, pki) in
let htotal = hash((pkstart, 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, Null))) 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);
(* Start verification of the responder *)
event beginResp(init, resp,
krcv, ksnd, ircv, isnd, cs1,
krcv0, ksnd0, ircv0, isnd0, pt0);
(* Confirm the SAS *)
in(phone, =sas);
out(phone, (sas, OK));
(* Accept the initiator identity and corresponding key material *)
event acceptInit(init, resp,
krcv, ksnd, ircv, isnd, cs1,
krcv0, ksnd0, ircv0, isnd0, pt0);
(* 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));
out(ch, sym_enc(bs2sk(ksnd0), bs2n(Null), ksnd0RespFlag));
out(ch, sym_enc(bs2sk(krcv0), bs2n(Null), krcv0RespFlag));
out(ch, sym_enc(bs2sk(isnd0), bs2n(Null), isnd0RespFlag));
out(ch, sym_enc(bs2sk(ircv0), bs2n(Null), ircv0RespFlag));
out(ch, sym_enc(bs2sk(pt0), bs2n(Null), msg0RespFlag));
(* Check for typos *)
out(ch, respHasTypo)
.
(* Role of the initiator *)
let processInitiatorComp(init:identity, resp:identity, phone:channel) =
(* Get responder public key *)
out(ch, resp);
in(ch, (pkResp:point, locResp:bitstring));
(* PKStart *)
new msg0C : bitstring;
new ski0C : scalar;
let pki0 = mult(ski0C, Base) in
let z0 = mult(ski0C, pkResp) in
let kdk0 = bs2mk(mac(bs2mk(Null), pt2bs(z0))) in
let context0 = (init, resp) in
let sessId0 = hash(context0) in
let kdk20 = bs2mk(mac(kdk0, (MasterStr, AlgId, context0, Null))) in
let ksnd0 = kdf(kdk20, InitMasterLabel, context0) in
let krcv0 = kdf(kdk20, RespMasterLabel, sessId0) in
let isnd0 = kdf(kdk20, InitIndexLabel, sessId0) in
let ircv0 = kdf(kdk20, RespIndexLabel, sessId0) in
let k0 = bs2sk(splitFst(ksnd0)) in
let n0 = bs2n(splitSnd(ksnd0)) in
let ct0 = aead_enc(k0, n0, isnd0, msg0C) in
new skiC : scalar;
let pki = mult(skiC, Base) in
let hpki = hash(pt2bs(pki)) in
let pkstart = (locResp, pki0, hpki, ct0) in
out(ch, pkstart);
(* DH1 *)
in(ch, dh1:bitstring);
let (pkr:point, hcsr:bitstring) = dh1 in
(* DH2 *)
let z = mult(skiC, pkr) in
let htotal = hash((pkstart, 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, Null))) 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 (=macr) = kdf(kdk2, RespMACLabel, context) in
let isnd = kdf(kdk2, InitIndexLabel, sessId) in
let ircv = kdf(kdk2, RespIndexLabel, sessId) in
(* Start verification of initiator identity *)
event beginInit(init, resp,
ksnd, krcv, isnd, ircv, cs1,
ksnd0, krcv0, isnd0, ircv0, msg0C);
(* Confirm the SAS *)
out(phone, sas);
in(phone, (=sas, ok:bitstring));
(* Check for typos *)
out(ch, initCompHasTypo)
.
(* Role of the responder *)
let processCompResponder(init:identity, resp:identity, phone:channel) =
(* Register public key *)
new skr0C : scalar;
let pkr0 = mult(skr0C, Base) in
let locr0 = kdf(pt2mk(pkr0), LocatorLabel, id2bs(resp)) in
out(ch, (resp, pkr0, locr0));
(* PKStart *)
in(ch, pkstart:bitstring);
let (=locr0, pki0:point, hpki:bitstring, ct:bitstring) = pkstart in
let z0 = mult(skr0C, pki0) in
let kdk0 = bs2mk(mac(bs2mk(Null), pt2bs(z0))) in
let context0 = (init, resp) in
let sessId0 = hash(context0) in
let kdk20 = bs2mk(mac(kdk0, (MasterStr, AlgId, context0, Null))) in
let ksnd0 = kdf(kdk20, RespMasterLabel, sessId0) in
let krcv0 = kdf(kdk20, InitMasterLabel, context0) in
let isnd0 = kdf(kdk20, RespIndexLabel, sessId0) in
let ircv0 = kdf(kdk20, InitIndexLabel, sessId0) in
let k0 = bs2sk(splitFst(krcv0)) in
let n0 = bs2n(splitSnd(krcv0)) in
let pt0 = aead_dec(k0, n0, ircv0, ct) in
(* DH1 *)
new skrC : scalar;
let pkr = mult(skrC, Base) in
let hpkr = hash(pt2bs(pkr)) in
let hcsr = mac(bs2mk(Null), (hpkr, RespStr)) in
let dh1 = (pkr, hcsr) in
out(ch, dh1);
(* DH2 *)
in(ch, (pki:point, maci:bitstring));
let (=hpki) = hash(pt2bs(pki)) in
(* Confirm *)
let z = mult(skrC, pki) in
let htotal = hash((pkstart, 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, Null))) 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);
(* Start verification of the responder *)
event beginResp(init, resp,
krcv, ksnd, ircv, isnd, cs1,
krcv0, ksnd0, ircv0, isnd0, pt0);
(* Confirm the SAS *)
in(phone, =sas);
out(phone, (sas, OK));
(* Check for typos *)
out(ch, respCompHasTypo)
.
(*** Main ***)
process
(* Allow arbitrary many protocol runs *)
!
(* Let the adversary decide who will engage in key negotation *)
in(ch, (init:identity, resp:identity));
(* Create a new phone channel *)
new phone : channel;
(* Allow eavesdropping on the phone channel *)
(! in(phone, x:bitstring); out(ch, x)) |
(* Server processes *)
(! processKeyRegistration) |
(! processGetKey) |
if init = Compromised then (
out(ch, phone);
processCompResponder(init, resp, phone)
) else if resp = Compromised then (
out(ch, phone);
processInitiatorComp(init, resp, phone)
) else (
processInitiator(init, resp, phone) |
processResponder(init, resp, phone)
)