art & beauty sync
authorVolker Birk <vb@pep-project.org>
Sat, 08 Jun 2019 19:45:18 +0200
branchsync
changeset 3825b8d55cc4755e
parent 3824 146e4fab0072
child 3826 09813a43e17d
art & beauty
sync/cond_act_sync.yml2
sync/gen_dot.ysl2
sync/sync.fsm
     1.1 --- a/sync/cond_act_sync.yml2	Sat Jun 08 15:26:34 2019 +0200
     1.2 +++ b/sync/cond_act_sync.yml2	Sat Jun 08 19:45:18 2019 +0200
     1.3 @@ -18,7 +18,7 @@
     1.4      |> *result = _result > 0;
     1.5  }
     1.6  
     1.7 -condition weAreFirst
     1.8 +condition weAreOfferer
     1.9  ||
    1.10      TID_t *t1 = &session->sync_state.keysync.challenge;
    1.11      TID_t *t2 = &session->sync_state.own.challenge;
     2.1 --- a/sync/gen_dot.ysl2	Sat Jun 08 15:26:34 2019 +0200
     2.2 +++ b/sync/gen_dot.ysl2	Sat Jun 08 19:45:18 2019 +0200
     2.3 @@ -8,17 +8,24 @@
     2.4      ||
     2.5      digraph finite_state_machine {
     2.6          rankdir=LR;
     2.7 -        node [shape = point];
     2.8 +        node [shape=point];
     2.9          InitState;
    2.10 -        node [shape = doublecircle];
    2.11 +        node [shape=doublecircle];
    2.12          End;
    2.13 -        node [shape = circle, style=filled, fillcolor = lightgrey];
    2.14 +        node [shape=circle, style=filled, fillcolor=lightgrey];
    2.15  
    2.16          `` apply "descendant::transition";
    2.17      }
    2.18      ||
    2.19  
    2.20 -    template "transition"
    2.21 -        | «ancestor::state/@name» -> «@target» [ label="«ancestor::event/@name»" ];
    2.22 +    template "transition" {
    2.23 +        const "event", "ancestor::event/@name";
    2.24 +        choose {
    2.25 +            when "ancestor::fsm/message[@name=$event]"
    2.26 +                | «ancestor::state/@name» -> «@target» [ label="«ancestor::event/@name»", color=blue ];
    2.27 +            otherwise
    2.28 +                | «ancestor::state/@name» -> «@target» [ label="«ancestor::event/@name»", color=red ];
    2.29 +        }
    2.30 +    }
    2.31  }
    2.32  
     3.1 --- a/sync/sync.fsm	Sat Jun 08 15:26:34 2019 +0200
     3.2 +++ b/sync/sync.fsm	Sat Jun 08 19:45:18 2019 +0200
     3.3 @@ -41,14 +41,14 @@
     3.4                      // this is our own Beacon; ignore
     3.5                  }
     3.6                  else {
     3.7 -                    if weAreFirst {
     3.8 +                    if weAreOfferer {
     3.9                          do useOwnChallenge;
    3.10                          send Beacon;
    3.11                      }
    3.12 -                    else /* we are second */ {
    3.13 +                    else /* we are requester */ {
    3.14                          do openNegotiation;
    3.15                          do tellWeAreNotGrouped;
    3.16 -                        // second is sending NegotiationRequest
    3.17 +                        // requester is sending NegotiationRequest
    3.18                          send NegotiationRequest;
    3.19                          do useOwnChallenge;
    3.20                      }
    3.21 @@ -62,25 +62,25 @@
    3.22                      }
    3.23                      else {
    3.24                          do storeNegotiation;
    3.25 -                        // first is sending NegotiationOpen
    3.26 +                        // offerer is accepting by confirming NegotiationOpen
    3.27                          send NegotiationOpen;
    3.28                          if partnerIsGrouped
    3.29 -                            go HandshakingWithGroup;
    3.30 +                            go HandshakingToJoin;
    3.31                          else
    3.32 -                            go HandshakingNewFirst;
    3.33 +                            go HandshakingOfferer;
    3.34                      }
    3.35                  }
    3.36              }
    3.37  
    3.38              on NegotiationOpen if sameNegotiationAndPartner {
    3.39 -                // second is receiving NegotiationOpen
    3.40 +                // requester is receiving NegotiationOpen
    3.41                  do storeNegotiation;
    3.42 -                go HandshakingNewSecond;
    3.43 +                go HandshakingRequester;
    3.44              }
    3.45          }
    3.46  
    3.47          // handshaking without existing Device group
    3.48 -        state HandshakingNewFirst timeout=600 {
    3.49 +        state HandshakingOfferer timeout=600 {
    3.50              on Init
    3.51                  do showSoleHandshake;
    3.52  
    3.53 @@ -108,17 +108,17 @@
    3.54              // Accept means init Phase1Commit
    3.55              on Accept {
    3.56                  do trustThisKey;
    3.57 -                send CommitAcceptFirst;
    3.58 -                go HandshakingNewPhase1First;
    3.59 +                send CommitAcceptOfferer;
    3.60 +                go HandshakingPhase1Offerer;
    3.61              }
    3.62  
    3.63 -            // got a CommitAccept from second
    3.64 -            on CommitAcceptSecond if sameNegotiationAndPartner
    3.65 -                go HandshakingNewPhase2First;
    3.66 +            // got a CommitAccept from requester
    3.67 +            on CommitAcceptRequester if sameNegotiationAndPartner
    3.68 +                go HandshakingPhase2Offerer;
    3.69          }
    3.70  
    3.71          // handshaking without existing Device group
    3.72 -        state HandshakingNewSecond timeout=600 {
    3.73 +        state HandshakingRequester timeout=600 {
    3.74              on Init
    3.75                  do showSoleHandshake;
    3.76  
    3.77 @@ -146,16 +146,16 @@
    3.78              // Accept means init Phase1Commit
    3.79              on Accept {
    3.80                  do trustThisKey;
    3.81 -                send CommitAcceptSecond;
    3.82 -                go HandshakingNewPhase1Second;
    3.83 +                send CommitAcceptRequester;
    3.84 +                go HandshakingPhase1Requester;
    3.85              }
    3.86  
    3.87 -            // got a CommitAccept from first
    3.88 -            on CommitAcceptFirst if sameNegotiationAndPartner
    3.89 -                go HandshakingNewPhase2Second;
    3.90 +            // got a CommitAccept from offerer
    3.91 +            on CommitAcceptOfferer if sameNegotiationAndPartner
    3.92 +                go HandshakingPhase2Requester;
    3.93          }
    3.94  
    3.95 -        state HandshakingNewPhase1First {
    3.96 +        state HandshakingPhase1Offerer {
    3.97              on Rollback if sameNegotiationAndPartner {
    3.98                  do untrustThisKey;
    3.99                  go Sole;
   3.100 @@ -167,12 +167,12 @@
   3.101                  go End;
   3.102              }
   3.103  
   3.104 -            on CommitAcceptSecond if sameNegotiationAndPartner {
   3.105 -                go NewGroupFirst;
   3.106 +            on CommitAcceptRequester if sameNegotiationAndPartner {
   3.107 +                go FormingGroupOfferer;
   3.108              }
   3.109          }
   3.110  
   3.111 -        state HandshakingNewPhase1Second {
   3.112 +        state HandshakingPhase1Requester {
   3.113              on Rollback if sameNegotiationAndPartner {
   3.114                  do untrustThisKey;
   3.115                  go Sole;
   3.116 @@ -184,12 +184,12 @@
   3.117                  go End;
   3.118              }
   3.119  
   3.120 -            on CommitAcceptFirst if sameNegotiationAndPartner {
   3.121 -                go NewGroupSecond;
   3.122 +            on CommitAcceptOfferer if sameNegotiationAndPartner {
   3.123 +                go FormingGroupRequester;
   3.124              }
   3.125          }
   3.126  
   3.127 -        state HandshakingNewPhase2First {
   3.128 +        state HandshakingPhase2Offerer {
   3.129              on Cancel {
   3.130                  send Rollback;
   3.131                  go Sole;
   3.132 @@ -202,13 +202,13 @@
   3.133              }
   3.134  
   3.135              on Accept {
   3.136 -                send CommitAcceptFirst;
   3.137 +                send CommitAcceptOfferer;
   3.138                  do trustThisKey;
   3.139 -                go NewGroupFirst;
   3.140 +                go FormingGroupOfferer;
   3.141              }
   3.142          }
   3.143  
   3.144 -        state HandshakingNewPhase2Second {
   3.145 +        state HandshakingPhase2Requester {
   3.146              on Cancel {
   3.147                  send Rollback;
   3.148                  go Sole;
   3.149 @@ -221,19 +221,19 @@
   3.150              }
   3.151  
   3.152              on Accept {
   3.153 -                send CommitAcceptSecond;
   3.154 +                send CommitAcceptRequester;
   3.155                  do trustThisKey;
   3.156 -                go NewGroupSecond;
   3.157 +                go FormingGroupRequester;
   3.158              }
   3.159          }
   3.160  
   3.161 -        state NewGroupFirst {
   3.162 +        state FormingGroupOfferer {
   3.163              on Init {
   3.164                  do prepareOwnKeys;
   3.165 -                send OwnKeysFirst; // we're not grouped yet, this is our own keys
   3.166 +                send OwnKeysOfferer; // we're not grouped yet, this is our own keys
   3.167              }
   3.168  
   3.169 -            on OwnKeysSecond {
   3.170 +            on OwnKeysRequester {
   3.171                  do saveGroupKeys;
   3.172                  do receivedKeysAreDefaultKeys;
   3.173                  do showGroupCreated;
   3.174 @@ -241,13 +241,13 @@
   3.175              }
   3.176          }
   3.177  
   3.178 -        state NewGroupSecond {
   3.179 +        state FormingGroupRequester {
   3.180              on Init {
   3.181                  do prepareOwnKeys;
   3.182 -                send OwnKeysSecond; // we're not grouped yet, this is our own keys
   3.183 +                send OwnKeysRequester; // we're not grouped yet, this is our own keys
   3.184              }
   3.185  
   3.186 -            on OwnKeysFirst {
   3.187 +            on OwnKeysOfferer {
   3.188                  do saveGroupKeys;
   3.189                  do ownKeysAreDefaultKeys;
   3.190                  do showGroupCreated;
   3.191 @@ -287,7 +287,7 @@
   3.192          }
   3.193  
   3.194          // sole device handshaking with group
   3.195 -        state HandshakingWithGroup {
   3.196 +        state HandshakingToJoin {
   3.197              on Init
   3.198                  do showJoinGroupHandshake;
   3.199  
   3.200 @@ -308,7 +308,7 @@
   3.201              }
   3.202  
   3.203              on CommitAcceptForGroup if sameNegotiationAndPartner
   3.204 -                go HandshakingJoinPhase2;
   3.205 +                go HandshakingToJoinPhase2;
   3.206  
   3.207              on CommitReject if sameNegotiationAndPartner {
   3.208                  do disable;
   3.209 @@ -319,11 +319,11 @@
   3.210              on Accept {
   3.211                  do trustThisKey;
   3.212                  send CommitAccept;
   3.213 -                go HandshakingJoinPhase1;
   3.214 +                go HandshakingToJoinPhase1;
   3.215              }
   3.216          }
   3.217  
   3.218 -        state HandshakingJoinPhase1 {
   3.219 +        state HandshakingToJoinPhase1 {
   3.220              on Rollback if sameNegotiationAndPartner
   3.221                  go Sole;
   3.222              
   3.223 @@ -333,10 +333,10 @@
   3.224              }
   3.225  
   3.226              on CommitAcceptForGroup if sameNegotiationAndPartner
   3.227 -                go JoinGroup;
   3.228 +                go JoiningGroup;
   3.229          }
   3.230  
   3.231 -        state HandshakingJoinPhase2 {
   3.232 +        state HandshakingToJoinPhase2 {
   3.233              on Cancel {
   3.234                  send Rollback;
   3.235                  go Sole;
   3.236 @@ -350,11 +350,11 @@
   3.237  
   3.238              on Accept {
   3.239                  do trustThisKey;
   3.240 -                go JoinGroup;
   3.241 +                go JoiningGroup;
   3.242              }
   3.243          }
   3.244  
   3.245 -        state JoinGroup {
   3.246 +        state JoiningGroup {
   3.247              on Init {
   3.248                  do prepareOwnKeys;
   3.249                  send OwnKeys;
   3.250 @@ -489,11 +489,11 @@
   3.251              field TID negotiation;
   3.252          }
   3.253  
   3.254 -        message CommitAcceptFirst 7, security=untrusted {
   3.255 +        message CommitAcceptOfferer 7, security=untrusted {
   3.256              field TID negotiation;
   3.257          }
   3.258  
   3.259 -        message CommitAcceptSecond 8, security=untrusted {
   3.260 +        message CommitAcceptRequester 8, security=untrusted {
   3.261              field TID negotiation;
   3.262          }
   3.263  
   3.264 @@ -519,11 +519,11 @@
   3.265              field IdentityList ownIdentities;
   3.266          }
   3.267  
   3.268 -        message OwnKeysFirst 14, security=attach_own_keys {
   3.269 +        message OwnKeysOfferer 14, security=attach_own_keys {
   3.270              field IdentityList ownIdentities;
   3.271          }
   3.272  
   3.273 -        message OwnKeysSecond 15, security=attach_own_keys {
   3.274 +        message OwnKeysRequester 15, security=attach_own_keys {
   3.275              field IdentityList ownIdentities;
   3.276          }
   3.277      }