rename to negotiation sync
authorVolker Birk <vb@pep-project.org>
Fri, 26 Apr 2019 05:47:58 +0200
branchsync
changeset 35509cc0d4868311
parent 3549 24c46fa0a068
child 3551 862b3d386f47
rename to negotiation
sync/cond_act_sync.yml2
sync/sync.fsm
sync/sync_protocol.txt
     1.1 --- a/sync/cond_act_sync.yml2	Thu Apr 25 20:49:59 2019 +0200
     1.2 +++ b/sync/cond_act_sync.yml2	Fri Apr 26 05:47:58 2019 +0200
     1.3 @@ -47,8 +47,8 @@
     1.4  
     1.5  condition sameTransaction
     1.6  ||
     1.7 -    TID_t *t1 = &session->sync_state.keysync.transaction;
     1.8 -    TID_t *t2 = &session->own_sync_state.transaction;
     1.9 +    TID_t *t1 = &session->sync_state.keysync.negotiation;
    1.10 +    TID_t *t2 = &session->own_sync_state.negotiation;
    1.11  
    1.12      *result = t1->size == t2->size && memcmp(t1->buf, t2->buf, t1->size) == 0;
    1.13  ||
    1.14 @@ -117,23 +117,23 @@
    1.15  
    1.16  action openTransaction {
    1.17  ||
    1.18 -    for (int i=0; i<session->sync_state.keysync.transaction.size; ++i) {
    1.19 -        if (session->sync_state.keysync.transaction.buf[i])
    1.20 +    for (int i=0; i<session->sync_state.keysync.negotiation.size; ++i) {
    1.21 +        if (session->sync_state.keysync.negotiation.buf[i])
    1.22              return PEP_STATUS_OK;
    1.23      }
    1.24  ||
    1.25 -    call "new_UUID" with "dst" > &session->sync_state.keysync.transaction
    1.26 +    call "new_UUID" with "dst" > &session->sync_state.keysync.negotiation
    1.27  }
    1.28  
    1.29  action closeTransaction
    1.30  ||
    1.31 -    memset(session->sync_state.keysync.transaction.buf, 0,
    1.32 -            session->sync_state.keysync.transaction.size);
    1.33 +    memset(session->sync_state.keysync.negotiation.buf, 0,
    1.34 +            session->sync_state.keysync.negotiation.size);
    1.35  ||
    1.36  
    1.37  action storeTransaction call "copy_UUID" {
    1.38 -    with "src" > &session->sync_state.keysync.transaction
    1.39 -    with "dst" > &session->own_sync_state.transaction
    1.40 +    with "src" > &session->sync_state.keysync.negotiation
    1.41 +    with "dst" > &session->own_sync_state.negotiation
    1.42  }
    1.43  
    1.44  function "show_handshake" {
    1.45 @@ -323,16 +323,6 @@
    1.46      free_identity_list(il);
    1.47  ||
    1.48  
    1.49 -action storeThisKey
    1.50 -||
    1.51 -    free(session->sync_state.common.signature_fpr);
    1.52 -    session->sync_state.common.signature_fpr =
    1.53 -            strndup((char *)session->sync_state.keysync.key.buf, session->sync_state.keysync.key.size);
    1.54 -    assert(session->sync_state.common.signature_fpr);
    1.55 -    if (!session->sync_state.common.signature_fpr)
    1.56 -        return PEP_OUT_OF_MEMORY;
    1.57 -||
    1.58 -
    1.59  action trustThisKey
    1.60  ||
    1.61      assert(session->sync_state.common.from && session->sync_state.common.signature_fpr);
     2.1 --- a/sync/sync.fsm	Thu Apr 25 20:49:59 2019 +0200
     2.2 +++ b/sync/sync.fsm	Fri Apr 26 05:47:58 2019 +0200
     2.3 @@ -45,7 +45,7 @@
     2.4                      }
     2.5                      else /* we are second */ {
     2.6                          do storeChallenge; // partner's challenge
     2.7 -                        do openTransaction; // NOP if transaction already open
     2.8 +                        do openTransaction; // NOP if negotiation already open
     2.9                          do storeTransaction;
    2.10                          do tellWeAreNotGrouped;
    2.11                          // second is sending HandshakeRequest
    2.12 @@ -104,12 +104,12 @@
    2.13              // Accept means init Phase1Commit
    2.14              on Accept {
    2.15                  do trustThisKey;
    2.16 -                send CommitAccept;
    2.17 +                send CommitAcceptFirst;
    2.18                  go HandshakingNewPhase1First;
    2.19              }
    2.20  
    2.21              // got a CommitAccept from second
    2.22 -            on CommitAcceptForGroup if sameTransaction
    2.23 +            on CommitAcceptSecond if sameTransaction
    2.24                  go HandshakingNewPhase2First;
    2.25          }
    2.26  
    2.27 @@ -142,12 +142,12 @@
    2.28              // Accept means init Phase1Commit
    2.29              on Accept {
    2.30                  do trustThisKey;
    2.31 -                send CommitAcceptForGroup;
    2.32 +                send CommitAcceptSecond;
    2.33                  go HandshakingNewPhase1Second;
    2.34              }
    2.35  
    2.36              // got a CommitAccept from first
    2.37 -            on CommitAccept if sameTransaction
    2.38 +            on CommitAcceptFirst if sameTransaction
    2.39                  go HandshakingNewPhase2Second;
    2.40          }
    2.41  
    2.42 @@ -163,8 +163,9 @@
    2.43                  go End;
    2.44              }
    2.45  
    2.46 -            on CommitAcceptForGroup if sameTransaction
    2.47 +            on CommitAcceptSecond if sameTransaction {
    2.48                  go NewGroupFirst;
    2.49 +            }
    2.50          }
    2.51  
    2.52          state HandshakingNewPhase1Second {
    2.53 @@ -179,8 +180,9 @@
    2.54                  go End;
    2.55              }
    2.56  
    2.57 -            on CommitAccept if sameTransaction
    2.58 +            on CommitAcceptFirst if sameTransaction {
    2.59                  go NewGroupSecond;
    2.60 +            }
    2.61          }
    2.62  
    2.63          state HandshakingNewPhase2First {
    2.64 @@ -196,6 +198,7 @@
    2.65              }
    2.66  
    2.67              on Accept {
    2.68 +                send CommitAcceptFirst;
    2.69                  do trustThisKey;
    2.70                  go NewGroupFirst;
    2.71              }
    2.72 @@ -214,6 +217,7 @@
    2.73              }
    2.74  
    2.75              on Accept {
    2.76 +                send CommitAcceptSecond;
    2.77                  do trustThisKey;
    2.78                  go NewGroupSecond;
    2.79              }
    2.80 @@ -222,10 +226,10 @@
    2.81          state NewGroupFirst {
    2.82              on Init {
    2.83                  do prepareOwnKeys;
    2.84 -                send GroupKeys; // we're not grouped yet, this is our own keys
    2.85 +                send OwnKeysFirst; // we're not grouped yet, this is our own keys
    2.86              }
    2.87  
    2.88 -            on GroupKeysAndClose if sameTransaction {
    2.89 +            on OwnKeysSecond {
    2.90                  do saveGroupKeys;
    2.91  
    2.92                  if keyElectionWon
    2.93 @@ -240,10 +244,10 @@
    2.94          state NewGroupSecond {
    2.95              on Init {
    2.96                  do prepareOwnKeys;
    2.97 -                send GroupKeysAndClose; // we're not grouped yet, this is our own keys
    2.98 +                send OwnKeysSecond; // we're not grouped yet, this is our own keys
    2.99              }
   2.100  
   2.101 -            on GroupKeys {
   2.102 +            on OwnKeysFirst {
   2.103                  do saveGroupKeys;
   2.104  
   2.105                  if keyElectionWon
   2.106 @@ -281,12 +285,8 @@
   2.107                  go HandshakingGrouped;
   2.108  
   2.109              on GroupTrustThisKey {
   2.110 -                do storeThisKey;
   2.111                  do trustThisKey;
   2.112              }
   2.113 -
   2.114 -            on GroupKeysAndClose
   2.115 -                do showDeviceAdded;
   2.116          }
   2.117  
   2.118          // sole device handshaking with group
   2.119 @@ -335,8 +335,9 @@
   2.120                  go End;
   2.121              }
   2.122  
   2.123 -            on CommitAcceptForGroup if sameTransaction
   2.124 +            on CommitAcceptForGroup if sameTransaction {
   2.125                  go JoinGroup;
   2.126 +            }
   2.127          }
   2.128  
   2.129          state HandshakingJoinPhase2 {
   2.130 @@ -363,7 +364,7 @@
   2.131                  send GroupKeys;
   2.132              }
   2.133  
   2.134 -            on GroupKeysAndClose {
   2.135 +            on GroupKeys if sameTransaction {
   2.136                  do saveGroupKeys;
   2.137                  do receivedKeysAreGroupKeys;
   2.138                  do showDeviceAdded;
   2.139 @@ -406,7 +407,6 @@
   2.140  
   2.141              on GroupTrustThisKey {
   2.142                  do hideHandshakeDialog;
   2.143 -                do storeThisKey;
   2.144                  do trustThisKey;
   2.145              }
   2.146  
   2.147 @@ -430,12 +430,11 @@
   2.148                  go Grouped;
   2.149  
   2.150              on CommitAccept if sameTransaction {
   2.151 -                send GroupKeysAndClose;
   2.152 +                send GroupKeys;
   2.153                  go Grouped;
   2.154              }
   2.155  
   2.156              on GroupTrustThisKey {
   2.157 -                do storeThisKey;
   2.158                  do trustThisKey;
   2.159              }
   2.160  
   2.161 @@ -463,12 +462,11 @@
   2.162              on Accept {
   2.163                  do trustThisKey;
   2.164                  send GroupTrustThisKey;
   2.165 -                send GroupKeysAndClose;
   2.166 +                send GroupKeys;
   2.167                  go Grouped;
   2.168              }
   2.169  
   2.170              on GroupTrustThisKey {
   2.171 -                do storeThisKey;
   2.172                  do trustThisKey;
   2.173              }
   2.174  
   2.175 @@ -498,44 +496,58 @@
   2.176          message HandshakeRequest 3, security=untrusted {
   2.177              field TID challenge;
   2.178              auto Version version;
   2.179 -            field TID transaction;
   2.180 +            field TID negotiation;
   2.181              field bool is_group;
   2.182          }
   2.183  
   2.184          message HandshakeAnswer 4, security=untrusted {
   2.185              auto Version version;
   2.186 -            field TID transaction;
   2.187 +            field TID negotiation;
   2.188          }
   2.189  
   2.190          message Rollback 5, security=untrusted {
   2.191 -            field TID transaction;
   2.192 +            field TID negotiation;
   2.193          }
   2.194  
   2.195          message CommitReject 6, security=untrusted {
   2.196 -            field TID transaction;
   2.197 +            field TID negotiation;
   2.198          }
   2.199  
   2.200 -        message CommitAccept 7, security=untrusted {
   2.201 -            field TID transaction;
   2.202 +        message CommitAcceptFirst 7, security=untrusted {
   2.203 +            field TID negotiation;
   2.204          }
   2.205  
   2.206 -        message CommitAcceptForGroup 8, security=untrusted {
   2.207 -            field TID transaction;
   2.208 +        message CommitAcceptSecond 8, security=untrusted {
   2.209 +            field TID negotiation;
   2.210 +        }
   2.211 +
   2.212 +        message CommitAccept 9, security=untrusted {
   2.213 +            field TID negotiation;
   2.214 +        }
   2.215 +
   2.216 +        message CommitAcceptForGroup 10, security=untrusted {
   2.217 +            field TID negotiation;
   2.218          }
   2.219  
   2.220          // default: security=trusted only
   2.221 -        message GroupTrustThisKey 9 {
   2.222 +        message GroupTrustThisKey 11 {
   2.223              field Hash key;
   2.224          }
   2.225  
   2.226          // security=attach_own_keys implies security=trusted
   2.227 -        message GroupKeysAndClose 10, security=attach_own_keys {
   2.228 -            field TID transaction;
   2.229 +        message GroupKeys 12, security=attach_own_keys {
   2.230              field IdentityList ownIdentities;
   2.231          }
   2.232  
   2.233 -        // security=attach_own_keys implies security=trusted
   2.234 -        message GroupKeys 11, security=attach_own_keys {
   2.235 +        message OwnKeys 13, security=attach_own_keys {
   2.236 +            field IdentityList ownIdentities;
   2.237 +        }
   2.238 +
   2.239 +        message OwnKeysFirst 14, security=attach_own_keys {
   2.240 +            field IdentityList ownIdentities;
   2.241 +        }
   2.242 +
   2.243 +        message OwnKeysSecond 15, security=attach_own_keys {
   2.244              field IdentityList ownIdentities;
   2.245          }
   2.246      }
     3.1 --- a/sync/sync_protocol.txt	Thu Apr 25 20:49:59 2019 +0200
     3.2 +++ b/sync/sync_protocol.txt	Fri Apr 26 05:47:58 2019 +0200
     3.3 @@ -4,36 +4,52 @@
     3.4  1. Protocol Stack
     3.5  -----------------
     3.6  
     3.7 -Trust Sync | Contact Sync | Task Sync
     3.8 -Sync | Key Sync
     3.9 +Key Sync | Trust Sync | Contact Sync | Task Sync
    3.10 +Sync
    3.11  Baseprotocol
    3.12  Transport
    3.13  
    3.14 -1. Device View
    3.15 +1. Group View
    3.16  --------------
    3.17  
    3.18  1.1 State Sole
    3.19  
    3.20 -A Device is in state Sole when it is not member of a Device group and when it
    3.21 +A Sender is in state Sole when it is not member of a Sender group and when it
    3.22  is not part of a Negotiation.
    3.23  
    3.24  1.1 State Grouped
    3.25  
    3.26 -A Device is in state Grouped when it is member of a Device group and when it is
    3.27 +A Sender is in state Grouped when it is member of a Sender group and when it is
    3.28  not part of a Negotiation.
    3.29  
    3.30 -1.1 State Handshaking
    3.31 -
    3.32 -A Device is in state Handshaking when it is triggered by receiving a Beacon.
    3.33 -
    3.34 -1.1 State SentCommit
    3.35 -
    3.36 -1.1 State ReceivedCommit
    3.37 -
    3.38  1. Transaction View for Negotiation
    3.39  -----------------------------------
    3.40  
    3.41 -A Negotiation is identified by the FPR of the Key of the Identity, which is
    3.42 -used for transport. 
    3.43 +1.1 TID
    3.44  
    3.45 +A TID (transaction ID) is a UUID version 4 variant 1.
    3.46  
    3.47 +1.1 Negotiation
    3.48 +
    3.49 +A Negotiation is a transaction identified by a TID.
    3.50 +
    3.51 +1. Roles and Keys
    3.52 +-----------------
    3.53 +
    3.54 +1.1 Sender signing
    3.55 +
    3.56 +The key with which the sender of the message is signing. In case of trusted
    3.57 +messages this is signalled within the encrypted message. This is signalled by
    3.58 +by opt_field pEp-sender-sign, which is not reflected to the outer message.
    3.59 +
    3.60 +Transports can opt to use HMAC or OMAC instead of digital signatures.
    3.61 +
    3.62 +1.1 Transport signing
    3.63 +
    3.64 +Keys with which others and not the sender are signing a message.
    3.65 +
    3.66 +1.1 Sender Group key
    3.67 +
    3.68 +This key is a sender signing key, which is used to update the group. If it is
    3.69 +reset the group breaks.
    3.70 +