key of comm partner sync
authorVolker Birk <vb@pep-project.org>
Fri, 25 Oct 2019 11:07:46 +0200
branchsync
changeset 4132bf7b5f139996
parent 4130 a4174e1e7199
child 4133 ff662df0bb63
key of comm partner
src/pgp_sequoia.c
sync/cond_act_sync.yml2
sync/sync.fsm
     1.1 --- a/src/pgp_sequoia.c	Thu Oct 24 23:38:46 2019 +0200
     1.2 +++ b/src/pgp_sequoia.c	Fri Oct 25 11:07:46 2019 +0200
     1.3 @@ -15,6 +15,8 @@
     1.4  
     1.5  #include "wrappers.h"
     1.6  
     1.7 +// #define SEQUOIA_DB_TRACING
     1.8 +
     1.9  #define TRACING 0
    1.10  #ifndef TRACING
    1.11  #  ifndef NDEBUG
    1.12 @@ -24,9 +26,6 @@
    1.13  #  endif
    1.14  #endif
    1.15  
    1.16 -#define fprintf _ignore_
    1.17 -void _ignore_(FILE *f, ...) { }
    1.18 -
    1.19  // enable tracing if in debugging mode
    1.20  #if TRACING
    1.21  #include "status_to_string.h"
    1.22 @@ -96,7 +95,7 @@
    1.23      }                                                               \
    1.24  } while(0)
    1.25  
    1.26 -#if 1
    1.27 +#ifdef SEQUOIA_DB_TRACING
    1.28  int sq_sql_trace_callback (unsigned trace_constant, 
    1.29                          void* context_ptr,
    1.30                          void* P,
    1.31 @@ -267,7 +266,7 @@
    1.32      free(path);
    1.33  #endif
    1.34  
    1.35 -#if 1      
    1.36 +#ifdef SEQUOIA_DB_TRACING
    1.37      sqlite3_trace_v2(session->key_db, 
    1.38          SQLITE_TRACE_STMT | SQLITE_TRACE_ROW | SQLITE_TRACE_CLOSE,
    1.39          sq_sql_trace_callback,
     2.1 --- a/sync/cond_act_sync.yml2	Thu Oct 24 23:38:46 2019 +0200
     2.2 +++ b/sync/cond_act_sync.yml2	Fri Oct 25 11:07:46 2019 +0200
     2.3 @@ -480,6 +480,31 @@
     2.4      free(user_id);
     2.5  ||
     2.6  
     2.7 +action useThisKey
     2.8 +||
     2.9 +    assert(session->sync_state.comm_partner.sender_fpr);
    2.10 +    if (!session->sync_state.comm_partner.sender_fpr)
    2.11 +        return PEP_ILLEGAL_VALUE;
    2.12 +
    2.13 +    const char *fpr = session->sync_state.comm_partner.sender_fpr;
    2.14 +    OCTET_STRING_fromBuf(&session->sync_state.keysync.key, fpr, strlen(fpr));
    2.15 +||
    2.16 +
    2.17 +action storeThisKey
    2.18 +||
    2.19 +    assert(session->sync_state.keysync.key.buf && session->sync_state.keysync.key.size);
    2.20 +    if (!(session->sync_state.keysync.key.buf && session->sync_state.keysync.key.size))
    2.21 +        return PEP_ILLEGAL_VALUE;
    2.22 +
    2.23 +    char *fpr = strndup(session->sync_state.keysync.key.buf, session->sync_state.keysync.key.size);
    2.24 +    assert(fpr);
    2.25 +    if (!fpr)
    2.26 +        return PEP_OUT_OF_MEMORY;
    2.27 +
    2.28 +    free(session->sync_state.comm_partner.sender_fpr);
    2.29 +    session->sync_state.comm_partner.sender_fpr = fpr;
    2.30 +||
    2.31 +
    2.32  action trustThisKey
    2.33  ||
    2.34      assert(session->sync_state.transport.from && session->sync_state.comm_partner.sender_fpr);
     3.1 --- a/sync/sync.fsm	Thu Oct 24 23:38:46 2019 +0200
     3.2 +++ b/sync/sync.fsm	Fri Oct 25 11:07:46 2019 +0200
     3.3 @@ -303,17 +303,17 @@
     3.4  
     3.5              on NegotiationOpen if sameNegotiationAndPartner {
     3.6                  do storeNegotiation;
     3.7 +                do useThisKey;
     3.8                  send GroupHandshake;
     3.9                  go HandshakingGrouped;
    3.10              }
    3.11 -
    3.12  /*
    3.13              on GroupHandshake {
    3.14 +                do storeThisKey;
    3.15                  do storeNegotiation;
    3.16                  go HandshakingGrouped;
    3.17              }
    3.18  */
    3.19 -
    3.20              on GroupTrustThisKey
    3.21                  do trustThisKey;
    3.22          }
    3.23 @@ -562,6 +562,7 @@
    3.24  
    3.25          message GroupHandshake 16 {
    3.26              field TID negotiation;
    3.27 +            field Hash key;
    3.28          }
    3.29      }
    3.30  }