this is communication partner's state sync
authorVolker Birk <vb@pep-project.org>
Wed, 29 May 2019 16:11:32 +0200
branchsync
changeset 376711a9d0f61073
parent 3765 6e0ded701a54
child 3768 7fc561191d28
this is communication partner's state
sync/cond_act_sync.yml2
sync/gen_message_func.ysl2
sync/gen_statemachine.ysl2
     1.1 --- a/sync/cond_act_sync.yml2	Wed May 29 11:37:44 2019 +0200
     1.2 +++ b/sync/cond_act_sync.yml2	Wed May 29 16:11:32 2019 +0200
     1.3 @@ -59,7 +59,7 @@
     1.4      TID_t *t1 = &session->sync_state.keysync.negotiation;
     1.5      TID_t *t2 = &session->own_sync_state.negotiation;
     1.6  
     1.7 -    const char *s1 = session->sync_state.common.signature_fpr;
     1.8 +    const char *s1 = session->sync_state.comm_partner.signature_fpr;
     1.9      const char *s2 = session->own_sync_state.signature_fpr;
    1.10  
    1.11      // test if TID is identical
    1.12 @@ -70,8 +70,8 @@
    1.13  
    1.14  condition keyElectionWon
    1.15  ||
    1.16 -    pEp_identity *from = session->sync_state.common.from;
    1.17 -    char *signature_fpr = session->sync_state.common.signature_fpr;
    1.18 +    pEp_identity *from = session->sync_state.comm_partner.from;
    1.19 +    char *signature_fpr = session->sync_state.comm_partner.signature_fpr;
    1.20  
    1.21      assert(from && from->address && from->address[0] && from->user_id &&
    1.22              from->user_id[0]);
    1.23 @@ -147,7 +147,7 @@
    1.24      // store a copy of this challenge
    1.25      call "copy_UUID" {
    1.26          with "src" > &session->own_sync_state.challenge
    1.27 -        with "dst" > &session->sync_state.common.challenge
    1.28 +        with "dst" > &session->sync_state.comm_partner.challenge
    1.29      }
    1.30  }
    1.31  
    1.32 @@ -157,17 +157,17 @@
    1.33  }
    1.34  
    1.35  action useOwnChallenge call "copy_UUID" {
    1.36 -    with "src" > &session->sync_state.common.challenge
    1.37 +    with "src" > &session->sync_state.comm_partner.challenge
    1.38      with "dst" > &session->own_sync_state.challenge
    1.39  }
    1.40  
    1.41  action newTransaction {
    1.42  ||
    1.43      // sender key must be stable while transaction
    1.44 -    assert(session->sync_state.common.signature_fpr);
    1.45 +    assert(session->sync_state.comm_partner.signature_fpr);
    1.46      free(session->own_sync_state.signature_fpr);
    1.47      session->own_sync_state.signature_fpr
    1.48 -            = strdup(session->sync_state.common.signature_fpr);
    1.49 +            = strdup(session->sync_state.comm_partner.signature_fpr);
    1.50      assert(session->own_sync_state.signature_fpr);
    1.51      if (!session->own_sync_state.signature_fpr)
    1.52          return PEP_OUT_OF_MEMORY;
    1.53 @@ -198,10 +198,10 @@
    1.54  action storeTransaction {
    1.55  ||
    1.56      // sender key must be stable while transaction
    1.57 -    assert(session->sync_state.common.signature_fpr);
    1.58 +    assert(session->sync_state.comm_partner.signature_fpr);
    1.59      free(session->own_sync_state.signature_fpr);
    1.60      session->own_sync_state.signature_fpr
    1.61 -            = strdup(session->sync_state.common.signature_fpr);
    1.62 +            = strdup(session->sync_state.comm_partner.signature_fpr);
    1.63      assert(session->own_sync_state.signature_fpr);
    1.64      if (!session->own_sync_state.signature_fpr)
    1.65          return PEP_OUT_OF_MEMORY;
    1.66 @@ -239,11 +239,11 @@
    1.67      ||
    1.68      otherwise
    1.69      ||
    1.70 -        assert(session->sync_state.common.from);
    1.71 -        if (!session->sync_state.common.from)
    1.72 +        assert(session->sync_state.comm_partner.from);
    1.73 +        if (!session->sync_state.comm_partner.from)
    1.74              return PEP_ILLEGAL_VALUE;
    1.75  
    1.76 -        pEp_identity *from = session->sync_state.common.from;
    1.77 +        pEp_identity *from = session->sync_state.comm_partner.from;
    1.78          pEp_identity *me = NULL;
    1.79          PEP_STATUS status = get_identity(session, from->address, from->user_id, &me);
    1.80          assert(status == PEP_STATUS_OK);
    1.81 @@ -262,10 +262,10 @@
    1.82              return PEP_OUT_OF_MEMORY;
    1.83          }
    1.84  
    1.85 -        assert(session->sync_state.common.signature_fpr);
    1.86 -        if (session->sync_state.common.signature_fpr) {
    1.87 +        assert(session->sync_state.comm_partner.signature_fpr);
    1.88 +        if (session->sync_state.comm_partner.signature_fpr) {
    1.89              free(partner->fpr);
    1.90 -            partner->fpr = strdup(session->sync_state.common.signature_fpr);
    1.91 +            partner->fpr = strdup(session->sync_state.comm_partner.signature_fpr);
    1.92              if (!partner->fpr) {
    1.93                  free_identity(me);
    1.94                  free_identity(partner);
    1.95 @@ -388,7 +388,7 @@
    1.96      for (il = session->own_sync_state.own_identities; il && il->ident ; il = il->next) {
    1.97          // replace partner's user_id with own user_id
    1.98          free(il->ident->user_id);
    1.99 -        il->ident->user_id = strdup(session->sync_state.common.from->user_id);
   1.100 +        il->ident->user_id = strdup(session->sync_state.comm_partner.from->user_id);
   1.101          if (!il->ident->user_id) {
   1.102              free_identity_list(il);
   1.103              return PEP_OUT_OF_MEMORY;
   1.104 @@ -412,15 +412,15 @@
   1.105  
   1.106  action trustThisKey
   1.107  ||
   1.108 -    assert(session->sync_state.common.from && session->sync_state.common.signature_fpr);
   1.109 -    if (!(session->sync_state.common.from && session->sync_state.common.signature_fpr))
   1.110 +    assert(session->sync_state.comm_partner.from && session->sync_state.comm_partner.signature_fpr);
   1.111 +    if (!(session->sync_state.comm_partner.from && session->sync_state.comm_partner.signature_fpr))
   1.112          return PEP_ILLEGAL_VALUE;
   1.113  
   1.114 -    pEp_identity *ident = identity_dup(session->sync_state.common.from);
   1.115 +    pEp_identity *ident = identity_dup(session->sync_state.comm_partner.from);
   1.116      if (!ident)
   1.117          return PEP_OUT_OF_MEMORY;
   1.118      free(ident->fpr);
   1.119 -    ident->fpr = strdup(session->sync_state.common.signature_fpr);
   1.120 +    ident->fpr = strdup(session->sync_state.comm_partner.signature_fpr);
   1.121      assert(ident->fpr);
   1.122      if (!ident->fpr) {
   1.123          free_identity(ident);
   1.124 @@ -439,13 +439,13 @@
   1.125  
   1.126  action untrustThisKey
   1.127  ||
   1.128 -    assert(session->sync_state.common.from && session->sync_state.common.signature_fpr);
   1.129 -    if (!(session->sync_state.common.from && session->sync_state.common.signature_fpr))
   1.130 +    assert(session->sync_state.comm_partner.from && session->sync_state.comm_partner.signature_fpr);
   1.131 +    if (!(session->sync_state.comm_partner.from && session->sync_state.comm_partner.signature_fpr))
   1.132          return PEP_ILLEGAL_VALUE;
   1.133  
   1.134 -    pEp_identity *ident = session->sync_state.common.from;
   1.135 +    pEp_identity *ident = session->sync_state.comm_partner.from;
   1.136      free(ident->fpr);
   1.137 -    ident->fpr = strdup(session->sync_state.common.signature_fpr);
   1.138 +    ident->fpr = strdup(session->sync_state.comm_partner.signature_fpr);
   1.139      assert(ident->fpr);
   1.140      if (!ident->fpr)
   1.141          return PEP_OUT_OF_MEMORY;
     2.1 --- a/sync/gen_message_func.ysl2	Wed May 29 11:37:44 2019 +0200
     2.2 +++ b/sync/gen_message_func.ysl2	Wed May 29 16:11:32 2019 +0200
     2.3 @@ -39,16 +39,16 @@
     2.4  // state
     2.5  
     2.6  struct «@name»_state_s {
     2.7 -    // common buffer for all types of «@name» messages
     2.8 +    // state about our communication partner
     2.9  
    2.10 -    struct common_state_s {
    2.11 +    struct comm_partner_state_s {
    2.12          // intermediate store own challenge
    2.13          TID_t challenge;
    2.14  
    2.15          // transport data
    2.16          pEp_identity *from;
    2.17          char *signature_fpr;
    2.18 -    } common;
    2.19 +    } comm_partner;
    2.20      `` apply "fsm", mode=state
    2.21  };
    2.22  
    2.23 @@ -113,8 +113,8 @@
    2.24      if (!session)
    2.25          return;
    2.26  
    2.27 -    free_identity(session->«yml:lcase(@name)»_state.common.from);
    2.28 -    free(session->«yml:lcase(@name)»_state.common.signature_fpr);
    2.29 +    free_identity(session->«yml:lcase(@name)»_state.comm_partner.from);
    2.30 +    free(session->«yml:lcase(@name)»_state.comm_partner.signature_fpr);
    2.31      free_stringlist(session->own_«yml:lcase(@name)»_state.own_keys);
    2.32      free_identity_list(session->own_«yml:lcase(@name)»_state.own_identities);
    2.33      session->own_«yml:lcase(@name)»_state.own_keys = NULL;
     3.1 --- a/sync/gen_statemachine.ysl2	Wed May 29 11:37:44 2019 +0200
     3.2 +++ b/sync/gen_statemachine.ysl2	Wed May 29 16:11:32 2019 +0200
     3.3 @@ -447,8 +447,8 @@
     3.4  
     3.5                      // these go anycast; previously used address is sticky (unicast)
     3.6                      `` for "fsm/message[@type='anycast']" |>> case «../@name»_PR_«yml:mixedCase(@name)»:
     3.7 -                        if (!session->«yml:lcase(@name)»_state.common.from `> |`|
     3.8 -                            (session->«yml:lcase(@name)»_state.common.from->flags &
     3.9 +                        if (!session->«yml:lcase(@name)»_state.comm_partner.from `> |`|
    3.10 +                            (session->«yml:lcase(@name)»_state.comm_partner.from->flags &
    3.11                              PEP_idf_not_for_«yml:lcase(@name)»)) {
    3.12  
    3.13                              // no address available yet, try to find one
    3.14 @@ -468,7 +468,7 @@
    3.15                              }
    3.16                          }
    3.17                          else {
    3.18 -                            pEp_identity *channel = identity_dup(session->«yml:lcase(@name)»_state.common.from);
    3.19 +                            pEp_identity *channel = identity_dup(session->«yml:lcase(@name)»_state.comm_partner.from);
    3.20                              if (!channel) {
    3.21                                  status = PEP_OUT_OF_MEMORY;
    3.22                                  goto the_end;
    3.23 @@ -521,13 +521,13 @@
    3.24                      `` for "fsm/message[@security='untrusted']" |>>> case «../@name»_PR_«yml:mixedCase(@name)»:
    3.25                              // add fpr of key of comm partner
    3.26  
    3.27 -                            assert(session->«yml:lcase(@name)»_state.common.signature_fpr);
    3.28 -                            if (!session->«yml:lcase(@name)»_state.common.signature_fpr) {
    3.29 +                            assert(session->«yml:lcase(@name)»_state.comm_partner.signature_fpr);
    3.30 +                            if (!session->«yml:lcase(@name)»_state.comm_partner.signature_fpr) {
    3.31                                  status = PEP_«yml:ucase(@name)»_CANNOT_ENCRYPT;
    3.32                                  goto the_end;
    3.33                              }
    3.34  
    3.35 -                            extra = new_stringlist(session->«yml:lcase(@name)»_state.common.signature_fpr);
    3.36 +                            extra = new_stringlist(session->«yml:lcase(@name)»_state.comm_partner.signature_fpr);
    3.37                              if (!extra) {
    3.38                                  status = PEP_OUT_OF_MEMORY;
    3.39                                  goto the_end;
    3.40 @@ -574,11 +574,11 @@
    3.41  
    3.42                              if (transaction) {
    3.43                                  assert(session->own_«yml:lcase(@name)»_state.signature_fpr &&
    3.44 -                                    session->«yml:lcase(@name)»_state.common.from &&
    3.45 -                                    session->«yml:lcase(@name)»_state.common.from->user_id);
    3.46 +                                    session->«yml:lcase(@name)»_state.comm_partner.from &&
    3.47 +                                    session->«yml:lcase(@name)»_state.comm_partner.from->user_id);
    3.48                                  if (!(session->own_«yml:lcase(@name)»_state.signature_fpr &&
    3.49 -                                        session->«yml:lcase(@name)»_state.common.from &&
    3.50 -                                        session->«yml:lcase(@name)»_state.common.from->user_id))
    3.51 +                                        session->«yml:lcase(@name)»_state.comm_partner.from &&
    3.52 +                                        session->«yml:lcase(@name)»_state.comm_partner.from->user_id))
    3.53                                  {
    3.54                                      status = PEP_«yml:ucase(@name)»_CANNOT_ENCRYPT;
    3.55                                      goto the_end;
    3.56 @@ -588,7 +588,7 @@
    3.57  
    3.58                                  pEp_identity *ident = new_identity(NULL,
    3.59                                          session->own_«yml:lcase(@name)»_state.signature_fpr,
    3.60 -                                        session->«yml:lcase(@name)»_state.common.from->user_id,
    3.61 +                                        session->«yml:lcase(@name)»_state.comm_partner.from->user_id,
    3.62                                          NULL
    3.63                                      );
    3.64                                  if (!ident) {
    3.65 @@ -808,14 +808,14 @@
    3.66                  // update transport data
    3.67  
    3.68                  if (ev->from) {
    3.69 -                    free_identity(session->«yml:lcase(@name)»_state.common.from);
    3.70 -                    session->«yml:lcase(@name)»_state.common.from = ev->from;
    3.71 +                    free_identity(session->«yml:lcase(@name)»_state.comm_partner.from);
    3.72 +                    session->«yml:lcase(@name)»_state.comm_partner.from = ev->from;
    3.73                      ev->from = NULL;
    3.74                  }
    3.75  
    3.76                  if (ev->signature_fpr) {
    3.77 -                    free(session->«yml:lcase(@name)»_state.common.signature_fpr);
    3.78 -                    session->«yml:lcase(@name)»_state.common.signature_fpr = ev->signature_fpr;
    3.79 +                    free(session->«yml:lcase(@name)»_state.comm_partner.signature_fpr);
    3.80 +                    session->«yml:lcase(@name)»_state.comm_partner.signature_fpr = ev->signature_fpr;
    3.81                      ev->signature_fpr = NULL;
    3.82                  }
    3.83