sending keys sync
authorVolker Birk <vb@pep-project.org>
Sun, 14 Apr 2019 11:09:11 +0200
branchsync
changeset 3517157a9616132a
parent 3516 32b4b47e1fb7
child 3518 673f89ac1def
sending keys
sync/sync.fsm
     1.1 --- a/sync/sync.fsm	Sun Apr 14 10:48:21 2019 +0200
     1.2 +++ b/sync/sync.fsm	Sun Apr 14 11:09:11 2019 +0200
     1.3 @@ -102,13 +102,13 @@
     1.4              // Accept means init Phase1Commit
     1.5              on Accept {
     1.6                  do trustThisKey;
     1.7 -                send CommitAcceptForGroup;
     1.8 +                send CommitAccept;
     1.9                  go HandshakingNewPhase1First;
    1.10              }
    1.11  
    1.12              // got a CommitAccept from second
    1.13 -            on CommitAccept if sameTransaction
    1.14 -                go HandshakingNewPhase2;
    1.15 +            on CommitAcceptForGroup if sameTransaction
    1.16 +                go HandshakingNewPhase2First;
    1.17          }
    1.18  
    1.19          // handshaking without existing Device group
    1.20 @@ -140,13 +140,13 @@
    1.21              // Accept means init Phase1Commit
    1.22              on Accept {
    1.23                  do trustThisKey;
    1.24 -                send CommitAccept;
    1.25 +                send CommitAcceptForGroup;
    1.26                  go HandshakingNewPhase1Second;
    1.27              }
    1.28  
    1.29              // got a CommitAccept from first
    1.30              on CommitAccept if sameTransaction
    1.31 -                go HandshakingNewPhase2;
    1.32 +                go HandshakingNewPhase2Second;
    1.33          }
    1.34  
    1.35          state HandshakingNewPhase1First {
    1.36 @@ -158,8 +158,8 @@
    1.37                  go End;
    1.38              }
    1.39  
    1.40 -            on CommitAccept if sameTransaction
    1.41 -                go NewGroup;
    1.42 +            on CommitAcceptForGroup if sameTransaction
    1.43 +                go NewGroupFirst;
    1.44          }
    1.45  
    1.46          state HandshakingNewPhase1Second {
    1.47 @@ -171,11 +171,11 @@
    1.48                  go End;
    1.49              }
    1.50  
    1.51 -            on CommitAcceptForGroup if sameTransaction
    1.52 -                go NewGroup;
    1.53 +            on CommitAccept if sameTransaction
    1.54 +                go NewGroupSecond;
    1.55          }
    1.56  
    1.57 -        state HandshakingNewPhase2 {
    1.58 +        state HandshakingNewPhase2First {
    1.59              on Cancel {
    1.60                  send Rollback;
    1.61                  go Sole;
    1.62 @@ -189,17 +189,50 @@
    1.63  
    1.64              on Accept {
    1.65                  do trustThisKey;
    1.66 -                go NewGroup;
    1.67 +                go NewGroupFirst;
    1.68              }
    1.69          }
    1.70  
    1.71 -        state NewGroup {
    1.72 +        state HandshakingNewPhase2Second {
    1.73 +            on Cancel {
    1.74 +                send Rollback;
    1.75 +                go Sole;
    1.76 +            }
    1.77 +
    1.78 +            on Reject {
    1.79 +                send CommitReject;
    1.80 +                do disable;
    1.81 +                go End;
    1.82 +            }
    1.83 +
    1.84 +            on Accept {
    1.85 +                do trustThisKey;
    1.86 +                go NewGroupSecond;
    1.87 +            }
    1.88 +        }
    1.89 +
    1.90 +        state NewGroupFirst {
    1.91 +            on Init {
    1.92 +                do prepareOwnKeys;
    1.93 +                send GroupKeys; // we're not grouped yet, this is our own keys
    1.94 +            }
    1.95 +
    1.96 +            on GroupKeysAndClose if sameTransaction {
    1.97 +                if keyElectionWon
    1.98 +                    do ownKeysAreGroupKeys;
    1.99 +                else
   1.100 +                    do receivedKeysAreGroupKeys;
   1.101 +                go Grouped;
   1.102 +            }
   1.103 +        }
   1.104 +
   1.105 +        state NewGroupSecond {
   1.106              on Init {
   1.107                  do prepareOwnKeys;
   1.108                  send GroupKeysAndClose; // we're not grouped yet, this is our own keys
   1.109              }
   1.110  
   1.111 -            on GroupKeysAndClose if sameTransaction {
   1.112 +            on GroupKeys if sameTransaction {
   1.113                  if keyElectionWon
   1.114                      do ownKeysAreGroupKeys;
   1.115                  else