some group features sync
authorVolker Birk <vb@pep-project.org>
Sun, 14 Apr 2019 16:54:48 +0200
branchsync
changeset 3524c87c6b4f3e08
parent 3523 9555e664423f
child 3525 03981c2354de
some group features
src/sync_api.h
sync/cond_act_sync.yml2
sync/sync.fsm
     1.1 --- a/src/sync_api.h	Sun Apr 14 16:00:52 2019 +0200
     1.2 +++ b/src/sync_api.h	Sun Apr 14 16:54:48 2019 +0200
     1.3 @@ -16,21 +16,21 @@
     1.4      SYNC_NOTIFY_UNDEFINED = 0,
     1.5  
     1.6      // request show handshake dialog
     1.7 -    SYNC_NOTIFY_INIT_ADD_OUR_DEVICE,
     1.8 -    SYNC_NOTIFY_INIT_ADD_OTHER_DEVICE,
     1.9 -    SYNC_NOTIFY_INIT_FORM_GROUP,
    1.10 -    SYNC_NOTIFY_INIT_MOVE_OUR_DEVICE,
    1.11 +    SYNC_NOTIFY_INIT_ADD_OUR_DEVICE = 1,
    1.12 +    SYNC_NOTIFY_INIT_ADD_OTHER_DEVICE = 2,
    1.13 +    SYNC_NOTIFY_INIT_FORM_GROUP = 3,
    1.14 +    // SYNC_NOTIFY_INIT_MOVE_OUR_DEVICE = 4,
    1.15  
    1.16      // handshake process timed out
    1.17 -    SYNC_NOTIFY_TIMEOUT,
    1.18 +    SYNC_NOTIFY_TIMEOUT = 5,
    1.19  
    1.20      // handshake accepted by user
    1.21 -    SYNC_NOTIFY_ACCEPTED_DEVICE_ADDED,
    1.22 -    SYNC_NOTIFY_ACCEPTED_GROUP_CREATED,
    1.23 -    SYNC_NOTIFY_ACCEPTED_DEVICE_MOVED,
    1.24 +    SYNC_NOTIFY_ACCEPTED_DEVICE_ADDED = 6,
    1.25 +    SYNC_NOTIFY_ACCEPTED_GROUP_CREATED = 7,
    1.26 +    // SYNC_NOTIFY_ACCEPTED_DEVICE_MOVED = 8,
    1.27  
    1.28      // handshake dialog must be closed
    1.29 -    SYNC_NOTIFY_OVERTAKEN
    1.30 +    SYNC_NOTIFY_OVERTAKEN = 9
    1.31  } sync_handshake_signal;
    1.32  
    1.33  
     2.1 --- a/sync/cond_act_sync.yml2	Sun Apr 14 16:00:52 2019 +0200
     2.2 +++ b/sync/cond_act_sync.yml2	Sun Apr 14 16:54:48 2019 +0200
     2.3 @@ -195,6 +195,12 @@
     2.4  action hideHandshakeDialog
     2.5      call "show_handshake" with "type" > SYNC_NOTIFY_OVERTAKEN
     2.6  
     2.7 +action showDeviceAdded
     2.8 +    call "show_handshake" with "type" > SYNC_NOTIFY_ACCEPTED_DEVICE_ADDED
     2.9 +
    2.10 +action showGroupCreated
    2.11 +    call "show_handshake" with "type" > SYNC_NOTIFY_ACCEPTED_GROUP_CREATED
    2.12 +
    2.13  timeout KeySync
    2.14      call "show_handshake" with "type" > SYNC_NOTIFY_TIMEOUT
    2.15  
    2.16 @@ -251,6 +257,16 @@
    2.17  
    2.18  action receivedKeysAreGroupKeys;
    2.19  
    2.20 +action storeThisKey
    2.21 +||
    2.22 +    free(session->sync_state.common.signature_fpr);
    2.23 +    session->sync_state.common.signature_fpr =
    2.24 +            strndup((char *)session->sync_state.keysync.key.buf, session->sync_state.keysync.key.size);
    2.25 +    assert(session->sync_state.common.signature_fpr);
    2.26 +    if (!session->sync_state.common.signature_fpr)
    2.27 +        return PEP_OUT_OF_MEMORY;
    2.28 +||
    2.29 +
    2.30  action trustThisKey
    2.31  ||
    2.32      assert(session->sync_state.common.from && session->sync_state.common.signature_fpr);
    2.33 @@ -271,6 +287,26 @@
    2.34      OCTET_STRING_fromBuf(&session->sync_state.keysync.key, ident->fpr, strlen(ident->fpr));
    2.35  ||
    2.36  
    2.37 +action untrustThisKey
    2.38 +||
    2.39 +    assert(session->sync_state.common.from && session->sync_state.common.signature_fpr);
    2.40 +    if (!(session->sync_state.common.from && session->sync_state.common.signature_fpr))
    2.41 +        return PEP_ILLEGAL_VALUE;
    2.42 +
    2.43 +    pEp_identity *ident = session->sync_state.common.from;
    2.44 +    free(ident->fpr);
    2.45 +    ident->fpr = strdup(session->sync_state.common.signature_fpr);
    2.46 +    assert(ident->fpr);
    2.47 +    if (!ident->fpr)
    2.48 +        return PEP_OUT_OF_MEMORY;
    2.49 +
    2.50 +    PEP_STATUS status = key_reset_trust(session, ident);
    2.51 +    if (status)
    2.52 +        return status;
    2.53 +
    2.54 +    OCTET_STRING_fromBuf(&session->sync_state.keysync.key, "", 0);
    2.55 +||
    2.56 +
    2.57  action tellWeAreGrouped
    2.58  ||
    2.59      session->sync_state.keysync.is_group = true;
     3.1 --- a/sync/sync.fsm	Sun Apr 14 16:00:52 2019 +0200
     3.2 +++ b/sync/sync.fsm	Sun Apr 14 16:54:48 2019 +0200
     3.3 @@ -151,10 +151,13 @@
     3.4          }
     3.5  
     3.6          state HandshakingNewPhase1First {
     3.7 -            on Rollback if sameTransaction
     3.8 +            on Rollback if sameTransaction {
     3.9 +                do untrustThisKey;
    3.10                  go Sole;
    3.11 +            }
    3.12              
    3.13              on CommitReject if sameTransaction {
    3.14 +                do untrustThisKey;
    3.15                  do disable;
    3.16                  go End;
    3.17              }
    3.18 @@ -164,10 +167,13 @@
    3.19          }
    3.20  
    3.21          state HandshakingNewPhase1Second {
    3.22 -            on Rollback if sameTransaction
    3.23 +            on Rollback if sameTransaction {
    3.24 +                do untrustThisKey;
    3.25                  go Sole;
    3.26 +            }
    3.27              
    3.28              on CommitReject if sameTransaction {
    3.29 +                do untrustThisKey;
    3.30                  do disable;
    3.31                  go End;
    3.32              }
    3.33 @@ -225,6 +231,7 @@
    3.34                      do ownKeysAreGroupKeys;
    3.35                  else
    3.36                      do receivedKeysAreGroupKeys;
    3.37 +                do showGroupCreated;
    3.38                  go Grouped;
    3.39              }
    3.40          }
    3.41 @@ -242,6 +249,7 @@
    3.42                      do ownKeysAreGroupKeys;
    3.43                  else
    3.44                      do receivedKeysAreGroupKeys;
    3.45 +                do showGroupCreated;
    3.46                  go Grouped;
    3.47              }
    3.48          }
    3.49 @@ -266,6 +274,14 @@
    3.50  
    3.51              on HandshakeAnswer if sameTransaction
    3.52                  go HandshakingGrouped;
    3.53 +
    3.54 +            on GroupTrustThisKey {
    3.55 +                do storeThisKey;
    3.56 +                do trustThisKey;
    3.57 +            }
    3.58 +
    3.59 +            on GroupKeysAndClose
    3.60 +                do showDeviceAdded;
    3.61          }
    3.62  
    3.63          // sole device handshaking with group
    3.64 @@ -343,6 +359,7 @@
    3.65              on GroupKeysAndClose {
    3.66                  do saveGroupKeys;
    3.67                  do receivedKeysAreGroupKeys;
    3.68 +                do showDeviceAdded;
    3.69                  go Grouped;
    3.70              }
    3.71          }
    3.72 @@ -382,7 +399,16 @@
    3.73  
    3.74              on GroupTrustThisKey {
    3.75                  do hideHandshakeDialog;
    3.76 -                go Grouped;
    3.77 +                do storeThisKey;
    3.78 +                do trustThisKey;
    3.79 +            }
    3.80 +
    3.81 +            on CommitAcceptForGroup {
    3.82 +                do showDeviceAdded;
    3.83 +                if sameTransaction {
    3.84 +                    do hideHandshakeDialog;
    3.85 +                    go Grouped;
    3.86 +                }
    3.87              }
    3.88  
    3.89              on GroupKeys
    3.90 @@ -401,8 +427,16 @@
    3.91                  go Grouped;
    3.92              }
    3.93  
    3.94 -            on GroupTrustThisKey
    3.95 -                go Grouped;
    3.96 +            on GroupTrustThisKey {
    3.97 +                do storeThisKey;
    3.98 +                do trustThisKey;
    3.99 +            }
   3.100 +
   3.101 +            on CommitAcceptForGroup {
   3.102 +                do showDeviceAdded;
   3.103 +                if sameTransaction
   3.104 +                    go Grouped;
   3.105 +            }
   3.106  
   3.107              on GroupKeys
   3.108                  do saveGroupKeys;
   3.109 @@ -427,8 +461,16 @@
   3.110              }
   3.111  
   3.112              on GroupTrustThisKey {
   3.113 -                do hideHandshakeDialog;
   3.114 -                go Grouped;
   3.115 +                do storeThisKey;
   3.116 +                do trustThisKey;
   3.117 +            }
   3.118 +
   3.119 +            on CommitAcceptForGroup {
   3.120 +                do showDeviceAdded;
   3.121 +                if sameTransaction {
   3.122 +                    do hideHandshakeDialog;
   3.123 +                    go Grouped;
   3.124 +                }
   3.125              }
   3.126  
   3.127              on GroupKeys