Merge with sync sequoia_windows
authorThomas
Tue, 28 May 2019 07:55:50 +0200
branchsequoia_windows
changeset 37469cae7b9305d1
parent 3738 93bdc04f45da
parent 3745 1ee3caae7f33
child 3748 2626a1c321ff
Merge with sync
src/pgp_sequoia.c
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/build-android/enable_address_sanitizer.patch	Tue May 28 07:55:50 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	Mon May 20 14:50:00 2019 +0200
     2.2 +++ b/build-android/jni/Android.mk	Tue May 28 07:55:50 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	Mon May 20 14:50:00 2019 +0200
     3.2 +++ b/build-android/jni/Application.mk	Tue May 28 07:55:50 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/blacklist.c	Mon May 20 14:50:00 2019 +0200
     4.2 +++ b/src/blacklist.c	Tue May 28 07:55:50 2019 +0200
     4.3 @@ -20,7 +20,7 @@
     4.4  
     4.5      int result;
     4.6  
     4.7 -    result = sqlite3_step(session->blacklist_add);
     4.8 +    result = Sqlite3_step(session->blacklist_add);
     4.9      switch (result) {
    4.10      case SQLITE_DONE:
    4.11          status = PEP_STATUS_OK;
    4.12 @@ -50,7 +50,7 @@
    4.13  
    4.14      int result;
    4.15  
    4.16 -    result = sqlite3_step(session->blacklist_delete);
    4.17 +    result = Sqlite3_step(session->blacklist_delete);
    4.18      switch (result) {
    4.19      case SQLITE_DONE:
    4.20          status = PEP_STATUS_OK;
    4.21 @@ -85,7 +85,7 @@
    4.22  
    4.23      int result;
    4.24  
    4.25 -    result = sqlite3_step(session->blacklist_is_listed);
    4.26 +    result = Sqlite3_step(session->blacklist_is_listed);
    4.27      switch (result) {
    4.28      case SQLITE_ROW:
    4.29          count = sqlite3_column_int(session->blacklist_is_listed, 0);
    4.30 @@ -125,7 +125,7 @@
    4.31  
    4.32      stringlist_t *_bl = _blacklist;
    4.33      do {
    4.34 -        result = sqlite3_step(session->blacklist_retrieve);
    4.35 +        result = Sqlite3_step(session->blacklist_retrieve);
    4.36          switch (result) {
    4.37          case SQLITE_ROW:
    4.38          {
     5.1 --- a/src/key_reset.c	Mon May 20 14:50:00 2019 +0200
     5.2 +++ b/src/key_reset.c	Tue May 28 07:55:50 2019 +0200
     5.3 @@ -39,7 +39,7 @@
     5.4              SQLITE_STATIC);
     5.5      sqlite3_bind_text(session->was_id_for_revoke_contacted, 2, user_id, -1,
     5.6              SQLITE_STATIC);        
     5.7 -    int result = sqlite3_step(session->was_id_for_revoke_contacted);
     5.8 +    int result = Sqlite3_step(session->was_id_for_revoke_contacted);
     5.9      switch (result) {
    5.10          case SQLITE_ROW: {
    5.11              *contacted = (sqlite3_column_int(session->was_id_for_revoke_contacted, 0) != 0);
    5.12 @@ -79,7 +79,7 @@
    5.13  
    5.14      int result;
    5.15      
    5.16 -    result = sqlite3_step(session->set_revoke_contact_as_notified);
    5.17 +    result = Sqlite3_step(session->set_revoke_contact_as_notified);
    5.18      switch (result) {
    5.19          case SQLITE_DONE:
    5.20              status = PEP_STATUS_OK;
     6.1 --- a/src/keymanagement.c	Mon May 20 14:50:00 2019 +0200
     6.2 +++ b/src/keymanagement.c	Tue May 28 07:55:50 2019 +0200
     6.3 @@ -282,7 +282,7 @@
     6.4  
     6.5      int result = -1;
     6.6      
     6.7 -    while ((result = sqlite3_step(session->get_all_keys_for_user)) == SQLITE_ROW) {
     6.8 +    while ((result = Sqlite3_step(session->get_all_keys_for_user)) == SQLITE_ROW) {
     6.9          const char* keyres = (const char *) sqlite3_column_text(session->get_all_keys_for_user, 0);
    6.10          if (keyres) {
    6.11              if (_kl)
    6.12 @@ -317,7 +317,7 @@
    6.13      sqlite3_bind_text(session->get_user_default_key, 1, user_id, 
    6.14                        -1, SQLITE_STATIC);
    6.15      
    6.16 -    const int result = sqlite3_step(session->get_user_default_key);
    6.17 +    const int result = Sqlite3_step(session->get_user_default_key);
    6.18      char* user_fpr = NULL;
    6.19      if (result == SQLITE_ROW) {
    6.20          const char* u_fpr =
    6.21 @@ -1621,7 +1621,7 @@
    6.22      
    6.23      int result;
    6.24      
    6.25 -    result = sqlite3_step(session->own_key_is_listed);
    6.26 +    result = Sqlite3_step(session->own_key_is_listed);
    6.27      switch (result) {
    6.28          case SQLITE_ROW:
    6.29              count = sqlite3_column_int(session->own_key_is_listed, 0);
    6.30 @@ -1671,7 +1671,7 @@
    6.31      sqlite3_bind_int(session->own_identities_retrieve, 1, excluded_flags);
    6.32  
    6.33      do {
    6.34 -        result = sqlite3_step(session->own_identities_retrieve);
    6.35 +        result = Sqlite3_step(session->own_identities_retrieve);
    6.36          switch (result) {
    6.37              case SQLITE_ROW:
    6.38                  address = (const char *)
    6.39 @@ -1765,7 +1765,7 @@
    6.40      sqlite3_bind_int(session->own_keys_retrieve, 1, excluded_flags);
    6.41  
    6.42      do {        
    6.43 -        result = sqlite3_step(session->own_keys_retrieve);
    6.44 +        result = Sqlite3_step(session->own_keys_retrieve);
    6.45          switch (result) {
    6.46              case SQLITE_ROW:
    6.47                  _bl = stringlist_add(_bl, (const char *)
    6.48 @@ -1906,7 +1906,7 @@
    6.49      sqlite3_bind_text(session->add_mistrusted_key, 1, fpr, -1,
    6.50              SQLITE_STATIC);
    6.51  
    6.52 -    result = sqlite3_step(session->add_mistrusted_key);
    6.53 +    result = Sqlite3_step(session->add_mistrusted_key);
    6.54      sqlite3_reset(session->add_mistrusted_key);
    6.55  
    6.56      if (result != SQLITE_DONE)
    6.57 @@ -1928,7 +1928,7 @@
    6.58      sqlite3_bind_text(session->delete_mistrusted_key, 1, fpr, -1,
    6.59              SQLITE_STATIC);
    6.60  
    6.61 -    result = sqlite3_step(session->delete_mistrusted_key);
    6.62 +    result = Sqlite3_step(session->delete_mistrusted_key);
    6.63      sqlite3_reset(session->delete_mistrusted_key);
    6.64  
    6.65      if (result != SQLITE_DONE)
    6.66 @@ -1955,7 +1955,7 @@
    6.67  
    6.68      int result;
    6.69  
    6.70 -    result = sqlite3_step(session->is_mistrusted_key);
    6.71 +    result = Sqlite3_step(session->is_mistrusted_key);
    6.72      switch (result) {
    6.73      case SQLITE_ROW:
    6.74          *mistrusted = sqlite3_column_int(session->is_mistrusted_key, 0);
     7.1 --- a/src/message_api.c	Mon May 20 14:50:00 2019 +0200
     7.2 +++ b/src/message_api.c	Tue May 28 07:55:50 2019 +0200
     7.3 @@ -4207,7 +4207,7 @@
     7.4      return num_to_asciihex(xor_num);
     7.5  }
     7.6  
     7.7 -static char* skip_separators(char* current, char* begin) {
     7.8 +static const char* skip_separators(const char* current, const char* begin) {
     7.9      while (current >= begin) {
    7.10          /* .:,;-_ ' ' - [2c-2e] [3a-3b] [20] [5f] */
    7.11          char check_char = *current;
    7.12 @@ -4245,71 +4245,73 @@
    7.13  }
    7.14  
    7.15  DYNAMIC_API PEP_STATUS get_trustwords(
    7.16 -    PEP_SESSION session, const pEp_identity* id1, const pEp_identity* id2,
    7.17 -    const char* lang, char **words, size_t *wsize, bool full
    7.18 -)
    7.19 +        PEP_SESSION session, const pEp_identity* id1, const pEp_identity* id2,
    7.20 +        const char* lang, char **words, size_t *wsize, bool full
    7.21 +    )
    7.22  {
    7.23 -    assert(session);
    7.24 -    assert(id1);
    7.25 -    assert(id2);
    7.26 -    assert(id1->fpr);
    7.27 -    assert(id2->fpr);
    7.28 -    assert(words);
    7.29 -    assert(wsize);
    7.30 -
    7.31 -    int SHORT_NUM_TWORDS = 5; 
    7.32 -    
    7.33 +    assert(session && id1 && id1->fpr && id2 && id2->fpr&& lang && words &&
    7.34 +            wsize);
    7.35 +    if (!(session && id1 && id1->fpr && id2 && id2->fpr&& lang && words &&
    7.36 +                wsize))
    7.37 +        return PEP_ILLEGAL_VALUE;
    7.38 +
    7.39 +    return get_trustwords_for_fprs(session, id1->fpr, id2->fpr, lang, words,
    7.40 +            wsize, full);
    7.41 +}
    7.42 +
    7.43 +DYNAMIC_API PEP_STATUS get_trustwords_for_fprs(
    7.44 +        PEP_SESSION session, const char* fpr1, const char* fpr2,
    7.45 +        const char* lang, char **words, size_t *wsize, bool full
    7.46 +    )
    7.47 +{
    7.48 +    assert(session && fpr1 && fpr2 && words && wsize);
    7.49 +    if (!(session && fpr1 && fpr2 && words && wsize))
    7.50 +        return PEP_ILLEGAL_VALUE;
    7.51 +
    7.52 +    const int SHORT_NUM_TWORDS = 5; 
    7.53      PEP_STATUS status = PEP_STATUS_OK;
    7.54      
    7.55 -    if (!(session && id1 && id2 && words && wsize) ||
    7.56 -        !(id1->fpr) || (!id2->fpr))
    7.57 -        return PEP_ILLEGAL_VALUE;
    7.58 -
    7.59 -    char *source1 = id1->fpr;
    7.60 -    char *source2 = id2->fpr;
    7.61 -
    7.62 -    int source1_len = strlen(source1);
    7.63 -    int source2_len = strlen(source2);
    7.64 -    int max_len;
    7.65 -        
    7.66      *words = NULL;    
    7.67      *wsize = 0;
    7.68  
    7.69 -    max_len = (source1_len > source2_len ? source1_len : source2_len);
    7.70 +    int fpr1_len = strlen(fpr1);
    7.71 +    int fpr2_len = strlen(fpr2);
    7.72 +        
    7.73 +    int max_len = (fpr1_len > fpr2_len ? fpr1_len : fpr2_len);
    7.74      
    7.75      char* XORed_fpr = (char*)(calloc(max_len + 1, 1));
    7.76      *(XORed_fpr + max_len) = '\0';
    7.77      char* result_curr = XORed_fpr + max_len - 1;
    7.78 -    char* source1_curr = source1 + source1_len - 1;
    7.79 -    char* source2_curr = source2 + source2_len - 1;
    7.80 -
    7.81 -    while (source1 <= source1_curr && source2 <= source2_curr) {
    7.82 -        source1_curr = skip_separators(source1_curr, source1);
    7.83 -        source2_curr = skip_separators(source2_curr, source2);
    7.84 +    const char* fpr1_curr = fpr1 + fpr1_len - 1;
    7.85 +    const char* fpr2_curr = fpr2 + fpr2_len - 1;
    7.86 +
    7.87 +    while (fpr1 <= fpr1_curr && fpr2 <= fpr2_curr) {
    7.88 +        fpr1_curr = skip_separators(fpr1_curr, fpr1);
    7.89 +        fpr2_curr = skip_separators(fpr2_curr, fpr2);
    7.90          
    7.91 -        if (source1_curr < source1 || source2_curr < source2)
    7.92 +        if (fpr1_curr < fpr1 || fpr2_curr < fpr2)
    7.93              break;
    7.94              
    7.95 -        char xor_hex = xor_hex_chars(*source1_curr, *source2_curr);
    7.96 +        char xor_hex = xor_hex_chars(*fpr1_curr, *fpr2_curr);
    7.97          if (xor_hex == '\0') {
    7.98              status = PEP_ILLEGAL_VALUE;
    7.99              goto error_release;
   7.100          }
   7.101          
   7.102          *result_curr = xor_hex;
   7.103 -        result_curr--; source1_curr--; source2_curr--;
   7.104 +        result_curr--; fpr1_curr--; fpr2_curr--;
   7.105      }
   7.106  
   7.107 -    char* remainder_start = NULL;
   7.108 -    char* remainder_curr = NULL;
   7.109 +    const char* remainder_start = NULL;
   7.110 +    const char* remainder_curr = NULL;
   7.111      
   7.112 -    if (source1 <= source1_curr) {
   7.113 -        remainder_start = source1;
   7.114 -        remainder_curr = source1_curr;
   7.115 +    if (fpr1 <= fpr1_curr) {
   7.116 +        remainder_start = fpr1;
   7.117 +        remainder_curr = fpr1_curr;
   7.118      }
   7.119 -    else if (source2 <= source2_curr) {
   7.120 -        remainder_start = source2;
   7.121 -        remainder_curr = source2_curr;
   7.122 +    else if (fpr2 <= fpr2_curr) {
   7.123 +        remainder_start = fpr2;
   7.124 +        remainder_curr = fpr2_curr;
   7.125      }
   7.126      if (remainder_curr) {
   7.127          while (remainder_start <= remainder_curr) {
     8.1 --- a/src/message_api.h	Mon May 20 14:50:00 2019 +0200
     8.2 +++ b/src/message_api.h	Tue May 28 07:55:50 2019 +0200
     8.3 @@ -388,9 +388,9 @@
     8.4  //        the caller is responsible to free() it (on Windoze use pEp_free())
     8.5  //
     8.6  DYNAMIC_API PEP_STATUS get_trustwords(
     8.7 -    PEP_SESSION session, const pEp_identity* id1, const pEp_identity* id2,
     8.8 -    const char* lang, char **words, size_t *wsize, bool full
     8.9 -);
    8.10 +        PEP_SESSION session, const pEp_identity* id1, const pEp_identity* id2,
    8.11 +        const char* lang, char **words, size_t *wsize, bool full
    8.12 +    );
    8.13  
    8.14  
    8.15  // get_message_trustwords() - get full trustwords string for message sender and reciever identities 
    8.16 @@ -421,12 +421,42 @@
    8.17  //        the caller is responsible to free() it (on Windoze use pEp_free())
    8.18  //
    8.19  DYNAMIC_API PEP_STATUS get_message_trustwords(
    8.20 -    PEP_SESSION session, 
    8.21 -    message *msg,
    8.22 -    stringlist_t *keylist,
    8.23 -    pEp_identity* received_by,
    8.24 -    const char* lang, char **words, bool full
    8.25 -);
    8.26 +        PEP_SESSION session, 
    8.27 +        message *msg,
    8.28 +        stringlist_t *keylist,
    8.29 +        pEp_identity* received_by,
    8.30 +        const char* lang, char **words, bool full
    8.31 +    );
    8.32 +
    8.33 +// get_trustwords_for_fprs() - get full trustwords string for a pair of fingerprints
    8.34 +//
    8.35 +//    parameters:
    8.36 +//        session (in)        session handle
    8.37 +//        fpr1 (in)           fingerprint 1
    8.38 +//        fpr2 (in)           fingerprint 2
    8.39 +//        lang (in)           C string with ISO 639-1 language code
    8.40 +//        words (out)         pointer to C string with all trustwords UTF-8 encoded,
    8.41 +//                            separated by a blank each
    8.42 +//                            NULL if language is not supported or trustword
    8.43 +//                            wordlist is damaged or unavailable
    8.44 +//        wsize (out)         length of full trustwords string
    8.45 +//        full (in)           if true, generate ALL trustwords for these identities.
    8.46 +//                            else, generate a fixed-size subset. (TODO: fixed-minimum-entropy
    8.47 +//                            subset in next version)
    8.48 +//
    8.49 +//    return value:
    8.50 +//        PEP_STATUS_OK            trustwords retrieved
    8.51 +//        PEP_OUT_OF_MEMORY        out of memory
    8.52 +//        PEP_TRUSTWORD_NOT_FOUND  at least one trustword not found
    8.53 +//
    8.54 +//    caveat:
    8.55 +//        the word pointer goes to the ownership of the caller
    8.56 +//        the caller is responsible to free() it (on Windoze use pEp_free())
    8.57 +//
    8.58 +DYNAMIC_API PEP_STATUS get_trustwords_for_fprs(
    8.59 +        PEP_SESSION session, const char* fpr1, const char* fpr2,
    8.60 +        const char* lang, char **words, size_t *wsize, bool full
    8.61 +    );
    8.62  
    8.63  // re_evaluate_message_rating() - re-evaluate already decrypted message rating
    8.64  //
     9.1 --- a/src/pEpEngine.c	Mon May 20 14:50:00 2019 +0200
     9.2 +++ b/src/pEpEngine.c	Tue May 28 07:55:50 2019 +0200
     9.3 @@ -533,7 +533,7 @@
     9.4  
     9.5      int retval = 0;
     9.6  
     9.7 -    int rc = sqlite3_step(stmt);  
     9.8 +    int rc = Sqlite3_step(stmt);  
     9.9      if (rc == SQLITE_DONE || rc == SQLITE_OK || rc == SQLITE_ROW) {
    9.10          retval = 1;
    9.11      }
    9.12 @@ -584,7 +584,7 @@
    9.13  
    9.14      int retval = 0;
    9.15  
    9.16 -    int rc = sqlite3_step(stmt);  
    9.17 +    int rc = Sqlite3_step(stmt);  
    9.18      if (rc == SQLITE_DONE || rc == SQLITE_OK || rc == SQLITE_ROW) {
    9.19          retval = 1;
    9.20      }
    9.21 @@ -607,7 +607,7 @@
    9.22      sqlite3_prepare_v2(session->db, sql_query, -1, &stmt, NULL);
    9.23      int i = 0;
    9.24      int int_result = 0;
    9.25 -    while ((int_result = sqlite3_step(stmt)) == SQLITE_ROW && i < _PEP_MAX_AFFECTED) {
    9.26 +    while ((int_result = Sqlite3_step(stmt)) == SQLITE_ROW && i < _PEP_MAX_AFFECTED) {
    9.27          table_names[i++] = strdup((const char*)(sqlite3_column_text(stmt, 0)));
    9.28      }
    9.29      
    9.30 @@ -2040,7 +2040,7 @@
    9.31      //     sqlite3_bind_text(session->log, 4, comment, -1, SQLITE_STATIC);
    9.32      // else
    9.33      //     sqlite3_bind_null(session->log, 4);
    9.34 -    // result = sqlite3_step(session->log);
    9.35 +    // result = Sqlite3_step(session->log);
    9.36      // sqlite3_reset(session->log);
    9.37      // 
    9.38      return PEP_STATUS_OK; // We ignore errors for this function.
    9.39 @@ -2094,7 +2094,7 @@
    9.40      sqlite3_bind_text(session->trustword, 1, lang, -1, SQLITE_STATIC);
    9.41      sqlite3_bind_int(session->trustword, 2, value);
    9.42  
    9.43 -    const int result = sqlite3_step(session->trustword);
    9.44 +    const int result = Sqlite3_step(session->trustword);
    9.45      if (result == SQLITE_ROW) {
    9.46          *word = strdup((const char *) sqlite3_column_text(session->trustword,
    9.47                      1));
    9.48 @@ -2289,7 +2289,7 @@
    9.49      
    9.50      sqlite3_reset(session->get_default_own_userid);
    9.51  
    9.52 -    const int result = sqlite3_step(session->get_default_own_userid);
    9.53 +    const int result = Sqlite3_step(session->get_default_own_userid);
    9.54      const char* id;
    9.55      
    9.56      switch (result) {
    9.57 @@ -2338,7 +2338,7 @@
    9.58  
    9.59      const char* tempid;
    9.60      
    9.61 -    const int result = sqlite3_step(session->get_userid_alias_default);
    9.62 +    const int result = Sqlite3_step(session->get_userid_alias_default);
    9.63      switch (result) {
    9.64      case SQLITE_ROW:
    9.65          tempid = (const char *) sqlite3_column_text(session->get_userid_alias_default, 0);
    9.66 @@ -2383,7 +2383,7 @@
    9.67      sqlite3_bind_text(session->add_userid_alias, 2, alias_id, -1,
    9.68              SQLITE_STATIC);
    9.69          
    9.70 -    result = sqlite3_step(session->add_userid_alias);
    9.71 +    result = Sqlite3_step(session->add_userid_alias);
    9.72  
    9.73      sqlite3_reset(session->add_userid_alias);
    9.74      if (result != SQLITE_DONE) {
    9.75 @@ -2420,7 +2420,7 @@
    9.76      sqlite3_bind_text(session->get_identity, 1, address, -1, SQLITE_STATIC);
    9.77      sqlite3_bind_text(session->get_identity, 2, user_id, -1, SQLITE_STATIC);
    9.78  
    9.79 -    const int result = sqlite3_step(session->get_identity);
    9.80 +    const int result = Sqlite3_step(session->get_identity);
    9.81      switch (result) {
    9.82      case SQLITE_ROW:
    9.83          _identity = new_identity(
    9.84 @@ -2483,7 +2483,7 @@
    9.85      sqlite3_bind_text(session->get_identities_by_userid, 1, user_id, -1, SQLITE_STATIC);
    9.86  
    9.87      int result = -1;
    9.88 -    while ((result = sqlite3_step(session->get_identities_by_userid)) == SQLITE_ROW) {
    9.89 +    while ((result = Sqlite3_step(session->get_identities_by_userid)) == SQLITE_ROW) {
    9.90              // "select address, fpr, username, comm_type, lang,"
    9.91              // "   identity.flags | pgp_keypair.flags,"
    9.92              // "   is_own"
    9.93 @@ -2561,7 +2561,7 @@
    9.94  
    9.95      int result = -1;
    9.96      
    9.97 -    while ((result = sqlite3_step(session->get_identities_by_main_key_id)) == SQLITE_ROW) {
    9.98 +    while ((result = Sqlite3_step(session->get_identities_by_main_key_id)) == SQLITE_ROW) {
    9.99          ident = new_identity(
   9.100                      (const char *) sqlite3_column_text(session->get_identities_by_main_key_id, 0),
   9.101                      fpr,
   9.102 @@ -2631,7 +2631,7 @@
   9.103      sqlite3_bind_text(session->get_identity_without_trust_check, 1, address, -1, SQLITE_STATIC);
   9.104      sqlite3_bind_text(session->get_identity_without_trust_check, 2, user_id, -1, SQLITE_STATIC);
   9.105  
   9.106 -    const int result = sqlite3_step(session->get_identity_without_trust_check);
   9.107 +    const int result = Sqlite3_step(session->get_identity_without_trust_check);
   9.108      switch (result) {
   9.109      case SQLITE_ROW:
   9.110          _identity = new_identity(
   9.111 @@ -2695,7 +2695,7 @@
   9.112      sqlite3_bind_text(session->get_identities_by_address, 1, address, -1, SQLITE_STATIC);
   9.113      int result;
   9.114  
   9.115 -    while ((result = sqlite3_step(session->get_identities_by_address)) == SQLITE_ROW) {
   9.116 +    while ((result = Sqlite3_step(session->get_identities_by_address)) == SQLITE_ROW) {
   9.117          //"select user_id, main_key_id, username, comm_type, lang,"
   9.118          //"   identity.flags, is_own"
   9.119          pEp_identity *ident = new_identity(
   9.120 @@ -2762,7 +2762,7 @@
   9.121      sqlite3_bind_text(session->exists_identity_entry, 2, identity->user_id, -1,
   9.122                        SQLITE_STATIC);
   9.123                    
   9.124 -    int result = sqlite3_step(session->exists_identity_entry);
   9.125 +    int result = Sqlite3_step(session->exists_identity_entry);
   9.126  
   9.127      switch (result) {
   9.128          case SQLITE_ROW: {
   9.129 @@ -2797,7 +2797,7 @@
   9.130      sqlite3_bind_text(session->exists_trust_entry, 2, identity->fpr, -1,
   9.131                        SQLITE_STATIC);
   9.132                    
   9.133 -    int result = sqlite3_step(session->exists_trust_entry);
   9.134 +    int result = Sqlite3_step(session->exists_trust_entry);
   9.135      switch (result) {
   9.136          case SQLITE_ROW: {
   9.137              // yeah yeah, I know, we could be lazy here, but it looks bad.
   9.138 @@ -2821,7 +2821,7 @@
   9.139      sqlite3_reset(session->set_pgp_keypair);
   9.140      sqlite3_bind_text(session->set_pgp_keypair, 1, fpr, -1,
   9.141              SQLITE_STATIC);
   9.142 -    result = sqlite3_step(session->set_pgp_keypair);
   9.143 +    result = Sqlite3_step(session->set_pgp_keypair);
   9.144      sqlite3_reset(session->set_pgp_keypair);
   9.145      if (result != SQLITE_DONE) {
   9.146          return PEP_CANNOT_SET_PGP_KEYPAIR;
   9.147 @@ -2854,7 +2854,7 @@
   9.148      sqlite3_bind_text(set_or_update, 2, identity->fpr, -1,
   9.149              SQLITE_STATIC);
   9.150      sqlite3_bind_int(set_or_update, 3, identity->comm_type);
   9.151 -    result = sqlite3_step(set_or_update);
   9.152 +    result = Sqlite3_step(set_or_update);
   9.153      assert(result == SQLITE_DONE);
   9.154      sqlite3_reset(set_or_update);
   9.155      if (result != SQLITE_DONE)
   9.156 @@ -2882,7 +2882,7 @@
   9.157              SQLITE_STATIC);
   9.158      sqlite3_bind_int(set_or_update, 4, identity->flags);
   9.159      sqlite3_bind_int(set_or_update, 5, identity->me);
   9.160 -    int result = sqlite3_step(set_or_update);
   9.161 +    int result = Sqlite3_step(set_or_update);
   9.162      sqlite3_reset(set_or_update);
   9.163      if (result != SQLITE_DONE)
   9.164          return PEP_CANNOT_SET_IDENTITY;
   9.165 @@ -2912,7 +2912,7 @@
   9.166          sqlite3_bind_null(set_or_update, 3);
   9.167      sqlite3_bind_text(set_or_update, 4, identity->fpr, -1,
   9.168                        SQLITE_STATIC);
   9.169 -    int result = sqlite3_step(set_or_update);
   9.170 +    int result = Sqlite3_step(set_or_update);
   9.171      sqlite3_reset(set_or_update);
   9.172      
   9.173      if (result != SQLITE_DONE)
   9.174 @@ -3028,7 +3028,7 @@
   9.175          sqlite3_reset(session->set_pgp_keypair);
   9.176          sqlite3_bind_text(session->set_pgp_keypair, 1, identity->fpr, -1,
   9.177                  SQLITE_STATIC);
   9.178 -        result = sqlite3_step(session->set_pgp_keypair);
   9.179 +        result = Sqlite3_step(session->set_pgp_keypair);
   9.180          sqlite3_reset(session->set_pgp_keypair);
   9.181          if (result != SQLITE_DONE) {
   9.182              sqlite3_exec(session->db, "ROLLBACK ;", NULL, NULL, NULL);
   9.183 @@ -3081,7 +3081,7 @@
   9.184      sqlite3_reset(session->update_trust_to_pEp);
   9.185      sqlite3_bind_text(session->update_trust_to_pEp, 1, user->user_id, -1,
   9.186              SQLITE_STATIC);
   9.187 -    int result = sqlite3_step(session->update_trust_to_pEp);
   9.188 +    int result = Sqlite3_step(session->update_trust_to_pEp);
   9.189      sqlite3_reset(session->update_trust_to_pEp);
   9.190      if (result != SQLITE_DONE)
   9.191          return PEP_CANNOT_SET_TRUST;
   9.192 @@ -3116,7 +3116,7 @@
   9.193      sqlite3_reset(session->set_as_pEp_user);
   9.194      sqlite3_bind_text(session->set_as_pEp_user, 1, user->user_id, -1,
   9.195              SQLITE_STATIC);
   9.196 -    int result = sqlite3_step(session->set_as_pEp_user);
   9.197 +    int result = Sqlite3_step(session->set_as_pEp_user);
   9.198      sqlite3_reset(session->set_as_pEp_user);
   9.199      
   9.200      if (result != SQLITE_DONE)
   9.201 @@ -3151,7 +3151,7 @@
   9.202          sqlite3_reset(session->exists_person);
   9.203          sqlite3_bind_text(session->exists_person, 1, user_id, -1,
   9.204                  SQLITE_STATIC);
   9.205 -        int result = sqlite3_step(session->exists_person);
   9.206 +        int result = Sqlite3_step(session->exists_person);
   9.207          switch (result) {
   9.208              case SQLITE_ROW: {
   9.209                  // yeah yeah, I know, we could be lazy here, but it looks bad.
   9.210 @@ -3189,7 +3189,7 @@
   9.211      sqlite3_bind_text(session->delete_person, 1, user_id, -1,
   9.212                        SQLITE_STATIC);
   9.213                        
   9.214 -    int result = sqlite3_step(session->delete_person);
   9.215 +    int result = Sqlite3_step(session->delete_person);
   9.216      
   9.217      if (result != SQLITE_DONE)
   9.218          status = PEP_UNKNOWN_ERROR;
   9.219 @@ -3224,7 +3224,7 @@
   9.220      sqlite3_reset(session->is_pEp_user);
   9.221      sqlite3_bind_text(session->is_pEp_user, 1, user_id, -1,
   9.222              SQLITE_STATIC);
   9.223 -    int result = sqlite3_step(session->is_pEp_user);
   9.224 +    int result = Sqlite3_step(session->is_pEp_user);
   9.225      switch (result) {
   9.226          case SQLITE_ROW: {
   9.227              // yeah yeah, I know, we could be lazy here, but it looks bad.
   9.228 @@ -3260,7 +3260,7 @@
   9.229      sqlite3_reset(session->is_own_address);
   9.230      sqlite3_bind_text(session->is_own_address, 1, address, -1,
   9.231              SQLITE_STATIC);
   9.232 -    int result = sqlite3_step(session->is_own_address);
   9.233 +    int result = Sqlite3_step(session->is_own_address);
   9.234      switch (result) {
   9.235          case SQLITE_ROW: {
   9.236              // yeah yeah, I know, we could be lazy here, but it looks bad.
   9.237 @@ -3292,7 +3292,7 @@
   9.238      sqlite3_bind_text(session->add_into_social_graph, 3, contact_ident->user_id, -1,
   9.239              SQLITE_STATIC);
   9.240          
   9.241 -    int result = sqlite3_step(session->add_into_social_graph);
   9.242 +    int result = Sqlite3_step(session->add_into_social_graph);
   9.243      sqlite3_reset(session->add_into_social_graph);
   9.244      
   9.245      if (result != SQLITE_DONE)
   9.246 @@ -3321,7 +3321,7 @@
   9.247      sqlite3_bind_text(session->get_own_address_binding_from_contact, 2, contact->user_id, -1,
   9.248              SQLITE_STATIC);
   9.249  
   9.250 -    int result = sqlite3_step(session->get_own_address_binding_from_contact);
   9.251 +    int result = Sqlite3_step(session->get_own_address_binding_from_contact);
   9.252      
   9.253      const char* own_address = NULL;
   9.254      
   9.255 @@ -3357,7 +3357,7 @@
   9.256      sqlite3_bind_text(session->remove_fpr_as_default, 1, fpr, -1,
   9.257                        SQLITE_STATIC);
   9.258  
   9.259 -    int result = sqlite3_step(session->remove_fpr_as_default);
   9.260 +    int result = Sqlite3_step(session->remove_fpr_as_default);
   9.261      sqlite3_reset(session->remove_fpr_as_default);
   9.262      
   9.263      if (result != SQLITE_DONE)
   9.264 @@ -3383,7 +3383,7 @@
   9.265      sqlite3_bind_text(session->replace_identities_fpr, 2, old_fpr, -1,
   9.266                        SQLITE_STATIC);
   9.267  
   9.268 -    int result = sqlite3_step(session->replace_identities_fpr);
   9.269 +    int result = Sqlite3_step(session->replace_identities_fpr);
   9.270      sqlite3_reset(session->replace_identities_fpr);
   9.271      
   9.272      if (result != SQLITE_DONE)
   9.273 @@ -3403,7 +3403,7 @@
   9.274      sqlite3_bind_int(session->update_trust_for_fpr, 1, comm_type);
   9.275      sqlite3_bind_text(session->update_trust_for_fpr, 2, fpr, -1,
   9.276              SQLITE_STATIC);
   9.277 -    int result = sqlite3_step(session->update_trust_for_fpr);
   9.278 +    int result = Sqlite3_step(session->update_trust_for_fpr);
   9.279      sqlite3_reset(session->update_trust_for_fpr);
   9.280      if (result != SQLITE_DONE) {
   9.281          return PEP_CANNOT_SET_TRUST;
   9.282 @@ -3435,7 +3435,7 @@
   9.283      sqlite3_bind_text(session->set_identity_flags, 3, identity->user_id, -1,
   9.284          SQLITE_STATIC);
   9.285          
   9.286 -    result = sqlite3_step(session->set_identity_flags);
   9.287 +    result = Sqlite3_step(session->set_identity_flags);
   9.288  
   9.289      sqlite3_reset(session->set_identity_flags);
   9.290      if (result != SQLITE_DONE)
   9.291 @@ -3467,7 +3467,7 @@
   9.292              SQLITE_STATIC);
   9.293      sqlite3_bind_text(session->unset_identity_flags, 3, identity->user_id, -1,
   9.294              SQLITE_STATIC);
   9.295 -    result = sqlite3_step(session->unset_identity_flags);
   9.296 +    result = Sqlite3_step(session->unset_identity_flags);
   9.297      sqlite3_reset(session->unset_identity_flags);
   9.298      if (result != SQLITE_DONE)
   9.299          return PEP_CANNOT_SET_IDENTITY;
   9.300 @@ -3491,7 +3491,7 @@
   9.301      sqlite3_reset(session->get_trust_by_userid);
   9.302      sqlite3_bind_text(session->get_trust_by_userid, 1, user_id, -1, SQLITE_STATIC);
   9.303  
   9.304 -    while ((result = sqlite3_step(session->get_trust_by_userid)) == SQLITE_ROW) {
   9.305 +    while ((result = Sqlite3_step(session->get_trust_by_userid)) == SQLITE_ROW) {
   9.306          if (!t_list)
   9.307              t_list = new_labeled_int_list(sqlite3_column_int(session->get_trust_by_userid, 1),
   9.308                                           (const char *) sqlite3_column_text(session->get_trust_by_userid, 0));
   9.309 @@ -3822,7 +3822,7 @@
   9.310              SQLITE_STATIC);
   9.311      sqlite3_bind_text(session->replace_userid, 2, old_uid, -1,
   9.312              SQLITE_STATIC);
   9.313 -    result = sqlite3_step(session->replace_userid);
   9.314 +    result = Sqlite3_step(session->replace_userid);
   9.315  #ifndef NDEBUG
   9.316      if (result) {
   9.317          const char *errmsg = sqlite3_errmsg(session->db);
   9.318 @@ -3848,7 +3848,7 @@
   9.319      sqlite3_reset(session->delete_key);
   9.320      sqlite3_bind_text(session->delete_key, 1, fpr, -1,
   9.321              SQLITE_STATIC);
   9.322 -    result = sqlite3_step(session->delete_key);
   9.323 +    result = Sqlite3_step(session->delete_key);
   9.324      sqlite3_reset(session->delete_key);
   9.325      if (result != SQLITE_DONE)
   9.326          return PEP_CANNOT_SET_PGP_KEYPAIR;
   9.327 @@ -3869,7 +3869,7 @@
   9.328      sqlite3_reset(session->refresh_userid_default_key);
   9.329      sqlite3_bind_text(session->refresh_userid_default_key, 1, user_id, -1,
   9.330              SQLITE_STATIC);
   9.331 -    result = sqlite3_step(session->refresh_userid_default_key);
   9.332 +    result = Sqlite3_step(session->refresh_userid_default_key);
   9.333      sqlite3_reset(session->refresh_userid_default_key);
   9.334      if (result != SQLITE_DONE)
   9.335          return PEP_CANNOT_SET_PERSON;
   9.336 @@ -3893,7 +3893,7 @@
   9.337              SQLITE_STATIC);
   9.338      sqlite3_bind_text(session->replace_main_user_fpr, 2, user_id, -1,
   9.339              SQLITE_STATIC);
   9.340 -    result = sqlite3_step(session->replace_main_user_fpr);
   9.341 +    result = Sqlite3_step(session->replace_main_user_fpr);
   9.342      sqlite3_reset(session->replace_main_user_fpr);
   9.343      if (result != SQLITE_DONE)
   9.344          return PEP_CANNOT_SET_PERSON;
   9.345 @@ -3920,7 +3920,7 @@
   9.346      sqlite3_reset(session->get_main_user_fpr);
   9.347      sqlite3_bind_text(session->get_main_user_fpr, 1, user_id, -1,
   9.348                        SQLITE_STATIC);
   9.349 -    result = sqlite3_step(session->get_main_user_fpr);
   9.350 +    result = Sqlite3_step(session->get_main_user_fpr);
   9.351      switch (result) {
   9.352      case SQLITE_ROW: {
   9.353          const char* _fpr = 
   9.354 @@ -3968,7 +3968,7 @@
   9.355      sqlite3_reset(session->mark_compromised);
   9.356      sqlite3_bind_text(session->mark_compromised, 1, fpr, -1,
   9.357              SQLITE_STATIC);
   9.358 -    result = sqlite3_step(session->mark_compromised);
   9.359 +    result = Sqlite3_step(session->mark_compromised);
   9.360      sqlite3_reset(session->mark_compromised);
   9.361  
   9.362      if (result != SQLITE_DONE)
   9.363 @@ -4008,7 +4008,7 @@
   9.364              SQLITE_STATIC);
   9.365      sqlite3_bind_text(session->get_trust, 2, identity->fpr, -1, SQLITE_STATIC);
   9.366  
   9.367 -    result = sqlite3_step(session->get_trust);
   9.368 +    result = Sqlite3_step(session->get_trust);
   9.369      switch (result) {
   9.370      case SQLITE_ROW: {
   9.371          int comm_type = (PEP_comm_type) sqlite3_column_int(session->get_trust,
   9.372 @@ -4047,7 +4047,7 @@
   9.373      sqlite3_reset(session->least_trust);
   9.374      sqlite3_bind_text(session->least_trust, 1, fpr, -1, SQLITE_STATIC);
   9.375  
   9.376 -    result = sqlite3_step(session->least_trust);
   9.377 +    result = Sqlite3_step(session->least_trust);
   9.378      switch (result) {
   9.379          case SQLITE_ROW: {
   9.380              int _comm_type = sqlite3_column_int(session->least_trust, 0);
   9.381 @@ -4478,7 +4478,7 @@
   9.382      int result;
   9.383  
   9.384      do {
   9.385 -        result = sqlite3_step(session->crashdump);
   9.386 +        result = Sqlite3_step(session->crashdump);
   9.387          switch (result) {
   9.388          case SQLITE_ROW:
   9.389              timestamp = (const char *) sqlite3_column_text(session->crashdump,
   9.390 @@ -4570,7 +4570,7 @@
   9.391      int result;
   9.392  
   9.393      do {
   9.394 -        result = sqlite3_step(session->languagelist);
   9.395 +        result = Sqlite3_step(session->languagelist);
   9.396          switch (result) {
   9.397          case SQLITE_ROW:
   9.398              lang = (const char *) sqlite3_column_text(session->languagelist,
   9.399 @@ -4638,7 +4638,7 @@
   9.400      const char *_phrase = NULL;
   9.401      int result;
   9.402  
   9.403 -    result = sqlite3_step(session->i18n_token);
   9.404 +    result = Sqlite3_step(session->i18n_token);
   9.405      switch (result) {
   9.406      case SQLITE_ROW:
   9.407          _phrase = (const char *) sqlite3_column_text(session->i18n_token, 0);
   9.408 @@ -4680,7 +4680,7 @@
   9.409      sqlite3_reset(session->sequence_value2);
   9.410      sqlite3_bind_text(session->sequence_value2, 1, name, -1,
   9.411              SQLITE_STATIC);
   9.412 -    int result = sqlite3_step(session->sequence_value2);
   9.413 +    int result = Sqlite3_step(session->sequence_value2);
   9.414      switch (result) {
   9.415          case SQLITE_ROW: {
   9.416              int32_t _value = (int32_t)
   9.417 @@ -4708,7 +4708,7 @@
   9.418  
   9.419      sqlite3_reset(session->sequence_value1);
   9.420      sqlite3_bind_text(session->sequence_value1, 1, name, -1, SQLITE_STATIC);
   9.421 -    int result = sqlite3_step(session->sequence_value1);
   9.422 +    int result = Sqlite3_step(session->sequence_value1);
   9.423      assert(result == SQLITE_DONE);
   9.424      sqlite3_reset(session->sequence_value1);
   9.425      if (result == SQLITE_DONE)
   9.426 @@ -4769,7 +4769,7 @@
   9.427      
   9.428      sqlite3_bind_text(session->own_key_is_listed, 1, fpr, -1,
   9.429              SQLITE_STATIC);
   9.430 -    int result = sqlite3_step(session->own_key_is_listed);
   9.431 +    int result = Sqlite3_step(session->own_key_is_listed);
   9.432      switch (result) {
   9.433          case SQLITE_ROW: {
   9.434              *own_key = (sqlite3_column_int(session->own_key_is_listed, 0) != 0);
   9.435 @@ -4813,7 +4813,7 @@
   9.436  
   9.437      int result;
   9.438      
   9.439 -    result = sqlite3_step(session->set_revoked);
   9.440 +    result = Sqlite3_step(session->set_revoked);
   9.441      switch (result) {
   9.442          case SQLITE_DONE:
   9.443              status = PEP_STATUS_OK;
   9.444 @@ -4855,7 +4855,7 @@
   9.445  
   9.446      int result;
   9.447      
   9.448 -    result = sqlite3_step(session->get_revoked);
   9.449 +    result = Sqlite3_step(session->get_revoked);
   9.450      switch (result) {
   9.451          case SQLITE_ROW: {
   9.452              *revoked_fpr = strdup((const char *)
   9.453 @@ -4899,7 +4899,7 @@
   9.454  
   9.455      int result;
   9.456      
   9.457 -    result = sqlite3_step(session->get_replacement_fpr);
   9.458 +    result = Sqlite3_step(session->get_replacement_fpr);
   9.459      switch (result) {
   9.460          case SQLITE_ROW: {
   9.461              *revoked_fpr = strdup((const char *)
   9.462 @@ -4938,7 +4938,7 @@
   9.463      sqlite3_reset(session->get_last_contacted);
   9.464      int result;
   9.465  
   9.466 -    while ((result = sqlite3_step(session->get_last_contacted)) == SQLITE_ROW) {
   9.467 +    while ((result = Sqlite3_step(session->get_last_contacted)) == SQLITE_ROW) {
   9.468          pEp_identity *ident = new_identity(
   9.469                  (const char *) sqlite3_column_text(session->get_last_contacted, 1),
   9.470                  NULL,
    10.1 --- a/src/pEpEngine.h	Mon May 20 14:50:00 2019 +0200
    10.2 +++ b/src/pEpEngine.h	Tue May 28 07:55:50 2019 +0200
    10.3 @@ -103,6 +103,7 @@
    10.4      PEP_SYNC_NO_CHANNEL                             = 0x0904,
    10.5      PEP_SYNC_CANNOT_ENCRYPT                         = 0x0905,
    10.6      PEP_SYNC_NO_MESSAGE_SEND_CALLBACK               = 0x0906,
    10.7 +    PEP_SYNC_CANNOT_START                           = 0x0907,
    10.8  
    10.9      PEP_CANNOT_INCREASE_SEQUENCE                    = 0x0971,
   10.10  
    11.1 --- a/src/pEp_internal.h	Mon May 20 14:50:00 2019 +0200
    11.2 +++ b/src/pEp_internal.h	Tue May 28 07:55:50 2019 +0200
    11.3 @@ -475,3 +475,15 @@
    11.4      _pEp_rand_max_bits = (int) ceil(log2((double) RAND_MAX));
    11.5      _pEp_log2_36 = log2(36);
    11.6  }
    11.7 +
    11.8 +// spinlock implementation
    11.9 +
   11.10 +static inline int Sqlite3_step(sqlite3_stmt* stmt)
   11.11 +{
   11.12 +    int rc;
   11.13 +    do {
   11.14 +        rc = sqlite3_step(stmt);
   11.15 +    } while (rc == SQLITE_BUSY || rc == SQLITE_LOCKED);
   11.16 +    return rc;
   11.17 +}
   11.18 +
    12.1 --- a/src/pgp_sequoia.c	Mon May 20 14:50:00 2019 +0200
    12.2 +++ b/src/pgp_sequoia.c	Tue May 28 07:55:50 2019 +0200
    12.3 @@ -455,7 +455,7 @@
    12.4                             pgp_tpk_t *tpkp, int *secretp)
    12.5  {
    12.6      PEP_STATUS status = PEP_STATUS_OK;
    12.7 -    int sqlite_result = sqlite3_step(stmt);
    12.8 +    int sqlite_result = Sqlite3_step(stmt);
    12.9      switch (sqlite_result) {
   12.10      case SQLITE_ROW:
   12.11          if (tpkp) {
   12.12 @@ -701,7 +701,7 @@
   12.13      char *name = NULL;
   12.14  
   12.15      sqlite3_stmt *stmt = session->sq_sql.begin_transaction;
   12.16 -    int sqlite_result = sqlite3_step(stmt);
   12.17 +    int sqlite_result = Sqlite3_step(stmt);
   12.18      sqlite3_reset(stmt);
   12.19      if (sqlite_result != SQLITE_DONE)
   12.20          ERROR_OUT(NULL, PEP_UNKNOWN_ERROR,
   12.21 @@ -747,7 +747,7 @@
   12.22      sqlite3_bind_int(stmt, 2, is_tsk);
   12.23      sqlite3_bind_blob(stmt, 3, tsk_buffer, tsk_buffer_len, SQLITE_STATIC);
   12.24  
   12.25 -    sqlite_result = sqlite3_step(stmt);
   12.26 +    sqlite_result = Sqlite3_step(stmt);
   12.27      sqlite3_reset(stmt);
   12.28      if (sqlite_result != SQLITE_DONE)
   12.29          ERROR_OUT(NULL, PEP_UNKNOWN_ERROR,
   12.30 @@ -765,7 +765,7 @@
   12.31          sqlite3_bind_text(stmt, 1, keyid_hex, -1, SQLITE_STATIC);
   12.32          sqlite3_bind_text(stmt, 2, fpr, -1, SQLITE_STATIC);
   12.33  
   12.34 -        sqlite_result = sqlite3_step(stmt);
   12.35 +        sqlite_result = Sqlite3_step(stmt);
   12.36          sqlite3_reset(stmt);
   12.37          free(keyid_hex);
   12.38          pgp_keyid_free(keyid);
   12.39 @@ -855,7 +855,7 @@
   12.40              sqlite3_bind_text(stmt, 1, email, -1, SQLITE_STATIC);
   12.41              sqlite3_bind_text(stmt, 2, fpr, -1, SQLITE_STATIC);
   12.42  
   12.43 -            sqlite_result = sqlite3_step(stmt);
   12.44 +            sqlite_result = Sqlite3_step(stmt);
   12.45              sqlite3_reset(stmt);
   12.46  
   12.47              if (sqlite_result != SQLITE_DONE) {
   12.48 @@ -889,7 +889,7 @@
   12.49          stmt = status == PEP_STATUS_OK
   12.50              ? session->sq_sql.commit_transaction
   12.51              : session->sq_sql.rollback_transaction;
   12.52 -        int sqlite_result = sqlite3_step(stmt);
   12.53 +        int sqlite_result = Sqlite3_step(stmt);
   12.54          sqlite3_reset(stmt);
   12.55          if (sqlite_result != SQLITE_DONE)
   12.56              ERROR_OUT(NULL, PEP_UNKNOWN_ERROR,
    13.1 --- a/src/sync_api.c	Mon May 20 14:50:00 2019 +0200
    13.2 +++ b/src/sync_api.c	Tue May 28 07:55:50 2019 +0200
    13.3 @@ -19,6 +19,15 @@
    13.4      if (!(session && notifyHandshake && retrieve_next_sync_event))
    13.5          return PEP_ILLEGAL_VALUE;
    13.6  
    13.7 +    identity_list *own_identities = NULL;
    13.8 +    PEP_STATUS status = own_identities_retrieve(session, &own_identities);
    13.9 +    if (status)
   13.10 +        return status;
   13.11 +    bool own_identities_available = own_identities && own_identities->ident;
   13.12 +    free_identity_list(own_identities);
   13.13 +    if (!own_identities_available)
   13.14 +        return PEP_SYNC_CANNOT_START;
   13.15 +
   13.16      session->sync_management = management;
   13.17      session->notifyHandshake = notifyHandshake;
   13.18      session->retrieve_next_sync_event = retrieve_next_sync_event;
    14.1 --- a/sync/sql_func.yml2	Mon May 20 14:50:00 2019 +0200
    14.2 +++ b/sync/sql_func.yml2	Tue May 28 07:55:50 2019 +0200
    14.3 @@ -31,7 +31,7 @@
    14.4      call "init_sql" with "sql", "$sql";
    14.5      ||
    14.6          int _result = 0;
    14.7 -        int_result = sqlite3_step(_sql);
    14.8 +        int_result = Sqlite3_step(_sql);
    14.9          assert(int_result == SQLITE_ROW);
   14.10          if (int_result == SQLITE_ROW)
   14.11              _result = sqlite3_column_int(_sql, 0);