-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathReKeyProtocol.xml
More file actions
316 lines (288 loc) · 8.99 KB
/
ReKeyProtocol.xml
File metadata and controls
316 lines (288 loc) · 8.99 KB
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
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE nta PUBLIC '-//Uppaal Team//DTD Flat System 1.1//EN' 'http://www.it.uu.se/research/group/darts/uppaal/flat-1_2.dtd'>
<nta>
<declaration>// Place global declarations here.
const int controllers_number = 3;
typedef int[1, controllers_number-1] controller_Id;
//max model time
const int MAXTIME = 17;
typedef int[0,MAXTIME] time_t;
int refresh = 2;
int grace = 2;
int validity = 4;
//discrete time
time_t current_time;
typedef int[1,2] sig_k;
//keyvault signing certificate
typedef struct{
int sig_ca;
int pk_ca;
}cert_ca;
const cert_ca system_cert_ca = {1,1};
//effective certificate with expiry time
typedef struct{
sig_k sig_ca;
int pk_eff;
int expiry;
time_t t;
}cert_eff;
typedef cert_eff EffectiveCertificates[controllers_number];
//NewEffectiveRequest
typedef struct{
int pk_eff_new;
int sig_eff_old;
time_t t;
}NewEff;
//array of new effs
typedef NewEff NewEffs[controllers_number];
NewEffs newEffs;
//controller modes
const int sparePart = 0;
const int controller = 1;
//array of controllers
typedef bool controllers[controllers_number];
//array of sig_eff for controllers
typedef int sig_effs[controllers_number];
sig_effs ctr_sig_effs;
//always one, could be invalid with wrong sk_eff
const int set_pk_eff = 1;
typedef int[1,2] sk_eff_gen;
//OT notification
bool notification = false;
//clock
clock x;
clock rekeyTime;
//init
const cert_eff initialized_cert = {1,1,9,0};
const cert_eff notinitialized_cert = {1,0,0,0};
EffectiveCertificates effectiveCertificates= {notinitialized_cert, initialized_cert, initialized_cert};
controllers system_controllers={false, true, true};
bool AllCertsValid(controllers ctrs){
int i;
bool have_certs = false;
bool result = false;
for(i = 0; i < controllers_number; i++){
if(ctrs[i] == true){
have_certs = true;
if((effectiveCertificates[i].sig_ca == system_cert_ca.sig_ca) && (effectiveCertificates[i].expiry + grace >= current_time)){
result = result || true;
}else{
result = false;
return result;
}
}
}
if(have_certs == true){
return result;
}else{
return true; // if no controllers in the system, well nothing can go wrong :)
}
}
broadcast chan RekeyInit;
chan NewEffectiveKey[controllers_number];
chan NewKVCert[controllers_number];
chan Rekey;
chan Notify;</declaration>
<template>
<name>OT</name>
<declaration>void HandleNotification(){
notification = true;
return;
}</declaration>
<location id="id0" x="0" y="0">
</location>
<init ref="id0"/>
<transition>
<source ref="id0"/>
<target ref="id0"/>
<label kind="synchronisation" x="18" y="-59">Notify?</label>
<nail x="0" y="-42"/>
<nail x="144" y="-42"/>
<nail x="144" y="0"/>
</transition>
</template>
<template>
<name>TimeDiscretizer</name>
<location id="id1" x="0" y="0">
<label kind="invariant" x="-153" y="17">x<=MAXTIME && x<=current_time + 1</label>
</location>
<init ref="id1"/>
<transition>
<source ref="id1"/>
<target ref="id1"/>
<label kind="guard" x="25" y="-59">x >= current_time +1</label>
<label kind="assignment" x="35" y="-42">current_time++</label>
<nail x="17" y="-42"/>
<nail x="187" y="-42"/>
<nail x="187" y="0"/>
</transition>
</template>
<template>
<name x="5" y="5">Keyvault</name>
<declaration>// Place local declarations here.
int new_eff_Id;
//Check the signature of the incoming old certificate
bool VerifyEffSig(int Id){
if((newEffs[Id].sig_eff_old / effectiveCertificates[Id].pk_eff) == 1 ){ //hmmm, maybe this could be better with root of trust?
return true;
}
return false;
}
//Issue new certificate based on the new pk_eff request
void IssueNewCertificate(int Id){
effectiveCertificates[Id].sig_ca = system_cert_ca.sig_ca; //self signed ca certificate of the keyvault
effectiveCertificates[Id].pk_eff = newEffs[Id].pk_eff_new;
effectiveCertificates[Id].expiry = current_time + validity;
effectiveCertificates[Id].t = current_time;
return;
}</declaration>
<location id="id2" x="0" y="0">
</location>
<location id="id3" x="-255" y="-68">
<urgent/>
</location>
<location id="id4" x="161" y="-59">
<committed/>
</location>
<init ref="id2"/>
<transition>
<source ref="id2"/>
<target ref="id4"/>
<label kind="synchronisation" x="52" y="-76">Rekey?</label>
<nail x="34" y="-59"/>
</transition>
<transition>
<source ref="id3"/>
<target ref="id2"/>
<label kind="guard" x="-238" y="42">!VerifyEffSig(new_eff_Id)</label>
<label kind="synchronisation" x="-187" y="68">Notify!</label>
<nail x="-314" y="25"/>
<nail x="-314" y="59"/>
<nail x="0" y="59"/>
</transition>
<transition>
<source ref="id3"/>
<target ref="id2"/>
<label kind="guard" x="-237" y="-34">VerifyEffSig(new_eff_Id)</label>
<label kind="synchronisation" x="-237" y="-17">NewKVCert[new_eff_Id]!</label>
<label kind="assignment" x="-237" y="0">IssueNewCertificate(new_eff_Id)</label>
<nail x="-255" y="0"/>
</transition>
<transition>
<source ref="id2"/>
<target ref="id3"/>
<label kind="select" x="-229" y="-102">Id:int[1, controllers_number - 1]</label>
<label kind="synchronisation" x="-204" y="-85">NewEffectiveKey[Id]?</label>
<label kind="assignment" x="-204" y="-68">new_eff_Id = Id</label>
<nail x="-25" y="-68"/>
</transition>
<transition>
<source ref="id4"/>
<target ref="id2"/>
<label kind="synchronisation" x="51" y="-17">RekeyInit!</label>
<nail x="161" y="-34"/>
<nail x="153" y="-34"/>
<nail x="144" y="0"/>
</transition>
</template>
<template>
<name>RekeyTimer</name>
<location id="id5" x="0" y="0">
<label kind="invariant" x="-10" y="17">rekeyTime <=refresh + grace</label>
</location>
<init ref="id5"/>
<transition>
<source ref="id5"/>
<target ref="id5"/>
<label kind="guard" x="8" y="-51">rekeyTime >= refresh</label>
<label kind="synchronisation" x="42" y="-34">Rekey!</label>
<label kind="assignment" x="34" y="-25">rekeyTime =0</label>
<nail x="0" y="-34"/>
<nail x="178" y="-34"/>
<nail x="178" y="0"/>
</transition>
</template>
<template>
<name>Controller</name>
<parameter>controller_Id my_Id, bool mode, cert_eff my_cert_eff, int my_sk_eff, bool robust_generator</parameter>
<declaration>int old_sk_eff;
clock clk;
void CreateSigEff(){
ctr_sig_effs[my_Id] = my_cert_eff.pk_eff * my_sk_eff;
return;
}
void GenerateNewEff(int pair){
CreateSigEff();
old_sk_eff = my_sk_eff;
if(robust_generator){
my_sk_eff = 1;
}else{
my_sk_eff = pair;
}
clk = 0;
return;
}
//Sends a request to the keyvault for new cert_eff
void ProvideNewPK_Eff(int Id){
newEffs[Id].pk_eff_new = set_pk_eff;
newEffs[Id].sig_eff_old = ctr_sig_effs[my_Id];
newEffs[Id].t = current_time;
return;
}
//Receives the new cert_eff from the keyvault
void GetNewCertificate(int Id){
my_cert_eff = effectiveCertificates[Id];
return;
}</declaration>
<location id="id6" x="0" y="0">
</location>
<location id="id7" x="238" y="0">
<label kind="invariant" x="212" y="-34">clk<=1</label>
</location>
<init ref="id6"/>
<transition>
<source ref="id6"/>
<target ref="id6"/>
<label kind="synchronisation" x="-153" y="-17">NewKVCert[my_Id]?</label>
<label kind="assignment" x="-178" y="51">GetNewCertificate(my_Id)</label>
<nail x="-161" y="0"/>
<nail x="-161" y="51"/>
<nail x="-25" y="51"/>
</transition>
<transition>
<source ref="id7"/>
<target ref="id6"/>
<label kind="guard" x="92" y="34">clk>=1</label>
<label kind="synchronisation" x="51" y="51">NewEffectiveKey[my_Id]!</label>
<label kind="assignment" x="51" y="68">ProvideNewPK_Eff(my_Id)</label>
<nail x="237" y="68"/>
<nail x="33" y="68"/>
</transition>
<transition>
<source ref="id6"/>
<target ref="id7"/>
<label kind="select" x="42" y="-51">pair:sk_eff_gen</label>
<label kind="guard" x="25" y="-34">mode == controller</label>
<label kind="synchronisation" x="51" y="-17">RekeyInit?</label>
<label kind="assignment" x="18" y="0">GenerateNewEff(pair)</label>
</transition>
</template>
<system>// Place template instantiations here.
controller1 = Controller(1, controller, initialized_cert, 1, false);
controller2 = Controller(2, controller, initialized_cert, 1, true);
keyvault1 = Keyvault();
timediscretizer = TimeDiscretizer();
//rekey timer definitions
rekeytimer = RekeyTimer();
//OT definitions
ot = OT();
// List one or more processes to be composed into a system.
system controller1, controller2, keyvault1, timediscretizer, rekeytimer, ot;
//system controller1, keyvault1, timediscretizer, rekeytimer, ot; </system>
<queries>
<query>
<formula>A[]AllCertsValid(system_controllers)</formula>
<comment></comment>
</query>
</queries>
</nta>