import prelude;
public acknowledging : Word;
public receipt : Word;
public of : Word;
public nonce : Word;
public to : Word;
type ChallengeAToB
= SoshChall ();
type ResponseBToA ( a:Any, b:Any, na:Any )
= SoshResp ( begun(b acknowledging to a receipt of nonce na) );
type ChallengeBToA ( a:Any, b:Any, nb:Any )
= SophChall ( begun(a acknowledging to b receipt of nonce nb) );
type ResponseAToB
= SophResp ();
pattern MsgKey
= ( PublicKey(p), p:Un );
pattern Msg1
= ( ChallengeAToB, Host );
pattern Msg2 (a:Any)
= ( na : ResponseBToA(a,b,na),
nb : ChallengeBToA(a,b,nb),
b : Host );
pattern Msg3
= ResponseAToB;
tag msgKey (MsgKey) : Auth <s:Server>;
tag msg1 (Msg1) : Auth (b:Any);
tag msg2 (Msg2(a)) : Auth (a:Any);
tag msg3 (Msg3) : Auth (b:Any);
client Initiator
(a:Host, b:Host, s:Server, sS:AuthKey(s), pA:PrivateKey(a))
at a is
{
establish Server at s is (socketS : Socket);
output socketS is (a,b);
input socketS is {| msgKey( pB:PublicKey(b), b) |}sS^-1;
establish Responder at b is (socketB : Socket);
new (na : ChallengeAToB);
output socketB is {| msg1(na,a) |}pB;
input socketB is {| msg2 (na, nb:ChallengeBToA(a,b,nb), b) |}pA^-1
[ begun (b acknowledging to a receipt of nonce na) ];
end (b acknowledging to a receipt of nonce na);
begin (a acknowledging to b receipt of nonce nb);
output socketB is {| msg3(nb) |}pB;
}
server Responder
(b:Host, s:Server, sS:AuthKey(s), pB:PrivateKey(b))
at b is (socket : Socket)
{
input socket is {| msg1 (na:ChallengeAToB, a:Un) |}pB^-1;
establish Server at s is (socketS : Socket);
output socketS is (b,a);
input socket is {| msgKey( pA:PublicKey(a), a ) |}sS^-1;
new (nb : ChallengeBToA(a,b,nb));
begin (b acknowledging to a receipt of nonce na);
output socket is {| msg2(na,nb,b) |}pA;
input socket is {| msg3(nb) |}pB^-1
[ begun (a acknowledging to b receipt of nonce nb) ];
end (a acknowledging to b receipt of nonce nb);
}
fun lkupKey (p:Any) : PublicKey(p);
server KeyServer (s:Server, sS:SignKey(s)) at s is (socket : Socket)
{
input socket is (p:Un,q:Un);
let pP:PublicKey(p) = lkupKey (p);
output socket is {| msgKey(pP,p) |}sS;
}
|