trustThisKey sync
authorVolker Birk <vb@pep-project.org>
Sun, 14 Apr 2019 10:48:21 +0200
branchsync
changeset 351632b4b47e1fb7
parent 3515 287699a9aa7c
child 3517 157a9616132a
trustThisKey
src/message_api.c
sync/cond_act_sync.yml2
sync/sync.fsm
     1.1 --- a/src/message_api.c	Sun Apr 14 10:04:28 2019 +0200
     1.2 +++ b/src/message_api.c	Sun Apr 14 10:48:21 2019 +0200
     1.3 @@ -3824,8 +3824,12 @@
     1.4          const char *data;
     1.5          char *sync_fpr = NULL;
     1.6          PEP_STATUS tmpstatus = base_extract_message(session, msg, &size, &data, &sync_fpr);
     1.7 -        if (!tmpstatus && size && data)
     1.8 -            signal_Sync_message(session, *rating, data, size, msg->from, sync_fpr);
     1.9 +        if (!tmpstatus && size && data) {
    1.10 +            if (sync_fpr)
    1.11 +                signal_Sync_message(session, *rating, data, size, msg->from, sync_fpr);
    1.12 +            else if (*keylist)
    1.13 +                signal_Sync_message(session, *rating, data, size, msg->from, (*keylist)->value);
    1.14 +        }
    1.15          free(sync_fpr);
    1.16      }
    1.17  
     2.1 --- a/sync/cond_act_sync.yml2	Sun Apr 14 10:04:28 2019 +0200
     2.2 +++ b/sync/cond_act_sync.yml2	Sun Apr 14 10:48:21 2019 +0200
     2.3 @@ -248,5 +248,23 @@
     2.4  
     2.5  action receivedKeysAreGroupKeys;
     2.6  
     2.7 +action trustThisKey
     2.8 +||
     2.9 +    assert(session->sync_state.common.from && session->sync_state.common.signature_fpr);
    2.10 +    if (!(session->sync_state.common.from && session->sync_state.common.signature_fpr))
    2.11 +        return PEP_ILLEGAL_VALUE;
    2.12 +
    2.13 +    pEp_identity *ident = session->sync_state.common.from;
    2.14 +    free(ident->fpr);
    2.15 +    ident->fpr = strdup(session->sync_state.common.signature_fpr);
    2.16 +    assert(ident->fpr);
    2.17 +    if (!ident->fpr)
    2.18 +        return PEP_OUT_OF_MEMORY;
    2.19 +
    2.20 +    PEP_STATUS status = trust_own_key(session, ident);
    2.21 +    if (status)
    2.22 +        return status;
    2.23 +||
    2.24 +
    2.25  action disable;
    2.26  
     3.1 --- a/sync/sync.fsm	Sun Apr 14 10:04:28 2019 +0200
     3.2 +++ b/sync/sync.fsm	Sun Apr 14 10:48:21 2019 +0200
     3.3 @@ -36,7 +36,7 @@
     3.4  
     3.5              on Beacon {
     3.6                  if sameChallenge {
     3.7 -                    // this is out own beacon; ignore
     3.8 +                    // this is our own beacon; ignore
     3.9                  }
    3.10                  else {
    3.11                      if weAreFirst {
    3.12 @@ -101,6 +101,7 @@
    3.13  
    3.14              // Accept means init Phase1Commit
    3.15              on Accept {
    3.16 +                do trustThisKey;
    3.17                  send CommitAcceptForGroup;
    3.18                  go HandshakingNewPhase1First;
    3.19              }
    3.20 @@ -138,6 +139,7 @@
    3.21  
    3.22              // Accept means init Phase1Commit
    3.23              on Accept {
    3.24 +                do trustThisKey;
    3.25                  send CommitAccept;
    3.26                  go HandshakingNewPhase1Second;
    3.27              }
    3.28 @@ -185,8 +187,10 @@
    3.29                  go End;
    3.30              }
    3.31  
    3.32 -            on Accept
    3.33 +            on Accept {
    3.34 +                do trustThisKey;
    3.35                  go NewGroup;
    3.36 +            }
    3.37          }
    3.38  
    3.39          state NewGroup {
    3.40 @@ -231,6 +235,7 @@
    3.41  
    3.42              // Accept is Phase1Commit
    3.43              on Accept {
    3.44 +                do trustThisKey;
    3.45                  send CommitAccept;
    3.46                  go HandshakingJoinPhase1;
    3.47              }
    3.48 @@ -264,8 +269,10 @@
    3.49                  go End;
    3.50              }
    3.51  
    3.52 -            on Accept
    3.53 +            on Accept {
    3.54 +                do trustThisKey;
    3.55                  go OwnGroup;
    3.56 +            }
    3.57          }
    3.58  
    3.59          state JoinGroup {
    3.60 @@ -322,6 +329,7 @@
    3.61  
    3.62              // Accept is Phase1Commit
    3.63              on Accept {
    3.64 +                do trustThisKey;
    3.65                  send CommitAcceptForGroup;
    3.66                  go HandshakingGroupedPhase1;
    3.67              }
    3.68 @@ -361,6 +369,7 @@
    3.69              }
    3.70  
    3.71              on Accept {
    3.72 +                do trustThisKey;
    3.73                  send GroupKeysAndClose;
    3.74                  go Grouped;
    3.75              }