for three parties sync
authorVolker Birk <vb@pep-project.org>
Thu, 02 May 2019 13:23:25 +0200
branchsync
changeset 360527595b58666d
parent 3604 4bf5759ea073
child 3606 341d6694d968
for three parties
sync/cond_act_sync.yml2
sync/sync.fsm
sync/sync_protocol.md
     1.1 --- a/sync/cond_act_sync.yml2	Thu May 02 11:23:41 2019 +0200
     1.2 +++ b/sync/cond_act_sync.yml2	Thu May 02 13:23:25 2019 +0200
     1.3 @@ -111,14 +111,33 @@
     1.4  function "copy_UUID" {
     1.5      param "src", param "dst";
     1.6      ||
     1.7 -        TID_t *src = «$src»;
     1.8 -        TID_t *dst = «$dst»;
     1.9 +        {
    1.10 +            TID_t *src = «$src»;
    1.11 +            TID_t *dst = «$dst»;
    1.12  
    1.13 -        assert(src->size == 16);
    1.14 -        if (!(src->size == 16))
    1.15 -            return PEP_UNKNOWN_ERROR;
    1.16 +            assert(src->size == 16);
    1.17 +            if (!(src->size == 16))
    1.18 +                return PEP_UNKNOWN_ERROR;
    1.19  
    1.20 -        OCTET_STRING_fromBuf(dst, (char *) src->buf, src->size);
    1.21 +            OCTET_STRING_fromBuf(dst, (char *) src->buf, src->size);
    1.22 +        }
    1.23 +    ||
    1.24 +}
    1.25 +
    1.26 +function "xor_UUID" {
    1.27 +    param "src", param "dst";
    1.28 +    ||
    1.29 +        {
    1.30 +            TID_t *src = «$src»;
    1.31 +            TID_t *dst = «$dst»;
    1.32 +
    1.33 +            assert(src->size == 16 && dst->size == 16);
    1.34 +            if (!(src->size == 16 && dst->size == 16))
    1.35 +                return PEP_UNKNOWN_ERROR;
    1.36 +
    1.37 +            for (int i=0; i < src->size; ++i)
    1.38 +                dst->buf[i] ^= src->buf[i];
    1.39 +        }
    1.40      ||
    1.41  }
    1.42  
    1.43 @@ -154,7 +173,14 @@
    1.44          return PEP_OUT_OF_MEMORY;
    1.45  
    1.46  ||
    1.47 -    call "new_UUID" with "dst" > &session->sync_state.keysync.negotiation
    1.48 +    call "copy_UUID" {
    1.49 +        with "src" > &session->sync_state.keysync.challenge
    1.50 +        with "dst" > &session->sync_state.keysync.negotiation
    1.51 +    }
    1.52 +    call "xor_UUID" {
    1.53 +        with "src" > &session->own_sync_state.challenge
    1.54 +        with "dst" > &session->sync_state.keysync.negotiation
    1.55 +    }
    1.56      call "copy_UUID" {
    1.57          with "src" > &session->sync_state.keysync.negotiation
    1.58          with "dst" > &session->own_sync_state.negotiation
     2.1 --- a/sync/sync.fsm	Thu May 02 11:23:41 2019 +0200
     2.2 +++ b/sync/sync.fsm	Thu May 02 13:23:25 2019 +0200
     2.3 @@ -23,9 +23,9 @@
     2.4  
     2.5          state Sole timeout=off {
     2.6              on Init {
     2.7 +                do closeTransaction;
     2.8 +                do newChallenge;
     2.9                  do showBeingSole;
    2.10 -                do newChallenge;
    2.11 -                do closeTransaction;
    2.12                  send Beacon;
    2.13              }
    2.14  
    2.15 @@ -46,11 +46,12 @@
    2.16                          send Beacon;
    2.17                      }
    2.18                      else /* we are second */ {
    2.19 -                        do replyChallenge; // partner's challenge
    2.20                          do newTransaction;
    2.21                          do tellWeAreNotGrouped;
    2.22                          // second is sending NegotiationRequest
    2.23 +                        do replyChallenge; // partner's challenge
    2.24                          send NegotiationRequest;
    2.25 +                        do useOwnChallenge;
    2.26                      }
    2.27                  }
    2.28              }
    2.29 @@ -264,8 +265,9 @@
    2.30  
    2.31          state Grouped timeout=off {
    2.32              on Init {
    2.33 +                do closeTransaction;
    2.34 +                do newChallenge;
    2.35                  do showBeingInGroup;
    2.36 -                do closeTransaction;
    2.37              }
    2.38  
    2.39              on GroupKeys
    2.40 @@ -277,10 +279,11 @@
    2.41              }
    2.42  
    2.43              on Beacon {
    2.44 -                do replyChallenge;
    2.45                  do newTransaction;
    2.46                  do tellWeAreGrouped;
    2.47 +                do replyChallenge; // partner's challenge
    2.48                  send NegotiationRequest;
    2.49 +                do useOwnChallenge;
    2.50              }
    2.51  
    2.52              on NegotiationOpen if sameTransactionAndPartner
     3.1 --- a/sync/sync_protocol.md	Thu May 02 11:23:41 2019 +0200
     3.2 +++ b/sync/sync_protocol.md	Thu May 02 13:23:25 2019 +0200
     3.3 @@ -47,7 +47,8 @@
     3.4  
     3.5  ### Negotiation
     3.6  
     3.7 -A Negotiation is a Transaction identified by a TID.
     3.8 +A Negotiation is a Transaction identified by a TID. The Negotiation's TID is
     3.9 +the XOR of the two Challenge TIDs, respectively.
    3.10  
    3.11  ## Roles and Keys
    3.12