get own keys sync
authorVolker Birk <vb@pep-project.org>
Mon, 25 Mar 2019 11:52:50 +0100
branchsync
changeset 3390a0204afa04e3
parent 3389 d5d388d3b227
child 3391 35926ed4974e
get own keys
sync/cond_act_sync.yml2
sync/gen_message_func.ysl2
sync/sync.fsm
     1.1 --- a/sync/cond_act_sync.yml2	Mon Mar 25 11:33:52 2019 +0100
     1.2 +++ b/sync/cond_act_sync.yml2	Mon Mar 25 11:52:50 2019 +0100
     1.3 @@ -166,9 +166,21 @@
     1.4  timeout KeySync
     1.5      call "show_handshake" with "type" > SYNC_NOTIFY_TIMEOUT
     1.6  
     1.7 +action prepareOwnKeys
     1.8 +||
     1.9 +    stringlist_t *own_keys;
    1.10 +    PEP_STATUS status = _own_keys_retrieve(session, &own_keys, PEP_idf_not_for_sync);
    1.11 +    if (status)
    1.12 +        return status;
    1.13 +
    1.14 +    if (session->sync_state.common.own_keys)
    1.15 +        free_stringlist(session->sync_state.common.own_keys);
    1.16 +    session->sync_state.common.own_keys = own_keys;
    1.17 +||
    1.18 +
    1.19  action saveGroupKeys
    1.20  ||
    1.21 -    identity_list *il = IdentityList_to_identity_list(&session->sync_state.keysync.identities, NULL);
    1.22 +    identity_list *il = IdentityList_to_identity_list(&session->sync_state.keysync.ownIdentities, NULL);
    1.23      if (!il)
    1.24          return PEP_OUT_OF_MEMORY;
    1.25      
    1.26 @@ -254,7 +266,7 @@
    1.27              }
    1.28          } while (result != SQLITE_DONE);
    1.29  
    1.30 -        IdentityList_t *r = IdentityList_from_identity_list(il, &session->sync_state.keysync.identities);
    1.31 +        IdentityList_t *r = IdentityList_from_identity_list(il, &session->sync_state.keysync.ownIdentities);
    1.32          free_identity_list(il);
    1.33          if (!r)
    1.34              return PEP_OUT_OF_MEMORY;
     2.1 --- a/sync/gen_message_func.ysl2	Mon Mar 25 11:33:52 2019 +0100
     2.2 +++ b/sync/gen_message_func.ysl2	Mon Mar 25 11:52:50 2019 +0100
     2.3 @@ -42,6 +42,7 @@
     2.4      struct common_state_s {
     2.5          pEp_identity *from;
     2.6          char *signature_fpr;
     2.7 +        stringlist_t *own_keys;
     2.8      } common;
     2.9  
    2.10      `` apply "fsm", mode=state
     3.1 --- a/sync/sync.fsm	Mon Mar 25 11:33:52 2019 +0100
     3.2 +++ b/sync/sync.fsm	Mon Mar 25 11:52:50 2019 +0100
     3.3 @@ -128,8 +128,10 @@
     3.4          }
     3.5  
     3.6          state NewGroup {
     3.7 -            on Init
     3.8 +            on Init {
     3.9 +                do prepareOwnKeys;
    3.10                  send GroupKeysAndClose; // we're not grouped yet, this is our own keys
    3.11 +            }
    3.12  
    3.13              on GroupKeysAndClose {
    3.14                  do saveGroupKeys;
    3.15 @@ -336,11 +338,11 @@
    3.16  
    3.17          message GroupKeysAndClose 8 {
    3.18              field TID transaction;
    3.19 -            field IdentityList identities;
    3.20 +            field IdentityList ownIdentities;
    3.21          }
    3.22  
    3.23          message GroupKeys 9 {
    3.24 -            field IdentityList identities;
    3.25 +            field IdentityList ownIdentities;
    3.26          }
    3.27      }
    3.28  }