merged w default krista_local_windows
authorkrista
Tue, 02 Aug 2016 12:55:50 +0200
branchkrista_local_windows
changeset 1124e50b654b3e14
parent 1123 65d39d3f13e6
parent 962 aff7b6e41fde
child 1125 89e75396c69a
merged w default
asn.1/pEpEngineASN1/pEpEngineASN1.vcxproj
     1.1 --- a/asn.1/pEpEngineASN1/pEpEngineASN1.vcxproj	Tue Jul 26 11:48:22 2016 +0200
     1.2 +++ b/asn.1/pEpEngineASN1/pEpEngineASN1.vcxproj	Tue Aug 02 12:55:50 2016 +0200
     1.3 @@ -61,23 +61,25 @@
     1.4        <GenerateDebugInformation>true</GenerateDebugInformation>
     1.5      </Link>
     1.6      <PreBuildEvent>
     1.7 -      <Command>
     1.8 -      </Command>
     1.9 -    </PreBuildEvent>
    1.10 -    <PreBuildEvent>
    1.11 -      <Message>ASN.1 source generation</Message>
    1.12 -    </PreBuildEvent>
    1.13 -    <CustomBuildStep>
    1.14        <Command>cd ..
    1.15  asn1c -gen-PER -fincludes-quoted -fcompound-names -pdu=PEP.Message pEp.asn1 devicegroup.asn1
    1.16  del converter-sample.c
    1.17  </Command>
    1.18 +    </PreBuildEvent>
    1.19 +    <PreBuildEvent>
    1.20 +      <Message>compiling ASN.1 description</Message>
    1.21 +    </PreBuildEvent>
    1.22 +    <CustomBuildStep>
    1.23 +      <Command>
    1.24 +      </Command>
    1.25      </CustomBuildStep>
    1.26      <CustomBuildStep>
    1.27 -      <Message>compiling ASN.1 description</Message>
    1.28 +      <Message>
    1.29 +      </Message>
    1.30      </CustomBuildStep>
    1.31      <CustomBuildStep>
    1.32 -      <Outputs>$(ProjectDir)..\DeviceGroup-Protocol.c;%(Outputs)</Outputs>
    1.33 +      <Outputs>
    1.34 +      </Outputs>
    1.35      </CustomBuildStep>
    1.36    </ItemDefinitionGroup>
    1.37    <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
    1.38 @@ -97,20 +99,23 @@
    1.39        <OptimizeReferences>true</OptimizeReferences>
    1.40      </Link>
    1.41      <PreBuildEvent>
    1.42 -      <Command>
    1.43 -      </Command>
    1.44 -    </PreBuildEvent>
    1.45 -    <CustomBuildStep>
    1.46        <Command>cd ..
    1.47  asn1c -gen-PER -fincludes-quoted -fcompound-names -pdu=PEP.Message pEp.asn1 devicegroup.asn1
    1.48  del converter-sample.c
    1.49  </Command>
    1.50 +      <Message>compiling ASN.1 description</Message>
    1.51 +    </PreBuildEvent>
    1.52 +    <CustomBuildStep>
    1.53 +      <Command>
    1.54 +      </Command>
    1.55      </CustomBuildStep>
    1.56      <CustomBuildStep>
    1.57 -      <Message>compiling ASN.1 description</Message>
    1.58 +      <Message>
    1.59 +      </Message>
    1.60      </CustomBuildStep>
    1.61      <CustomBuildStep>
    1.62 -      <Outputs>$(ProjectDir)..\DeviceGroup-Protocol.c;%(Outputs)</Outputs>
    1.63 +      <Outputs>
    1.64 +      </Outputs>
    1.65      </CustomBuildStep>
    1.66    </ItemDefinitionGroup>
    1.67    <ItemGroup>
     2.1 --- a/db/create_system_db.sql	Tue Jul 26 11:48:22 2016 +0200
     2.2 +++ b/db/create_system_db.sql	Tue Aug 02 12:55:50 2016 +0200
     2.3 @@ -42,6 +42,6 @@
     2.4  INSERT INTO i18n_token VALUES ('ca', 1000, 'Vull mostrar les trustwords en català');
     2.5  
     2.6  INSERT INTO i18n_language VALUES ('tr', 'Türkçe');
     2.7 -INSERT INTO i18n_token VALUES ('tr', 1000, 'Güvenlik kelimelerini Türk dilinde görüntülemek istiyorum.');
     2.8 +INSERT INTO i18n_token VALUES ('tr', 1000, 'Güvenlik kelimelerini Türk dilinde görüntülemek istiyorum');
     2.9  -- add more languages here
    2.10  
     3.1 --- a/src/keymanagement.c	Tue Jul 26 11:48:22 2016 +0200
     3.2 +++ b/src/keymanagement.c	Tue Aug 02 12:55:50 2016 +0200
     3.3 @@ -134,7 +134,7 @@
     3.4          snprintf(identity->user_id, strlen(identity->address) + 5,
     3.5                   "TOFU_%s", identity->address);
     3.6      }
     3.7 -    
     3.8 + 
     3.9      status = get_identity(session,
    3.10                            identity->address,
    3.11                            identity->user_id,
    3.12 @@ -203,8 +203,12 @@
    3.13              identity->lang[1] = stored_identity->lang[1];
    3.14              identity->lang[2] = 0;
    3.15          }
    3.16 +
    3.17 +        identity->flags = stored_identity->flags;
    3.18      }
    3.19      else /* stored_identity == NULL */ {
    3.20 +        identity->flags = 0;
    3.21 +
    3.22          if (!EMPTYSTR(identity->fpr)) {
    3.23              PEP_comm_type _comm_type_key;
    3.24  
    3.25 @@ -230,6 +234,7 @@
    3.26          if (EMPTYSTR(identity->username)) { // mitigate
    3.27              free(identity->username);
    3.28              identity->username = strdup("anonymous");
    3.29 +            assert(identity->username);
    3.30              if (identity->username == NULL){
    3.31                  status = PEP_OUT_OF_MEMORY;
    3.32                  goto exit_free;
    3.33 @@ -389,6 +394,8 @@
    3.34                  return PEP_OUT_OF_MEMORY;
    3.35              }
    3.36          }
    3.37 +
    3.38 +        identity->flags = stored_identity->flags;
    3.39      }
    3.40      else if (!EMPTYSTR(identity->fpr))
    3.41      {
    3.42 @@ -396,6 +403,8 @@
    3.43          // import of private key, or similar.
    3.44  
    3.45          // Take given fpr as-is.
    3.46 +
    3.47 +        identity->flags = 0;
    3.48      }
    3.49      else
    3.50      {
    3.51 @@ -404,6 +413,8 @@
    3.52          if (status != PEP_STATUS_OK) {
    3.53              return status;
    3.54          }
    3.55 +
    3.56 +        identity->flags = 0;
    3.57      }
    3.58  
    3.59      bool revoked = false;
     4.1 --- a/src/keymanagement.h	Tue Jul 26 11:48:22 2016 +0200
     4.2 +++ b/src/keymanagement.h	Tue Aug 02 12:55:50 2016 +0200
     4.3 @@ -18,6 +18,8 @@
     4.4  //      asynchronous management implementation, so retrieve_next_identity()
     4.5  //      will return this identity later
     4.6  //      at least identity->address must be a non-empty UTF-8 string as input
     4.7 +//      update_identity() never writes flags; use set_identity_flags() for
     4.8 +//      writing
     4.9  
    4.10  DYNAMIC_API PEP_STATUS update_identity(
    4.11          PEP_SESSION session, pEp_identity * identity
    4.12 @@ -40,6 +42,7 @@
    4.13  //      it can need a decent amount of time to return
    4.14  //      if you need to do this asynchronous, you need to return an identity
    4.15  //      with retrieve_next_identity() where pEp_identity.me is true
    4.16 +//      myself() never writes flags; use set_identity_flags() for writing
    4.17  
    4.18  DYNAMIC_API PEP_STATUS myself(PEP_SESSION session, pEp_identity * identity);
    4.19  
     5.1 --- a/src/message_api.c	Tue Jul 26 11:48:22 2016 +0200
     5.2 +++ b/src/message_api.c	Tue Aug 02 12:55:50 2016 +0200
     5.3 @@ -102,21 +102,20 @@
     5.4      if (longmsg == NULL)
     5.5          longmsg = "";
     5.6  
     5.7 -    size_t bufsize = strlen(shortmsg) + strlen(longmsg) + 12;
     5.8 +    const char * const subject = "Subject: ";
     5.9 +    const size_t SUBJ_LEN = 9;
    5.10 +    const char * const newlines = "\n\n";
    5.11 +    const size_t NL_LEN = 2;
    5.12 +
    5.13 +    size_t bufsize = SUBJ_LEN + strlen(shortmsg) + NL_LEN + strlen(longmsg) + 1;
    5.14      ptext = calloc(1, bufsize);
    5.15      assert(ptext);
    5.16      if (ptext == NULL)
    5.17          return NULL;
    5.18  
    5.19 -    strlcpy(ptext, "Subject: ", bufsize);
    5.20 -    bufsize -= 9;
    5.21 -    
    5.22 +    strlcpy(ptext, subject, bufsize);
    5.23      strlcat(ptext, shortmsg, bufsize);
    5.24 -    bufsize -= strlen(shortmsg);
    5.25 -    
    5.26 -    strlcat(ptext, "\n\n", bufsize);
    5.27 -    bufsize -= 2;
    5.28 -    
    5.29 +    strlcat(ptext, newlines, bufsize);
    5.30      strlcat(ptext, longmsg, bufsize);
    5.31  
    5.32      return ptext;
    5.33 @@ -628,7 +627,7 @@
    5.34      case PEP_rating_b0rken:
    5.35          return "b0rken";
    5.36      case PEP_rating_under_attack:
    5.37 -        return "unter_attack";
    5.38 +        return "under_attack";
    5.39      default:
    5.40          return "undefined";
    5.41      }
    5.42 @@ -642,7 +641,7 @@
    5.43  {
    5.44      assert(msg);
    5.45  
    5.46 -    add_opt_field(msg, "X-pEp-Version", "1.0");
    5.47 +    add_opt_field(msg, "X-pEp-Version", PEP_VERSION);
    5.48      
    5.49      if (color != PEP_rating_undefined)
    5.50          add_opt_field(msg, "X-EncStatus", color_to_string(color));
    5.51 @@ -1599,8 +1598,8 @@
    5.52      if (!(session && msg && ident))
    5.53          return PEP_ILLEGAL_VALUE;
    5.54  
    5.55 -    message *dst; 
    5.56 -    stringlist_t *keylist;
    5.57 +    message *dst = NULL; 
    5.58 +    stringlist_t *keylist = NULL;
    5.59      PEP_color color;
    5.60      PEP_decrypt_flags_t flags; 
    5.61  
    5.62 @@ -1617,6 +1616,8 @@
    5.63      }
    5.64  
    5.65      free_identity_list(private_il);
    5.66 +    free_stringlist(keylist);
    5.67 +    free_message(dst);
    5.68  
    5.69      return status;
    5.70  
     6.1 --- a/src/pEpEngine.c	Tue Jul 26 11:48:22 2016 +0200
     6.2 +++ b/src/pEpEngine.c	Tue Aug 02 12:55:50 2016 +0200
     6.3 @@ -6,6 +6,19 @@
     6.4  
     6.5  static int init_count = -1;
     6.6  
     6.7 +static int user_version(void *_version, int count, char **text, char **name)
     6.8 +{
     6.9 +    assert(_version);
    6.10 +    assert(count == 1);
    6.11 +    assert(text && text[0]);
    6.12 +    if (!(_version && count == 1 && text && text[0]))
    6.13 +        return -1;
    6.14 +
    6.15 +    int *version = (int *) _version;
    6.16 +    *version = atoi(text[0]);
    6.17 +    return 0;
    6.18 +}
    6.19 +
    6.20  DYNAMIC_API PEP_STATUS init(PEP_SESSION *session)
    6.21  {
    6.22      PEP_STATUS status = PEP_STATUS_OK;
    6.23 @@ -16,6 +29,7 @@
    6.24      static const char *sql_set_person;
    6.25      static const char *sql_set_pgp_keypair;
    6.26      static const char *sql_set_identity;
    6.27 +    static const char *sql_set_identity_flags;
    6.28      static const char *sql_set_trust;
    6.29      static const char *sql_get_trust;
    6.30      static const char *sql_least_trust;
    6.31 @@ -112,15 +126,37 @@
    6.32  
    6.33      sqlite3_busy_timeout(_session->system_db, 1000);
    6.34  
    6.35 +// increment this when patching DDL
    6.36 +#define _DDL_USER_VERSION "1"
    6.37 +
    6.38      if (in_first) {
    6.39          int_result = sqlite3_exec(
    6.40              _session->db,
    6.41 -                "create table if not exists version_info (\n"
    6.42 +                "create table version_info (\n"
    6.43                  "   id integer primary key,\n"
    6.44                  "   timestamp integer default (datetime('now')) ,\n"
    6.45                  "   version text,\n"
    6.46                  "   comment text\n"
    6.47 -                ");\n"
    6.48 +                ");\n",
    6.49 +                NULL,
    6.50 +                NULL,
    6.51 +                NULL
    6.52 +        );
    6.53 +        if (int_result == SQLITE_OK) {
    6.54 +            int_result = sqlite3_exec(
    6.55 +                _session->db,
    6.56 +                "pragma user_version = "_DDL_USER_VERSION";\n"
    6.57 +                "insert or replace into version_info (id, version)"
    6.58 +                    "values (1, '" PEP_ENGINE_VERSION "');",
    6.59 +                NULL,
    6.60 +                NULL,
    6.61 +                NULL
    6.62 +            );
    6.63 +            assert(int_result == SQLITE_OK);
    6.64 +        }
    6.65 +
    6.66 +        int_result = sqlite3_exec(
    6.67 +            _session->db,
    6.68                  "create table if not exists log (\n"
    6.69                  "   timestamp integer default (datetime('now')) ,\n"
    6.70                  "   title text not null,\n"
    6.71 @@ -160,6 +196,7 @@
    6.72                  "       references pgp_keypair (fpr)\n"
    6.73                  "       on delete set null,\n"
    6.74                  "   comment text,\n"
    6.75 +                "   flags integer default (0),"
    6.76                  "   primary key (address, user_id)\n"
    6.77                  ");\n"
    6.78                  "create table if not exists trust (\n"
    6.79 @@ -196,19 +233,45 @@
    6.80          );
    6.81          assert(int_result == SQLITE_OK);
    6.82  
    6.83 +        int version;
    6.84          int_result = sqlite3_exec(
    6.85              _session->db,
    6.86 -            "insert or replace into version_info (id, version) values (1, '1.1');",
    6.87 -            NULL,
    6.88 -            NULL,
    6.89 +            "pragma user_version;",
    6.90 +            user_version,
    6.91 +            &version,
    6.92              NULL
    6.93          );
    6.94          assert(int_result == SQLITE_OK);
    6.95  
    6.96 +        if (version < 1) {
    6.97 +            int_result = sqlite3_exec(
    6.98 +                _session->db,
    6.99 +                "alter table identity\n"
   6.100 +                "   add column flags integer default (0);",
   6.101 +                NULL,
   6.102 +                NULL,
   6.103 +                NULL
   6.104 +            );
   6.105 +            assert(int_result == SQLITE_OK);
   6.106 +        }
   6.107 +
   6.108 +        if (version < atoi(_DDL_USER_VERSION)) {
   6.109 +            int_result = sqlite3_exec(
   6.110 +                _session->db,
   6.111 +                "pragma user_version = "_DDL_USER_VERSION";\n"
   6.112 +                "insert or replace into version_info (id, version)"
   6.113 +                    "values (1, '" PEP_ENGINE_VERSION "');",
   6.114 +                NULL,
   6.115 +                NULL,
   6.116 +                NULL
   6.117 +            );
   6.118 +            assert(int_result == SQLITE_OK);
   6.119 +        }
   6.120 +
   6.121          sql_log = "insert into log (title, entity, description, comment)"
   6.122                    "values (?1, ?2, ?3, ?4);";
   6.123  
   6.124 -        sql_get_identity =  "select fpr, username, comm_type, lang"
   6.125 +        sql_get_identity =  "select fpr, username, comm_type, lang, flags"
   6.126                              "   from identity"
   6.127                              "   join person on id = identity.user_id"
   6.128                              "   join pgp_keypair on fpr = identity.main_key_id"
   6.129 @@ -230,7 +293,11 @@
   6.130                                "values (upper(replace(?1,' ',''))) ;";
   6.131  
   6.132          sql_set_identity = "insert or replace into identity (address, main_key_id, "
   6.133 -                           "user_id) values (?1, upper(replace(?2,' ','')), ?3) ;";
   6.134 +                           "user_id, flags) values (?1, upper(replace(?2,' ','')),"
   6.135 +                           "?3, ?4) ;";
   6.136 +
   6.137 +        sql_set_identity_flags = "update identity set flags = ?1 "
   6.138 +                                 "where address = ?2 and user_id = ?3 ;";
   6.139  
   6.140          sql_set_trust = "insert or replace into trust (user_id, pgp_keypair_fpr, comm_type) "
   6.141                          "values (?1, upper(replace(?2,' ','')), ?3) ;";
   6.142 @@ -322,6 +389,10 @@
   6.143              (int)strlen(sql_set_identity), &_session->set_identity, NULL);
   6.144      assert(int_result == SQLITE_OK);
   6.145  
   6.146 +    int_result = sqlite3_prepare_v2(_session->db, sql_set_identity_flags,
   6.147 +            (int)strlen(sql_set_identity_flags), &_session->set_identity_flags, NULL);
   6.148 +    assert(int_result == SQLITE_OK);
   6.149 +
   6.150      int_result = sqlite3_prepare_v2(_session->db, sql_set_trust,
   6.151              (int)strlen(sql_set_trust), &_session->set_trust, NULL);
   6.152      assert(int_result == SQLITE_OK);
   6.153 @@ -464,6 +535,8 @@
   6.154                  sqlite3_finalize(session->set_pgp_keypair);
   6.155              if (session->set_identity)
   6.156                  sqlite3_finalize(session->set_identity);
   6.157 +            if (session->set_identity_flags)
   6.158 +                sqlite3_finalize(session->set_identity_flags);
   6.159              if (session->set_trust)
   6.160                  sqlite3_finalize(session->set_trust);
   6.161              if (session->get_trust)
   6.162 @@ -486,6 +559,18 @@
   6.163                  sqlite3_finalize(session->blacklist_is_listed);
   6.164              if (session->blacklist_retrieve)
   6.165                  sqlite3_finalize(session->blacklist_retrieve);
   6.166 +            if (session->own_key_is_listed)
   6.167 +                sqlite3_finalize(session->own_key_is_listed);
   6.168 +            if (session->own_key_retrieve)
   6.169 +                sqlite3_finalize(session->own_key_retrieve);
   6.170 +            if (session->sequence_value1)
   6.171 +                sqlite3_finalize(session->sequence_value1);
   6.172 +            if (session->sequence_value2)
   6.173 +                sqlite3_finalize(session->sequence_value2);
   6.174 +            if (session->set_revoked)
   6.175 +                sqlite3_finalize(session->set_revoked);
   6.176 +            if (session->get_revoked)
   6.177 +                sqlite3_finalize(session->get_revoked);
   6.178  
   6.179              if (session->db)
   6.180                  sqlite3_close_v2(session->db);
   6.181 @@ -753,6 +838,7 @@
   6.182      dup->lang[1] = src->lang[1];
   6.183      dup->lang[2] = 0;
   6.184      dup->me = src->me;
   6.185 +    dup->flags = src->flags;
   6.186  
   6.187      return dup;
   6.188  }
   6.189 @@ -815,6 +901,7 @@
   6.190              _identity->lang[1] = _lang[1];
   6.191              _identity->lang[2] = 0;
   6.192          }
   6.193 +        _identity->flags = (unsigned int) sqlite3_column_int(session->get_identity, 4);
   6.194          *identity = _identity;
   6.195          break;
   6.196      default:
   6.197 @@ -890,6 +977,7 @@
   6.198              SQLITE_STATIC);
   6.199      sqlite3_bind_text(session->set_identity, 3, identity->user_id, -1,
   6.200              SQLITE_STATIC);
   6.201 +    sqlite3_bind_int(session->set_identity, 4, identity->flags);
   6.202      result = sqlite3_step(session->set_identity);
   6.203      sqlite3_reset(session->set_identity);
   6.204      if (result != SQLITE_DONE) {
   6.205 @@ -917,6 +1005,37 @@
   6.206          return PEP_COMMIT_FAILED;
   6.207  }
   6.208  
   6.209 +DYNAMIC_API PEP_STATUS set_identity_flags(
   6.210 +        PEP_SESSION session,
   6.211 +        pEp_identity *identity,
   6.212 +        unsigned int flags
   6.213 +    )
   6.214 +{
   6.215 +    int result;
   6.216 +
   6.217 +    assert(session);
   6.218 +    assert(identity);
   6.219 +    assert(identity->address);
   6.220 +    assert(identity->user_id);
   6.221 +
   6.222 +    if (!(session && identity && identity->address && identity->user_id))
   6.223 +        return PEP_ILLEGAL_VALUE;
   6.224 +
   6.225 +    sqlite3_reset(session->set_identity_flags);
   6.226 +    sqlite3_bind_int(session->set_identity_flags, 1, flags);
   6.227 +    sqlite3_bind_text(session->set_identity_flags, 2, identity->address, -1,
   6.228 +            SQLITE_STATIC);
   6.229 +    sqlite3_bind_text(session->set_identity_flags, 3, identity->user_id, -1,
   6.230 +            SQLITE_STATIC);
   6.231 +    result = sqlite3_step(session->set_identity_flags);
   6.232 +    sqlite3_reset(session->set_identity_flags);
   6.233 +    if (result != SQLITE_DONE)
   6.234 +        return PEP_CANNOT_SET_IDENTITY;
   6.235 +
   6.236 +    identity->flags = flags;
   6.237 +    return PEP_STATUS_OK;
   6.238 +}
   6.239 +
   6.240  DYNAMIC_API PEP_STATUS mark_as_compromized(
   6.241          PEP_SESSION session,
   6.242          const char *fpr
     7.1 --- a/src/pEpEngine.h	Tue Jul 26 11:48:22 2016 +0200
     7.2 +++ b/src/pEpEngine.h	Tue Aug 02 12:55:50 2016 +0200
     7.3 @@ -12,7 +12,7 @@
     7.4  #include "stringlist.h"
     7.5  #include "timestamp.h"
     7.6  
     7.7 -#define PEP_VERSION "1.0"
     7.8 +#define PEP_VERSION "1.0" // protocol version
     7.9  
    7.10  #define PEP_OWN_USERID "pEp_own_userId"
    7.11      
    7.12 @@ -379,6 +379,11 @@
    7.13      PEP_ct_pEp = 0xff
    7.14  } PEP_comm_type;
    7.15  
    7.16 +typedef enum _identity_flags {
    7.17 +    PEP_idf_not_for_sync = 1,   // don't use this identity for sync
    7.18 +    PEP_idf_group = 2           // identity of group of persons
    7.19 +} identity_flags;
    7.20 +
    7.21  typedef struct _pEp_identity {
    7.22      char *address;              // C string with address UTF-8 encoded
    7.23      char *fpr;                  // C string with fingerprint UTF-8 encoded
    7.24 @@ -388,6 +393,7 @@
    7.25      char lang[3];               // language of conversation
    7.26                                  // ISO 639-1 ALPHA-2, last byte is 0
    7.27      bool me;                    // if this is the local user herself/himself
    7.28 +    unsigned int flags;         // identity_flag1 | identity_flag2 | ...
    7.29  } pEp_identity;
    7.30  
    7.31  typedef struct _identity_list {
    7.32 @@ -405,7 +411,7 @@
    7.33  //      username (in)       UTF-8 string or NULL 
    7.34  //
    7.35  //  return value:
    7.36 -//      pEp_identity struct with correct size values or NULL if out of memory
    7.37 +//      pEp_identity struct or NULL if out of memory
    7.38  //
    7.39  //  caveat:
    7.40  //      the strings are copied; the original strings are still being owned by
    7.41 @@ -417,13 +423,13 @@
    7.42      );
    7.43  
    7.44  
    7.45 -// identity_dup() - allocate memory and set the string and size fields
    7.46 +// identity_dup() - allocate memory and duplicate
    7.47  //
    7.48  //  parameters:
    7.49  //      src (in)            identity to duplicate
    7.50  //
    7.51  //  return value:
    7.52 -//      pEp_identity struct with correct size values or NULL if out of memory
    7.53 +//      pEp_identity struct or NULL if out of memory
    7.54  //
    7.55  //  caveat:
    7.56  //      the strings are copied; the original strings are still being owned by
    7.57 @@ -480,18 +486,37 @@
    7.58  //        PEP_CANNOT_SET_PGP_KEYPAIR    writing to table pgp_keypair failed
    7.59  //        PEP_CANNOT_SET_IDENTITY       writing to table identity failed
    7.60  //        PEP_COMMIT_FAILED             SQL commit failed
    7.61 -//      PEP_KEY_BLACKLISTED             Key blacklisted, cannot set identity
    7.62 +//        PEP_KEY_BLACKLISTED           Key blacklisted, cannot set identity
    7.63  //
    7.64  //    caveat:
    7.65 -//        in the identity structure you need to set the const char * fields to
    7.66 -//        UTF-8 C strings
    7.67 -//        the size fields are ignored
    7.68 +//        address, fpr, user_id and username must be given
    7.69  
    7.70  DYNAMIC_API PEP_STATUS set_identity(
    7.71          PEP_SESSION session, const pEp_identity *identity
    7.72      );
    7.73  
    7.74  
    7.75 +// set_identity_flags() - update identity flags on existing identity
    7.76 +//
    7.77 +//    parameters:
    7.78 +//        session (in)        session handle
    7.79 +//        identity (in,out)   pointer to pEp_identity structure
    7.80 +//        flags (in)          new value for flags
    7.81 +//
    7.82 +//    return value:
    7.83 +//        PEP_STATUS_OK = 0             encryption and signing succeeded
    7.84 +//        PEP_CANNOT_SET_IDENTITY       update of identity failed
    7.85 +//
    7.86 +//    caveat:
    7.87 +//        address and user_id must be given in identity
    7.88 +
    7.89 +DYNAMIC_API PEP_STATUS set_identity_flags(
    7.90 +        PEP_SESSION session,
    7.91 +        pEp_identity *identity,
    7.92 +        unsigned int flags
    7.93 +    );
    7.94 +
    7.95 +
    7.96  // mark_as_compromized() - mark key in trust db as compromized
    7.97  //
    7.98  //    parameters:
     8.1 --- a/src/pEp_internal.h	Tue Jul 26 11:48:22 2016 +0200
     8.2 +++ b/src/pEp_internal.h	Tue Aug 02 12:55:50 2016 +0200
     8.3 @@ -1,4 +1,4 @@
     8.4 -#define PEP_ENGINE_VERSION "0.7.0"
     8.5 +#define PEP_ENGINE_VERSION "0.8.0"
     8.6  
     8.7  // maximum attachment size to import as key 1MB, maximum of 20 attachments
     8.8  
     8.9 @@ -97,6 +97,7 @@
    8.10      sqlite3_stmt *set_person;
    8.11      sqlite3_stmt *set_pgp_keypair;
    8.12      sqlite3_stmt *set_identity;
    8.13 +    sqlite3_stmt *set_identity_flags;
    8.14      sqlite3_stmt *set_trust;
    8.15      sqlite3_stmt *get_trust;
    8.16      sqlite3_stmt *least_trust;
     9.1 --- a/test/msg_no_key.asc	Tue Jul 26 11:48:22 2016 +0200
     9.2 +++ b/test/msg_no_key.asc	Tue Aug 02 12:55:50 2016 +0200
     9.3 @@ -1,86 +1,44 @@
     9.4 -From: Test no key <test@nokey.plop>
     9.5 -To: Still no key <still@nokey.blup>
     9.6 -Subject: pEp
     9.7 -X-pEp-Version: 1.0
     9.8 +To: notreal@kgrothoff.org
     9.9 +From: Krista Grothoff <notreal@kgrothoff.org>
    9.10 +Subject: test3
    9.11 +Message-ID: <579B4AB5.4090402@kgrothoff.org>
    9.12 +Date: Fri, 29 Jul 2016 14:23:17 +0200
    9.13 +User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101
    9.14 + Thunderbird/38.8.0
    9.15  MIME-Version: 1.0
    9.16 -Content-Type: multipart/encrypted; boundary="74b0dc5119495cff2ae8944a625558ec"; 
    9.17 - protocol="application/pgp-encrypted"
    9.18 +Content-Type: multipart/encrypted;
    9.19 + protocol="application/pgp-encrypted";
    9.20 + boundary="Vkb6PtN2UuPCNGnI4hCGU6LNQN66590UU"
    9.21  
    9.22 ---74b0dc5119495cff2ae8944a625558ec
    9.23 +This is an OpenPGP/MIME encrypted message (RFC 4880 and 3156)
    9.24 +--Vkb6PtN2UuPCNGnI4hCGU6LNQN66590UU
    9.25  Content-Type: application/pgp-encrypted
    9.26 +Content-Description: PGP/MIME version identification
    9.27  
    9.28  Version: 1
    9.29 ---74b0dc5119495cff2ae8944a625558ec
    9.30 -Content-Type: application/octet-stream
    9.31 -Content-Transfer-Encoding: 7bit
    9.32 -Content-Disposition: inline; filename="msg.asc"
    9.33 +
    9.34 +--Vkb6PtN2UuPCNGnI4hCGU6LNQN66590UU
    9.35 +Content-Type: application/octet-stream; name="encrypted.asc"
    9.36 +Content-Description: OpenPGP encrypted message
    9.37 +Content-Disposition: inline; filename="encrypted.asc"
    9.38  
    9.39  -----BEGIN PGP MESSAGE-----
    9.40  
    9.41 -hQEMA3RCTrevwG3jAQf/ajRuor6jilyO5RvQqkhTH5EIl70QbRKCFv+R09/JVY3J
    9.42 -+UmpmZUWR91STplFyHWap2bIPnmLi7iTYhJf2n7w5NmDVju4fykw8rVl+khShdZu
    9.43 -harEilWGdiKnPoux/iBeicflLSiKI5hoR/kk2XPPvyDCCFUIwF3md96W+PFom3mv
    9.44 -asgJ5wUGW2VXIx608pP0iRh6Nb6adtcShggK2ClBYMfLvHXZ6J/hxAJLa03geIWR
    9.45 -rsPEsYvGHlF8pkpnJj1SqbIL5Wl1SDjzxvd3xj19O+ykOtcs+1SDIL8ieup1xBUy
    9.46 -2dnTaWbNwl/i6YkyFWFH03pj0g1UH5U0j60BAVHdBIUBDAPkhdA1fp/D8QEH/32c
    9.47 -Bvfo7YSQ4Lh2yLAJbNsw9vi6Pn+FeNQRLFJK0ncnUMHEywIQTXrhRPOI52Y1Dl5C
    9.48 -JlRbba1e3APOClWr1h12kF+7eTNTPjcnAK+qifzCZgqudL47eMbZQUdc/ycBHsML
    9.49 -5Am1LoDnaRIGUoNVJyrH2sQCov3tSCMcaQ4RoCkDwNef6iLYEtBh+jE9mIIOr5fE
    9.50 -6iLwAigzOh4zx94znCv58nV7jp6wWbCGCRjMTQEI3bLiwv6qVwzTYOoch719LYen
    9.51 -+lRMufz+JwQpn8Uj4d8HYNB3Dzn+WMPORG0ANxO7s1CT1a8GwEEX3Kxc4McxLWX0
    9.52 -4KH5dsV1Sb2u7pM1vqTS6wGi6x3rXCef/fD52xGy4yoBputlqT7esWa7yptmlhwD
    9.53 -nnP40nDubynyKCnxzEHpoLDsmULyDlZqXEFSjLOBxFu/sBfm2uzZ47MR/Eod5rEB
    9.54 -tzcXOBDS8Hc/yr5bRBoKxXoLdcocZtTnczgFNcaTlRy219DkqvUM8DQfkPcsWqBE
    9.55 -Thn83B92nkQbm/so3oRNAUdm3Z8w2a3wZao+WB73OYKgB3ugXf52L6GWTWOOxn1H
    9.56 -VXqxTJokGMCBomIsBJn300gEDXwNJhyYWGHpYPp9am/Ym/ZamwnKSfQlh8+d4z63
    9.57 -8NM78UHJWKUNnn7yP8Vd4zc05fYQFyxM1mXS2YlW5Ch5DkOOu0XNSam2f/9W/7xd
    9.58 -9WMtgKGQ33h+vqmnJ6gpzyUSfJ8QRcYzuCMxW0rPLIrxnP/V5+lV0GqaIkMyQxCH
    9.59 -OvaclLOTvsW9gNRAkUFxvfPdwq3pTim8GSd2oCxETIaBI2xca2NQ6NtKjddbADbV
    9.60 -mbPdyJHKahEVuAXLQ8KVmdcvEjaJYt+Mch14p439vxo611VNYTaSOuoqEeB9VYEP
    9.61 -8TkP80l7d7q9iJ9mF1jw/+ykdpDWPGn3zECeg2vXCvksqtyMJ/XeflYxge3H8LRZ
    9.62 -DUwDa5crXH5Iq7pSwdzWvVTzjkBZzawY3zJGMTpnnb4EdTQldBdHQxCgTHMBWn7f
    9.63 -6FqFXmMAHJC3nYs8ysFmfGLIiOjdedGc3O95oMFcYjzHafKc6LH1GGkNCDRXYC8M
    9.64 -mJm3lpDxkCselGXeHBopuxLFmmv8xZ2vdu454r69lMIDgE2huEdsNyTzKc3aG00B
    9.65 -jE5etwcxGEFRAbHS4EvYY63DwCYr4Qh7uKh7jID2skT8zGPQitPOYBuOJ/2h0thK
    9.66 -e3Ztohf+P/VSYIipXZP6dCYNRTVoaPFfKA9+OyLXWccADpmqXJe8wCQ397Eo2gNW
    9.67 -Yl6P57cCHn8mW7SIWwePmSnYAHn0uAkpIYked6p5vNHX/6xHjXLeeFTVC3ZK5gFh
    9.68 -6C2xEvLh41ACLPdeqM3ANXWiZDYnkZ9LlwV2EZywTI6urd+OcslGuRf1lrfnFDWm
    9.69 -K2w4PKxhoziizxrn6OjAzF+d9iqn0VOLh1H9PuMVbHwEO8vhYH0vfyjxkXUdLBgK
    9.70 -nSXZ9BPv9IL1CYhhN6hFiP1Va8SteHDhmMzRLZ9hjkTdLEP5Lu+AVwH0FkviaAan
    9.71 -s5gGdFe+pOmmkuC5s589XTpIGGug60z2u38SoN0LvtSPene7Wh1nNyzVPiyaFR1L
    9.72 -r78VH3BfUWHEVfGcAlNjajHWFZoCMHjKUPvlcMURls6ZfQwhF/3RGs1X2F6Ts1LO
    9.73 -CaoU4R+iKAgzfSYBKfCKbkjbBXAfq17IBohXcVZZlbKUbKUlGLdxqHWppI5wYJki
    9.74 -ME5iHyoM5HZYHWnsi76fA3sHrwifIuFTl85EZQgR2OUJb3tn3g1ckz5sTscUm2Af
    9.75 -fquWYyPcfF4MyVfbbxjTvVqg0JUAwSXY3t+b1JGBlnrmcu0JBprEuYL60KWmNh+p
    9.76 -jawapj1Cu7GXBrWanEjhZrLKZF3GO3SCBKnINLnWTxWOxO3aSBskGkiNTjMUtWur
    9.77 -7V37A2OKmVTZccTzWzHfppHmsBdvdflMNz1aYy+YgC3YF/5/gDBSsStQoECiZQDx
    9.78 -oENYxI9p6qXepgl0HAeagvWoX82/iKf42mMXdgjPRM+hd0vXvzI1KubQ641b6DUZ
    9.79 -JYYdMFcCW1LfbFb8+/9vF7orFSYIqVW75SLNcb9MMas5KoOcHWrJIK3vHyV+w6fI
    9.80 -8tNzkcvUCMRyiCBkq74JXt1a/yalNjtMvXqU7W3dhTQeZ4OwbYSx0wHJWVjk0o3d
    9.81 -dIl9Y0ig+QJF6MDYOw5NQ/ys3iNhDZVurgFk3eIncFoIHB4k9QovGQNUA/F2qtyR
    9.82 -BtVFYiS5aIQ7tosWWTb7FbBlSTZV1rO8YDi/oQ3XiVLV0ZDan68lQfOO8pE6oIQ+
    9.83 -ZaWXi1jK2koJjV4Vc7+NqLw0FhEuJME7EFI+iuIg8aXKQxP3H0vsdq71L/qxSIcb
    9.84 -V7RnSCDEZPbfssuShzegOkdVWn4u+5lF2ZB6vtt5/noOuopfup1DLBe9OTs8PEg8
    9.85 -JawLixRqWE5njDCVWxinmoovvlaWkshG+2C9+Pc0R6MB1j3G3HdOV03jk+yrAQ2S
    9.86 -hwXmkWEHhhKbF6tdamKJan2ahO/wuW4DSYiAc64ys1bpWctipgaDodgmXa1KkEan
    9.87 -44cQMf0yISdBex8uKqddQDplNxojT1ysky824X3vnApYjZ1O9/9EnQRn9BYuHdIL
    9.88 -8zat3qQAJO0cS0qAnQquoWzPzq7rumHxn248+mox6hD7Bxr+j6lbwyZRnaCcWFbu
    9.89 -11LUs0+pXDB+tKR6iGbuBuLLnj87LtjfzgkpDvlogBiaTFylJ+z4mfvpco05DfmU
    9.90 -CPyLr8LNIm6C3BVWDotgfVzIpsVuLGn+0JGB32RwYK79ngiFbgzjyTpGoIrPSAlr
    9.91 -gcrPR2XpXKMqOIktxJXMNWkBEg0w0ho7pviRCev+/yIxFV5zBNNUYYux1iAJPInQ
    9.92 -HDODyPFxC3YkRiFsw1c1GxI0dWdefQD7ClS8PFDrMIUeuPZMMt1TwUDB49uJqI7i
    9.93 -+n4MSfrxk1VTdSBH6dGk34ryoymMRwdLFcMyjNOICeCBnvmbc8qbBNg1hnr1Mbaz
    9.94 -pJl0dVXorszIZtx0EdE4KXu0+F8+LED6ASSH4lYLlsKirZkfDuTCE88d6MIIpjpb
    9.95 -wOm9ZP7Cb7YbCtFDm1pUF/L/J4TMnPjhufGdXbHwX1E1rB8pcnsShOLJrIhZWeq/
    9.96 -TWl9kmfbcM6OZVzedz1Eq9H5GE5BT/yTNmlrVR5Z2a7xwjbxE6uP+SPhx3Tga4Us
    9.97 -ivBOudkcifSy44AxjYOhPLaFxygs7We4JLIn0WOB6D7hvRDjL4osOKRiqJ5G56kZ
    9.98 -pZ6wGXUUZJzdUAuPPl2mAyxkpErZTXe3ENMFh3vU7YF3ovWgT7en6sRlVV6aCBc+
    9.99 -VNyM6OHFQlMeMowLWacONMQCVKsbMsOtLgBKryqTXugIBJclSV8vDy0zhuQoeQ1B
   9.100 -hUeA4uxoljnTkr5bLnBeKbC8vpViC2cHKsnmDX0cpE/ybyvXAHhbKHGbW912gylv
   9.101 -5V2h/Sct/wleXYYHBTQTsZpbQjAZmn8R8LUfG6H1Ig4CfH8oeBIkjaSt4z9zUBsp
   9.102 -0FdLyughCihVz98UJGVDh/H4fQIyXytqycFwF/mst//GXH9/VzJwRcqUz7MKQxoO
   9.103 -Pd2Y0r3rz5hfj78l1NOXYgdpEzLvQkyQbujU8foJJOxA0pRYlLN9Xr3AoQ==
   9.104 -=uymV
   9.105 +hQEMAxqoixpCqEC5AQgAw2FSvhWUNOLTXDigj/0sSAvjsiRnywXoa+IWXECZhIy0
   9.106 +78J+Ib66VgdVUuHuxa2tw1EojKWtSrDlcxJUnWwcewRaRzwGmZ2OTTvMb+ri8y4B
   9.107 +YdwDsL0MthWiXO/V81kiYjyA5jn6e1p4kYPWJCHTeBu1DKZFreulD/ckMFBFgbwt
   9.108 +fttSaMMDuU3gjlQET3kOppWLatMevosXiwUOBr3fhDZvGIGu9OI6tiXlul0B1+aG
   9.109 +YSn81tIaZKPixlgVVmJYXVbz/P1PM2ilbGbOOyrcDvY2YDFiQfjdjh7V+noshB9u
   9.110 +n3MBQ/altgUdjfPX8KDp7RACddr2QuoY2SGF1PMcwNLAmgFZ4T1kAtaT4l7+/nF5
   9.111 +c/DhDccRFLtb3wNjuhMs1QJQy+2O5cJBvT42U+0TM72MFTwRNwXlWNkn8r8eJfZj
   9.112 +6TUyZqNK6LqKKZksNUIVhGPcore3HPhfiSVV8k7iRG8mZ2wfMe25hhGG/0+pCOiB
   9.113 +9/OCXKOgFNlWSVzfmbQ9dAvxaZVlDOrgy7weS8aGkH73B+u70SX9iXNvmfLoXv90
   9.114 +0oimyhfkMd+9lK9rFwqh/RankVun1V03lQJhyaPMotWOIw06Z+8s495G3h6UiUIu
   9.115 +vqBfr6mPzIVVrIuSeWSBY/lE+1+3DUUTbx5lDWynRxND7bd7m1uwcl2nIAcmsJ+R
   9.116 +JKm1+JTEwoYgcPBUT+lxshFexqXv19hk7NWIAmhNmEpRRsi27gqmk5IVDmeR4upr
   9.117 +w65H7Es9EN0no0C5ZjUdGke4jQ0ILL8akqDFTWp8vCUuQgKZNHRayQZ84cg=
   9.118 +=q/R9
   9.119  -----END PGP MESSAGE-----
   9.120  
   9.121 ---74b0dc5119495cff2ae8944a625558ec--
   9.122 +--Vkb6PtN2UuPCNGnI4hCGU6LNQN66590UU--
   9.123 +