Merge with sync sequoia_windows
authorThomas
Tue, 11 Jun 2019 08:00:44 +0200
branchsequoia_windows
changeset 38273030ae87f2f9
parent 3819 0c1bcfa6f9f3
parent 3826 09813a43e17d
child 3833 97d3517be4a3
Merge with sync
sync/sync.fsm
     1.1 --- a/sync/cond_act_sync.yml2	Fri Jun 07 07:41:36 2019 +0200
     1.2 +++ b/sync/cond_act_sync.yml2	Tue Jun 11 08:00:44 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 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/sync/gen_doc.yml2	Tue Jun 11 08:00:44 2019 +0200
     2.3 @@ -0,0 +1,44 @@
     2.4 +include yslt.yml2
     2.5 +
     2.6 +tstylesheet {
     2.7 +    template "/protocol" {
     2.8 +        | protocol «@name»
     2.9 +        apply "fsm" sort "@name";
    2.10 +    }
    2.11 +    template "fsm" {
    2.12 +        | fsm «@name»
    2.13 +        apply "state" sort "@name";
    2.14 +        |
    2.15 +        for "set:distinct(*/event/@name)" {
    2.16 +            sort ".";
    2.17 +            |> event «.»
    2.18 +        }
    2.19 +        |
    2.20 +        for "set:distinct(descendant::action/@name)" {
    2.21 +            sort ".";
    2.22 +            |> action «.»
    2.23 +        }
    2.24 +        |
    2.25 +        for "set:distinct(descendant::condition/@name)" {
    2.26 +            sort ".";
    2.27 +            |> condition «.»
    2.28 +        }
    2.29 +        |
    2.30 +        apply "descendant::transition"
    2.31 +            sort "ancestor::state/@name",
    2.32 +            sort "@target",
    2.33 +            sort "ancestor::event/@name";
    2.34 +        |
    2.35 +        apply "message" sort "@name";
    2.36 +        |
    2.37 +        for "set:distinct(message/field/@name)" {
    2.38 +            sort ".";
    2.39 +            |> field «.»
    2.40 +        }
    2.41 +    }
    2.42 +    template "state" | state «@name»
    2.43 +    template "transition"
    2.44 +        | transition from «ancestor::state/@name» to «@target» on event «ancestor::event/@name»
    2.45 +    template "message" | message «@name»
    2.46 +}
    2.47 +
     3.1 --- a/sync/gen_dot.ysl2	Fri Jun 07 07:41:36 2019 +0200
     3.2 +++ b/sync/gen_dot.ysl2	Tue Jun 11 08:00:44 2019 +0200
     3.3 @@ -8,17 +8,24 @@
     3.4      ||
     3.5      digraph finite_state_machine {
     3.6          rankdir=LR;
     3.7 -        node [shape = point];
     3.8 +        node [shape=point];
     3.9          InitState;
    3.10 -        node [shape = doublecircle];
    3.11 +        node [shape=doublecircle];
    3.12          End;
    3.13 -        node [shape = circle, style=filled, fillcolor = lightgrey];
    3.14 +        node [shape=circle, style=filled, fillcolor=lightgrey];
    3.15  
    3.16          `` apply "descendant::transition";
    3.17      }
    3.18      ||
    3.19  
    3.20 -    template "transition"
    3.21 -        | «ancestor::state/@name» -> «@target» [ label="«ancestor::event/@name»" ];
    3.22 +    template "transition" {
    3.23 +        const "event", "ancestor::event/@name";
    3.24 +        choose {
    3.25 +            when "ancestor::fsm/message[@name=$event]"
    3.26 +                | «ancestor::state/@name» -> «@target» [ label="«ancestor::event/@name»", color=blue ];
    3.27 +            otherwise
    3.28 +                | «ancestor::state/@name» -> «@target» [ label="«ancestor::event/@name»", color=red ];
    3.29 +        }
    3.30 +    }
    3.31  }
    3.32  
     4.1 --- a/sync/sync.fsm	Fri Jun 07 07:41:36 2019 +0200
     4.2 +++ b/sync/sync.fsm	Tue Jun 11 08:00:44 2019 +0200
     4.3 @@ -41,14 +41,14 @@
     4.4                      // this is our own Beacon; ignore
     4.5                  }
     4.6                  else {
     4.7 -                    if weAreFirst {
     4.8 +                    if weAreOfferer {
     4.9                          do useOwnChallenge;
    4.10                          send Beacon;
    4.11                      }
    4.12 -                    else /* we are second */ {
    4.13 +                    else /* we are requester */ {
    4.14                          do openNegotiation;
    4.15                          do tellWeAreNotGrouped;
    4.16 -                        // second is sending NegotiationRequest
    4.17 +                        // requester is sending NegotiationRequest
    4.18                          send NegotiationRequest;
    4.19                          do useOwnChallenge;
    4.20                      }
    4.21 @@ -62,25 +62,25 @@
    4.22                      }
    4.23                      else {
    4.24                          do storeNegotiation;
    4.25 -                        // first is sending NegotiationOpen
    4.26 +                        // offerer is accepting by confirming NegotiationOpen
    4.27                          send NegotiationOpen;
    4.28                          if partnerIsGrouped
    4.29 -                            go HandshakingWithGroup;
    4.30 +                            go HandshakingToJoin;
    4.31                          else
    4.32 -                            go HandshakingNewFirst;
    4.33 +                            go HandshakingOfferer;
    4.34                      }
    4.35                  }
    4.36              }
    4.37  
    4.38              on NegotiationOpen if sameNegotiationAndPartner {
    4.39 -                // second is receiving NegotiationOpen
    4.40 +                // requester is receiving NegotiationOpen
    4.41                  do storeNegotiation;
    4.42 -                go HandshakingNewSecond;
    4.43 +                go HandshakingRequester;
    4.44              }
    4.45          }
    4.46  
    4.47          // handshaking without existing Device group
    4.48 -        state HandshakingNewFirst timeout=600 {
    4.49 +        state HandshakingOfferer timeout=600 {
    4.50              on Init
    4.51                  do showSoleHandshake;
    4.52  
    4.53 @@ -108,17 +108,17 @@
    4.54              // Accept means init Phase1Commit
    4.55              on Accept {
    4.56                  do trustThisKey;
    4.57 -                send CommitAcceptFirst;
    4.58 -                go HandshakingNewPhase1First;
    4.59 +                send CommitAcceptOfferer;
    4.60 +                go HandshakingPhase1Offerer;
    4.61              }
    4.62  
    4.63 -            // got a CommitAccept from second
    4.64 -            on CommitAcceptSecond if sameNegotiationAndPartner
    4.65 -                go HandshakingNewPhase2First;
    4.66 +            // got a CommitAccept from requester
    4.67 +            on CommitAcceptRequester if sameNegotiationAndPartner
    4.68 +                go HandshakingPhase2Offerer;
    4.69          }
    4.70  
    4.71          // handshaking without existing Device group
    4.72 -        state HandshakingNewSecond timeout=600 {
    4.73 +        state HandshakingRequester timeout=600 {
    4.74              on Init
    4.75                  do showSoleHandshake;
    4.76  
    4.77 @@ -146,16 +146,16 @@
    4.78              // Accept means init Phase1Commit
    4.79              on Accept {
    4.80                  do trustThisKey;
    4.81 -                send CommitAcceptSecond;
    4.82 -                go HandshakingNewPhase1Second;
    4.83 +                send CommitAcceptRequester;
    4.84 +                go HandshakingPhase1Requester;
    4.85              }
    4.86  
    4.87 -            // got a CommitAccept from first
    4.88 -            on CommitAcceptFirst if sameNegotiationAndPartner
    4.89 -                go HandshakingNewPhase2Second;
    4.90 +            // got a CommitAccept from offerer
    4.91 +            on CommitAcceptOfferer if sameNegotiationAndPartner
    4.92 +                go HandshakingPhase2Requester;
    4.93          }
    4.94  
    4.95 -        state HandshakingNewPhase1First {
    4.96 +        state HandshakingPhase1Offerer {
    4.97              on Rollback if sameNegotiationAndPartner {
    4.98                  do untrustThisKey;
    4.99                  go Sole;
   4.100 @@ -167,12 +167,12 @@
   4.101                  go End;
   4.102              }
   4.103  
   4.104 -            on CommitAcceptSecond if sameNegotiationAndPartner {
   4.105 -                go NewGroupFirst;
   4.106 +            on CommitAcceptRequester if sameNegotiationAndPartner {
   4.107 +                go FormingGroupOfferer;
   4.108              }
   4.109          }
   4.110  
   4.111 -        state HandshakingNewPhase1Second {
   4.112 +        state HandshakingPhase1Requester {
   4.113              on Rollback if sameNegotiationAndPartner {
   4.114                  do untrustThisKey;
   4.115                  go Sole;
   4.116 @@ -184,12 +184,12 @@
   4.117                  go End;
   4.118              }
   4.119  
   4.120 -            on CommitAcceptFirst if sameNegotiationAndPartner {
   4.121 -                go NewGroupSecond;
   4.122 +            on CommitAcceptOfferer if sameNegotiationAndPartner {
   4.123 +                go FormingGroupRequester;
   4.124              }
   4.125          }
   4.126  
   4.127 -        state HandshakingNewPhase2First {
   4.128 +        state HandshakingPhase2Offerer {
   4.129              on Cancel {
   4.130                  send Rollback;
   4.131                  go Sole;
   4.132 @@ -202,13 +202,13 @@
   4.133              }
   4.134  
   4.135              on Accept {
   4.136 -                send CommitAcceptFirst;
   4.137 +                send CommitAcceptOfferer;
   4.138                  do trustThisKey;
   4.139 -                go NewGroupFirst;
   4.140 +                go FormingGroupOfferer;
   4.141              }
   4.142          }
   4.143  
   4.144 -        state HandshakingNewPhase2Second {
   4.145 +        state HandshakingPhase2Requester {
   4.146              on Cancel {
   4.147                  send Rollback;
   4.148                  go Sole;
   4.149 @@ -221,19 +221,19 @@
   4.150              }
   4.151  
   4.152              on Accept {
   4.153 -                send CommitAcceptSecond;
   4.154 +                send CommitAcceptRequester;
   4.155                  do trustThisKey;
   4.156 -                go NewGroupSecond;
   4.157 +                go FormingGroupRequester;
   4.158              }
   4.159          }
   4.160  
   4.161 -        state NewGroupFirst {
   4.162 +        state FormingGroupOfferer {
   4.163              on Init {
   4.164                  do prepareOwnKeys;
   4.165 -                send OwnKeysFirst; // we're not grouped yet, this is our own keys
   4.166 +                send OwnKeysOfferer; // we're not grouped yet, this is our own keys
   4.167              }
   4.168  
   4.169 -            on OwnKeysSecond {
   4.170 +            on OwnKeysRequester {
   4.171                  do saveGroupKeys;
   4.172                  do receivedKeysAreDefaultKeys;
   4.173                  do showGroupCreated;
   4.174 @@ -241,15 +241,14 @@
   4.175              }
   4.176          }
   4.177  
   4.178 -        state NewGroupSecond {
   4.179 +        state FormingGroupRequester {
   4.180              on Init {
   4.181                  do prepareOwnKeys;
   4.182 -                send OwnKeysSecond; // we're not grouped yet, this is our own keys
   4.183 +                send OwnKeysRequester; // we're not grouped yet, this is our own keys
   4.184              }
   4.185  
   4.186 -            on OwnKeysFirst {
   4.187 +            on OwnKeysOfferer {
   4.188                  do saveGroupKeys;
   4.189 -
   4.190                  do ownKeysAreDefaultKeys;
   4.191                  do showGroupCreated;
   4.192                  go Grouped;
   4.193 @@ -282,13 +281,12 @@
   4.194                  go HandshakingGrouped;
   4.195              }
   4.196  
   4.197 -            on GroupTrustThisKey {
   4.198 +            on GroupTrustThisKey
   4.199                  do trustThisKey;
   4.200 -            }
   4.201          }
   4.202  
   4.203          // sole device handshaking with group
   4.204 -        state HandshakingWithGroup {
   4.205 +        state HandshakingToJoin {
   4.206              on Init
   4.207                  do showJoinGroupHandshake;
   4.208  
   4.209 @@ -308,8 +306,8 @@
   4.210                  go End;
   4.211              }
   4.212  
   4.213 -            on CommitAccept if sameNegotiationAndPartner
   4.214 -                go HandshakingJoinPhase2;
   4.215 +            on CommitAcceptForGroup if sameNegotiationAndPartner
   4.216 +                go HandshakingToJoinPhase2;
   4.217  
   4.218              on CommitReject if sameNegotiationAndPartner {
   4.219                  do disable;
   4.220 @@ -320,11 +318,11 @@
   4.221              on Accept {
   4.222                  do trustThisKey;
   4.223                  send CommitAccept;
   4.224 -                go HandshakingJoinPhase1;
   4.225 +                go HandshakingToJoinPhase1;
   4.226              }
   4.227          }
   4.228  
   4.229 -        state HandshakingJoinPhase1 {
   4.230 +        state HandshakingToJoinPhase1 {
   4.231              on Rollback if sameNegotiationAndPartner
   4.232                  go Sole;
   4.233              
   4.234 @@ -333,12 +331,11 @@
   4.235                  go End;
   4.236              }
   4.237  
   4.238 -            on CommitAcceptForGroup if sameNegotiationAndPartner {
   4.239 -                go JoinGroup;
   4.240 -            }
   4.241 +            on CommitAcceptForGroup if sameNegotiationAndPartner
   4.242 +                go JoiningGroup;
   4.243          }
   4.244  
   4.245 -        state HandshakingJoinPhase2 {
   4.246 +        state HandshakingToJoinPhase2 {
   4.247              on Cancel {
   4.248                  send Rollback;
   4.249                  go Sole;
   4.250 @@ -352,19 +349,16 @@
   4.251  
   4.252              on Accept {
   4.253                  do trustThisKey;
   4.254 -                go JoinGroup;
   4.255 +                go JoiningGroup;
   4.256              }
   4.257          }
   4.258  
   4.259 -        state JoinGroup {
   4.260 -            on Init {
   4.261 -                do prepareOwnKeys;
   4.262 -                send OwnKeys;
   4.263 -            }
   4.264 -
   4.265 +        state JoiningGroup {
   4.266              on GroupKeys {
   4.267                  do saveGroupKeys;
   4.268                  do receivedKeysAreDefaultKeys;
   4.269 +                do prepareOwnKeys;
   4.270 +                send GroupKeys;
   4.271                  do showDeviceAdded;
   4.272                  go Grouped;
   4.273              }
   4.274 @@ -408,14 +402,6 @@
   4.275                  do trustThisKey;
   4.276              }
   4.277  
   4.278 -            on CommitAcceptForGroup {
   4.279 -                do showDeviceAdded;
   4.280 -                if sameNegotiationAndPartner {
   4.281 -                    do hideHandshakeDialog;
   4.282 -                    go Grouped;
   4.283 -                }
   4.284 -            }
   4.285 -
   4.286              on GroupKeys
   4.287                  do saveGroupKeys;
   4.288          }
   4.289 @@ -499,11 +485,11 @@
   4.290              field TID negotiation;
   4.291          }
   4.292  
   4.293 -        message CommitAcceptFirst 7, security=untrusted {
   4.294 +        message CommitAcceptOfferer 7, security=untrusted {
   4.295              field TID negotiation;
   4.296          }
   4.297  
   4.298 -        message CommitAcceptSecond 8, security=untrusted {
   4.299 +        message CommitAcceptRequester 8, security=untrusted {
   4.300              field TID negotiation;
   4.301          }
   4.302  
   4.303 @@ -525,15 +511,11 @@
   4.304              field IdentityList ownIdentities;
   4.305          }
   4.306  
   4.307 -        message OwnKeys 13, security=attach_own_keys {
   4.308 +        message OwnKeysOfferer 13, security=attach_own_keys {
   4.309              field IdentityList ownIdentities;
   4.310          }
   4.311  
   4.312 -        message OwnKeysFirst 14, security=attach_own_keys {
   4.313 -            field IdentityList ownIdentities;
   4.314 -        }
   4.315 -
   4.316 -        message OwnKeysSecond 15, security=attach_own_keys {
   4.317 +        message OwnKeysRequester 14, security=attach_own_keys {
   4.318              field IdentityList ownIdentities;
   4.319          }
   4.320      }