-
Notifications
You must be signed in to change notification settings - Fork 1
/
sigma.spthy
165 lines (147 loc) · 3.22 KB
/
sigma.spthy
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
theory SIGMA
begin
builtins: diffie-hellman, signing
// MAC
functions: mac/2
// PKI Provisioning
rule RegisterPK:
[ Fr(~ltk) ]
-->
[
!Ltk($A, ~ltk),
!Pk($A, pk(~ltk)),
Out(pk(~ltk))
]
rule RevealLTK:
[ !Ltk(A, ltk) ]
--[ LtkReveal(A) ]->
[ Out(ltk) ]
// C->S: g^x
// S->C: g^y, S, Sig_S(g^x, g^y) MAC_k(S)
// C->S: C, Sig_C(g^y, g^x) MAC_k(C)
// Client logic
rule ClientInit:
[
!Ltk(C, ltkC),
Fr(~x)
]
--[ ClientSentRequest(C, $S, ~x) ]->
[
ClientWait(C, $S, ~x, ltkC),
Out('g'^~x)
]
rule ClientFinish:
let
msgIn = <'g'^x, gy>
msgOut = <gy, 'g'^x>
sigOut = sign(msgOut, ltkC)
k = gy^x
macOut = mac(C, k)
in
[
In(<gy, sigIn, macIn>),
ClientWait(C, S, x, ltkC),
!Pk(S, pkS)
]
--[ Neq(gy, 'g'^x),
Eq(mac(k, S), macIn),
Eq(verify(sigIn, msgIn, pkS), true),
ClientDone(C, S, 'g'^x, gy, k) ]->
[
Out(<C, sigOut, macOut>)
]
// Server logic
rule ServerInit:
let
msg = <gx, 'g'^~y>
sig = sign(msg, ltkS)
k = gx^~y
macVal = mac(k, S)
in
[
In(<gx>),
!Ltk(S, ltkS),
Fr(~y)
]
--[ ServerResponded(S, gx, 'g'^~y) ]->
[
ServerWait(S, gx, ~y, k),
Out(<'g'^~y, sig, macVal>)
]
rule ServerFinish:
let
msg = <'g'^y, gx>
in
[
In(<C, sig, macVal>),
!Pk(C, pkC),
ServerWait(S, gx, y, k)
]
--[ Eq(mac(k, C), macVal),
Eq(verify(sig, msg, pkC), true),
ServerDone(S, C, gx, 'g'^y, k) ]->
[]
// Restrictions
restriction Equality:
"All x y #i. Eq(x,y) @i ==> x = y"
restriction Inequality:
"All x y #i. Neq(x,y) @i ==> not(x = y)"
// Functionality test
lemma HonestTrace:
exists-trace
"
Ex C S gx gy k #i #j.
ClientDone(C, S, gx, gy, k) @ #i
& ServerDone(S, C, gx, gy, k) @ #j
& not(Ex A #k. LtkReveal(A) @ #k)
"
// If a client has established a session key,
// ... then the server has the same key,
// ... and it is not known to the attacker
// ... unless one of the long-term keys was compromised
lemma KeySecrecy:
"
not(Ex C S gx gy k #i #j #k.
ClientDone(C, S, gx, gy, k) @ #i
& ServerDone(S, C, gx, gy, k) @ #j
& K(k) @ #k
& not(Ex #rc. LtkReveal(C) @ #rc)
& not(Ex #rs. LtkReveal(S) @ #rs)
)
"
// If a client has established a session key
// ... then it's based on a response from a server
lemma ServerLiveness:
"
All C S gx gy k #i.
ClientDone(C, S, gx, gy, k) @ #i
==> ( (Ex #j. (ServerResponded(S, gx, gy) @ #j) & (#j < #i))
| (Ex #rc. LtkReveal(C) @ #rc)
| (Ex #rs. LtkReveal(S) @ #rs)
)
"
// If a server has established a session key
// ... then it's based on a request from a client
lemma ClientLiveness:
"
All C S gx gy k #i.
ServerDone(S, C, gx, gy, k) @ #i
==> ( (Ex #j. (ClientDone(C, S, gx, gy, k) @ #j) & (#j < #i))
| (Ex #rc. LtkReveal(C) @ #rc)
| (Ex #rs. LtkReveal(S) @ #rs)
)
"
// ... injective agreement
lemma InjectiveAgreement:
"
All C S gx gy k #i.
ServerDone(S, C, gx, gy, k) @ #i
==> ( not(Ex C2 S2 gx2 gy2 #i2.
ServerDone(S2, C2, gx2, gy2, k) @ #i2
& not(#i2 = #i)
)
| (Ex #rc. LtkReveal(C) @ #rc)
| (Ex #rs. LtkReveal(S) @ #rs)
)
"
end