response added sync
authorVolker Birk <vb@pep-project.org>
Thu, 16 Jan 2020 16:22:16 +0100
branchsync
changeset 43394cbb64ab4936
parent 4338 7a9de0786596
child 4340 7f1a81347f7c
response added
sync/cond_act_sync.yml2
sync/sync.fsm
     1.1 --- a/sync/cond_act_sync.yml2	Thu Jan 16 15:32:16 2020 +0100
     1.2 +++ b/sync/cond_act_sync.yml2	Thu Jan 16 16:22:16 2020 +0100
     1.3 @@ -37,6 +37,14 @@
     1.4      *result = t1->size == t2->size && memcmp(t1->buf, t2->buf, t1->size) == 0;
     1.5  ||
     1.6  
     1.7 +condition sameResponse
     1.8 +||
     1.9 +    TID_t *t1 = &session->sync_state.keysync.response;
    1.10 +    TID_t *t2 = &session->sync_state.own.response;
    1.11 +
    1.12 +    *result = t1->size == t2->size && memcmp(t1->buf, t2->buf, t1->size) == 0;
    1.13 +||
    1.14 +
    1.15  condition sameNegotiation
    1.16  ||
    1.17      TID_t *t1 = &session->sync_state.keysync.negotiation;
    1.18 @@ -154,6 +162,13 @@
    1.19          with "dst" > &session->sync_state.keysync.challenge
    1.20      }
    1.21  
    1.22 +    // random new response
    1.23 +    call "new_UUID" with "dst" > &session->sync_state.own.response
    1.24 +    call "copy_UUID" {
    1.25 +        with "src" > &session->sync_state.own.response
    1.26 +        with "dst" > &session->sync_state.keysync.response
    1.27 +    }
    1.28 +
    1.29      // this is the random data we are using as a base
    1.30      call "new_UUID" with "dst" > &session->sync_state.own.negotiation
    1.31  ||
    1.32 @@ -169,6 +184,11 @@
    1.33      with "dst" > &session->sync_state.keysync.challenge
    1.34  }
    1.35  
    1.36 +action useOwnResponse call "copy_UUID" {
    1.37 +    with "src" > &session->sync_state.own.response
    1.38 +    with "dst" > &session->sync_state.keysync.response
    1.39 +}
    1.40 +
    1.41  action openNegotiation {
    1.42  ||
    1.43      // sender key must be stable while transaction
     2.1 --- a/sync/sync.fsm	Thu Jan 16 15:32:16 2020 +0100
     2.2 +++ b/sync/sync.fsm	Thu Jan 16 16:22:16 2020 +0100
     2.3 @@ -18,7 +18,7 @@
     2.4                  if deviceGrouped
     2.5                      go Grouped;
     2.6                  do newChallengeAndNegotiationBase;
     2.7 -                debug > initial beacon
     2.8 +                debug > initial Beacon
     2.9                  send Beacon;
    2.10                  go Sole;
    2.11              }
    2.12 @@ -46,13 +46,14 @@
    2.13                  else {
    2.14                      if weAreOfferer {
    2.15                          do useOwnChallenge;
    2.16 -                        debug > we are offerer
    2.17 +                        debug > we are Offerer
    2.18                          send Beacon;
    2.19                      }
    2.20                      else /* we are requester */ {
    2.21                          do openNegotiation;
    2.22                          do tellWeAreNotGrouped;
    2.23                          // requester is sending NegotiationRequest
    2.24 +                        do useOwnResponse;
    2.25                          send NegotiationRequest;
    2.26                          do useOwnChallenge;
    2.27                      }
    2.28 @@ -62,21 +63,16 @@
    2.29              // we get this from another sole device
    2.30              on NegotiationRequest {
    2.31                  if sameChallenge { // challenge accepted
    2.32 -                    if sameNegotiation {
    2.33 -                        debug > this is our own NegotiationRequest; ignore
    2.34 -                    }
    2.35 -                    else {
    2.36 -                        do storeNegotiation;
    2.37 -                        // offerer is accepting by confirming NegotiationOpen
    2.38 -                        send NegotiationOpen;
    2.39 -                        go HandshakingOfferer;
    2.40 -                    }
    2.41 +                    do storeNegotiation;
    2.42 +                    // offerer is accepting by confirming NegotiationOpen
    2.43 +                    send NegotiationOpen;
    2.44 +                    go HandshakingOfferer;
    2.45                  }
    2.46              }
    2.47  
    2.48              // we get this from an existing device group
    2.49              on NegotiationRequestGrouped {
    2.50 -                if sameChallenge { debub > challenge accepted
    2.51 +                if sameChallenge { // challenge accepted
    2.52                      do storeNegotiation;
    2.53                      // offerer is accepting by confirming NegotiationOpen
    2.54                      send NegotiationOpen;
    2.55 @@ -84,10 +80,15 @@
    2.56                  }
    2.57              }
    2.58  
    2.59 -            on NegotiationOpen if sameNegotiationAndPartner {
    2.60 -                debug > requester is receiving NegotiationOpen
    2.61 -                do storeNegotiation;
    2.62 -                go HandshakingRequester;
    2.63 +            on NegotiationOpen {
    2.64 +                if sameResponse {
    2.65 +                    debug > Requester is receiving NegotiationOpen
    2.66 +                    do storeNegotiation;
    2.67 +                    go HandshakingRequester;
    2.68 +                }
    2.69 +                else {
    2.70 +                    debug > cannot approve NegotiationOpen
    2.71 +                }
    2.72              }
    2.73          }
    2.74  
    2.75 @@ -555,12 +556,14 @@
    2.76  
    2.77          message NegotiationRequest 3, security=untrusted {
    2.78              field TID challenge;
    2.79 +            field TID response;
    2.80              auto Version version;
    2.81              field TID negotiation;
    2.82              field bool is_group;
    2.83          }
    2.84  
    2.85          message NegotiationOpen 4, security=untrusted {
    2.86 +            field TID response;
    2.87              auto Version version;
    2.88              field TID negotiation;
    2.89          }