2023-12-07 20:21:10 +00:00
|
|
|
/*
|
|
|
|
* Coursework 2 PI protocol
|
|
|
|
*/
|
|
|
|
usertype String;
|
|
|
|
usertype Timestamp;
|
|
|
|
usertype Sessionkey;
|
|
|
|
|
|
|
|
hashfunction H1;
|
|
|
|
|
|
|
|
protocol protocolPI(Network, Application, Phone) {
|
|
|
|
|
2023-12-11 18:18:47 +00:00
|
|
|
/* Role R - Phone
|
2023-12-07 20:21:10 +00:00
|
|
|
*
|
|
|
|
* has keys k(N,R)
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
role Phone {
|
|
|
|
|
|
|
|
var SesK: SessionKey;
|
|
|
|
var tl: Timestamp;
|
|
|
|
|
2023-12-11 18:18:47 +00:00
|
|
|
recv_keysPhone(Network,Phone, {H1(SesK, tl, Application)}k(Network, Phone), {SesK, tl, Application}k(Network, Phone));
|
2023-12-07 20:21:10 +00:00
|
|
|
|
|
|
|
var mApp: String;
|
|
|
|
|
2023-12-11 18:18:47 +00:00
|
|
|
recv_1(Application,Phone, {mApp, Application, Phone }SesK);
|
2023-12-07 20:21:10 +00:00
|
|
|
|
|
|
|
fresh mPhone: String;
|
|
|
|
|
2023-12-12 19:11:04 +00:00
|
|
|
claim_phone1(Phone, Running, Application, mApp, SesK);
|
2023-12-07 20:21:10 +00:00
|
|
|
|
2023-12-11 18:18:47 +00:00
|
|
|
send_2(Phone,Application, {mApp, mPhone}SesK);
|
2023-12-07 20:21:10 +00:00
|
|
|
|
|
|
|
claim_phone2(Phone, Secret, SesK);
|
2023-12-12 19:11:04 +00:00
|
|
|
claim_application1(Phone, Commit, Application, mApp, SesK);
|
2023-12-07 20:21:10 +00:00
|
|
|
claim_network2(Phone, Commit, Network, SesK, tl);
|
|
|
|
claim_phone3(Phone, Nisynch);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Role S - Application
|
|
|
|
*
|
|
|
|
* has keys k(N,S)
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
role Application {
|
|
|
|
|
|
|
|
fresh nApp: Nonce;
|
|
|
|
|
|
|
|
send_refreshKeys(Application,Network, Application, Phone, nApp);
|
|
|
|
|
|
|
|
var SesK: SessionKey;
|
|
|
|
var tl: Timestamp;
|
|
|
|
|
2023-12-11 18:18:47 +00:00
|
|
|
recv_keysApp(Network,Application, {H1(SesK, tl, nApp, Phone)}k(Network, Application), {SesK, tl, nApp, Phone}k(Network, Application));
|
2023-12-07 20:21:10 +00:00
|
|
|
|
|
|
|
fresh mApp: String;
|
|
|
|
var mPhone: String;
|
|
|
|
|
2023-12-12 19:11:04 +00:00
|
|
|
claim_application1(Application, Running, Phone, mApp, SesK);
|
2023-12-07 20:21:10 +00:00
|
|
|
|
2023-12-11 18:18:47 +00:00
|
|
|
send_1(Application,Phone, {mApp, Application, Phone}SesK);
|
2023-12-07 20:21:10 +00:00
|
|
|
|
2023-12-11 18:18:47 +00:00
|
|
|
recv_2(Phone,Application, {mApp, mPhone}SesK);
|
2023-12-07 20:21:10 +00:00
|
|
|
|
|
|
|
claim_application2(Application, Secret, SesK);
|
2023-12-12 19:11:04 +00:00
|
|
|
claim_phone1(Application, Commit, Phone, mApp, SesK);
|
2023-12-07 20:21:10 +00:00
|
|
|
claim_network1(Application, Commit, Network, SesK, tl);
|
|
|
|
|
|
|
|
claim_application3(Application, Nisynch);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Role N - Network
|
|
|
|
*
|
|
|
|
* has keys k(N,R) and k(N,S)
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
role Network {
|
|
|
|
|
|
|
|
var nApp: Nonce;
|
|
|
|
|
|
|
|
recv_refreshKeys(Application,Network, Application, Phone, nApp);
|
|
|
|
|
|
|
|
fresh SesK: SessionKey;
|
|
|
|
fresh tl: Timestamp;
|
|
|
|
|
|
|
|
claim_netwrok1(Network, Running, Application, SesK, tl);
|
|
|
|
|
2023-12-11 18:18:47 +00:00
|
|
|
send_keysApp(Network,Application, { H1(SesK, tl, nApp, Phone) }k(Network, Application) , {SesK, tl, nApp, Phone}k(Network, Application));
|
2023-12-07 20:21:10 +00:00
|
|
|
|
|
|
|
claim_network2(Network, Running, Phone, SesK, tl);
|
2023-12-11 18:18:47 +00:00
|
|
|
send_keysPhone(Network,Phone, {H1(SesK, tl, Application)}k(Network, Phone), {SesK, tl, Application}k(Network, Phone));
|
2023-12-07 20:21:10 +00:00
|
|
|
|
|
|
|
claim_network3(Network, Secret, SesK);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|