store sender key with transaction sync
authorVolker Birk <vb@pep-project.org>
Tue, 30 Apr 2019 21:02:44 +0200
branchsync
changeset 359069969ad8d4af
parent 3589 0627024f0184
child 3591 19d842c279ee
store sender key with transaction
sync/cond_act_sync.yml2
sync/gen_message_func.ysl2
     1.1 --- a/sync/cond_act_sync.yml2	Tue Apr 30 18:04:39 2019 +0200
     1.2 +++ b/sync/cond_act_sync.yml2	Tue Apr 30 21:02:44 2019 +0200
     1.3 @@ -117,10 +117,22 @@
     1.4  
     1.5  action openTransaction {
     1.6  ||
     1.7 +    // if transaction already open do nothing
     1.8      for (int i=0; i<session->sync_state.keysync.negotiation.size; ++i) {
     1.9          if (session->sync_state.keysync.negotiation.buf[i])
    1.10              return PEP_STATUS_OK;
    1.11      }
    1.12 +
    1.13 +    // sender key must be stable while transaction
    1.14 +    if (!session->own_sync_state.signature_fpr) {
    1.15 +        assert(session->sync_state.common.signature_fpr);
    1.16 +        session->own_sync_state.signature_fpr
    1.17 +                = strdup(session->sync_state.common.signature_fpr);
    1.18 +        assert(session->own_sync_state.signature_fpr);
    1.19 +        if (!session->own_sync_state.signature_fpr)
    1.20 +            return PEP_OUT_OF_MEMORY;
    1.21 +    }
    1.22 +
    1.23  ||
    1.24      call "new_UUID" with "dst" > &session->sync_state.keysync.negotiation
    1.25  }
    1.26 @@ -129,6 +141,8 @@
    1.27  ||
    1.28      memset(session->sync_state.keysync.negotiation.buf, 0,
    1.29              session->sync_state.keysync.negotiation.size);
    1.30 +    free(session->own_sync_state.signature_fpr);
    1.31 +    session->own_sync_state.signature_fpr = NULL;
    1.32  ||
    1.33  
    1.34  action storeTransaction call "copy_UUID" {
     2.1 --- a/sync/gen_message_func.ysl2	Tue Apr 30 18:04:39 2019 +0200
     2.2 +++ b/sync/gen_message_func.ysl2	Tue Apr 30 21:02:44 2019 +0200
     2.3 @@ -41,9 +41,11 @@
     2.4  struct «@name»_state_s {
     2.5      struct common_state_s {
     2.6          pEp_identity *from;
     2.7 -        char *signature_fpr;
     2.8          stringlist_t *own_keys;
     2.9          identity_list *own_identities;
    2.10 +
    2.11 +        // transport data
    2.12 +        char *signature_fpr;
    2.13      } common;
    2.14  
    2.15      `` apply "fsm", mode=state
    2.16 @@ -51,6 +53,9 @@
    2.17  
    2.18  struct own_«@name»_state_s {
    2.19      `` for "func:distinctName(fsm/message/field[@type='TID'])" |> «func:ctype()» «@name»;
    2.20 +
    2.21 +    // transport data
    2.22 +    char *signature_fpr;
    2.23  };
    2.24  
    2.25  void free_«@name»_state(PEP_SESSION session);