merge sync
authorKrista 'DarthMama' Bennett <krista@pep.foundation>
Tue, 28 May 2019 15:54:22 +0200
branchsync
changeset 3752856412ae847e
parent 3751 c40e8cffdb1d
parent 3747 82fe58af7b53
child 3753 7eabcd28a967
merge
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/build-android/enable_address_sanitizer.patch	Tue May 28 15:54:22 2019 +0200
     1.3 @@ -0,0 +1,92 @@
     1.4 +diff --git a/build-android/jni/Android.mk b/build-android/jni/Android.mk
     1.5 +--- a/build-android/jni/Android.mk
     1.6 ++++ b/build-android/jni/Android.mk
     1.7 +@@ -14,7 +14,9 @@
     1.8 + 
     1.9 + LOCAL_MODULE    := pEpEngine
    1.10 + LOCAL_CFLAGS    += -std=c99
    1.11 +-
    1.12 ++#LOCAL_CFLAGS    += -fsanitize=address -fno-omit-frame-pointer
    1.13 ++#LOCAL_LDFLAGS   += -fsanitize=address
    1.14 ++#LOCAL_ARM_MODE := arm
    1.15 + # from http://www.sqlite.org/android/finfo?name=jni/sqlite/Android.mk 
    1.16 + #      http://www.sqlite.org/android/artifact/e8ed354b3e58c835
    1.17 + 
    1.18 +@@ -28,6 +30,7 @@
    1.19 +                     $(GPGME_INCLUDE_PATH) \
    1.20 +                     $(LIBETPAN_PATH)/include
    1.21 + LOCAL_C_INCLUDES += $(GPGBUILD)/$(TARGET_ARCH_ABI)/app_opt/include
    1.22 ++LOCAL_C_INCLUDES += /home/huss/src/test/sequoia/openpgp-ffi/include
    1.23 + 
    1.24 + $(shell sh $(LOCAL_PATH)/../takeOutHeaderFiles.sh $(LOCAL_PATH)../../)
    1.25 + LOCAL_EXPORT_C_INCLUDES += $(LOCAL_PATH)../include
    1.26 +@@ -38,5 +41,6 @@
    1.27 + ASN1_SRC_FILES := $(wildcard $(LOCAL_PATH)/../../asn.1/*.c)
    1.28 + LOCAL_SRC_FILES := $(ENGINE_SRC_FILES:%=%)  $(ASN1_SRC_FILES:$(LOCAL_PATH)/%=%)
    1.29 + 
    1.30 ++#LOCAL_ADDRESS_SANITIZER:=true
    1.31 + 
    1.32 + include $(BUILD_STATIC_LIBRARY)
    1.33 +diff --git a/src/pEpEngine.c b/src/pEpEngine.c
    1.34 +--- a/src/pEpEngine.c
    1.35 ++++ b/src/pEpEngine.c
    1.36 +@@ -2015,7 +2015,7 @@
    1.37 + // N.B. If testing (so NDEBUG not defined) but this message is spam,
    1.38 + //      put -D_PEP_SERVICE_LOG_OFF into CFLAGS/CXXFLAGS     
    1.39 + #if !defined(NDEBUG) && !defined(_PEP_SERVICE_LOG_OFF)
    1.40 +-    fprintf(stdout, "\n*** %s %s %s %s\n", title, entity, description, comment);
    1.41 ++    __android_log_print(ANDROID_LOG_DEBUG, "pEpEngine", " %s :: %s :: %s :: %s ", title, entity, description, comment);
    1.42 +     session->service_log = true;
    1.43 + #endif
    1.44 + 
    1.45 +diff --git a/sync/gen_dot.ysl2 b/sync/gen_dot.ysl2
    1.46 +--- a/sync/gen_dot.ysl2
    1.47 ++++ b/sync/gen_dot.ysl2
    1.48 +@@ -9,7 +9,7 @@
    1.49 +     digraph finite_state_machine {
    1.50 +         rankdir=LR;
    1.51 +         node [shape = doublecircle];
    1.52 +-        `apply "state[@end='1']" mode=end`;
    1.53 ++        `apply "state[@timeout='off']" mode=end`;
    1.54 +         node [shape = circle];
    1.55 + 
    1.56 +         `` apply "state" mode=do
    1.57 +diff --git a/sync/sync.fsm b/sync/sync.fsm
    1.58 +--- a/sync/sync.fsm
    1.59 ++++ b/sync/sync.fsm
    1.60 +@@ -155,7 +155,7 @@
    1.61 +                 go HandshakingNewPhase2Second;
    1.62 +         }
    1.63 + 
    1.64 +-        state HandshakingNewPhase1First {
    1.65 ++        state HandshakingNewPhase1First timeout=300 {
    1.66 +             on Rollback if sameTransactionAndPartner {
    1.67 +                 do untrustThisKey;
    1.68 +                 go Sole;
    1.69 +@@ -172,7 +172,7 @@
    1.70 +             }
    1.71 +         }
    1.72 + 
    1.73 +-        state HandshakingNewPhase1Second {
    1.74 ++        state HandshakingNewPhase1Second timeout=300 {
    1.75 +             on Rollback if sameTransactionAndPartner {
    1.76 +                 do untrustThisKey;
    1.77 +                 go Sole;
    1.78 +@@ -189,7 +189,7 @@
    1.79 +             }
    1.80 +         }
    1.81 + 
    1.82 +-        state HandshakingNewPhase2First {
    1.83 ++        state HandshakingNewPhase2First timeout=300 {
    1.84 +             on Cancel {
    1.85 +                 send Rollback;
    1.86 +                 go Sole;
    1.87 +@@ -208,7 +208,7 @@
    1.88 +             }
    1.89 +         }
    1.90 + 
    1.91 +-        state HandshakingNewPhase2Second {
    1.92 ++        state HandshakingNewPhase2Second timeout=300 {
    1.93 +             on Cancel {
    1.94 +                 send Rollback;
    1.95 +                 go Sole;
     2.1 --- a/build-android/jni/Android.mk	Tue May 28 15:53:52 2019 +0200
     2.2 +++ b/build-android/jni/Android.mk	Tue May 28 15:54:22 2019 +0200
     2.3 @@ -5,7 +5,6 @@
     2.4  LOCAL_PATH := $(call my-dir)
     2.5  
     2.6  LIBETPAN_PATH:=  $(LOCAL_PATH)/../../../pEpJNIAdapter/android/external/libetpan/build-android
     2.7 -GPGME_INCLUDE_PATH:=  $(LOCAL_PATH)/../../../pEpJNIAdapter/android/external/data/data/pep.android.k9/app_opt/include
     2.8  
     2.9  include $(CLEAR_VARS)
    2.10  
    2.11 @@ -13,10 +12,6 @@
    2.12  $(error LIBETPAN_PATH must be set)
    2.13  endif
    2.14  
    2.15 -ifeq ($(GPGME_INCLUDE_PATH),)
    2.16 -$(error GPGME_INCLUDE_PATH must be set)
    2.17 -endif
    2.18 -
    2.19  LOCAL_MODULE    := pEpEngine
    2.20  LOCAL_CFLAGS    += -std=c99
    2.21  
    2.22 @@ -27,17 +22,18 @@
    2.23  # Android has no globally writable temp directory, if this is not defined the
    2.24  # application throws an exception when it tries to create a temp file.
    2.25  #
    2.26 -LOCAL_CFLAGS    += -DSQLITE_TEMP_STORE=3
    2.27 +LOCAL_CFLAGS    += -DSQLITE_TEMP_STORE=3 -DUSE_SEQUOIA
    2.28  
    2.29  LOCAL_C_INCLUDES += $(LOCAL_PATH)/../../asn.1 \
    2.30                      $(GPGME_INCLUDE_PATH) \
    2.31                      $(LIBETPAN_PATH)/include
    2.32 -LOCAL_C_INCLUDES += $(GPGBUILD)/include
    2.33 +LOCAL_C_INCLUDES += $(GPGBUILD)/$(TARGET_ARCH_ABI)/app_opt/include
    2.34  
    2.35  $(shell sh $(LOCAL_PATH)/../takeOutHeaderFiles.sh $(LOCAL_PATH)../../)
    2.36  LOCAL_EXPORT_C_INCLUDES += $(LOCAL_PATH)../include
    2.37  
    2.38 -ENGINE_SRC_FILES := $(shell find $(LOCAL_PATH)/../../src/ ! -name "*sequoia*" ! -name "*netpgp*" -name "*.c")
    2.39 +#ENGINE_SRC_FILES := $(shell find $(LOCAL_PATH)/../../src/ ! -name "*sequoia*" ! -name "*netpgp*" -name "*.c")
    2.40 +ENGINE_SRC_FILES := $(shell find $(LOCAL_PATH)/../../src/ ! -name "*gpg*" ! -name "*netpgp*" -name "*.c")
    2.41  #ENGINE_SRC_FILES := $(wildcard $(LOCAL_PATH)/../../src/*.c)
    2.42  ASN1_SRC_FILES := $(wildcard $(LOCAL_PATH)/../../asn.1/*.c)
    2.43  LOCAL_SRC_FILES := $(ENGINE_SRC_FILES:%=%)  $(ASN1_SRC_FILES:$(LOCAL_PATH)/%=%)
     3.1 --- a/build-android/jni/Application.mk	Tue May 28 15:53:52 2019 +0200
     3.2 +++ b/build-android/jni/Application.mk	Tue May 28 15:54:22 2019 +0200
     3.3 @@ -1,4 +1,4 @@
     3.4  APP_OPTIM := debug
     3.5  APP_PLATFORM=android-21
     3.6 -APP_ABI := armeabi-v7a
     3.7 +APP_ABI := arm64-v8a
     3.8  NDK_TOOLCHAIN_VERSION = clang
     4.1 --- a/src/message_api.c	Tue May 28 15:53:52 2019 +0200
     4.2 +++ b/src/message_api.c	Tue May 28 15:54:22 2019 +0200
     4.3 @@ -4207,7 +4207,7 @@
     4.4      return num_to_asciihex(xor_num);
     4.5  }
     4.6  
     4.7 -static char* skip_separators(char* current, char* begin) {
     4.8 +static const char* skip_separators(const char* current, const char* begin) {
     4.9      while (current >= begin) {
    4.10          /* .:,;-_ ' ' - [2c-2e] [3a-3b] [20] [5f] */
    4.11          char check_char = *current;
    4.12 @@ -4245,71 +4245,73 @@
    4.13  }
    4.14  
    4.15  DYNAMIC_API PEP_STATUS get_trustwords(
    4.16 -    PEP_SESSION session, const pEp_identity* id1, const pEp_identity* id2,
    4.17 -    const char* lang, char **words, size_t *wsize, bool full
    4.18 -)
    4.19 +        PEP_SESSION session, const pEp_identity* id1, const pEp_identity* id2,
    4.20 +        const char* lang, char **words, size_t *wsize, bool full
    4.21 +    )
    4.22  {
    4.23 -    assert(session);
    4.24 -    assert(id1);
    4.25 -    assert(id2);
    4.26 -    assert(id1->fpr);
    4.27 -    assert(id2->fpr);
    4.28 -    assert(words);
    4.29 -    assert(wsize);
    4.30 -
    4.31 -    int SHORT_NUM_TWORDS = 5; 
    4.32 -    
    4.33 +    assert(session && id1 && id1->fpr && id2 && id2->fpr&& lang && words &&
    4.34 +            wsize);
    4.35 +    if (!(session && id1 && id1->fpr && id2 && id2->fpr&& lang && words &&
    4.36 +                wsize))
    4.37 +        return PEP_ILLEGAL_VALUE;
    4.38 +
    4.39 +    return get_trustwords_for_fprs(session, id1->fpr, id2->fpr, lang, words,
    4.40 +            wsize, full);
    4.41 +}
    4.42 +
    4.43 +DYNAMIC_API PEP_STATUS get_trustwords_for_fprs(
    4.44 +        PEP_SESSION session, const char* fpr1, const char* fpr2,
    4.45 +        const char* lang, char **words, size_t *wsize, bool full
    4.46 +    )
    4.47 +{
    4.48 +    assert(session && fpr1 && fpr2 && words && wsize);
    4.49 +    if (!(session && fpr1 && fpr2 && words && wsize))
    4.50 +        return PEP_ILLEGAL_VALUE;
    4.51 +
    4.52 +    const int SHORT_NUM_TWORDS = 5; 
    4.53      PEP_STATUS status = PEP_STATUS_OK;
    4.54      
    4.55 -    if (!(session && id1 && id2 && words && wsize) ||
    4.56 -        !(id1->fpr) || (!id2->fpr))
    4.57 -        return PEP_ILLEGAL_VALUE;
    4.58 -
    4.59 -    char *source1 = id1->fpr;
    4.60 -    char *source2 = id2->fpr;
    4.61 -
    4.62 -    int source1_len = strlen(source1);
    4.63 -    int source2_len = strlen(source2);
    4.64 -    int max_len;
    4.65 -        
    4.66      *words = NULL;    
    4.67      *wsize = 0;
    4.68  
    4.69 -    max_len = (source1_len > source2_len ? source1_len : source2_len);
    4.70 +    int fpr1_len = strlen(fpr1);
    4.71 +    int fpr2_len = strlen(fpr2);
    4.72 +        
    4.73 +    int max_len = (fpr1_len > fpr2_len ? fpr1_len : fpr2_len);
    4.74      
    4.75      char* XORed_fpr = (char*)(calloc(max_len + 1, 1));
    4.76      *(XORed_fpr + max_len) = '\0';
    4.77      char* result_curr = XORed_fpr + max_len - 1;
    4.78 -    char* source1_curr = source1 + source1_len - 1;
    4.79 -    char* source2_curr = source2 + source2_len - 1;
    4.80 -
    4.81 -    while (source1 <= source1_curr && source2 <= source2_curr) {
    4.82 -        source1_curr = skip_separators(source1_curr, source1);
    4.83 -        source2_curr = skip_separators(source2_curr, source2);
    4.84 +    const char* fpr1_curr = fpr1 + fpr1_len - 1;
    4.85 +    const char* fpr2_curr = fpr2 + fpr2_len - 1;
    4.86 +
    4.87 +    while (fpr1 <= fpr1_curr && fpr2 <= fpr2_curr) {
    4.88 +        fpr1_curr = skip_separators(fpr1_curr, fpr1);
    4.89 +        fpr2_curr = skip_separators(fpr2_curr, fpr2);
    4.90          
    4.91 -        if (source1_curr < source1 || source2_curr < source2)
    4.92 +        if (fpr1_curr < fpr1 || fpr2_curr < fpr2)
    4.93              break;
    4.94              
    4.95 -        char xor_hex = xor_hex_chars(*source1_curr, *source2_curr);
    4.96 +        char xor_hex = xor_hex_chars(*fpr1_curr, *fpr2_curr);
    4.97          if (xor_hex == '\0') {
    4.98              status = PEP_ILLEGAL_VALUE;
    4.99              goto error_release;
   4.100          }
   4.101          
   4.102          *result_curr = xor_hex;
   4.103 -        result_curr--; source1_curr--; source2_curr--;
   4.104 +        result_curr--; fpr1_curr--; fpr2_curr--;
   4.105      }
   4.106  
   4.107 -    char* remainder_start = NULL;
   4.108 -    char* remainder_curr = NULL;
   4.109 +    const char* remainder_start = NULL;
   4.110 +    const char* remainder_curr = NULL;
   4.111      
   4.112 -    if (source1 <= source1_curr) {
   4.113 -        remainder_start = source1;
   4.114 -        remainder_curr = source1_curr;
   4.115 +    if (fpr1 <= fpr1_curr) {
   4.116 +        remainder_start = fpr1;
   4.117 +        remainder_curr = fpr1_curr;
   4.118      }
   4.119 -    else if (source2 <= source2_curr) {
   4.120 -        remainder_start = source2;
   4.121 -        remainder_curr = source2_curr;
   4.122 +    else if (fpr2 <= fpr2_curr) {
   4.123 +        remainder_start = fpr2;
   4.124 +        remainder_curr = fpr2_curr;
   4.125      }
   4.126      if (remainder_curr) {
   4.127          while (remainder_start <= remainder_curr) {
     5.1 --- a/src/message_api.h	Tue May 28 15:53:52 2019 +0200
     5.2 +++ b/src/message_api.h	Tue May 28 15:54:22 2019 +0200
     5.3 @@ -388,9 +388,9 @@
     5.4  //        the caller is responsible to free() it (on Windoze use pEp_free())
     5.5  //
     5.6  DYNAMIC_API PEP_STATUS get_trustwords(
     5.7 -    PEP_SESSION session, const pEp_identity* id1, const pEp_identity* id2,
     5.8 -    const char* lang, char **words, size_t *wsize, bool full
     5.9 -);
    5.10 +        PEP_SESSION session, const pEp_identity* id1, const pEp_identity* id2,
    5.11 +        const char* lang, char **words, size_t *wsize, bool full
    5.12 +    );
    5.13  
    5.14  
    5.15  // get_message_trustwords() - get full trustwords string for message sender and reciever identities 
    5.16 @@ -421,12 +421,42 @@
    5.17  //        the caller is responsible to free() it (on Windoze use pEp_free())
    5.18  //
    5.19  DYNAMIC_API PEP_STATUS get_message_trustwords(
    5.20 -    PEP_SESSION session, 
    5.21 -    message *msg,
    5.22 -    stringlist_t *keylist,
    5.23 -    pEp_identity* received_by,
    5.24 -    const char* lang, char **words, bool full
    5.25 -);
    5.26 +        PEP_SESSION session, 
    5.27 +        message *msg,
    5.28 +        stringlist_t *keylist,
    5.29 +        pEp_identity* received_by,
    5.30 +        const char* lang, char **words, bool full
    5.31 +    );
    5.32 +
    5.33 +// get_trustwords_for_fprs() - get full trustwords string for a pair of fingerprints
    5.34 +//
    5.35 +//    parameters:
    5.36 +//        session (in)        session handle
    5.37 +//        fpr1 (in)           fingerprint 1
    5.38 +//        fpr2 (in)           fingerprint 2
    5.39 +//        lang (in)           C string with ISO 639-1 language code
    5.40 +//        words (out)         pointer to C string with all trustwords UTF-8 encoded,
    5.41 +//                            separated by a blank each
    5.42 +//                            NULL if language is not supported or trustword
    5.43 +//                            wordlist is damaged or unavailable
    5.44 +//        wsize (out)         length of full trustwords string
    5.45 +//        full (in)           if true, generate ALL trustwords for these identities.
    5.46 +//                            else, generate a fixed-size subset. (TODO: fixed-minimum-entropy
    5.47 +//                            subset in next version)
    5.48 +//
    5.49 +//    return value:
    5.50 +//        PEP_STATUS_OK            trustwords retrieved
    5.51 +//        PEP_OUT_OF_MEMORY        out of memory
    5.52 +//        PEP_TRUSTWORD_NOT_FOUND  at least one trustword not found
    5.53 +//
    5.54 +//    caveat:
    5.55 +//        the word pointer goes to the ownership of the caller
    5.56 +//        the caller is responsible to free() it (on Windoze use pEp_free())
    5.57 +//
    5.58 +DYNAMIC_API PEP_STATUS get_trustwords_for_fprs(
    5.59 +        PEP_SESSION session, const char* fpr1, const char* fpr2,
    5.60 +        const char* lang, char **words, size_t *wsize, bool full
    5.61 +    );
    5.62  
    5.63  // re_evaluate_message_rating() - re-evaluate already decrypted message rating
    5.64  //
     6.1 --- a/src/pEpEngine.c	Tue May 28 15:53:52 2019 +0200
     6.2 +++ b/src/pEpEngine.c	Tue May 28 15:54:22 2019 +0200
     6.3 @@ -2017,32 +2017,31 @@
     6.4  #if !defined(NDEBUG) && !defined(_PEP_SERVICE_LOG_OFF)
     6.5      fprintf(stdout, "\n*** %s %s %s %s\n", title, entity, description, comment);
     6.6      session->service_log = true;
     6.7 +
     6.8 +    int result;
     6.9 +    
    6.10 +    assert(session);
    6.11 +    assert(title);
    6.12 +    assert(entity);
    6.13 +    
    6.14 +    if (!(session && title && entity))
    6.15 +        return PEP_ILLEGAL_VALUE;
    6.16 +    
    6.17 +    sqlite3_reset(session->log);
    6.18 +    sqlite3_bind_text(session->log, 1, title, -1, SQLITE_STATIC);
    6.19 +    sqlite3_bind_text(session->log, 2, entity, -1, SQLITE_STATIC);
    6.20 +    if (description)
    6.21 +        sqlite3_bind_text(session->log, 3, description, -1, SQLITE_STATIC);
    6.22 +    else
    6.23 +        sqlite3_bind_null(session->log, 3);
    6.24 +    if (comment)
    6.25 +        sqlite3_bind_text(session->log, 4, comment, -1, SQLITE_STATIC);
    6.26 +    else
    6.27 +        sqlite3_bind_null(session->log, 4);
    6.28 +    result = Sqlite3_step(session->log);
    6.29 +    sqlite3_reset(session->log);
    6.30 +    
    6.31  #endif
    6.32 -
    6.33 -    // PEP_STATUS status = PEP_STATUS_OK;
    6.34 -    // int result;
    6.35 -    // 
    6.36 -    // assert(session);
    6.37 -    // assert(title);
    6.38 -    // assert(entity);
    6.39 -    // 
    6.40 -    // if (!(session && title && entity))
    6.41 -    //     return PEP_ILLEGAL_VALUE;
    6.42 -    // 
    6.43 -    // sqlite3_reset(session->log);
    6.44 -    // sqlite3_bind_text(session->log, 1, title, -1, SQLITE_STATIC);
    6.45 -    // sqlite3_bind_text(session->log, 2, entity, -1, SQLITE_STATIC);
    6.46 -    // if (description)
    6.47 -    //     sqlite3_bind_text(session->log, 3, description, -1, SQLITE_STATIC);
    6.48 -    // else
    6.49 -    //     sqlite3_bind_null(session->log, 3);
    6.50 -    // if (comment)
    6.51 -    //     sqlite3_bind_text(session->log, 4, comment, -1, SQLITE_STATIC);
    6.52 -    // else
    6.53 -    //     sqlite3_bind_null(session->log, 4);
    6.54 -    // result = Sqlite3_step(session->log);
    6.55 -    // sqlite3_reset(session->log);
    6.56 -    // 
    6.57      return PEP_STATUS_OK; // We ignore errors for this function.
    6.58  }
    6.59  
    6.60 @@ -5071,3 +5070,18 @@
    6.61  }
    6.62  
    6.63  #endif
    6.64 +
    6.65 +DYNAMIC_API void _service_error_log(PEP_SESSION session, const char *entity,
    6.66 +        PEP_STATUS status, const char *where)
    6.67 +{
    6.68 +    char buffer[128];
    6.69 +    static const size_t size = 127;
    6.70 +    memset(buffer, 0, size+1);
    6.71 +#ifdef PEP_STATUS_TO_STRING
    6.72 +    snprintf(buffer, size, "%s %.4x", pEp_status_to_string(status), status);
    6.73 +#else
    6.74 +    snprintf(buffer, size, "error %.4x", status);
    6.75 +#endif
    6.76 +    log_service(session, "### service error log ###", entity, buffer, where);
    6.77 +}
    6.78 +
     7.1 --- a/src/pEpEngine.h	Tue May 28 15:53:52 2019 +0200
     7.2 +++ b/src/pEpEngine.h	Tue May 28 15:54:22 2019 +0200
     7.3 @@ -103,6 +103,7 @@
     7.4      PEP_SYNC_NO_CHANNEL                             = 0x0904,
     7.5      PEP_SYNC_CANNOT_ENCRYPT                         = 0x0905,
     7.6      PEP_SYNC_NO_MESSAGE_SEND_CALLBACK               = 0x0906,
     7.7 +    PEP_SYNC_CANNOT_START                           = 0x0907,
     7.8  
     7.9      PEP_CANNOT_INCREASE_SEQUENCE                    = 0x0971,
    7.10  
    7.11 @@ -437,6 +438,11 @@
    7.12  #define SERVICE_LOG(session, title, entity, desc) \
    7.13      log_service((session), (title), (entity), (desc), "service " __FILE__ ":" S_LINE)
    7.14  
    7.15 +DYNAMIC_API void _service_error_log(PEP_SESSION session, const char *entity,
    7.16 +        PEP_STATUS status, const char *where);
    7.17 +
    7.18 +#define SERVICE_ERROR_LOG(session, entity, status) \
    7.19 +    _service_error_log((session), (entity), (status), __FILE__ ":" S_LINE)
    7.20  
    7.21  // trustword() - get the corresponding trustword for a 16 bit value
    7.22  //
    7.23 @@ -562,47 +568,6 @@
    7.24      PEP_ct_pEp = 0xff
    7.25  } PEP_comm_type;
    7.26  
    7.27 -static inline const char *pep_comm_type_to_string(PEP_comm_type ct) {
    7.28 -    switch (ct) {
    7.29 -    case PEP_ct_unknown: return "unknown";
    7.30 -    case PEP_ct_no_encryption: return "no_encryption";
    7.31 -    case PEP_ct_no_encrypted_channel: return "no_encrypted_channel";
    7.32 -    case PEP_ct_key_not_found: return "key_not_found";
    7.33 -    case PEP_ct_key_expired: return "key_expired";
    7.34 -    case PEP_ct_key_revoked: return "key_revoked";
    7.35 -    case PEP_ct_key_b0rken: return "key_b0rken";
    7.36 -    case PEP_ct_my_key_not_included: return "my_key_not_included";
    7.37 -    case PEP_ct_security_by_obscurity: return "security_by_obscurity";
    7.38 -    case PEP_ct_b0rken_crypto: return "b0rken_crypto";
    7.39 -    case PEP_ct_key_too_short: return "key_too_short";
    7.40 -    case PEP_ct_compromised: return "compromised";
    7.41 -    case PEP_ct_mistrusted: return "mistrusted";
    7.42 -    case PEP_ct_unconfirmed_encryption: return "unconfirmed_encryption";
    7.43 -    case PEP_ct_OpenPGP_weak_unconfirmed: return "OpenPGP_weak_unconfirmed";
    7.44 -    case PEP_ct_to_be_checked: return "to_be_checked";
    7.45 -    case PEP_ct_SMIME_unconfirmed: return "SMIME_unconfirmed";
    7.46 -    case PEP_ct_CMS_unconfirmed: return "CMS_unconfirmed";
    7.47 -    case PEP_ct_strong_but_unconfirmed: return "strong_but_unconfirmed";
    7.48 -    case PEP_ct_OpenPGP_unconfirmed: return "OpenPGP_unconfirmed";
    7.49 -    case PEP_ct_OTR_unconfirmed: return "OTR_unconfirmed";
    7.50 -    case PEP_ct_unconfirmed_enc_anon: return "unconfirmed_enc_anon";
    7.51 -    case PEP_ct_pEp_unconfirmed: return "pEp_unconfirmed";
    7.52 -    case PEP_ct_confirmed: return "confirmed";
    7.53 -    case PEP_ct_confirmed_encryption: return "confirmed_encryption";
    7.54 -    case PEP_ct_OpenPGP_weak: return "OpenPGP_weak";
    7.55 -    case PEP_ct_to_be_checked_confirmed: return "to_be_checked_confirmed";
    7.56 -    case PEP_ct_SMIME: return "SMIME";
    7.57 -    case PEP_ct_CMS: return "CMS";
    7.58 -    case PEP_ct_strong_encryption: return "strong_encryption";
    7.59 -    case PEP_ct_OpenPGP: return "OpenPGP";
    7.60 -    case PEP_ct_OTR: return "OTR";
    7.61 -    case PEP_ct_confirmed_enc_anon: return "confirmed_enc_anon";
    7.62 -    case PEP_ct_pEp: return "pEp";
    7.63 -    default: return "invalid comm type";
    7.64 -    }
    7.65 -}
    7.66 -
    7.67 -
    7.68  typedef enum _identity_flags {
    7.69      // the first octet flags are app defined settings
    7.70      PEP_idf_not_for_sync = 0x0001,   // don't use this identity for sync
     8.1 --- a/src/status_to_string.h	Tue May 28 15:53:52 2019 +0200
     8.2 +++ b/src/status_to_string.h	Tue May 28 15:54:22 2019 +0200
     8.3 @@ -4,6 +4,10 @@
     8.4  extern "C" {
     8.5  #endif
     8.6  
     8.7 +#ifndef PEP_STATUS_TO_STRING
     8.8 +#define PEP_STATUS_TO_STRING
     8.9 +#endif
    8.10 +
    8.11  static inline const char *pEp_status_to_string(PEP_STATUS status) {
    8.12      switch (status) {
    8.13      case PEP_STATUS_OK: return "PEP_STATUS_OK";
    8.14 @@ -103,6 +107,46 @@
    8.15      }
    8.16  }
    8.17  
    8.18 +static inline const char *pEp_comm_type_to_string(PEP_comm_type ct) {
    8.19 +    switch (ct) {
    8.20 +    case PEP_ct_unknown: return "unknown";
    8.21 +    case PEP_ct_no_encryption: return "no_encryption";
    8.22 +    case PEP_ct_no_encrypted_channel: return "no_encrypted_channel";
    8.23 +    case PEP_ct_key_not_found: return "key_not_found";
    8.24 +    case PEP_ct_key_expired: return "key_expired";
    8.25 +    case PEP_ct_key_revoked: return "key_revoked";
    8.26 +    case PEP_ct_key_b0rken: return "key_b0rken";
    8.27 +    case PEP_ct_my_key_not_included: return "my_key_not_included";
    8.28 +    case PEP_ct_security_by_obscurity: return "security_by_obscurity";
    8.29 +    case PEP_ct_b0rken_crypto: return "b0rken_crypto";
    8.30 +    case PEP_ct_key_too_short: return "key_too_short";
    8.31 +    case PEP_ct_compromised: return "compromised";
    8.32 +    case PEP_ct_mistrusted: return "mistrusted";
    8.33 +    case PEP_ct_unconfirmed_encryption: return "unconfirmed_encryption";
    8.34 +    case PEP_ct_OpenPGP_weak_unconfirmed: return "OpenPGP_weak_unconfirmed";
    8.35 +    case PEP_ct_to_be_checked: return "to_be_checked";
    8.36 +    case PEP_ct_SMIME_unconfirmed: return "SMIME_unconfirmed";
    8.37 +    case PEP_ct_CMS_unconfirmed: return "CMS_unconfirmed";
    8.38 +    case PEP_ct_strong_but_unconfirmed: return "strong_but_unconfirmed";
    8.39 +    case PEP_ct_OpenPGP_unconfirmed: return "OpenPGP_unconfirmed";
    8.40 +    case PEP_ct_OTR_unconfirmed: return "OTR_unconfirmed";
    8.41 +    case PEP_ct_unconfirmed_enc_anon: return "unconfirmed_enc_anon";
    8.42 +    case PEP_ct_pEp_unconfirmed: return "pEp_unconfirmed";
    8.43 +    case PEP_ct_confirmed: return "confirmed";
    8.44 +    case PEP_ct_confirmed_encryption: return "confirmed_encryption";
    8.45 +    case PEP_ct_OpenPGP_weak: return "OpenPGP_weak";
    8.46 +    case PEP_ct_to_be_checked_confirmed: return "to_be_checked_confirmed";
    8.47 +    case PEP_ct_SMIME: return "SMIME";
    8.48 +    case PEP_ct_CMS: return "CMS";
    8.49 +    case PEP_ct_strong_encryption: return "strong_encryption";
    8.50 +    case PEP_ct_OpenPGP: return "OpenPGP";
    8.51 +    case PEP_ct_OTR: return "OTR";
    8.52 +    case PEP_ct_confirmed_enc_anon: return "confirmed_enc_anon";
    8.53 +    case PEP_ct_pEp: return "pEp";
    8.54 +    default: return "invalid comm type";
    8.55 +    }
    8.56 +}
    8.57 +
    8.58  #ifdef __cplusplus
    8.59  } // "C"
    8.60  #endif
     9.1 --- a/src/sync_api.c	Tue May 28 15:53:52 2019 +0200
     9.2 +++ b/src/sync_api.c	Tue May 28 15:54:22 2019 +0200
     9.3 @@ -19,6 +19,15 @@
     9.4      if (!(session && notifyHandshake && retrieve_next_sync_event))
     9.5          return PEP_ILLEGAL_VALUE;
     9.6  
     9.7 +    identity_list *own_identities = NULL;
     9.8 +    PEP_STATUS status = own_identities_retrieve(session, &own_identities);
     9.9 +    if (status)
    9.10 +        return status;
    9.11 +    bool own_identities_available = own_identities && own_identities->ident;
    9.12 +    free_identity_list(own_identities);
    9.13 +    if (!own_identities_available)
    9.14 +        return PEP_SYNC_CANNOT_START;
    9.15 +
    9.16      session->sync_management = management;
    9.17      session->notifyHandshake = notifyHandshake;
    9.18      session->retrieve_next_sync_event = retrieve_next_sync_event;
    10.1 --- a/sync/gen_statemachine.ysl2	Tue May 28 15:53:52 2019 +0200
    10.2 +++ b/sync/gen_statemachine.ysl2	Tue May 28 15:54:22 2019 +0200
    10.3 @@ -766,6 +766,8 @@
    10.4                  free(data);
    10.5                  free(key_data);
    10.6                  free_«@name»_message(msg);
    10.7 +                if (status)
    10.8 +                    SERVICE_ERROR_LOG(session, "send_«@name»_message()", status);
    10.9                  return status;
   10.10              }
   10.11