Merge default in test_diphoton test_diphoton
authorEdouard Tisserant <edouard@pep-project.org>
Thu, 15 Jun 2017 11:35:44 +0200
branchtest_diphoton
changeset 18601975a3b9bc37
parent 1816 dc9bc5fa3f18
parent 1859 acf5c59a49e3
child 1883 183848e382a2
Merge default in test_diphoton
src/keymanagement.c
src/pEpEngine.c
src/pEp_internal.h
src/platform_windows.cpp
     1.1 --- a/.hgignore	Fri Jun 02 11:55:04 2017 +0200
     1.2 +++ b/.hgignore	Thu Jun 15 11:35:44 2017 +0200
     1.3 @@ -47,10 +47,10 @@
     1.4  *.xml
     1.5  *.dot
     1.6  *.svg
     1.7 -.imported
     1.8  gpg-agent.conf
     1.9  gpg.conf
    1.10  pubring.gpg
    1.11  random_seed
    1.12  secring.gpg
    1.13  trustdb.gpg
    1.14 +.pEp_management.db
     2.1 --- a/Makefile.conf	Fri Jun 02 11:55:04 2017 +0200
     2.2 +++ b/Makefile.conf	Thu Jun 15 11:35:44 2017 +0200
     2.3 @@ -2,7 +2,7 @@
     2.4  
     2.5  BUILD_ON=$(shell uname)
     2.6  BUILD_FOR=$(BUILD_ON)
     2.7 -OPTIMIZE=-g -Wall -O0 -fPIC
     2.8 +OPTIMIZE=-g -Wall -O0 -fPIC -DDEBUG_ERRORSTACK
     2.9  #OPTIMIZE=-O3 -Wall -DNDEBUG -std=c99
    2.10  LD=$(CC)
    2.11  #CC=gcc-mp-4.9 -std=c99 -fstrict-aliasing -Wstrict-aliasing=3
     3.1 --- a/build-mac/pEpEngine.xcodeproj/project.pbxproj	Fri Jun 02 11:55:04 2017 +0200
     3.2 +++ b/build-mac/pEpEngine.xcodeproj/project.pbxproj	Thu Jun 15 11:35:44 2017 +0200
     3.3 @@ -190,6 +190,7 @@
     3.4  
     3.5  /* Begin PBXFileReference section */
     3.6  		430D258A1C9ED75A00B94535 /* blacklist.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = blacklist.c; path = ../src/blacklist.c; sourceTree = "<group>"; };
     3.7 +		4346F86A1ECB38E700381CBE /* sync_app.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = sync_app.h; path = ../src/sync_app.h; sourceTree = "<group>"; };
     3.8  		4354FF641D6EDF300033069C /* sync_impl.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = sync_impl.c; path = ../src/sync_impl.c; sourceTree = "<group>"; };
     3.9  		4354FF681D6EE1A70033069C /* NULL.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = NULL.c; path = ../asn.1/NULL.c; sourceTree = "<group>"; };
    3.10  		43BA0F451D7964750059172F /* asn1_helper.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = asn1_helper.c; path = ../src/asn1_helper.c; sourceTree = "<group>"; };
    3.11 @@ -517,6 +518,7 @@
    3.12  				646C41421D510D2C00C63EFF /* sync_send_actions.c */,
    3.13  				646C41431D510D2C00C63EFF /* sync.c */,
    3.14  				646C41441D510D2C00C63EFF /* sync.h */,
    3.15 +				4346F86A1ECB38E700381CBE /* sync_app.h */,
    3.16  				646788871CEB3D120001F54C /* map_asn1.c */,
    3.17  				646788881CEB3D120001F54C /* map_asn1.h */,
    3.18  				430D258A1C9ED75A00B94535 /* blacklist.c */,
    3.19 @@ -779,7 +781,7 @@
    3.20  			);
    3.21  			runOnlyForDeploymentPostprocessing = 0;
    3.22  			shellPath = /bin/sh;
    3.23 -			shellScript = "mkdir -p \"$BUILT_PRODUCTS_DIR/include\"\n\ncp \"$SRCROOT/../src/\"{\\\npEpEngine.h,\\\ncryptotech.h,\\\nkeymanagement.h,\\\nmessage_api.h,\\\ndynamic_api.h,\\\nstringlist.h,\\\ntimestamp.h,\\\nidentity_list.h,\\\nbloblist.h,\\\nstringpair.h,\\\nmessage.h,\\\nmime.h} \"$BUILT_PRODUCTS_DIR/include\"\n\nbash -l -c \"make -C ../asn.1 generate\"\nbash -l -c \"make -C ../asn.1\"\nbash -l -c \"LC_ALL=en_US.UTF-8 YML_PATH=$HOME/yml2 make -C ../sync\"\n";
    3.24 +			shellScript = "mkdir -p \"$BUILT_PRODUCTS_DIR/include\"\n\ncp \"$SRCROOT/../src/\"{\\\npEpEngine.h,\\\ncryptotech.h,\\\nkeymanagement.h,\\\nmessage_api.h,\\\ndynamic_api.h,\\\nstringlist.h,\\\ntimestamp.h,\\\nidentity_list.h,\\\nbloblist.h,\\\nstringpair.h,\\\nmessage.h,\\\nmime.h,\\\nsync_fsm.h,\\\nsync.h,\\\nsync_app.h} \"$BUILT_PRODUCTS_DIR/include\"\n\nbash -l -c \"make -C ../asn.1 generate\"\nbash -l -c \"make -C ../asn.1\"\nbash -l -c \"LC_ALL=en_US.UTF-8 YML_PATH=$HOME/yml2 make -C ../sync\"\n";
    3.25  		};
    3.26  /* End PBXShellScriptBuildPhase section */
    3.27  
     4.1 --- a/db/create_system_db.sql	Fri Jun 02 11:55:04 2017 +0200
     4.2 +++ b/db/create_system_db.sql	Thu Jun 15 11:35:44 2017 +0200
     4.3 @@ -46,5 +46,8 @@
     4.4  
     4.5  INSERT INTO i18n_language VALUES ('tr', 'Türkçe');
     4.6  INSERT INTO i18n_token VALUES ('tr', 1000, 'Güvenlik kelimelerini Türkçe görüntülemek istiyorum');
     4.7 +
     4.8 +INSERT INTO i18n_language VALUES ('nl', 'Nederlands');
     4.9 +INSERT INTO i18n_token VALUES ('nl', 1000, 'Ik wil de trustwords in de nederlandse taal laten zien');
    4.10  -- add more languages here
    4.11  
     5.1 --- a/src/Makefile	Fri Jun 02 11:55:04 2017 +0200
     5.2 +++ b/src/Makefile	Thu Jun 15 11:35:44 2017 +0200
     5.3 @@ -93,7 +93,7 @@
     5.4  install: $(TARGET)
     5.5  	cp $< $(PREFIX)/lib/
     5.6  	mkdir -p $(PREFIX)/include/pEp
     5.7 -	cp pEpEngine.h keymanagement.h message_api.h dynamic_api.h stringlist.h timestamp.h identity_list.h bloblist.h stringpair.h message.h mime.h cryptotech.h sync.h sync_fsm.h blacklist.h openpgp_compat.h $(PREFIX)/include/pEp/
     5.8 +	cp pEpEngine.h keymanagement.h message_api.h dynamic_api.h stringlist.h timestamp.h identity_list.h bloblist.h stringpair.h message.h mime.h cryptotech.h sync.h sync_fsm.h sync_app.h blacklist.h openpgp_compat.h $(PREFIX)/include/pEp/
     5.9  
    5.10  uninstall:
    5.11  	rm -f $(PREFIX)/lib/$(TARGET)
     6.1 --- a/src/keymanagement.c	Fri Jun 02 11:55:04 2017 +0200
     6.2 +++ b/src/keymanagement.c	Thu Jun 15 11:35:44 2017 +0200
     6.3 @@ -91,7 +91,7 @@
     6.4      assert(!EMPTYSTR(identity->address));
     6.5  
     6.6      if (!(session && identity && !EMPTYSTR(identity->address)))
     6.7 -        return PEP_ILLEGAL_VALUE;
     6.8 +        return ADD_TO_LOG(PEP_ILLEGAL_VALUE);
     6.9  
    6.10      if (identity->me || (identity->user_id && strcmp(identity->user_id, PEP_OWN_USERID) == 0)) {
    6.11          identity->me = true;
    6.12 @@ -144,9 +144,23 @@
    6.13  
    6.14          /* if we have a stored_identity fpr */
    6.15          if (!EMPTYSTR(stored_identity->fpr)) {
    6.16 -            status = blacklist_is_listed(session, stored_identity->fpr, &dont_use_stored_fpr);
    6.17 -            if (status != PEP_STATUS_OK)
    6.18 -                dont_use_stored_fpr = true; 
    6.19 +            bool revoked = false;
    6.20 +            status = key_revoked(session, stored_identity->fpr, &revoked);
    6.21 +            
    6.22 +            if (status != PEP_STATUS_OK || revoked)
    6.23 +                dont_use_stored_fpr = true;
    6.24 +                
    6.25 +            if (revoked) {
    6.26 +                // Do stuff
    6.27 +                status = update_trust_for_fpr(session, stored_identity->fpr, PEP_ct_key_revoked);
    6.28 +                // What to do on failure? FIXME
    6.29 +                status = replace_identities_fpr(session, stored_identity->fpr, "");
    6.30 +            }
    6.31 +            else {    
    6.32 +                status = blacklist_is_listed(session, stored_identity->fpr, &dont_use_stored_fpr);
    6.33 +                if (status != PEP_STATUS_OK)
    6.34 +                    dont_use_stored_fpr = true; 
    6.35 +            }
    6.36          }
    6.37              
    6.38  
    6.39 @@ -312,7 +326,7 @@
    6.40      free_identity(stored_identity);
    6.41      free_identity(temp_id);
    6.42      
    6.43 -    return status;
    6.44 +    return ADD_TO_LOG(status);
    6.45  }
    6.46  
    6.47  PEP_STATUS elect_ownkey(
    6.48 @@ -339,19 +353,14 @@
    6.49          for (_keylist = keylist; _keylist && _keylist->value; _keylist = _keylist->next) {
    6.50              bool is_own = false;
    6.51              
    6.52 -            if (session->use_only_own_private_keys)
    6.53 -            {
    6.54 -                status = own_key_is_listed(session, _keylist->value, &is_own);
    6.55 -                assert(status == PEP_STATUS_OK);
    6.56 -                if (status != PEP_STATUS_OK) {
    6.57 -                    free_stringlist(keylist);
    6.58 -                    return status;
    6.59 -                }
    6.60 +            status = own_key_is_listed(session, _keylist->value, &is_own);
    6.61 +            assert(status == PEP_STATUS_OK);
    6.62 +            if (status != PEP_STATUS_OK) {
    6.63 +                free_stringlist(keylist);
    6.64 +                return status;
    6.65              }
    6.66 -
    6.67 -            // TODO : also accept synchronized device group keys ?
    6.68              
    6.69 -            if (!session->use_only_own_private_keys || is_own)
    6.70 +            if (is_own)
    6.71              {
    6.72                  PEP_comm_type _comm_type_key;
    6.73                  
    6.74 @@ -407,7 +416,7 @@
    6.75      
    6.76      *is_usable = !dont_use_fpr;
    6.77      
    6.78 -    return status;
    6.79 +    return ADD_TO_LOG(status);
    6.80  }
    6.81  
    6.82  PEP_STATUS _myself(PEP_SESSION session, pEp_identity * identity, bool do_keygen, bool ignore_flags)
    6.83 @@ -425,7 +434,7 @@
    6.84      if (!(session && identity && !EMPTYSTR(identity->address) &&
    6.85              (EMPTYSTR(identity->user_id) ||
    6.86              strcmp(identity->user_id, PEP_OWN_USERID) == 0)))
    6.87 -        return PEP_ILLEGAL_VALUE;
    6.88 +        return ADD_TO_LOG(PEP_ILLEGAL_VALUE);
    6.89  
    6.90      identity->comm_type = PEP_ct_pEp;
    6.91      identity->me = true;
    6.92 @@ -526,7 +535,7 @@
    6.93          status = elect_ownkey(session, identity);
    6.94          assert(status == PEP_STATUS_OK);
    6.95          if (status != PEP_STATUS_OK) {
    6.96 -            return status;
    6.97 +            return ADD_TO_LOG(status);
    6.98          }
    6.99  
   6.100          bool has_private = false;
   6.101 @@ -556,27 +565,18 @@
   6.102      {
   6.103          status = key_revoked(session, identity->fpr, &revoked);
   6.104  
   6.105 -        // Forces re-election if key is missing and own-key-only not forced
   6.106 -        if (!session->use_only_own_private_keys && status == PEP_KEY_NOT_FOUND) 
   6.107 +        if (status != PEP_STATUS_OK) 
   6.108          {
   6.109 -            status = elect_ownkey(session, identity);
   6.110 -            assert(status == PEP_STATUS_OK);
   6.111 -            if (status != PEP_STATUS_OK) {
   6.112 -                return status;
   6.113 -            }
   6.114 -        } 
   6.115 -        else if (status != PEP_STATUS_OK) 
   6.116 -        {
   6.117 -            return status;
   6.118 +            return ADD_TO_LOG(status);
   6.119          }
   6.120      }
   6.121     
   6.122      bool new_key_generated = false;
   6.123  
   6.124      if (EMPTYSTR(identity->fpr) || revoked)
   6.125 -    {        
   6.126 +    {
   6.127          if(!do_keygen){
   6.128 -            return PEP_GET_KEY_FAILED;
   6.129 +            return ADD_TO_LOG(PEP_GET_KEY_FAILED);
   6.130          }
   6.131  
   6.132          if(revoked)
   6.133 @@ -594,7 +594,7 @@
   6.134              DEBUG_LOG("generating key pair failed", "debug", buf);
   6.135              if(revoked && r_fpr)
   6.136                  free(r_fpr);
   6.137 -            return status;
   6.138 +            return ADD_TO_LOG(status);
   6.139          }
   6.140  
   6.141          new_key_generated = true;
   6.142 @@ -605,7 +605,7 @@
   6.143                                   identity->fpr, time(NULL));
   6.144              free(r_fpr);
   6.145              if (status != PEP_STATUS_OK) {
   6.146 -                return status;
   6.147 +                return ADD_TO_LOG(status);
   6.148              }
   6.149          }
   6.150      }
   6.151 @@ -618,7 +618,7 @@
   6.152  
   6.153          assert(status == PEP_STATUS_OK);
   6.154          if (status != PEP_STATUS_OK) {
   6.155 -            return status;
   6.156 +            return ADD_TO_LOG(status);
   6.157          }
   6.158  
   6.159          if (status == PEP_STATUS_OK && expired) {
   6.160 @@ -646,12 +646,12 @@
   6.161          }
   6.162      }
   6.163  
   6.164 -    return PEP_STATUS_OK;
   6.165 +    return ADD_TO_LOG(PEP_STATUS_OK);
   6.166  }
   6.167  
   6.168  DYNAMIC_API PEP_STATUS myself(PEP_SESSION session, pEp_identity * identity)
   6.169  {
   6.170 -    return _myself(session, identity, true, false);
   6.171 +    return ADD_TO_LOG(_myself(session, identity, true, false));
   6.172  }
   6.173  
   6.174  DYNAMIC_API PEP_STATUS register_examine_function(
   6.175 @@ -1023,7 +1023,7 @@
   6.176      return _own_keys_retrieve(session, keylist, 0);
   6.177  }
   6.178  
   6.179 -// TODO: Unused for now, but should be used when sync receive old keys (ENGINE-145)
   6.180 +// FIXME: should it be be used when sync receive old keys ? (ENGINE-145)
   6.181  DYNAMIC_API PEP_STATUS set_own_key(
   6.182         PEP_SESSION session,
   6.183         const char *address,
   6.184 @@ -1033,12 +1033,12 @@
   6.185      PEP_STATUS status = PEP_STATUS_OK;
   6.186      
   6.187      assert(session &&
   6.188 -           address && address[0] &&
   6.189 +           address &&
   6.190             fpr && fpr[0]
   6.191            );
   6.192      
   6.193      if (!(session &&
   6.194 -          address && address[0] &&
   6.195 +          address &&
   6.196            fpr && fpr[0]
   6.197           ))
   6.198          return PEP_ILLEGAL_VALUE;
     7.1 --- a/src/keymanagement.h	Fri Jun 02 11:55:04 2017 +0200
     7.2 +++ b/src/keymanagement.h	Thu Jun 15 11:35:44 2017 +0200
     7.3 @@ -15,6 +15,11 @@
     7.4  //      session (in)        session to use
     7.5  //      identity (inout)    identity information of communication partner
     7.6  //                          (identity->fpr is OUT ONLY)
     7.7 +//  return value:
     7.8 +//      PEP_STATUS_OK if identity could be updated,
     7.9 +//      PEP_GET_KEY_FAILED for own identity that must be completed (myself())
    7.10 +//      any other value on error
    7.11 +//
    7.12  //  caveat:
    7.13  //      if this function returns PEP_ct_unknown or PEP_ct_key_expired in
    7.14  //      identity->comm_type, the caller must insert the identity into the
    7.15 @@ -159,7 +164,6 @@
    7.16          pEp_identity *ident
    7.17      );
    7.18  
    7.19 -
    7.20  // own_key_is_listed() - returns true id key is listed as own key
    7.21  //
    7.22  //  parameters:
    7.23 @@ -235,7 +239,12 @@
    7.24          stringlist_t **keylist
    7.25        );
    7.26  
    7.27 +DYNAMIC_API PEP_STATUS set_own_key(
    7.28 +       PEP_SESSION session,
    7.29 +       const char *address,
    7.30 +       const char *fpr
    7.31 +    );
    7.32 +
    7.33  #ifdef __cplusplus
    7.34  }
    7.35  #endif
    7.36 -
     8.1 --- a/src/message_api.c	Fri Jun 02 11:55:04 2017 +0200
     8.2 +++ b/src/message_api.c	Thu Jun 15 11:35:44 2017 +0200
     8.3 @@ -169,19 +169,22 @@
     8.4                      goto enomem;
     8.5              }
     8.6          }
     8.7 +        *shortmsg = _shortmsg;
     8.8      }
     8.9      else {
    8.10 -        _shortmsg = strdup("");
    8.11 -        assert(_shortmsg);
    8.12 -        if (_shortmsg == NULL)
    8.13 -            goto enomem;
    8.14 +        // If there's no "Subject: " and the shortmsg is
    8.15 +        // pEp (or anything else), then we shouldn't be replacing it.
    8.16 +        // Chances are that the message wasn't encrypted
    8.17 +        // using pEp and that the actually subject IS pEp. In any event,
    8.18 +        // erasing the subject line when we don't have one in the plaintext
    8.19 +        // isn't the right behaviour.
    8.20 +        // _shortmsg = strdup("");
    8.21          _longmsg = strdup(src);
    8.22          assert(_longmsg);
    8.23          if (_longmsg == NULL)
    8.24              goto enomem;
    8.25      }
    8.26 -
    8.27 -    *shortmsg = _shortmsg;
    8.28 +    
    8.29      *longmsg = _longmsg;
    8.30  
    8.31      return 0;
    8.32 @@ -794,6 +797,7 @@
    8.33          return PEP_rating_unencrypted;
    8.34  
    8.35      case PEP_DECRYPTED:
    8.36 +    case PEP_DECRYPT_SIGNATURE_DOES_NOT_MATCH:
    8.37          return PEP_rating_unreliable;
    8.38  
    8.39      case PEP_DECRYPTED_AND_VERIFIED:
    8.40 @@ -1100,20 +1104,20 @@
    8.41      assert(enc_format != PEP_enc_none);
    8.42  
    8.43      if (!(session && src && dst && enc_format != PEP_enc_none))
    8.44 -        return PEP_ILLEGAL_VALUE;
    8.45 +        return ADD_TO_LOG(PEP_ILLEGAL_VALUE);
    8.46  
    8.47      if (src->dir == PEP_dir_incoming)
    8.48 -        return PEP_ILLEGAL_VALUE;
    8.49 +        return ADD_TO_LOG(PEP_ILLEGAL_VALUE);
    8.50  
    8.51      determine_encryption_format(src);
    8.52      if (src->enc_format != PEP_enc_none)
    8.53 -        return PEP_ILLEGAL_VALUE;
    8.54 +        return ADD_TO_LOG(PEP_ILLEGAL_VALUE);
    8.55  
    8.56      *dst = NULL;
    8.57  
    8.58      status = myself(session, src->from);
    8.59      if (status != PEP_STATUS_OK)
    8.60 -        goto pep_error;
    8.61 +        GOTO(pep_error);
    8.62  
    8.63      keys = new_stringlist(src->from->fpr);
    8.64      if (keys == NULL)
    8.65 @@ -1147,7 +1151,7 @@
    8.66          PEP_STATUS _status = update_identity(session, _il->ident);
    8.67          if (_status != PEP_STATUS_OK) {
    8.68              status = _status;
    8.69 -            goto pep_error;
    8.70 +            GOTO(pep_error);
    8.71          }
    8.72  
    8.73          if (_il->ident->fpr && _il->ident->fpr[0]) {
    8.74 @@ -1168,7 +1172,7 @@
    8.75              PEP_STATUS _status = update_identity(session, _il->ident);
    8.76              if (_status != PEP_STATUS_OK) {
    8.77                  status = _status;
    8.78 -                goto pep_error;
    8.79 +                GOTO(pep_error);
    8.80              }
    8.81  
    8.82              if (_il->ident->fpr && _il->ident->fpr[0]) {
    8.83 @@ -1189,7 +1193,7 @@
    8.84              if (_status != PEP_STATUS_OK)
    8.85              {
    8.86                  status = _status;
    8.87 -                goto pep_error;
    8.88 +                GOTO(pep_error);
    8.89              }
    8.90  
    8.91              if (_il->ident->fpr && _il->ident->fpr[0]) {
    8.92 @@ -1214,7 +1218,7 @@
    8.93          free_stringlist(keys);
    8.94          if (!session->passive_mode && !(flags & PEP_encrypt_flag_force_no_attached_key))
    8.95              attach_own_key(session, src);
    8.96 -        return PEP_UNENCRYPTED;
    8.97 +        return ADD_TO_LOG(PEP_UNENCRYPTED);
    8.98      }
    8.99      else {
   8.100          msg = clone_to_empty_message(src);
   8.101 @@ -1241,14 +1245,14 @@
   8.102          default:
   8.103              assert(0);
   8.104              status = PEP_ILLEGAL_VALUE;
   8.105 -            goto pep_error;
   8.106 +            GOTO(pep_error);
   8.107          }
   8.108  
   8.109          if (status == PEP_OUT_OF_MEMORY)
   8.110              goto enomem;
   8.111  
   8.112          if (status != PEP_STATUS_OK)
   8.113 -            goto pep_error;
   8.114 +            GOTO(pep_error);
   8.115      }
   8.116  
   8.117      free_stringlist(keys);
   8.118 @@ -1271,7 +1275,7 @@
   8.119      }
   8.120  
   8.121      *dst = msg;
   8.122 -    return status;
   8.123 +    return ADD_TO_LOG(status);
   8.124  
   8.125  enomem:
   8.126      status = PEP_OUT_OF_MEMORY;
   8.127 @@ -1280,7 +1284,7 @@
   8.128      free_stringlist(keys);
   8.129      free_message(msg);
   8.130  
   8.131 -    return status;
   8.132 +    return ADD_TO_LOG(status);
   8.133  }
   8.134  
   8.135  DYNAMIC_API PEP_STATUS encrypt_message_for_self(
   8.136 @@ -1302,18 +1306,18 @@
   8.137      assert(enc_format != PEP_enc_none);
   8.138  
   8.139      if (!(session && src && dst && enc_format != PEP_enc_none))
   8.140 -        return PEP_ILLEGAL_VALUE;
   8.141 +        return ADD_TO_LOG(PEP_ILLEGAL_VALUE);
   8.142  
   8.143      if (src->dir == PEP_dir_incoming)
   8.144 -        return PEP_ILLEGAL_VALUE;
   8.145 +        return ADD_TO_LOG(PEP_ILLEGAL_VALUE);
   8.146  
   8.147      determine_encryption_format(src);
   8.148      if (src->enc_format != PEP_enc_none)
   8.149 -        return PEP_ILLEGAL_VALUE;
   8.150 +        return ADD_TO_LOG(PEP_ILLEGAL_VALUE);
   8.151  
   8.152      status = myself(session, target_id);
   8.153      if (status != PEP_STATUS_OK)
   8.154 -        goto pep_error;
   8.155 +        GOTO(pep_error);
   8.156  
   8.157      *dst = NULL;
   8.158  
   8.159 @@ -1390,7 +1394,7 @@
   8.160      free_stringlist(keys);
   8.161      free_message(msg);
   8.162  
   8.163 -    return status;
   8.164 +    return ADD_TO_LOG(status);
   8.165  }
   8.166  
   8.167  static bool is_a_pEpmessage(const message *msg)
   8.168 @@ -1419,7 +1423,7 @@
   8.169                  && src->from->comm_type != PEP_ct_pEp)
   8.170          {
   8.171              src->from->comm_type |= PEP_ct_pEp_unconfirmed;
   8.172 -            status = update_identity(session, src->from);
   8.173 +            status = set_identity(session, src->from);
   8.174          }
   8.175          return status;
   8.176      }
   8.177 @@ -1457,8 +1461,8 @@
   8.178  
   8.179      char* curr_line = signpost;
   8.180  //    const char* end_text = ptext + psize;
   8.181 -    const char* boundary_key = "boundary=\"";
   8.182 -    const size_t BOUNDARY_KEY_SIZE = 10;
   8.183 +    const char* boundary_key = "boundary=";
   8.184 +    const size_t BOUNDARY_KEY_SIZE = 9;
   8.185  
   8.186      char* start_boundary = strstr(curr_line, boundary_key);
   8.187      if (!start_boundary)
   8.188 @@ -1466,11 +1470,17 @@
   8.189  
   8.190      start_boundary += BOUNDARY_KEY_SIZE;
   8.191  
   8.192 -    char* end_boundary = strstr(start_boundary, "\"");
   8.193 +    bool quoted = (*start_boundary == '"');
   8.194 +
   8.195 +    if (quoted)
   8.196 +        start_boundary++;
   8.197 +        
   8.198 +    char* end_boundary = (quoted ? strstr(start_boundary, "\"") : strstr(start_boundary, ";")); // FIXME: third possiblity is CRLF, or?
   8.199  
   8.200      if (!end_boundary)
   8.201          return PEP_UNKNOWN_ERROR;
   8.202  
   8.203 +    // Add space for the "--"
   8.204      size_t boundary_strlen = (end_boundary - start_boundary) + 2;
   8.205  
   8.206      signed_boundary = calloc(1, boundary_strlen + 1);
   8.207 @@ -1484,7 +1494,11 @@
   8.208  
   8.209      start_boundary += boundary_strlen;
   8.210  
   8.211 -    while (*start_boundary == '\n')
   8.212 +    if (*start_boundary == '\r') {
   8.213 +        if (*(start_boundary + 1) == '\n')
   8.214 +            start_boundary += 2;
   8.215 +    }
   8.216 +    else if (*start_boundary == '\n')
   8.217          start_boundary++;
   8.218  
   8.219      end_boundary = strstr(start_boundary + boundary_strlen, signed_boundary);
   8.220 @@ -1492,7 +1506,10 @@
   8.221      if (!end_boundary)
   8.222          return PEP_UNKNOWN_ERROR;
   8.223  
   8.224 -    end_boundary--; // See RFC3156 section 5...
   8.225 +    // See RFC3156 section 5...
   8.226 +    end_boundary--; 
   8.227 +    if (*(end_boundary - 1) == '\r')
   8.228 +        end_boundary--; 
   8.229  
   8.230      *ssize = end_boundary - start_boundary;
   8.231      *stext = start_boundary;
   8.232 @@ -1578,6 +1595,52 @@
   8.233      return status;
   8.234  }
   8.235  
   8.236 +PEP_STATUS amend_rating_according_to_sender_and_recipients(
   8.237 +    PEP_SESSION session,
   8.238 +    PEP_rating *rating,
   8.239 +    pEp_identity *sender,
   8.240 +    stringlist_t *recipients) {
   8.241 +    
   8.242 +    PEP_STATUS status = PEP_STATUS_OK;
   8.243 +
   8.244 +    if (*rating > PEP_rating_mistrust) {
   8.245 +        PEP_rating kl_rating = PEP_rating_undefined;
   8.246 +
   8.247 +        if (recipients)
   8.248 +            kl_rating = keylist_rating(session, recipients);
   8.249 +
   8.250 +        if (kl_rating <= PEP_rating_mistrust) {
   8.251 +            *rating = kl_rating;
   8.252 +        }
   8.253 +        else if (*rating >= PEP_rating_reliable &&
   8.254 +                 kl_rating < PEP_rating_reliable) {
   8.255 +            *rating = PEP_rating_unreliable;
   8.256 +        }
   8.257 +        else if (*rating >= PEP_rating_reliable &&
   8.258 +                 kl_rating >= PEP_rating_reliable) {
   8.259 +            if (!(sender && sender->user_id && sender->user_id[0])) {
   8.260 +                *rating = PEP_rating_unreliable;
   8.261 +            }
   8.262 +            else {
   8.263 +                char *fpr = recipients->value;
   8.264 +                pEp_identity *_sender = new_identity(sender->address, fpr,
   8.265 +                                                   sender->user_id, sender->username);
   8.266 +                if (_sender == NULL)
   8.267 +                    return PEP_OUT_OF_MEMORY;
   8.268 +                status = get_trust(session, _sender);
   8.269 +                if (_sender->comm_type != PEP_ct_unknown) {
   8.270 +                    *rating = worst_rating(_rating(_sender->comm_type, PEP_rating_undefined),
   8.271 +                              kl_rating);
   8.272 +                }
   8.273 +                free_identity(_sender);
   8.274 +                if (status == PEP_CANNOT_FIND_IDENTITY)
   8.275 +                   status = PEP_STATUS_OK;
   8.276 +            }
   8.277 +        }
   8.278 +    }
   8.279 +    return status;
   8.280 +}
   8.281 +
   8.282  
   8.283  DYNAMIC_API PEP_STATUS _decrypt_message(
   8.284          PEP_SESSION session,
   8.285 @@ -1606,7 +1669,7 @@
   8.286      assert(flags);
   8.287  
   8.288      if (!(session && src && dst && keylist && rating && flags))
   8.289 -        return PEP_ILLEGAL_VALUE;
   8.290 +        return ADD_TO_LOG(PEP_ILLEGAL_VALUE);
   8.291  
   8.292      *flags = 0;
   8.293  
   8.294 @@ -1617,7 +1680,7 @@
   8.295      // we would need to check signature
   8.296      status = _update_identity_for_incoming_message(session, src);
   8.297      if(status != PEP_STATUS_OK)
   8.298 -        return status;
   8.299 +        return ADD_TO_LOG(status);
   8.300  
   8.301      // Get detached signature, if any
   8.302      bloblist_t* detached_sig = NULL;
   8.303 @@ -1651,7 +1714,7 @@
   8.304                                  PEP_decrypt_flag_consume;
   8.305                  }
   8.306                  else if (status != PEP_STATUS_OK) {
   8.307 -                    return status;
   8.308 +                    return ADD_TO_LOG(status);
   8.309                  }
   8.310              }
   8.311              
   8.312 @@ -1683,7 +1746,7 @@
   8.313                  }
   8.314              }
   8.315              
   8.316 -            return PEP_UNENCRYPTED;
   8.317 +            return ADD_TO_LOG(PEP_UNENCRYPTED);
   8.318  
   8.319          case PEP_enc_PGP_MIME:
   8.320              ctext = src->attachments->next->value;
   8.321 @@ -1707,7 +1770,7 @@
   8.322                                                     csize, dsig_text, dsig_size,
   8.323                                                     &ptext, &psize, &_keylist);
   8.324      if (status > PEP_CANNOT_DECRYPT_UNKNOWN){
   8.325 -        goto pep_error;
   8.326 +        GOTO(pep_error);
   8.327      }
   8.328  
   8.329      decrypt_status = status;
   8.330 @@ -1883,7 +1946,9 @@
   8.331              case PEP_enc_PGP_MIME_Outlook1:
   8.332                  status = copy_fields(msg, src);
   8.333                  if (status != PEP_STATUS_OK)
   8.334 -                    goto pep_error;
   8.335 +                {
   8.336 +                    GOTO(pep_error);
   8.337 +                }
   8.338  
   8.339                  if (src->shortmsg == NULL || strcmp(src->shortmsg, "pEp") == 0)
   8.340                  {
   8.341 @@ -1892,9 +1957,24 @@
   8.342  
   8.343                      int r = separate_short_and_long(msg->longmsg, &shortmsg,
   8.344                              &longmsg);
   8.345 +                    
   8.346                      if (r == -1)
   8.347                          goto enomem;
   8.348  
   8.349 +                    if (shortmsg == NULL) {
   8.350 +                        if (src->shortmsg == NULL)
   8.351 +                            shortmsg = strdup("");
   8.352 +                        else {
   8.353 +                            // FIXME: is msg->shortmsg always a copy of
   8.354 +                            // src->shortmsg already?
   8.355 +                            // if so, we need to change the logic so
   8.356 +                            // that in this case, we don't free msg->shortmsg
   8.357 +                            // and do this strdup, etc.
   8.358 +                            shortmsg = strdup(src->shortmsg);
   8.359 +                        }
   8.360 +                    }
   8.361 +
   8.362 +
   8.363                      free(msg->shortmsg);
   8.364                      free(msg->longmsg);
   8.365  
   8.366 @@ -1941,7 +2021,9 @@
   8.367  
   8.368              status = _update_identity_for_incoming_message(session, src);
   8.369              if(status != PEP_STATUS_OK)
   8.370 -                goto pep_error;
   8.371 +            {
   8.372 +                GOTO(pep_error);
   8.373 +            }
   8.374  
   8.375              char *re_ptext = NULL;
   8.376              size_t re_psize;
   8.377 @@ -1955,50 +2037,22 @@
   8.378              free(re_ptext);
   8.379  
   8.380              if (status > PEP_CANNOT_DECRYPT_UNKNOWN)
   8.381 -                goto pep_error;
   8.382 +            {
   8.383 +                GOTO(pep_error);
   8.384 +            }
   8.385  
   8.386              decrypt_status = status;
   8.387          }
   8.388  
   8.389          *rating = decrypt_rating(decrypt_status);
   8.390  
   8.391 -        if (*rating > PEP_rating_mistrust) {
   8.392 -            PEP_rating kl_rating = PEP_rating_undefined;
   8.393 -
   8.394 -            if (_keylist)
   8.395 -                kl_rating = keylist_rating(session, _keylist);
   8.396 -
   8.397 -            if (kl_rating <= PEP_rating_mistrust) {
   8.398 -                *rating = kl_rating;
   8.399 -            }
   8.400 -            else if (*rating >= PEP_rating_reliable &&
   8.401 -                     kl_rating < PEP_rating_reliable) {
   8.402 -                *rating = PEP_rating_unreliable;
   8.403 -            }
   8.404 -            else if (*rating >= PEP_rating_reliable &&
   8.405 -                     kl_rating >= PEP_rating_reliable) {
   8.406 -                if (!(src->from && src->from->user_id && src->from->user_id[0])) {
   8.407 -                    *rating = PEP_rating_unreliable;
   8.408 -                }
   8.409 -                else {
   8.410 -                    char *fpr = _keylist->value;
   8.411 -                    pEp_identity *_from = new_identity(src->from->address, fpr,
   8.412 -                                                       src->from->user_id, src->from->username);
   8.413 -                    if (_from == NULL)
   8.414 -                        goto enomem;
   8.415 -                    status = get_trust(session, _from);
   8.416 -                    if (_from->comm_type != PEP_ct_unknown) {
   8.417 -                        *rating = worst_rating(_rating(_from->comm_type, PEP_rating_undefined),
   8.418 -                                  kl_rating);
   8.419 -                    }
   8.420 -                    free_identity(_from);
   8.421 -                    if (status == PEP_CANNOT_FIND_IDENTITY)
   8.422 -                       status = PEP_STATUS_OK;
   8.423 -                    if (status != PEP_STATUS_OK)
   8.424 -                        goto pep_error;
   8.425 -                }
   8.426 -            }
   8.427 -        }
   8.428 +        status = amend_rating_according_to_sender_and_recipients(session,
   8.429 +                                                                 rating,
   8.430 +                                                                 src->from,
   8.431 +                                                                 _keylist);
   8.432 +
   8.433 +        if (status != PEP_STATUS_OK)
   8.434 +            GOTO(pep_error);
   8.435      }
   8.436      else
   8.437      {
   8.438 @@ -2034,7 +2088,6 @@
   8.439                              PEP_decrypt_flag_ignore :
   8.440                              PEP_decrypt_flag_consume;
   8.441  
   8.442 -                status = decrypt_status;
   8.443              }
   8.444              else if (status != PEP_STATUS_OK){
   8.445                  goto pep_error;
   8.446 @@ -2053,7 +2106,10 @@
   8.447      *dst = msg;
   8.448      *keylist = _keylist;
   8.449  
   8.450 -    return status;
   8.451 +    if(decrypt_status == PEP_DECRYPTED_AND_VERIFIED)
   8.452 +        return ADD_TO_LOG(PEP_STATUS_OK);
   8.453 +    else
   8.454 +        return ADD_TO_LOG(decrypt_status);
   8.455  
   8.456  enomem:
   8.457      status = PEP_OUT_OF_MEMORY;
   8.458 @@ -2063,7 +2119,7 @@
   8.459      free_message(msg);
   8.460      free_stringlist(_keylist);
   8.461  
   8.462 -    return status;
   8.463 +    return ADD_TO_LOG(status);
   8.464  }
   8.465  
   8.466  DYNAMIC_API PEP_STATUS decrypt_message(
   8.467 @@ -2112,8 +2168,7 @@
   8.468  
   8.469      free_identity_list(private_il);
   8.470  
   8.471 -    return status;
   8.472 -
   8.473 +    return ADD_TO_LOG(status);
   8.474  }
   8.475  
   8.476  static void _max_comm_type_from_identity_list(
   8.477 @@ -2154,10 +2209,10 @@
   8.478      assert(rating);
   8.479  
   8.480      if (!(session && msg && rating))
   8.481 -        return PEP_ILLEGAL_VALUE;
   8.482 +        return ADD_TO_LOG(PEP_ILLEGAL_VALUE);
   8.483  
   8.484      if (msg->dir != PEP_dir_outgoing)
   8.485 -        return PEP_ILLEGAL_VALUE;
   8.486 +        return ADD_TO_LOG(PEP_ILLEGAL_VALUE);
   8.487  
   8.488      *rating = PEP_rating_undefined;
   8.489  
   8.490 @@ -2241,7 +2296,7 @@
   8.491  
   8.492      // this should never happen
   8.493      assert(false);
   8.494 -	return PEP_color_no_color;
   8.495 +    return PEP_color_no_color;
   8.496  }
   8.497  
   8.498  DYNAMIC_API PEP_STATUS get_trustwords(
   8.499 @@ -2304,7 +2359,7 @@
   8.500                  goto error_release;
   8.501              break;
   8.502          default:
   8.503 -            return PEP_UNKNOWN_ERROR; // shouldn't be possible
   8.504 +            return ADD_TO_LOG(PEP_UNKNOWN_ERROR); // shouldn't be possible
   8.505      }
   8.506  
   8.507      size_t _wsize = first_wsize + second_wsize;
   8.508 @@ -2346,7 +2401,7 @@
   8.509      the_end:
   8.510      free(first_set);
   8.511      free(second_set);
   8.512 -    return status;
   8.513 +    return ADD_TO_LOG(status);
   8.514  }
   8.515  
   8.516  DYNAMIC_API PEP_STATUS get_message_trustwords(
   8.517 @@ -2432,7 +2487,7 @@
   8.518  
   8.519      if (status != PEP_STATUS_OK) {
   8.520          free_identity(partner);
   8.521 -        return status;
   8.522 +        return ADD_TO_LOG(status);
   8.523      }
   8.524     
   8.525      // Find own identity corresponding to given account address.
   8.526 @@ -2445,7 +2500,7 @@
   8.527  
   8.528      if (status != PEP_STATUS_OK) {
   8.529          free_identity(stored_identity);
   8.530 -        return status;
   8.531 +        return ADD_TO_LOG(status);
   8.532      }
   8.533  
   8.534      // get the trustwords
   8.535 @@ -2454,7 +2509,7 @@
   8.536                              partner, received_by, 
   8.537                              lang, words, &wsize, full);
   8.538  
   8.539 -    return status;
   8.540 +    return ADD_TO_LOG(status);
   8.541  }
   8.542  
   8.543  DYNAMIC_API PEP_STATUS MIME_decrypt_message(
   8.544 @@ -2476,10 +2531,11 @@
   8.545      PEP_STATUS status = PEP_STATUS_OK;
   8.546      message* tmp_msg = NULL;
   8.547      message* dec_msg = NULL;
   8.548 +    *mime_plaintext = NULL;
   8.549  
   8.550      status = mime_decode_message(mimetext, size, &tmp_msg);
   8.551      if (status != PEP_STATUS_OK)
   8.552 -        goto pep_error;
   8.553 +        GOTO(pep_error);
   8.554  
   8.555      PEP_STATUS decrypt_status = decrypt_message(session,
   8.556                                                  tmp_msg,
   8.557 @@ -2492,17 +2548,10 @@
   8.558          dec_msg = message_dup(tmp_msg);
   8.559      }
   8.560          
   8.561 -    if (decrypt_status > PEP_CANNOT_DECRYPT_UNKNOWN)
   8.562 +    if (decrypt_status > PEP_CANNOT_DECRYPT_UNKNOWN || !dec_msg)
   8.563      {
   8.564          status = decrypt_status;
   8.565 -        goto pep_error;
   8.566 -    }
   8.567 -
   8.568 -    assert(dec_msg);
   8.569 -    
   8.570 -    if (!dec_msg) {
   8.571 -        status = PEP_UNKNOWN_ERROR;
   8.572 -        goto pep_error;
   8.573 +        GOTO(pep_error);
   8.574      }
   8.575  
   8.576      status = mime_encode_message(dec_msg, false, mime_plaintext);
   8.577 @@ -2511,14 +2560,14 @@
   8.578      {
   8.579          free(tmp_msg);
   8.580          free(dec_msg);
   8.581 -        return decrypt_status;
   8.582 +        return ADD_TO_LOG(decrypt_status);
   8.583      }
   8.584      
   8.585  pep_error:
   8.586      free_message(tmp_msg);
   8.587      free_message(dec_msg);
   8.588  
   8.589 -    return status;
   8.590 +    return ADD_TO_LOG(status);
   8.591  }
   8.592  
   8.593  
   8.594 @@ -2538,7 +2587,7 @@
   8.595  
   8.596      status = mime_decode_message(mimetext, size, &tmp_msg);
   8.597      if (status != PEP_STATUS_OK)
   8.598 -        goto pep_error;
   8.599 +        GOTO(pep_error);
   8.600  
   8.601      // This isn't incoming, though... so we need to reverse the direction
   8.602      tmp_msg->dir = PEP_dir_outgoing;
   8.603 @@ -2549,12 +2598,12 @@
   8.604                               enc_format,
   8.605                               flags);
   8.606      if (status != PEP_STATUS_OK)
   8.607 -        goto pep_error;
   8.608 +        GOTO(pep_error);
   8.609  
   8.610  
   8.611      if (!enc_msg) {
   8.612          status = PEP_UNKNOWN_ERROR;
   8.613 -        goto pep_error;
   8.614 +        GOTO(pep_error);
   8.615      }
   8.616  
   8.617      status = mime_encode_message(enc_msg, false, mime_ciphertext);
   8.618 @@ -2563,7 +2612,7 @@
   8.619      free_message(tmp_msg);
   8.620      free_message(enc_msg);
   8.621  
   8.622 -    return status;
   8.623 +    return ADD_TO_LOG(status);
   8.624  
   8.625  }
   8.626  
   8.627 @@ -2607,5 +2656,145 @@
   8.628      free_message(tmp_msg);
   8.629      free_message(enc_msg);
   8.630  
   8.631 -    return status;
   8.632 +    return ADD_TO_LOG(status);
   8.633  }
   8.634 +
   8.635 +static PEP_rating string_to_rating(const char * rating)
   8.636 +{
   8.637 +    if (rating == NULL)
   8.638 +        return PEP_rating_undefined;
   8.639 +    if (strcmp(rating, "cannot_decrypt") == 0)
   8.640 +        return PEP_rating_cannot_decrypt;
   8.641 +    if (strcmp(rating, "have_no_key") == 0)
   8.642 +        return PEP_rating_have_no_key;
   8.643 +    if (strcmp(rating, "unencrypted") == 0)
   8.644 +        return PEP_rating_unencrypted;
   8.645 +    if (strcmp(rating, "unencrypted_for_some") == 0)
   8.646 +        return PEP_rating_unencrypted_for_some;
   8.647 +    if (strcmp(rating, "unreliable") == 0)
   8.648 +        return PEP_rating_unreliable;
   8.649 +    if (strcmp(rating, "reliable") == 0)
   8.650 +        return PEP_rating_reliable;
   8.651 +    if (strcmp(rating, "trusted") == 0)
   8.652 +        return PEP_rating_trusted;
   8.653 +    if (strcmp(rating, "trusted_and_anonymized") == 0)
   8.654 +        return PEP_rating_trusted_and_anonymized;
   8.655 +    if (strcmp(rating, "fully_anonymous") == 0)
   8.656 +        return PEP_rating_fully_anonymous;
   8.657 +    if (strcmp(rating, "mistrust") == 0)
   8.658 +        return PEP_rating_mistrust;
   8.659 +    if (strcmp(rating, "b0rken") == 0)
   8.660 +        return PEP_rating_b0rken;
   8.661 +    if (strcmp(rating, "under_attack") == 0)
   8.662 +        return PEP_rating_under_attack;
   8.663 +    return PEP_rating_undefined;
   8.664 +}
   8.665 +
   8.666 +static PEP_STATUS string_to_keylist(const char * skeylist, stringlist_t **keylist)
   8.667 +{
   8.668 +    if (skeylist == NULL || keylist == NULL)
   8.669 +        return PEP_ILLEGAL_VALUE;
   8.670 +
   8.671 +    stringlist_t *rkeylist = NULL;
   8.672 +    stringlist_t *_kcurr = NULL;
   8.673 +    const char * fpr_begin = skeylist;
   8.674 +    const char * fpr_end = NULL;
   8.675 +
   8.676 +    do {
   8.677 +        fpr_end = strstr(fpr_begin, ",");
   8.678 +        
   8.679 +        char * fpr = strndup(
   8.680 +            fpr_begin,
   8.681 +            (fpr_end == NULL) ? strlen(fpr_begin) : fpr_end - fpr_begin);
   8.682 +        
   8.683 +        if (fpr == NULL)
   8.684 +            goto enomem;
   8.685 +        
   8.686 +        _kcurr = stringlist_add(_kcurr, fpr);
   8.687 +        if (_kcurr == NULL) {
   8.688 +            free(fpr);
   8.689 +            goto enomem;
   8.690 +        }
   8.691 +        
   8.692 +        if (rkeylist == NULL)
   8.693 +            rkeylist = _kcurr;
   8.694 +        
   8.695 +        fpr_begin = fpr_end ? fpr_end + 1 : NULL;
   8.696 +        
   8.697 +    } while (fpr_begin);
   8.698 +    
   8.699 +    *keylist = rkeylist;
   8.700 +    return PEP_STATUS_OK;
   8.701 +    
   8.702 +enomem:
   8.703 +    free_stringlist(rkeylist);
   8.704 +    return PEP_OUT_OF_MEMORY;
   8.705 +}
   8.706 +
   8.707 +DYNAMIC_API PEP_STATUS re_evaluate_message_rating(
   8.708 +    PEP_SESSION session,
   8.709 +    message *msg,
   8.710 +    stringlist_t *x_keylist,
   8.711 +    PEP_rating x_enc_status,
   8.712 +    PEP_rating *rating
   8.713 +)
   8.714 +{
   8.715 +    PEP_STATUS status = PEP_STATUS_OK;
   8.716 +    stringlist_t *_keylist = x_keylist;
   8.717 +    bool must_free_keylist = false;
   8.718 +    PEP_rating _rating;
   8.719 +
   8.720 +    assert(session);
   8.721 +    assert(msg);
   8.722 +    assert(rating);
   8.723 +
   8.724 +    if (!(session && msg && rating))
   8.725 +        return ADD_TO_LOG(PEP_ILLEGAL_VALUE);
   8.726 +
   8.727 +    *rating = PEP_rating_undefined;
   8.728 +
   8.729 +    if (x_enc_status == PEP_rating_undefined){
   8.730 +        for (stringpair_list_t *i = msg->opt_fields; i && i->value ; i=i->next) {
   8.731 +            if (strcasecmp(i->value->key, "X-EncStatus") == 0){
   8.732 +                x_enc_status = string_to_rating(i->value->value);
   8.733 +                goto got_rating;
   8.734 +            }
   8.735 +        }
   8.736 +        return ADD_TO_LOG(PEP_ILLEGAL_VALUE);
   8.737 +    }
   8.738 +
   8.739 +got_rating:
   8.740 +
   8.741 +    _rating = x_enc_status;
   8.742 +
   8.743 +    if (_keylist == NULL){
   8.744 +        for (stringpair_list_t *i = msg->opt_fields; i && i->value ; i=i->next) {
   8.745 +            if (strcasecmp(i->value->key, "X-KeyList") == 0){
   8.746 +                status = string_to_keylist(i->value->value, &_keylist);
   8.747 +                if (status != PEP_STATUS_OK)
   8.748 +                    GOTO(pep_error);
   8.749 +                must_free_keylist = true;
   8.750 +                goto got_keylist;
   8.751 +            }
   8.752 +        }
   8.753 +        return ADD_TO_LOG(PEP_ILLEGAL_VALUE);
   8.754 +    }
   8.755 +got_keylist:
   8.756 +
   8.757 +    status = update_identity(session, msg->from);
   8.758 +    if (status != PEP_STATUS_OK)
   8.759 +        GOTO(pep_error);
   8.760 +
   8.761 +    status = amend_rating_according_to_sender_and_recipients(session,
   8.762 +                                                             &_rating,
   8.763 +                                                             msg->from,
   8.764 +                                                             _keylist);
   8.765 +    if (status == PEP_STATUS_OK)
   8.766 +        *rating = _rating;
   8.767 +    
   8.768 +pep_error:
   8.769 +    if (must_free_keylist)
   8.770 +        free_stringlist(_keylist);
   8.771 +
   8.772 +    return ADD_TO_LOG(status);
   8.773 +}
     9.1 --- a/src/message_api.h	Fri Jun 02 11:55:04 2017 +0200
     9.2 +++ b/src/message_api.h	Thu Jun 15 11:35:44 2017 +0200
     9.3 @@ -47,11 +47,14 @@
     9.4  //
     9.5  //  return value:
     9.6  //      PEP_STATUS_OK                   on success
     9.7 -//		PEP_KEY_NOT_FOUND	            at least one of the receipient keys
     9.8 -//		                                could not be found
     9.9 -//		PEP_KEY_HAS_AMBIG_NAME          at least one of the receipient keys has
    9.10 -//		                                an ambiguous name
    9.11 -//		PEP_GET_KEY_FAILED		        cannot retrieve key
    9.12 +//      PEP_KEY_NOT_FOUND	            at least one of the receipient keys
    9.13 +//                                      could not be found
    9.14 +//      PEP_KEY_HAS_AMBIG_NAME          at least one of the receipient keys has
    9.15 +//                                      an ambiguous name
    9.16 +//      PEP_GET_KEY_FAILED		        cannot retrieve key
    9.17 +//      PEP_UNENCRYPTED                 no recipients with usable key, 
    9.18 +//                                      message is left unencrypted,
    9.19 +//                                      and key is attached to it
    9.20  //
    9.21  //	caveat:
    9.22  //	    the ownershop of src remains with the caller
    9.23 @@ -224,7 +227,9 @@
    9.24  //      flags (out)         flags to signal special decryption features
    9.25  //
    9.26  //  return value:
    9.27 -//      error status or PEP_STATUS_OK on success
    9.28 +//      error status 
    9.29 +//      or PEP_DECRYPTED if message decrypted but not verified
    9.30 +//      or PEP_STATUS_OK on success
    9.31  //
    9.32  //	caveat:
    9.33  //	    the ownership of src remains with the caller
    9.34 @@ -422,6 +427,35 @@
    9.35      const char* lang, char **words, bool full
    9.36  );
    9.37  
    9.38 +// re_evaluate_message_rating() - re-evaluate already decrypted message rating
    9.39 +//
    9.40 +//  parameters:
    9.41 +//      session (in)            session handle
    9.42 +//      msg (in)                message to get the rating for
    9.43 +//      x_keylist (in)          decrypted message recipients keys fpr
    9.44 +//      x_enc_status (in)       original rating for the decrypted message
    9.45 +//      rating (out)            rating for the message
    9.46 +//
    9.47 +//  return value:
    9.48 +//      PEP_ILLEGAL_VALUE       if decrypted message doesn't contain 
    9.49 +//                              X-EncStatus optional field and x_enc_status is 
    9.50 +//                              pEp_rating_udefined
    9.51 +//                              or if decrypted message doesn't contain 
    9.52 +//                              X-Keylist optional field and x_keylist is NULL
    9.53 +//      PEP_OUT_OF_MEMORY       if not enough memory could be allocated
    9.54 +//
    9.55 +//  caveat:
    9.56 +//      msg->from must point to a valid pEp_identity
    9.57 +//      the ownership of msg remains with the caller
    9.58 +//	    the ownership of x_keylist remains with to the caller
    9.59 +
    9.60 +DYNAMIC_API PEP_STATUS re_evaluate_message_rating(
    9.61 +    PEP_SESSION session,
    9.62 +    message *msg,
    9.63 +    stringlist_t *x_keylist,
    9.64 +    PEP_rating x_enc_status,
    9.65 +    PEP_rating *rating
    9.66 +);
    9.67  #ifdef __cplusplus
    9.68  }
    9.69  #endif
    10.1 --- a/src/pEpEngine.c	Fri Jun 02 11:55:04 2017 +0200
    10.2 +++ b/src/pEpEngine.c	Thu Jun 15 11:35:44 2017 +0200
    10.3 @@ -29,6 +29,11 @@
    10.4      "       and pgp_keypair_fpr = identity.main_key_id"
    10.5      "   where address = ?1 and identity.user_id = ?2;";
    10.6  
    10.7 +static const char *sql_replace_identities_fpr =  
    10.8 +    "update identity"
    10.9 +    "   set main_key_id = ?1 "
   10.10 +    "   where main_key_id = ?2 ;";
   10.11 +
   10.12  // Set person, but if already exist, only update.
   10.13  // if main_key_id already set, don't touch.
   10.14  static const char *sql_set_person = 
   10.15 @@ -85,6 +90,11 @@
   10.16      "insert or replace into trust (user_id, pgp_keypair_fpr, comm_type) "
   10.17      "values (?1, upper(replace(?2,' ','')), ?3) ;";
   10.18  
   10.19 +static const char *sql_update_trust_for_fpr =
   10.20 +    "update trust "
   10.21 +    "set comm_type = ?1 "
   10.22 +    "where pgp_keypair_fpr = upper(replace(?2,' ','')) ;";
   10.23 +
   10.24  static const char *sql_get_trust = 
   10.25      "select comm_type from trust where user_id = ?1 "
   10.26      "and pgp_keypair_fpr = upper(replace(?2,' ','')) ;";
   10.27 @@ -136,7 +146,11 @@
   10.28      " union "
   10.29      "  select main_key_id from identity "
   10.30      "   where main_key_id = upper(replace(?1,' ',''))"
   10.31 -    "    and user_id = '" PEP_OWN_USERID "' );";
   10.32 +    "    and user_id = '" PEP_OWN_USERID "' "
   10.33 +    " union "
   10.34 +    "  select fpr from own_keys "
   10.35 +    "   where fpr = upper(replace(?1,' ',''))"
   10.36 +    " );";
   10.37  
   10.38  static const char *sql_own_identities_retrieve =  
   10.39      "select address, fpr, username, "
   10.40 @@ -209,6 +223,7 @@
   10.41      int int_result;
   10.42      
   10.43      bool in_first = false;
   10.44 +    bool very_first = false;
   10.45  
   10.46      assert(sqlite3_threadsafe());
   10.47      if (!sqlite3_threadsafe())
   10.48 @@ -234,6 +249,10 @@
   10.49  
   10.50      _session->version = PEP_ENGINE_VERSION;
   10.51  
   10.52 +#ifdef DEBUG_ERRORSTACK
   10.53 +    _session->errorstack = new_stringlist("init()");
   10.54 +#endif
   10.55 +
   10.56      assert(LOCAL_DB);
   10.57      if (LOCAL_DB == NULL) {
   10.58          status = PEP_INIT_CANNOT_OPEN_DB;
   10.59 @@ -462,6 +481,11 @@
   10.60                  assert(int_result == SQLITE_OK);
   10.61              }
   10.62          }
   10.63 +        else { 
   10.64 +            // Version from DB was 0, it means this is initial setup.
   10.65 +            // DB has just been created, and all tables are empty.
   10.66 +            very_first = true;
   10.67 +        }
   10.68  
   10.69          if (version < atoi(_DDL_USER_VERSION)) {
   10.70              int_result = sqlite3_exec(
   10.71 @@ -475,7 +499,6 @@
   10.72              );
   10.73              assert(int_result == SQLITE_OK);
   10.74          }
   10.75 -
   10.76      }
   10.77  
   10.78      int_result = sqlite3_prepare_v2(_session->db, sql_log,
   10.79 @@ -490,6 +513,11 @@
   10.80              (int)strlen(sql_get_identity), &_session->get_identity, NULL);
   10.81      assert(int_result == SQLITE_OK);
   10.82  
   10.83 +    int_result = sqlite3_prepare_v2(_session->db, sql_replace_identities_fpr,
   10.84 +            (int)strlen(sql_replace_identities_fpr), 
   10.85 +            &_session->replace_identities_fpr, NULL);
   10.86 +    assert(int_result == SQLITE_OK);
   10.87 +
   10.88      int_result = sqlite3_prepare_v2(_session->db, sql_set_person,
   10.89              (int)strlen(sql_set_person), &_session->set_person, NULL);
   10.90      assert(int_result == SQLITE_OK);
   10.91 @@ -525,6 +553,10 @@
   10.92              (int)strlen(sql_set_trust), &_session->set_trust, NULL);
   10.93      assert(int_result == SQLITE_OK);
   10.94  
   10.95 +    int_result = sqlite3_prepare_v2(_session->db, sql_update_trust_for_fpr,
   10.96 +            (int)strlen(sql_update_trust_for_fpr), &_session->update_trust_for_fpr, NULL);
   10.97 +    assert(int_result == SQLITE_OK);
   10.98 +
   10.99      int_result = sqlite3_prepare_v2(_session->db, sql_get_trust,
  10.100              (int)strlen(sql_get_trust), &_session->get_trust, NULL);
  10.101      assert(int_result == SQLITE_OK);
  10.102 @@ -635,11 +667,44 @@
  10.103      // runtime config
  10.104  
  10.105  #ifdef ANDROID
  10.106 -    _session->use_only_own_private_keys = true;
  10.107  #elif TARGET_OS_IPHONE
  10.108 -    _session->use_only_own_private_keys = true;
  10.109 -#else
  10.110 -    _session->use_only_own_private_keys = false;
  10.111 +#else /* Desktop */
  10.112 +    if (very_first)
  10.113 +    {
  10.114 +        // On first run, all private keys already present in PGP keyring 
  10.115 +        // are taken as own in order to seamlessly integrate with
  10.116 +        // pre-existing GPG setup.
  10.117 +
  10.118 +        ////////////////////////////// WARNING: ///////////////////////////
  10.119 +        // Considering all PGP priv keys as own is dangerous in case of 
  10.120 +        // re-initialization of pEp DB, while keeping PGP keyring as-is!
  10.121 +        //
  10.122 +        // Indeed, if pEpEngine did import spoofed private keys in previous
  10.123 +        // install, then those keys become automatically trusted in case 
  10.124 +        // pEp_management.db is deleted.
  10.125 +        //
  10.126 +        // A solution to distinguish bare GPG keyring from pEp keyring is
  10.127 +        // needed here. Then keys managed by pEpEngine wouldn't be
  10.128 +        // confused with GPG keys managed by the user through GPA.
  10.129 +        ///////////////////////////////////////////////////////////////////
  10.130 +        
  10.131 +        stringlist_t *keylist = NULL;
  10.132 +
  10.133 +        status = find_private_keys(_session, NULL, &keylist);
  10.134 +        assert(status != PEP_OUT_OF_MEMORY);
  10.135 +        if (status == PEP_OUT_OF_MEMORY)
  10.136 +            return PEP_OUT_OF_MEMORY;
  10.137 +        
  10.138 +        if (keylist != NULL && keylist->value != NULL)
  10.139 +        {
  10.140 +            stringlist_t *_keylist;
  10.141 +            for (_keylist = keylist; _keylist && _keylist->value; _keylist = _keylist->next) {
  10.142 +                status = set_own_key(_session, 
  10.143 +                                     "" /* address is unused in own_keys */,
  10.144 +                                     _keylist->value);
  10.145 +            }
  10.146 +        }
  10.147 +    }
  10.148  #endif
  10.149  
  10.150      // sync_session set to own session by default
  10.151 @@ -685,6 +750,8 @@
  10.152                  sqlite3_finalize(session->trustword);
  10.153              if (session->get_identity)
  10.154                  sqlite3_finalize(session->get_identity);
  10.155 +            if (session->replace_identities_fpr)
  10.156 +                sqlite3_finalize(session->replace_identities_fpr);        
  10.157              if (session->set_person)
  10.158                  sqlite3_finalize(session->set_person);
  10.159              if (session->set_device_group)
  10.160 @@ -701,6 +768,8 @@
  10.161                  sqlite3_finalize(session->unset_identity_flags);
  10.162              if (session->set_trust)
  10.163                  sqlite3_finalize(session->set_trust);
  10.164 +            if (session->update_trust_for_fpr)
  10.165 +                sqlite3_finalize(session->update_trust_for_fpr);
  10.166              if (session->get_trust)
  10.167                  sqlite3_finalize(session->get_trust);
  10.168              if (session->least_trust)
  10.169 @@ -749,6 +818,9 @@
  10.170          release_transport_system(session, out_last);
  10.171          release_cryptotech(session, out_last);
  10.172  
  10.173 +#ifdef DEBUG_ERRORSTACK
  10.174 +        free_stringlist(session->errorstack);
  10.175 +#endif
  10.176          free(session);
  10.177      }
  10.178  }
  10.179 @@ -765,19 +837,18 @@
  10.180      session->unencrypted_subject = enable;
  10.181  }
  10.182  
  10.183 -DYNAMIC_API void config_use_only_own_private_keys(PEP_SESSION session,
  10.184 -        bool enable)
  10.185 -{
  10.186 -    assert(session);
  10.187 -    session->use_only_own_private_keys = enable;
  10.188 -}
  10.189 -
  10.190  DYNAMIC_API void config_keep_sync_msg(PEP_SESSION session, bool enable)
  10.191  {
  10.192      assert(session);
  10.193      session->keep_sync_msg = enable;
  10.194  }
  10.195  
  10.196 +DYNAMIC_API void config_service_log(PEP_SESSION session, bool enable)
  10.197 +{
  10.198 +    assert(session);
  10.199 +    session->service_log = enable;
  10.200 +}
  10.201 +
  10.202  DYNAMIC_API PEP_STATUS log_event(
  10.203          PEP_SESSION session,
  10.204          const char *title,
  10.205 @@ -815,7 +886,25 @@
  10.206      } while (result == SQLITE_BUSY);
  10.207      sqlite3_reset(session->log);
  10.208  
  10.209 -    return status;
  10.210 +    return ADD_TO_LOG(status);
  10.211 +}
  10.212 +
  10.213 +DYNAMIC_API PEP_STATUS log_service(
  10.214 +        PEP_SESSION session,
  10.215 +        const char *title,
  10.216 +        const char *entity,
  10.217 +        const char *description,
  10.218 +        const char *comment
  10.219 +    )
  10.220 +{
  10.221 +    assert(session);
  10.222 +    if (!session)
  10.223 +        return PEP_ILLEGAL_VALUE;
  10.224 +
  10.225 +    if (session->service_log)
  10.226 +        return log_event(session, title, entity, description, comment);
  10.227 +    else
  10.228 +        return PEP_STATUS_OK;
  10.229  }
  10.230  
  10.231  DYNAMIC_API PEP_STATUS trustword(
  10.232 @@ -1105,13 +1194,15 @@
  10.233                  identity->user_id && identity->username))
  10.234          return PEP_ILLEGAL_VALUE;
  10.235  
  10.236 +    PEP_STATUS status = PEP_STATUS_OK;
  10.237 +    
  10.238      bool listed;
  10.239  
  10.240      bool has_fpr = (identity->fpr && identity->fpr[0] != '\0');
  10.241      
  10.242      if (has_fpr) {    
  10.243          // blacklist check
  10.244 -        PEP_STATUS status = blacklist_is_listed(session, identity->fpr, &listed);
  10.245 +        status = blacklist_is_listed(session, identity->fpr, &listed);
  10.246          assert(status == PEP_STATUS_OK);
  10.247          if (status != PEP_STATUS_OK)
  10.248              return status;
  10.249 @@ -1189,6 +1280,8 @@
  10.250              }
  10.251          }
  10.252  
  10.253 +        // status = set_trust(session, identity->user_id, identity->fpr,
  10.254 +        //                    identity->comm_type)
  10.255          sqlite3_reset(session->set_trust);
  10.256          sqlite3_bind_text(session->set_trust, 1, identity->user_id, -1,
  10.257                  SQLITE_STATIC);
  10.258 @@ -1210,6 +1303,52 @@
  10.259          return PEP_COMMIT_FAILED;
  10.260  }
  10.261  
  10.262 +PEP_STATUS replace_identities_fpr(PEP_SESSION session, 
  10.263 +                                 const char* old_fpr, 
  10.264 +                                 const char* new_fpr) 
  10.265 +{
  10.266 +    assert(old_fpr);
  10.267 +    assert(new_fpr);
  10.268 +    
  10.269 +    if (!old_fpr || !new_fpr)
  10.270 +        return PEP_ILLEGAL_VALUE;
  10.271 +            
  10.272 +    sqlite3_reset(session->replace_identities_fpr);
  10.273 +    sqlite3_bind_text(session->replace_identities_fpr, 1, new_fpr, -1,
  10.274 +                      SQLITE_STATIC);
  10.275 +    sqlite3_bind_text(session->replace_identities_fpr, 2, old_fpr, -1,
  10.276 +                      SQLITE_STATIC);
  10.277 +
  10.278 +    int result = sqlite3_step(session->replace_identities_fpr);
  10.279 +    sqlite3_reset(session->replace_identities_fpr);
  10.280 +    
  10.281 +    if (result != SQLITE_DONE)
  10.282 +        return PEP_CANNOT_SET_IDENTITY;
  10.283 +
  10.284 +    return PEP_STATUS_OK;
  10.285 +}
  10.286 +
  10.287 +
  10.288 +PEP_STATUS update_trust_for_fpr(PEP_SESSION session, 
  10.289 +                                const char* fpr, 
  10.290 +                                PEP_comm_type comm_type)
  10.291 +{
  10.292 +    if (!fpr)
  10.293 +        return PEP_ILLEGAL_VALUE;
  10.294 +        
  10.295 +    sqlite3_reset(session->update_trust_for_fpr);
  10.296 +    sqlite3_bind_int(session->update_trust_for_fpr, 1, comm_type);
  10.297 +    sqlite3_bind_text(session->update_trust_for_fpr, 2, fpr, -1,
  10.298 +            SQLITE_STATIC);
  10.299 +    int result = sqlite3_step(session->update_trust_for_fpr);
  10.300 +    sqlite3_reset(session->update_trust_for_fpr);
  10.301 +    if (result != SQLITE_DONE) {
  10.302 +        return PEP_CANNOT_SET_TRUST;
  10.303 +    }
  10.304 +    
  10.305 +    return PEP_STATUS_OK;
  10.306 +}
  10.307 +
  10.308  DYNAMIC_API PEP_STATUS set_device_group(
  10.309          PEP_SESSION session,
  10.310          const char *group_name
  10.311 @@ -1863,7 +2002,7 @@
  10.312      status = PEP_OUT_OF_MEMORY;
  10.313  
  10.314  the_end:
  10.315 -    return status;
  10.316 +    return ADD_TO_LOG(status);
  10.317  }
  10.318  
  10.319  DYNAMIC_API PEP_STATUS get_languagelist(
  10.320 @@ -2252,8 +2391,8 @@
  10.321  
  10.322  PEP_STATUS find_private_keys(PEP_SESSION session, const char* pattern,
  10.323                               stringlist_t **keylist) {
  10.324 -    assert(session && pattern && keylist);
  10.325 -    if (!(session && pattern && keylist))
  10.326 +    assert(session && keylist);
  10.327 +    if (!(session && keylist))
  10.328          return PEP_ILLEGAL_VALUE;
  10.329      
  10.330      return session->cryptotech[PEP_crypt_OpenPGP].find_private_keys(session, pattern,
  10.331 @@ -2286,3 +2425,52 @@
  10.332  
  10.333      return PEP_STATUS_OK;
  10.334  }
  10.335 +
  10.336 +#ifdef DEBUG_ERRORSTACK
  10.337 +PEP_STATUS session_add_error(PEP_SESSION session, const char* file, unsigned line, PEP_STATUS status)
  10.338 +{
  10.339 +    char logline[48];
  10.340 +    if(status>0)
  10.341 +    {
  10.342 +        snprintf(logline,47, "%.24s:%u status=%u (0x%x)", file, line, status, status);
  10.343 +    }else{
  10.344 +        snprintf(logline,47, "%.24s:%u status=%i.", file, line, status);
  10.345 +    }
  10.346 +    stringlist_add(session->errorstack, logline); // logline is copied! :-)
  10.347 +    return status;
  10.348 +}
  10.349 +
  10.350 +DYNAMIC_API const stringlist_t* get_errorstack(PEP_SESSION session)
  10.351 +{
  10.352 +    return session->errorstack;
  10.353 +}
  10.354 +
  10.355 +DYNAMIC_API void clear_errorstack(PEP_SESSION session)
  10.356 +{
  10.357 +    const int old_len = stringlist_length(session->errorstack);
  10.358 +    char buf[48];
  10.359 +    free_stringlist(session->errorstack);
  10.360 +    snprintf(buf, 47, "(%i elements cleared)", old_len);
  10.361 +    session->errorstack = new_stringlist(buf);
  10.362 +}
  10.363 +
  10.364 +#else
  10.365 +
  10.366 +static stringlist_t* dummy_errorstack = NULL;
  10.367 +
  10.368 +DYNAMIC_API const stringlist_t* get_errorstack(PEP_SESSION session)
  10.369 +{
  10.370 +    if(dummy_errorstack == NULL)
  10.371 +    {
  10.372 +        dummy_errorstack = new_stringlist("( Please recompile pEpEngine with -DDEBUG_ERRORSTACK )");
  10.373 +    }
  10.374 +
  10.375 +    return dummy_errorstack;
  10.376 +}
  10.377 +
  10.378 +DYNAMIC_API void clear_errorstack(PEP_SESSION session)
  10.379 +{
  10.380 +    // nothing to do here
  10.381 +}
  10.382 +
  10.383 +#endif
    11.1 --- a/src/pEpEngine.h	Fri Jun 02 11:55:04 2017 +0200
    11.2 +++ b/src/pEpEngine.h	Thu Jun 15 11:35:44 2017 +0200
    11.3 @@ -46,6 +46,7 @@
    11.4      PEP_KEY_HAS_AMBIG_NAME                          = 0x0202,
    11.5      PEP_GET_KEY_FAILED                              = 0x0203,
    11.6      PEP_CANNOT_EXPORT_KEY                           = 0x0204,
    11.7 +    PEP_CANNOT_EDIT_KEY                             = 0x0205,
    11.8      
    11.9      PEP_CANNOT_FIND_IDENTITY                        = 0x0301,
   11.10      PEP_CANNOT_SET_PERSON                           = 0x0381,
   11.11 @@ -147,6 +148,25 @@
   11.12  DYNAMIC_API void release(PEP_SESSION session);
   11.13  
   11.14  
   11.15 +// const stringlist_t* get_errorstack(PEP_SESSION) - get the error stack for that session, if any
   11.16 +//
   11.17 +//  parameters:
   11.18 +//        session (in)    session handle
   11.19 +//
   11.20 +//    caveat:
   11.21 +//        To get a useful error stack you have to compile with -DDEBUG_ERRORSTACK
   11.22 +//        The error stack belongs to the session. Do no not change it!
   11.23 +DYNAMIC_API const stringlist_t* get_errorstack(PEP_SESSION session);
   11.24 +
   11.25 +
   11.26 +// void clear_errorstack(PEP_SESSION) - clear the error stack for that session, if any
   11.27 +//
   11.28 +//  parameters:
   11.29 +//        session (in)    session handle
   11.30 +//
   11.31 +DYNAMIC_API void clear_errorstack(PEP_SESSION session);
   11.32 +
   11.33 +
   11.34  // config_passive_mode() - enable passive mode
   11.35  //
   11.36  //  parameters:
   11.37 @@ -182,6 +202,14 @@
   11.38  DYNAMIC_API void config_keep_sync_msg(PEP_SESSION session, bool enable);
   11.39  
   11.40  
   11.41 +// config_service_log() - log more for service purposes
   11.42 +//
   11.43 +//      session (in)    session handle
   11.44 +//      enable (in)     flag if enabled or disabled
   11.45 +
   11.46 +DYNAMIC_API void config_service_log(PEP_SESSION session, bool enable);
   11.47 +
   11.48 +
   11.49  // decrypt_and_verify() - decrypt and/or verify a message
   11.50  //
   11.51  //    parameters:
   11.52 @@ -296,6 +324,17 @@
   11.53      );
   11.54  
   11.55  
   11.56 +DYNAMIC_API PEP_STATUS log_service(PEP_SESSION session, const char *title,
   11.57 +        const char *entity, const char *description, const char *comment);
   11.58 +
   11.59 +#define _STR_(x) #x
   11.60 +#define _D_STR_(x) _STR_(x)
   11.61 +#define S_LINE _D_STR_(__LINE__)
   11.62 +
   11.63 +#define SERVICE_LOG(session, title, entity, desc) \
   11.64 +    log_service((session), (title), (entity), (desc), "service " __FILE__ ":" S_LINE)
   11.65 +
   11.66 +
   11.67  // trustword() - get the corresponding trustword for a 16 bit value
   11.68  //
   11.69  //    parameters:
   11.70 @@ -524,6 +563,11 @@
   11.71          pEp_identity **identity
   11.72      );
   11.73  
   11.74 +PEP_STATUS replace_identities_fpr(PEP_SESSION session, 
   11.75 +                                 const char* old_fpr, 
   11.76 +                                 const char* new_fpr); 
   11.77 +
   11.78 +
   11.79  // set_identity() - set identity information
   11.80  //
   11.81  //    parameters:
   11.82 @@ -807,6 +851,14 @@
   11.83  
   11.84  DYNAMIC_API PEP_STATUS get_trust(PEP_SESSION session, pEp_identity *identity);
   11.85  
   11.86 +PEP_STATUS set_trust(PEP_SESSION session, 
   11.87 +                            const char* user_id,
   11.88 +                            const char* fpr, 
   11.89 +                            PEP_comm_type comm_type);
   11.90 +                            
   11.91 +PEP_STATUS update_trust_for_fpr(PEP_SESSION session, 
   11.92 +                                const char* fpr, 
   11.93 +                                PEP_comm_type comm_type);
   11.94  
   11.95  // least_trust() - get the least known trust level for a key in the database
   11.96  //
   11.97 @@ -905,6 +957,12 @@
   11.98          bool *revoked
   11.99      );
  11.100  
  11.101 +PEP_STATUS get_key_userids(
  11.102 +        PEP_SESSION session,
  11.103 +        const char* fpr,
  11.104 +        stringlist_t** keylist
  11.105 +    );
  11.106 +
  11.107  
  11.108  // get_crashdump_log() - get the last log messages out
  11.109  //
    12.1 --- a/src/pEp_internal.h	Fri Jun 02 11:55:04 2017 +0200
    12.2 +++ b/src/pEp_internal.h	Thu Jun 15 11:35:44 2017 +0200
    12.3 @@ -100,6 +100,7 @@
    12.4      sqlite3_stmt *log;
    12.5      sqlite3_stmt *trustword;
    12.6      sqlite3_stmt *get_identity;
    12.7 +    sqlite3_stmt *replace_identities_fpr;
    12.8      sqlite3_stmt *set_person;
    12.9      sqlite3_stmt *set_device_group;
   12.10      sqlite3_stmt *get_device_group;
   12.11 @@ -108,6 +109,7 @@
   12.12      sqlite3_stmt *set_identity_flags;
   12.13      sqlite3_stmt *unset_identity_flags;
   12.14      sqlite3_stmt *set_trust;
   12.15 +    sqlite3_stmt *update_trust_for_fpr;
   12.16      sqlite3_stmt *get_trust;
   12.17      sqlite3_stmt *least_trust;
   12.18      sqlite3_stmt *mark_compromized;
   12.19 @@ -159,11 +161,15 @@
   12.20  
   12.21      bool passive_mode;
   12.22      bool unencrypted_subject;
   12.23 -    bool use_only_own_private_keys;
   12.24      bool keep_sync_msg;
   12.25 +    bool service_log;
   12.26      
   12.27 +#ifdef DEBUG_ERRORSTACK
   12.28 +    stringlist_t* errorstack;
   12.29 +#endif
   12.30  };
   12.31  
   12.32 +
   12.33  PEP_STATUS init_transport_system(PEP_SESSION session, bool in_first);
   12.34  void release_transport_system(PEP_SESSION session, bool out_last);
   12.35  
   12.36 @@ -178,14 +184,14 @@
   12.37  // #else
   12.38  #ifdef ANDROID
   12.39  #include <android/log.h>
   12.40 -#define  LOG_MORE(...)  __android_log_print(ANDROID_LOG_DEBUG, "pEpEngine", " %s :: %s :: %s ", __VA_ARGS__);
   12.41 +#define  LOG_MORE(...)  __android_log_print(ANDROID_LOG_DEBUG, "pEpEngine", " %s :: %s :: %s :: %s ", __VA_ARGS__);
   12.42  #else
   12.43  #include <stdio.h>
   12.44 -#define  LOG_MORE(...)  printf("pEpEngine DEBUG_LOG('%s','%s','%s')\n", __VA_ARGS__);
   12.45 +#define  LOG_MORE(...)  fprintf(stderr, "pEpEngine DEBUG_LOG('%s','%s','%s','%s')\n", __VA_ARGS__);
   12.46  #endif
   12.47  #define DEBUG_LOG(TITLE, ENTITY, DESC) {\
   12.48 -    log_event(session, (TITLE), (ENTITY), (DESC), "debug");\
   12.49 -    LOG_MORE((TITLE), (ENTITY), (DESC))\
   12.50 +    log_event(session, (TITLE), (ENTITY), (DESC), "debug " __FILE__ ":" S_LINE);\
   12.51 +    LOG_MORE((TITLE), (ENTITY), (DESC), __FILE__ ":" S_LINE)\
   12.52  }
   12.53  // #endif
   12.54  
   12.55 @@ -306,3 +312,13 @@
   12.56  
   12.57      return comparison == 0;
   12.58  }
   12.59 +
   12.60 +
   12.61 +#ifdef DEBUG_ERRORSTACK
   12.62 +    PEP_STATUS session_add_error(PEP_SESSION session, const char* file, unsigned line, PEP_STATUS status);
   12.63 +    #define ADD_TO_LOG(status)   session_add_error(session, __FILE__, __LINE__, (status))
   12.64 +    #define GOTO(label)          do{ (void)session_add_error(session, __FILE__, __LINE__, status); goto label; }while(0)
   12.65 +#else
   12.66 +    #define ADD_TO_LOG(status)   (status)
   12.67 +    #define GOTO(label)          goto label
   12.68 +#endif
    13.1 --- a/src/pgp_gpg.c	Fri Jun 02 11:55:04 2017 +0200
    13.2 +++ b/src/pgp_gpg.c	Thu Jun 15 11:35:44 2017 +0200
    13.3 @@ -39,8 +39,7 @@
    13.4          assert(length == stringlist_length(values));
    13.5          if (!(length == stringlist_length(values) &&
    13.6                length <= sizeof(unsigned int) * CHAR_BIT)) {
    13.7 -            r = Fclose(f);
    13.8 -            assert(r == 0);
    13.9 +            Fclose(f);
   13.10  
   13.11              return false;
   13.12          }
   13.13 @@ -62,6 +61,8 @@
   13.14  
   13.15                          if (i == n) {
   13.16                              r = Fclose(f);
   13.17 +                            if (r != 0)
   13.18 +                                return false;
   13.19                              return true;
   13.20                          }
   13.21                      }
   13.22 @@ -83,11 +84,15 @@
   13.23          if ((found & i) == 0) {
   13.24              r = Fprintf(f, "%s %s\n", _k->value, _v->value);
   13.25              assert(r >= 0);
   13.26 +            if(r<0)
   13.27 +                return false;
   13.28          }
   13.29      }
   13.30  
   13.31      r = Fclose(f);
   13.32      assert(r == 0);
   13.33 +    if (r != 0)
   13.34 +        return false;
   13.35  
   13.36      return true;
   13.37  }
   13.38 @@ -1352,6 +1357,8 @@
   13.39  
   13.40      reading = gpg.gpgme_data_read(dh, buffer, _size);
   13.41      assert(_size == reading);
   13.42 +    if(_size != reading)
   13.43 +        return PEP_CANNOT_EXPORT_KEY;
   13.44  
   13.45      // safeguard for the naive user
   13.46      buffer[_size] = 0;
   13.47 @@ -1547,7 +1554,6 @@
   13.48      gpgme_key_t key;
   13.49  
   13.50      assert(session);
   13.51 -    assert(pattern);
   13.52      assert(keylist);
   13.53  
   13.54      *keylist = NULL;
   13.55 @@ -1584,7 +1590,9 @@
   13.56                  gpgme_user_id_t kuid = key->uids;
   13.57                  // check that at least one uid's email matches pattern exactly
   13.58                  while(kuid) {
   13.59 -                    if(kuid->email && strcmp(kuid->email, pattern) == 0){
   13.60 +                    if((pattern && kuid->email && strcmp(kuid->email, pattern) == 0) ||
   13.61 +                       pattern == NULL /* match all */ )
   13.62 +                    { 
   13.63                          char *fpr = key->subkeys->fpr;
   13.64                          assert(fpr);
   13.65                          _k = stringlist_add(_k, fpr);
   13.66 @@ -1939,11 +1947,14 @@
   13.67      gpgme_error = gpg.gpgme_op_edit(session->ctx, key, renew_fsm, &handle,
   13.68              output);
   13.69      assert(gpgme_error == GPG_ERR_NO_ERROR);
   13.70 +    if(gpgme_error != GPG_ERR_NO_ERROR) {
   13.71 +        status = PEP_CANNOT_EDIT_KEY;
   13.72 +    }
   13.73  
   13.74      gpg.gpgme_data_release(output);
   13.75      gpg.gpgme_key_unref(key);
   13.76  
   13.77 -    return PEP_STATUS_OK;
   13.78 +    return status;
   13.79  }
   13.80  
   13.81  typedef struct _revoke_state {
   13.82 @@ -2126,11 +2137,14 @@
   13.83      gpgme_error = gpg.gpgme_op_edit(session->ctx, key, revoke_fsm, &handle,
   13.84              output);
   13.85      assert(gpgme_error == GPG_ERR_NO_ERROR);
   13.86 +    if(gpgme_error != GPG_ERR_NO_ERROR) {
   13.87 +        status = PEP_CANNOT_EDIT_KEY;
   13.88 +    }
   13.89  
   13.90      gpg.gpgme_data_release(output);
   13.91      gpg.gpgme_key_unref(key);
   13.92  
   13.93 -    return PEP_STATUS_OK;
   13.94 +    return status;
   13.95  }
   13.96  
   13.97  PEP_STATUS pgp_key_expired(
    14.1 --- a/src/pgp_netpgp.c	Fri Jun 02 11:55:04 2017 +0200
    14.2 +++ b/src/pgp_netpgp.c	Thu Jun 15 11:35:44 2017 +0200
    14.3 @@ -241,6 +241,9 @@
    14.4      unsigned i,j;
    14.5  
    14.6      *length = 0;
    14.7 +    
    14.8 +    if (str == NULL)
    14.9 +        return 0;
   14.10  
   14.11      while(*str && *length < PGP_FINGERPRINT_SIZE){
   14.12          while (*str == ' ') str++;
   14.13 @@ -1055,18 +1058,18 @@
   14.14      PEP_STATUS result;
   14.15      char *buffer;
   14.16      size_t buflen;
   14.17 +    const pgp_keyring_t *srcring;
   14.18  
   14.19      assert(session);
   14.20      assert(fprstr);
   14.21      assert(key_data);
   14.22      assert(size);
   14.23  
   14.24 -    // TODO : support export secret key
   14.25 -    // crashing stub until export secret supported
   14.26 -    assert(!secret);
   14.27      if (secret)
   14.28 -        return PEP_ILLEGAL_VALUE;
   14.29 -
   14.30 +        srcring = netpgp.secring;
   14.31 +    else
   14.32 +        srcring = netpgp.pubring;
   14.33 +    
   14.34      if (!session || !fprstr || !key_data || !size)
   14.35          return PEP_ILLEGAL_VALUE;
   14.36  
   14.37 @@ -1077,7 +1080,7 @@
   14.38      if (str_to_fpr(fprstr, fpr, &fprlen)) {
   14.39          unsigned from = 0;
   14.40  
   14.41 -        if ((key = (pgp_key_t *)pgp_getkeybyfpr(netpgp.io, netpgp.pubring,
   14.42 +        if ((key = (pgp_key_t *)pgp_getkeybyfpr(netpgp.io, srcring,
   14.43                                                  fpr, fprlen, &from,
   14.44                                                  NULL,0,0)) == NULL) {
   14.45              result = PEP_KEY_NOT_FOUND;
   14.46 @@ -1895,10 +1898,9 @@
   14.47      PEP_STATUS result;
   14.48  
   14.49      assert(session);
   14.50 -    assert(pattern);
   14.51      assert(keylist);
   14.52  
   14.53 -    if (!session || !pattern || !keylist )
   14.54 +    if (!session || !keylist )
   14.55      {
   14.56          return PEP_ILLEGAL_VALUE;
   14.57      }
    15.1 --- a/src/platform_windows.cpp	Fri Jun 02 11:55:04 2017 +0200
    15.2 +++ b/src/platform_windows.cpp	Thu Jun 15 11:35:44 2017 +0200
    15.3 @@ -139,17 +139,17 @@
    15.4      assert(filename);
    15.5  	assert(flag == RTLD_LAZY); // only lazy binding is implemented
    15.6  
    15.7 -	// Look up GnuPG installation in current user scope
    15.8 -	bool result = readRegistryString(HKEY_CURRENT_USER,
    15.9 -		TEXT("SOFTWARE\\GNU\\GnuPG"), TEXT("Install Directory"), path,
   15.10 -		PATH_BUF_SIZE, NULL);
   15.11 -	// If not found in current user, look up in local machine
   15.12 +	// Look up GnuPG installation in current user scope
   15.13 +	bool result = readRegistryString(HKEY_CURRENT_USER,
   15.14 +		TEXT("SOFTWARE\\GNU\\GnuPG"), TEXT("Install Directory"), path,
   15.15 +		PATH_BUF_SIZE, NULL);
   15.16 +	// If not found in current user, look up in local machine
   15.17  	if (!result)
   15.18 -		result = readRegistryString(HKEY_LOCAL_MACHINE,
   15.19 -			TEXT("SOFTWARE\\GNU\\GnuPG"), TEXT("Install Directory"), path,
   15.20 -			PATH_BUF_SIZE, NULL);
   15.21 -	assert(result);
   15.22 -	if (!result)
   15.23 +		result = readRegistryString(HKEY_LOCAL_MACHINE,
   15.24 +			TEXT("SOFTWARE\\GNU\\GnuPG"), TEXT("Install Directory"), path,
   15.25 +			PATH_BUF_SIZE, NULL);
   15.26 +	assert(result);
   15.27 +	if (!result)
   15.28  		return NULL;
   15.29  
   15.30      SetDllDirectory(TEXT(""));
    16.1 --- a/src/sync.h	Fri Jun 02 11:55:04 2017 +0200
    16.2 +++ b/src/sync.h	Thu Jun 15 11:35:44 2017 +0200
    16.3 @@ -203,7 +203,7 @@
    16.4  
    16.5  #include "message.h"
    16.6  #include "sync_fsm.h"
    16.7 -
    16.8 +#include "sync_app.h"
    16.9  
   16.10  // this module is for being used WITHOUT the Transport API in transport.h
   16.11  // DO NOT USE IT WHEN USING Transport API!
   16.12 @@ -227,28 +227,6 @@
   16.13  
   16.14  typedef PEP_STATUS (*messageToSend_t)(void *obj, message *msg);
   16.15  
   16.16 -// TODO add this to generated code.
   16.17 -typedef enum _sync_handshake_signal {
   16.18 -    SYNC_NOTIFY_UNDEFINED = 0,
   16.19 -
   16.20 -    // request show handshake dialog
   16.21 -    SYNC_NOTIFY_INIT_ADD_OUR_DEVICE,
   16.22 -    SYNC_NOTIFY_INIT_ADD_OTHER_DEVICE,
   16.23 -    SYNC_NOTIFY_INIT_FORM_GROUP,
   16.24 -    SYNC_NOTIFY_INIT_MOVE_OUR_DEVICE,
   16.25 -
   16.26 -    // handshake process timed out
   16.27 -    SYNC_NOTIFY_TIMEOUT,
   16.28 -
   16.29 -    // handshake accepted by user
   16.30 -    SYNC_NOTIFY_ACCEPTED_DEVICE_ADDED,
   16.31 -    SYNC_NOTIFY_ACCEPTED_GROUP_CREATED,
   16.32 -    SYNC_NOTIFY_ACCEPTED_DEVICE_MOVED,
   16.33 -
   16.34 -    // handshake dialog must be closed
   16.35 -    SYNC_NOTIFY_OVERTAKEN
   16.36 -} sync_handshake_signal;
   16.37 -
   16.38  // notifyHandshake() - notify UI about sync handshaking process
   16.39  //
   16.40  //  parameters:
    17.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    17.2 +++ b/src/sync_app.h	Thu Jun 15 11:35:44 2017 +0200
    17.3 @@ -0,0 +1,34 @@
    17.4 +//
    17.5 +//  sync_app.h
    17.6 +//  pEpEngine
    17.7 +//
    17.8 +//  Created by Dirk Zimmermann on 16.05.17.
    17.9 +//  Copyright © 2017 Edouard Tisserant. All rights reserved.
   17.10 +//
   17.11 +
   17.12 +#ifndef sync_app_h
   17.13 +#define sync_app_h
   17.14 +
   17.15 +// TODO add this to generated code.
   17.16 +typedef enum _sync_handshake_signal {
   17.17 +    SYNC_NOTIFY_UNDEFINED = 0,
   17.18 +
   17.19 +    // request show handshake dialog
   17.20 +    SYNC_NOTIFY_INIT_ADD_OUR_DEVICE,
   17.21 +    SYNC_NOTIFY_INIT_ADD_OTHER_DEVICE,
   17.22 +    SYNC_NOTIFY_INIT_FORM_GROUP,
   17.23 +    SYNC_NOTIFY_INIT_MOVE_OUR_DEVICE,
   17.24 +
   17.25 +    // handshake process timed out
   17.26 +    SYNC_NOTIFY_TIMEOUT,
   17.27 +
   17.28 +    // handshake accepted by user
   17.29 +    SYNC_NOTIFY_ACCEPTED_DEVICE_ADDED,
   17.30 +    SYNC_NOTIFY_ACCEPTED_GROUP_CREATED,
   17.31 +    SYNC_NOTIFY_ACCEPTED_DEVICE_MOVED,
   17.32 +
   17.33 +    // handshake dialog must be closed
   17.34 +    SYNC_NOTIFY_OVERTAKEN
   17.35 +} sync_handshake_signal;
   17.36 +
   17.37 +#endif /* sync_app_h */
    18.1 --- a/test/Makefile	Fri Jun 02 11:55:04 2017 +0200
    18.2 +++ b/test/Makefile	Thu Jun 15 11:35:44 2017 +0200
    18.3 @@ -2,10 +2,10 @@
    18.4  # This file is under GNU General Public License 3.0
    18.5  # see LICENSE.txt
    18.6  
    18.7 +HERE := $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
    18.8 +
    18.9  include ../Makefile.conf
   18.10  
   18.11 -export GNUPGHOME=.
   18.12 -
   18.13  CC?=g++ -std=gnu++11 -pthread
   18.14  CXX?=g++ -std=gnu++11 -pthread
   18.15  LD?=$(CXX)
   18.16 @@ -34,32 +34,50 @@
   18.17  # don't delete .o files!
   18.18  .PRECIOUS: %.o
   18.19  
   18.20 +unexport GNUPGHOME;
   18.21 +TEST_HOME=$(HERE)/test_home
   18.22 +TEST_HOME_SKEL=$(TEST_HOME)_skel
   18.23 +TEST_GNUPGHOME_SKEL=$(TEST_HOME)_skel/.gnupg
   18.24 +
   18.25 +ifeq ($(shell uname), Darwin)
   18.26 +    LIBPATH = DYLD_LIBRARY_PATH
   18.27 +    LLDB_BIN = /Applications/Xcode.app/Contents/Developer/usr/bin/lldb
   18.28 +else
   18.29 +    LIBPATH = LD_LIBRARY_PATH
   18.30 +    LLDB_BIN = lldb
   18.31 +endif
   18.32 +
   18.33 +TEST_CMD_PFX = $(LIBPATH)=$(HOME)/lib:../src HOME=$(TEST_HOME)
   18.34 +
   18.35 +test_home_skel:
   18.36 +	mkdir -p test_home_skel
   18.37 +	-cat 0x*.asc *_sec.asc | gpg2 --import --homedir $(TEST_GNUPGHOME_SKEL)
   18.38 +
   18.39 +test_home_: test_home_skel
   18.40 +	rm -rf test_home
   18.41 +	cp -a test_home_skel test_home
   18.42 +
   18.43  clean:
   18.44  	rm -f *.o $(TARGET) *.a *~ $(UNIT_TESTS) pep_Dokument_Titel.pdf msg4.asc
   18.45 -	rm -Rf *.dSYM .imported pubring.gpg secring.gpg random_seed *.conf trustdb.gpg
   18.46 +	rm -Rf *.dSYM test_home test_home_skel pubring.gpg secring.gpg random_seed *.conf trustdb.gpg
   18.47  
   18.48 -.imported:
   18.49 -	-cat 0x*.asc *_sec.asc | gpg2 --import
   18.50 -	touch .imported
   18.51 -
   18.52 -test: pEpEngineTest .imported
   18.53 -	LD_LIBRARY_PATH=~/lib:../src ./pEpEngineTest
   18.54 +test: pEpEngineTest test_home_
   18.55 +	$(TEST_CMD_PFX) ./pEpEngineTest
   18.56  
   18.57  %_test : %_test.o test_util.o
   18.58  	 $(LD) $(LDFLAGS) -o $@ $^ $(LDLIBS)
   18.59  
   18.60 -%_run : %
   18.61 -	LD_LIBRARY_PATH=~/lib:../src ./$<
   18.62 +%_run : % test_home_
   18.63 +	$(TEST_CMD_PFX) ./$<
   18.64  
   18.65 +%_lldb : % test_home_
   18.66 +	$(TEST_CMD_PFX) $(LLDB_BIN) ./$<
   18.67  
   18.68 -%_lldb : %
   18.69 -	LD_LIBRARY_PATH=~/lib:../src lldb ./$<
   18.70 +%_valgrind : % test_home_
   18.71 +	$(TEST_CMD_PFX) valgrind --leak-check=yes ./$<
   18.72  
   18.73 -%_valgrind : %
   18.74 -	LD_LIBRARY_PATH=~/lib:../src valgrind --leak-check=yes ./$<
   18.75 -
   18.76 -%_gdb : %
   18.77 -	LD_LIBRARY_PATH=~/lib:../src gdb ./$<
   18.78 +%_gdb : % test_home_
   18.79 +	$(TEST_CMD_PFX) gdb ./$<
   18.80  
   18.81  unit_tests: $(UNIT_TESTS) $(UNIT_TESTS_RUN)
   18.82  
    19.1 --- a/test/apple_mail_test.cc	Fri Jun 02 11:55:04 2017 +0200
    19.2 +++ b/test/apple_mail_test.cc	Thu Jun 15 11:35:44 2017 +0200
    19.3 @@ -26,16 +26,16 @@
    19.4  
    19.5      const string keytextkey1 = slurp("test_keys/pub/pep-test-apple-0x1CCBC7D7_pub.asc");
    19.6      const string keytextkey2 = slurp("test_keys/priv/pep-test-recip-0x08DB0AEE_priv.asc");
    19.7 +    const string keytextkey3 = slurp("test_keys/pub/pep-test-recip-0x08DB0AEE_pub.asc");
    19.8  
    19.9      PEP_STATUS statuskey1 = import_key(session, keytextkey1.c_str(), keytextkey1.length(), NULL);
   19.10      PEP_STATUS statuskey2 = import_key(session, keytextkey2.c_str(), keytextkey2.length(), NULL);
   19.11 +    PEP_STATUS statuskey3 = import_key(session, keytextkey3.c_str(), keytextkey3.length(), NULL);
   19.12          
   19.13      const string mailtext = slurp(mailfile);
   19.14 -    pEp_identity * me = new_identity("pep.test.recip@kgrothoff.org", NULL, PEP_OWN_USERID, "pEp Test Recipient");    
   19.15 +    pEp_identity * me = new_identity("pep.test.recip@kgrothoff.org", "93D19F24AD6F4C4BA9134AAF84D9217908DB0AEE", PEP_OWN_USERID, "pEp Test Recipient");    
   19.16      me->me = true;    
   19.17 -    PEP_STATUS status = update_identity(session, me);
   19.18 -    trust_personal_key(session, me);    
   19.19 -    status = update_identity(session, me);
   19.20 +    PEP_STATUS status = myself(session, me);
   19.21      
   19.22      pEp_identity * you = new_identity("pep.test.apple@pep-project.org", NULL, "TOFU_pep.test.apple@pep-project.org", "pEp Test Recipient");    
   19.23      you->me = false;    
    20.1 --- a/test/encrypt_for_identity_test.cc	Fri Jun 02 11:55:04 2017 +0200
    20.2 +++ b/test/encrypt_for_identity_test.cc	Thu Jun 15 11:35:44 2017 +0200
    20.3 @@ -9,6 +9,7 @@
    20.4  #include <assert.h>
    20.5  #include "mime.h"
    20.6  #include "message_api.h"
    20.7 +#include "keymanagement.h"
    20.8  #include "test_util.h"
    20.9  
   20.10  using namespace std;
   20.11 @@ -35,9 +36,13 @@
   20.12      assert(statuspriv == PEP_STATUS_OK);
   20.13  
   20.14      cout << "creating message…\n";
   20.15 -    pEp_identity* alice = new_identity("pep.test.alice@pep-project.org", NULL, PEP_OWN_USERID, "Alice Test");
   20.16 +    pEp_identity* alice = new_identity("pep.test.alice@pep-project.org", "4ABE3AAF59AC32CFE4F86500A9411D176FF00E97", PEP_OWN_USERID, "Alice Test");
   20.17      pEp_identity* bob = new_identity("pep.test.bob@pep-project.org", NULL, "42", "Bob Test");
   20.18      alice->me = true;
   20.19 +
   20.20 +    PEP_STATUS mystatus = myself(session, alice);
   20.21 +    assert(mystatus == PEP_STATUS_OK);
   20.22 +
   20.23      identity_list* to_list = new_identity_list(bob); // to bob
   20.24      message* outgoing_message = new_message(PEP_dir_outgoing);
   20.25      assert(outgoing_message);
    21.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    21.2 +++ b/test/external_revoke_test.cc	Thu Jun 15 11:35:44 2017 +0200
    21.3 @@ -0,0 +1,329 @@
    21.4 +// This file is under GNU General Public License 3.0
    21.5 +// see LICENSE.txt
    21.6 +
    21.7 +#include <stdlib.h>
    21.8 +#include <string.h>
    21.9 +#include <time.h>
   21.10 +#include "platform.h"
   21.11 +#include <iostream>
   21.12 +#include <fstream>
   21.13 +#include <assert.h>
   21.14 +#include "mime.h"
   21.15 +#include "message_api.h"
   21.16 +#include "test_util.h"
   21.17 +
   21.18 +using namespace std;
   21.19 +
   21.20 +int main() {
   21.21 +    cout << "\n*** external_revoke_test.cc ***\n\n";
   21.22 +
   21.23 +    PEP_SESSION session;
   21.24 +    
   21.25 +    cout << "calling init()\n";
   21.26 +    PEP_STATUS status = init(&session);   
   21.27 +    assert(status == PEP_STATUS_OK);
   21.28 +    assert(session);
   21.29 +    cout << "init() completed.\n";
   21.30 +
   21.31 +#ifndef NETPGP
   21.32 +    char* fprs[2];
   21.33 +
   21.34 +    const string fenris_pub_key = slurp("test_keys/pub/pep.test.fenris-0x4F3D2900_pub.asc");
   21.35 +    const string fenris_priv_key = slurp("test_keys/priv/pep.test.fenris-0x4F3D2900_priv.asc");
   21.36 +
   21.37 +    assert(fenris_pub_key.length() != 0);
   21.38 +    assert(fenris_priv_key.length() != 0);
   21.39 +    
   21.40 +    PEP_STATUS statuspub = import_key(session, fenris_pub_key.c_str(), fenris_pub_key.length(), NULL);
   21.41 +    PEP_STATUS statuspriv = import_key(session, fenris_priv_key.c_str(), fenris_priv_key.length(), NULL);
   21.42 +    assert(statuspub == PEP_STATUS_OK);
   21.43 +    assert(statuspriv == PEP_STATUS_OK);
   21.44 +
   21.45 +    // Create sender ID
   21.46 +    
   21.47 +    pEp_identity * me = new_identity("pep.test.fenris@thisstilldoesntwork.lu", "0969FA229DF21C832A64A04711B1B9804F3D2900", PEP_OWN_USERID, "Fenris Hawke");
   21.48 +    status = myself(session, me);
   21.49 +    
   21.50 +    // Create key
   21.51 +
   21.52 +    cout << "Creating new id for : ";
   21.53 +    char *uniqname = strdup("AAAAtestuser@testdomain.org");
   21.54 +    srandom(time(NULL));
   21.55 +    for(int i=0; i < 4;i++)
   21.56 +        uniqname[i] += random() & 0xf;
   21.57 +    
   21.58 +    cout << uniqname << "\n";
   21.59 +    pEp_identity * recip1 = new_identity(uniqname, NULL, NULL, "Test User");
   21.60 +
   21.61 +    status = generate_keypair(session, recip1);
   21.62 +    
   21.63 +    cout << "Generated fingerprint ";
   21.64 +    cout << recip1->fpr << "\n";
   21.65 +
   21.66 +    fprs[0] = strdup(recip1->fpr);
   21.67 +    
   21.68 +    cout << endl << "*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*" << endl;
   21.69 +    cout << "Trust and revoke single key, ensure trust changes, then generate new key and ensure rating is correct." << endl;
   21.70 +    cout << "*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*" << endl << endl;
   21.71 +    
   21.72 +    cout << endl << "---------------------------------------------------------" << endl;
   21.73 +    cout << "1a. Encrypt message for trusted partner." << endl;
   21.74 +    cout << "---------------------------------------------------------" << endl << endl;
   21.75 +
   21.76 +    cout << "Trusting personal key for " << uniqname << endl;
   21.77 +    // Trust it
   21.78 +    recip1->me = false;
   21.79 +    status = update_identity(session, recip1);
   21.80 +    status = trust_personal_key(session, recip1);
   21.81 +    status = update_identity(session, recip1);
   21.82 +    
   21.83 +    // TODO: Check trust?
   21.84 +    cout << "Done! Trusted personal key with fpr " << recip1->fpr << " for " << uniqname << endl;
   21.85 +
   21.86 +    const char* r1_userid = (recip1->user_id ? strdup(recip1->user_id) : NULL);
   21.87 +
   21.88 +    
   21.89 +    // encrypt something to the key
   21.90 +    cout << "Creating message…\n";
   21.91 +    identity_list* to_list = new_identity_list(identity_dup(recip1)); // to bob
   21.92 +    message* outgoing_msg = new_message(PEP_dir_outgoing);
   21.93 +    assert(outgoing_msg);
   21.94 +    outgoing_msg->from = identity_dup(me);
   21.95 +    outgoing_msg->to = to_list;
   21.96 +    outgoing_msg->shortmsg = strdup("Greetings, humans!");
   21.97 +    outgoing_msg->longmsg = strdup("This is a test of the emergency message system. This is only a test. BEEP.");
   21.98 +    outgoing_msg->attachments = new_bloblist(NULL, 0, "application/octet-stream", NULL);
   21.99 +    cout << "Message created.\n";
  21.100 +
  21.101 +    message* encrypted_outgoing_msg = NULL;
  21.102 +
  21.103 +    cout << "Encrypting message to " << uniqname << "…\n";    
  21.104 +    status = encrypt_message(session, outgoing_msg, NULL, &encrypted_outgoing_msg, PEP_enc_PGP_MIME, 0);
  21.105 +    cout << "Encrypted message with status " << tl_status_string(status) << endl;
  21.106 +    // check status
  21.107 +    assert(status == PEP_STATUS_OK);
  21.108 +    assert(encrypted_outgoing_msg);
  21.109 +
  21.110 +    cout << "Checking message recipient comm_type from message." << endl;
  21.111 +    // check comm_type
  21.112 +    cout << "comm_type: " << tl_ct_string(encrypted_outgoing_msg->to->ident->comm_type) << endl;
  21.113 +    assert(encrypted_outgoing_msg->to->ident->comm_type == PEP_ct_OpenPGP);
  21.114 +    
  21.115 +    status = get_trust(session, recip1);
  21.116 +    
  21.117 +    cout << "Recip's trust DB comm_type = " << hex << tl_ct_string(recip1->comm_type) << endl;
  21.118 +    assert(recip1->comm_type == PEP_ct_OpenPGP); // FIXME: PEP_ct_pEp???
  21.119 +
  21.120 +    // decrypt message
  21.121 +    free_message(outgoing_msg);
  21.122 +    outgoing_msg = NULL;
  21.123 +
  21.124 +    stringlist_t* keylist = nullptr;
  21.125 +    PEP_rating rating;
  21.126 +    PEP_decrypt_flags_t flags;
  21.127 +
  21.128 +    cout << endl << "---------------------------------------------------------" << endl;
  21.129 +    cout << "1b. Decrypt message that was encrypted for trusted partner." << endl;
  21.130 +    cout << "---------------------------------------------------------" << endl << endl;
  21.131 +
  21.132 +    cout << "Decrypting message." << endl;
  21.133 +    status = decrypt_message(session, encrypted_outgoing_msg, &outgoing_msg, &keylist, &rating, &flags);
  21.134 +    cout << "Decrypted message with status " << tl_status_string(status) << endl;
  21.135 +    assert(status == PEP_STATUS_OK);
  21.136 +    assert(rating == PEP_rating_trusted);
  21.137 +
  21.138 +    // check rating
  21.139 +    cout << "Rating of decrypted message to trusted recip: " << tl_rating_string(rating) << endl;
  21.140 +    assert(rating == PEP_rating_trusted); // FIXME: trusted and anonymised?
  21.141 +    
  21.142 +    // check comm_type
  21.143 +    status = get_trust(session, recip1);
  21.144 +
  21.145 +    cout << "Recip's trust DB comm_type = " << tl_ct_string(recip1->comm_type) << endl;
  21.146 +    assert(recip1->comm_type == PEP_ct_OpenPGP); // FIXME: PEP_ct_pEp???
  21.147 +
  21.148 +    cout << endl << "---------------------------------------------------------" << endl;
  21.149 +    cout << "2a. Revoke key for (currently) trusted partner." << endl;
  21.150 +    cout << "---------------------------------------------------------" << endl << endl;
  21.151 +    // externally revoke key
  21.152 +    // (note - as of 23.5.17, revoke_key() doesn't touch the trust db, just the keyring, so we can do this)
  21.153 +
  21.154 +    cout << "Revoking key." << endl;
  21.155 +    status = get_identity(session, uniqname, r1_userid, &recip1);    
  21.156 +    status = revoke_key(session, recip1->fpr, "encrypt_for_identity_test");
  21.157 +    cout << "Status of revocation call for " << recip1->fpr << " is "<< tl_status_string(status) << endl;
  21.158 +
  21.159 +    // free messages
  21.160 +    free_message(outgoing_msg);
  21.161 +    free_message(encrypted_outgoing_msg);
  21.162 +    outgoing_msg = NULL;
  21.163 +    encrypted_outgoing_msg = NULL;
  21.164 +    
  21.165 +    // encrypt something to the key
  21.166 +    cout << "creating message…\n";
  21.167 +    to_list = new_identity_list(identity_dup(recip1)); // to bob
  21.168 +    outgoing_msg = new_message(PEP_dir_outgoing);
  21.169 +    assert(outgoing_msg);
  21.170 +    outgoing_msg->from = identity_dup(me);
  21.171 +    outgoing_msg->to = to_list;
  21.172 +    outgoing_msg->shortmsg = strdup("Greetings, humans!");
  21.173 +    outgoing_msg->longmsg = strdup("This is a test of the emergency message system. This is only a test. BEEP.");
  21.174 +    outgoing_msg->attachments = new_bloblist(NULL, 0, "application/octet-stream", NULL);
  21.175 +    cout << "message created.\n";
  21.176 +
  21.177 +    encrypted_outgoing_msg = NULL;
  21.178 +    message* decrypted_msg = NULL;
  21.179 +
  21.180 +    cout << endl << "---------------------------------------------------------" << endl;
  21.181 +    cout << "2b. Encrypt message for recip whose key has been externally revoked in the keyring, not the app." << endl;
  21.182 +    cout << "---------------------------------------------------------" << endl << endl;
  21.183 +
  21.184 +    status = encrypt_message(session, outgoing_msg, NULL, &encrypted_outgoing_msg, PEP_enc_PGP_MIME, 0);
  21.185 +    cout << "Encryption returns with status " << tl_status_string(status) << endl;
  21.186 +
  21.187 +    PEP_comm_type ct = (encrypted_outgoing_msg ? encrypted_outgoing_msg->to->ident->comm_type : outgoing_msg->to->ident->comm_type);
  21.188 +
  21.189 +    cout << endl << "---------------------------------------------------------" << endl;
  21.190 +    cout << "2c. Check trust of recip, whose only key has been revoked, once an encryption attempt has been made." << endl;
  21.191 +    cout << "---------------------------------------------------------" << endl << endl;
  21.192 +
  21.193 +    // check comm_type
  21.194 +    cout << "comm_type: " << tl_ct_string(ct) << endl;
  21.195 +    assert(ct == PEP_ct_key_revoked);
  21.196 +    
  21.197 +    status = get_trust(session, recip1);
  21.198 +
  21.199 +    cout << "Recip's trust DB comm_type = " << hex << tl_ct_string(recip1->comm_type) << endl;
  21.200 +    assert(recip1->comm_type == PEP_ct_key_revoked);
  21.201 +
  21.202 +    cout << endl << "---------------------------------------------------------" << endl;
  21.203 +    cout << "2d. Try to decrypt message that was encrypted for revoked key guy." << endl;
  21.204 +    cout << "---------------------------------------------------------" << endl << endl;
  21.205 +    // decrypt message
  21.206 +//    free_message(outgoing_msg);
  21.207 +//    outgoing_msg = NULL;
  21.208 +    // FIXME: Make this make more sense
  21.209 +    status = decrypt_message(session, outgoing_msg, &decrypted_msg, &keylist, &rating, &flags);
  21.210 +    cout << "Decryption returns with status " << tl_status_string(status) << endl;
  21.211 +    assert(status == PEP_UNENCRYPTED);
  21.212 +    
  21.213 +    // check rating
  21.214 +    cout << "Rating of decrypted message to trusted recip: " << tl_rating_string(rating) << endl;
  21.215 +    assert(rating == PEP_rating_unencrypted);
  21.216 +
  21.217 +    ct = (decrypted_msg ? decrypted_msg->to->ident->comm_type : outgoing_msg->to->ident->comm_type);
  21.218 +
  21.219 +    cout << "comm_type: " << tl_ct_string(ct) << endl;
  21.220 +    assert(ct == PEP_ct_key_revoked);
  21.221 +    
  21.222 +    status = get_trust(session, recip1);
  21.223 +    
  21.224 +    cout << "Recip's trust DB comm_type = " << hex << tl_ct_string(recip1->comm_type) << endl;
  21.225 +    assert(recip1->comm_type == PEP_ct_key_revoked);
  21.226 +
  21.227 +    free_message(encrypted_outgoing_msg);
  21.228 +    free_message(decrypted_msg);
  21.229 +    free_message(outgoing_msg);
  21.230 +    outgoing_msg = NULL;
  21.231 +    decrypted_msg = NULL;
  21.232 +    encrypted_outgoing_msg = NULL;
  21.233 +
  21.234 +    cout << endl << "---------------------------------------------------------" << endl;
  21.235 +    cout << "3a. Generate new key, but don't explicitly trust it." << endl;
  21.236 +    cout << "---------------------------------------------------------" << endl << endl;
  21.237 +
  21.238 +    // now: generate new key
  21.239 +    free(recip1->fpr);
  21.240 +    recip1->fpr = NULL;
  21.241 +    status = generate_keypair(session, recip1);
  21.242 +    
  21.243 +    cout << "Generated fingerprint \n";
  21.244 +    cout << recip1->fpr << "\n";
  21.245 +    fprs[1] = strdup(recip1->fpr);
  21.246 +
  21.247 +    // try again
  21.248 +    cout << endl << "---------------------------------------------------------" << endl;
  21.249 +    cout << "3b. Try to send something to the email address of our revoked friend, make sure a new key is used to encrypt." << endl;
  21.250 +    cout << "---------------------------------------------------------" << endl << endl;
  21.251 +    
  21.252 +    // encrypt something to the key
  21.253 +    cout << "Creating message…\n";
  21.254 +    to_list = new_identity_list(identity_dup(recip1)); // to bob
  21.255 +    outgoing_msg = new_message(PEP_dir_outgoing);
  21.256 +    assert(outgoing_msg);
  21.257 +    outgoing_msg->from = identity_dup(me);
  21.258 +    outgoing_msg->to = to_list;
  21.259 +    outgoing_msg->shortmsg = strdup("Greetings, humans!");
  21.260 +    outgoing_msg->longmsg = strdup("This is a test of the emergency message system. This is only a test. BEEP.");
  21.261 +    outgoing_msg->attachments = new_bloblist(NULL, 0, "application/octet-stream", NULL);
  21.262 +    cout << "Message created.\n";
  21.263 +
  21.264 +    status = encrypt_message(session, outgoing_msg, NULL, &encrypted_outgoing_msg, PEP_enc_PGP_MIME, 0);
  21.265 +
  21.266 +    ct = (encrypted_outgoing_msg ? encrypted_outgoing_msg->to->ident->comm_type : outgoing_msg->to->ident->comm_type);
  21.267 +
  21.268 +    // CHECK STATUS???
  21.269 +    cout << "Encryption returns with status " << tl_status_string(status) << endl;
  21.270 +
  21.271 +    // check comm_type
  21.272 +    cout << "comm_type: " << tl_ct_string(ct) << endl;
  21.273 +    assert(ct == PEP_ct_OpenPGP_unconfirmed);
  21.274 +    
  21.275 +    status = get_trust(session, recip1);
  21.276 +
  21.277 +    cout << "Recip's trust DB comm_type = " << hex << tl_ct_string(recip1->comm_type) << endl;
  21.278 +    assert(recip1->comm_type == PEP_ct_OpenPGP_unconfirmed);
  21.279 +
  21.280 +    // decrypt message
  21.281 +//    free_message(outgoing_msg);
  21.282 +//    outgoing_msg = NULL;
  21.283 +
  21.284 +    cout << endl << "---------------------------------------------------------" << endl;
  21.285 +    cout << "3c. Decrypt... that... message!" << endl;
  21.286 +    cout << "---------------------------------------------------------" << endl << endl;
  21.287 +
  21.288 +
  21.289 +    status = decrypt_message(session, encrypted_outgoing_msg, &decrypted_msg, &keylist, &rating, &flags);
  21.290 +    cout << "Decryption returns with status " << tl_status_string(status) << endl;
  21.291 +    assert(status == PEP_STATUS_OK);
  21.292 +
  21.293 +    // check rating
  21.294 +    cout << "Rating of decrypted message to trusted recip: " << tl_rating_string(rating) << endl;
  21.295 +    assert(rating == PEP_rating_reliable);
  21.296 +
  21.297 +    ct = (decrypted_msg ? decrypted_msg->to->ident->comm_type : outgoing_msg->to->ident->comm_type);
  21.298 +
  21.299 +    cout << "comm_type: " << tl_ct_string(ct) << endl;
  21.300 +    assert(ct == PEP_ct_OpenPGP_unconfirmed);
  21.301 +    
  21.302 +    status = get_trust(session, recip1);
  21.303 +    
  21.304 +    cout << "Recip's trust DB comm_type = " << hex << tl_ct_string(recip1->comm_type) << endl;
  21.305 +    assert(recip1->comm_type == PEP_ct_OpenPGP_unconfirmed);
  21.306 +
  21.307 +    free_message(encrypted_outgoing_msg);
  21.308 +    free_message(decrypted_msg);
  21.309 +    free_message(outgoing_msg);
  21.310 +    outgoing_msg = NULL;
  21.311 +    decrypted_msg = NULL;
  21.312 +    encrypted_outgoing_msg = NULL;
  21.313 +
  21.314 +    free_identity(me);
  21.315 +    free_identity(recip1);
  21.316 +    free(uniqname);
  21.317 +    
  21.318 +    delete_keypair(session, fprs[0]);    
  21.319 +    delete_keypair(session, fprs[1]);
  21.320 +    
  21.321 +    free(fprs[0]);
  21.322 +    free(fprs[1]);
  21.323 +    
  21.324 +#else
  21.325 +    cout << "Sorry, test is not defined for NETPGP at this time." << endl;
  21.326 +    
  21.327 +#endif
  21.328 +    
  21.329 +    release(session);
  21.330 +
  21.331 +    return 0;
  21.332 +}
    22.1 --- a/test/least_color_group_test.cc	Fri Jun 02 11:55:04 2017 +0200
    22.2 +++ b/test/least_color_group_test.cc	Thu Jun 15 11:35:44 2017 +0200
    22.3 @@ -43,7 +43,8 @@
    22.4      const string mailtext = slurp(mailfile);
    22.5      cout << "\t All files read successfully." << std::endl;
    22.6  
    22.7 -    pEp_identity * me1 = new_identity("pep.color.test.P@kgrothoff.org", NULL, 
    22.8 +    pEp_identity * me1 = new_identity("pep.color.test.P@kgrothoff.org", 
    22.9 +                                      "7EE6C60C68851954E1797F81EA59715E3EBE215C", 
   22.10                                        PEP_OWN_USERID, "Pep Color Test P (recip)");
   22.11      me1->me = true;
   22.12      PEP_STATUS status = update_identity(session, me1);
    23.1 --- a/test/least_common_denom_color_test.cc	Fri Jun 02 11:55:04 2017 +0200
    23.2 +++ b/test/least_common_denom_color_test.cc	Thu Jun 15 11:35:44 2017 +0200
    23.3 @@ -58,7 +58,6 @@
    23.4      
    23.5      message* msg_ptr = nullptr;
    23.6      message* dest_msg = nullptr;
    23.7 -    message* final_ptr = nullptr;
    23.8      stringlist_t* keylist = nullptr;
    23.9      PEP_rating rating;
   23.10      PEP_decrypt_flags_t flags;
   23.11 @@ -66,53 +65,69 @@
   23.12      status = mime_decode_message(mailtext.c_str(), mailtext.length(), &msg_ptr);
   23.13      assert(status == PEP_STATUS_OK);
   23.14      assert(msg_ptr);
   23.15 -    final_ptr = msg_ptr;
   23.16 +
   23.17      status = decrypt_message(session, msg_ptr, &dest_msg, &keylist, &rating, &flags);
   23.18 -    final_ptr = dest_msg ? dest_msg : msg_ptr;
   23.19 -  
   23.20 -    cout << "shortmsg: " << final_ptr->shortmsg << endl << endl;
   23.21 -    cout << "longmsg: " << final_ptr->longmsg << endl << endl;
   23.22 -    cout << "longmsg_formatted: " << (final_ptr->longmsg_formatted ? final_ptr->longmsg_formatted : "(empty)") << endl << endl;
   23.23 -
   23.24 +    assert(status == PEP_STATUS_OK);
   23.25 +    assert(dest_msg);
   23.26      /* message is signed and no recip is mistrusted... */
   23.27      assert(color_from_rating(rating) == PEP_color_yellow);
   23.28  
   23.29 -    if (final_ptr == dest_msg)
   23.30 -    	free_message(dest_msg);
   23.31 -    free_message(msg_ptr);
   23.32 -    free_stringlist(keylist);
   23.33 +    cout << "shortmsg: " << dest_msg->shortmsg << endl << endl;
   23.34 +    cout << "longmsg: " << dest_msg->longmsg << endl << endl;
   23.35 +    cout << "longmsg_formatted: " << (dest_msg->longmsg_formatted ? dest_msg->longmsg_formatted : "(empty)") << endl << endl;
   23.36 +
   23.37 +    PEP_rating decrypt_rating = rating;
   23.38 +    
   23.39 +    /* re-evaluate rating, counting on optional fields */
   23.40 +    status = re_evaluate_message_rating(session, dest_msg, NULL, PEP_rating_undefined, &rating);
   23.41 +    assert(status == PEP_STATUS_OK);
   23.42 +    assert(color_from_rating(rating) == PEP_color_yellow);
   23.43 +
   23.44 +    /* re-evaluate rating, without optional fields */
   23.45 +    status = re_evaluate_message_rating(session, dest_msg, keylist, decrypt_rating, &rating);
   23.46 +    assert(status == PEP_STATUS_OK);
   23.47 +    assert(color_from_rating(rating) == PEP_color_yellow);
   23.48  
   23.49      /* Ok, now mistrust one recip */
   23.50      key_mistrusted(session, recip2);
   23.51 +
   23.52 +    /* re-evaluate rating, counting on optional fields */
   23.53 +    status = re_evaluate_message_rating(session, dest_msg, NULL, PEP_rating_undefined, &rating);
   23.54 +    assert(status == PEP_STATUS_OK);
   23.55 +    assert(color_from_rating(rating) == PEP_color_red);
   23.56 +
   23.57 +    /* re-evaluate rating, without optional fields */
   23.58 +    status = re_evaluate_message_rating(session, dest_msg, keylist, decrypt_rating, &rating);
   23.59 +    assert(status == PEP_STATUS_OK);
   23.60 +    assert(color_from_rating(rating) == PEP_color_red);
   23.61 +
   23.62 +    free_message(dest_msg);
   23.63 +    free_message(msg_ptr);
   23.64 +    free_stringlist(keylist);
   23.65      
   23.66      msg_ptr = nullptr;
   23.67      dest_msg = nullptr;
   23.68 -    final_ptr = nullptr;
   23.69      keylist = nullptr;
   23.70      rating = PEP_rating_unreliable;
   23.71  
   23.72      status = mime_decode_message(mailtext.c_str(), mailtext.length(), &msg_ptr);
   23.73      assert(status == PEP_STATUS_OK);
   23.74      assert(msg_ptr);
   23.75 -    final_ptr = msg_ptr;
   23.76      status = decrypt_message(session, msg_ptr, &dest_msg, &keylist, &rating, &flags);
   23.77 -    final_ptr = dest_msg ? dest_msg : msg_ptr;
   23.78    
   23.79 -    cout << "shortmsg: " << final_ptr->shortmsg << endl << endl;
   23.80 -    cout << "longmsg: " << final_ptr->longmsg << endl << endl;
   23.81 -    cout << "longmsg_formatted: " << (final_ptr->longmsg_formatted ? final_ptr->longmsg_formatted : "(empty)") << endl << endl;
   23.82 +    cout << "shortmsg: " << dest_msg->shortmsg << endl << endl;
   23.83 +    cout << "longmsg: " << dest_msg->longmsg << endl << endl;
   23.84 +    cout << "longmsg_formatted: " << (dest_msg->longmsg_formatted ? dest_msg->longmsg_formatted : "(empty)") << endl << endl;
   23.85  
   23.86      /* message is signed and no recip is mistrusted... */
   23.87      assert(color_from_rating(rating) == PEP_color_red);
   23.88  
   23.89 -    if (final_ptr == dest_msg)
   23.90 -    	free_message(dest_msg);
   23.91 +    free_message(dest_msg);
   23.92      free_message(msg_ptr);
   23.93      free_stringlist(keylist);
   23.94  
   23.95      msg_ptr = nullptr;
   23.96      dest_msg = nullptr;
   23.97 -    final_ptr = nullptr;
   23.98      keylist = nullptr;
   23.99      rating = PEP_rating_unreliable;
  23.100      
    24.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    24.2 +++ b/test/pEp_subject_received_test.cc	Thu Jun 15 11:35:44 2017 +0200
    24.3 @@ -0,0 +1,222 @@
    24.4 +#include <iostream>
    24.5 +#include <iostream>
    24.6 +#include <fstream>
    24.7 +#include <string>
    24.8 +#include <cstring> // for strcmp()
    24.9 +#include <assert.h>
   24.10 +#include "blacklist.h"
   24.11 +#include "keymanagement.h"
   24.12 +#include "message_api.h"
   24.13 +#include "mime.h"
   24.14 +#include "test_util.h" // for slurp()
   24.15 +
   24.16 +using namespace std;
   24.17 +
   24.18 +int main(int argc, char** argv) {
   24.19 +
   24.20 +    cout << "\n*** check that pEp subject is handled properly in received mails ***\n\n";
   24.21 +
   24.22 +    PEP_SESSION session;
   24.23 +    
   24.24 +    cout << "calling init()\n";
   24.25 +    PEP_STATUS status1 = init(&session);   
   24.26 +    assert(status1 == PEP_STATUS_OK);
   24.27 +    assert(session);
   24.28 +    cout << "init() completed.\n";
   24.29 +
   24.30 +    const char* keytexts[3];
   24.31 +
   24.32 +    const string keytextkey1 = slurp("test_keys/pub/pep-test-alice-0x6FF00E97_pub.asc");
   24.33 +    const string keytextkey2 = slurp("test_keys/priv/pep-test-recip-0x08DB0AEE_priv.asc");
   24.34 +    const string keytextkey3 = slurp("test_keys/pub/pep-test-recip-0x08DB0AEE_pub.asc");
   24.35 +    PEP_STATUS statuskey1 = import_key(session, keytextkey1.c_str(), keytextkey1.length(), NULL);
   24.36 +    PEP_STATUS statuskey2 = import_key(session, keytextkey2.c_str(), keytextkey2.length(), NULL);
   24.37 +    PEP_STATUS statuskey3 = import_key(session, keytextkey3.c_str(), keytextkey3.length(), NULL);
   24.38 +
   24.39 +    pEp_identity * me = new_identity("pep.test.recip@kgrothoff.org", "93D19F24AD6F4C4BA9134AAF84D9217908DB0AEE", PEP_OWN_USERID, "pEp Test Recipient");    
   24.40 +    me->me = true;    
   24.41 +    PEP_STATUS status = myself(session, me);
   24.42 +    
   24.43 +    pEp_identity * you = new_identity("pep.test.apple@pep-project.org", NULL, "TOFU_pep.test.apple@pep-project.org", "pEp Test Recipient");    
   24.44 +    you->me = false;    
   24.45 +    
   24.46 +    status = update_identity(session, you);
   24.47 +    trust_personal_key(session, you);
   24.48 +    status = update_identity(session, you);
   24.49 +
   24.50 +
   24.51 +    
   24.52 +    const char* mailfiles[] = {"test_mails/pEp_encrypted_subject_IS_pEp.eml",
   24.53 +                                "test_mails/pEp_subject_normal.eml",
   24.54 +                                "test_mails/pEp_subject_normal_signed.eml",
   24.55 +                                "test_mails/pEp_subject_normal_unencrypted.eml",
   24.56 +                                "test_mails/pEp_subject_pEp.eml",
   24.57 +                                "test_mails/pEp_unencrypted_pEp_subject.eml"};
   24.58 +                                
   24.59 +
   24.60 +    cout << "------------------------------------------------------------------------------------------" << endl;
   24.61 +    cout << "Test 1: Normal encrypted mail, pEp as substitute subject, regular subject in crypto text." << endl;
   24.62 +    cout << "------------------------------------------------------------------------------------------" << endl;
   24.63 +        
   24.64 +    string mailtext = slurp(mailfiles[1]);
   24.65 +    
   24.66 +    message* msg_ptr = nullptr;
   24.67 +    message* dest_msg = nullptr;
   24.68 +    message* final_ptr = nullptr;
   24.69 +    stringlist_t* keylist = nullptr;
   24.70 +    PEP_rating rating;
   24.71 +    PEP_decrypt_flags_t flags;
   24.72 +    
   24.73 +    status = mime_decode_message(mailtext.c_str(), mailtext.length(), &msg_ptr);
   24.74 +    assert(status == PEP_STATUS_OK);
   24.75 +    assert(msg_ptr);
   24.76 +    final_ptr = msg_ptr;
   24.77 +    status = decrypt_message(session, msg_ptr, &dest_msg, &keylist, &rating, &flags);
   24.78 +    final_ptr = dest_msg ? dest_msg : msg_ptr;
   24.79 +  
   24.80 +    cout << "shortmsg: " << final_ptr->shortmsg << endl << endl;
   24.81 +    cout << "longmsg: " << final_ptr->longmsg << endl << endl;
   24.82 +    cout << "longmsg_formatted: " << (final_ptr->longmsg_formatted ? final_ptr->longmsg_formatted : "(empty)") << endl << endl;
   24.83 +
   24.84 +    assert(strcmp("This is the usual pEp subject that should replace the above.", final_ptr->shortmsg) == 0);
   24.85 +
   24.86 +    cout << "Test 1: Subject replaced as expected." << endl << endl;
   24.87 +
   24.88 +    if (final_ptr == dest_msg)
   24.89 +    	free_message(dest_msg);
   24.90 +    free_message(msg_ptr);
   24.91 +    free_stringlist(keylist);
   24.92 +
   24.93 +    cout << "-------------------------------------------------------------------------------------------------" << endl;
   24.94 +    cout << "Test 2: Normal encrypted/signed mail, pEp as substitute subject, regular subject in crypto text." << endl;
   24.95 +    cout << "-------------------------------------------------------------------------------------------------" << endl;
   24.96 +
   24.97 +    msg_ptr = nullptr;
   24.98 +    dest_msg = nullptr;
   24.99 +    final_ptr = nullptr;
  24.100 +    keylist = nullptr;
  24.101 +    rating = PEP_rating_unreliable;
  24.102 +    
  24.103 +    mailtext = slurp(mailfiles[2]);
  24.104 +    
  24.105 +    status = mime_decode_message(mailtext.c_str(), mailtext.length(), &msg_ptr);
  24.106 +    assert(status == PEP_STATUS_OK);
  24.107 +    assert(msg_ptr);
  24.108 +    final_ptr = msg_ptr;
  24.109 +    status = decrypt_message(session, msg_ptr, &dest_msg, &keylist, &rating, &flags);
  24.110 +    final_ptr = dest_msg ? dest_msg : msg_ptr;
  24.111 +  
  24.112 +    cout << "shortmsg: " << final_ptr->shortmsg << endl << endl;
  24.113 +    cout << "longmsg: " << final_ptr->longmsg << endl << endl;
  24.114 +    cout << "longmsg_formatted: " << (final_ptr->longmsg_formatted ? final_ptr->longmsg_formatted : "(empty)") << endl << endl;
  24.115 +
  24.116 +    assert(strcmp("Now signed!", final_ptr->shortmsg) == 0);
  24.117 +
  24.118 +    cout << "Test 2: Subject replaced as expected." << endl << endl;
  24.119 +
  24.120 +    if (final_ptr == dest_msg)
  24.121 +        free_message(dest_msg);
  24.122 +    free_message(msg_ptr);
  24.123 +    free_stringlist(keylist);
  24.124 +    
  24.125 +    cout << "-----------------------------------------------------------------------" << endl;
  24.126 +    cout << "Test 3: Encrypted mail, pEp as actual subject, no subject in body text." << endl;
  24.127 +    cout << "-----------------------------------------------------------------------" << endl;
  24.128 +
  24.129 +    msg_ptr = nullptr;
  24.130 +    dest_msg = nullptr;
  24.131 +    final_ptr = nullptr;
  24.132 +    keylist = nullptr;
  24.133 +    rating = PEP_rating_unreliable;
  24.134 +    
  24.135 +    mailtext = slurp(mailfiles[0]);
  24.136 +    
  24.137 +    status = mime_decode_message(mailtext.c_str(), mailtext.length(), &msg_ptr);
  24.138 +    assert(status == PEP_STATUS_OK);
  24.139 +    assert(msg_ptr);
  24.140 +    final_ptr = msg_ptr;
  24.141 +    status = decrypt_message(session, msg_ptr, &dest_msg, &keylist, &rating, &flags);
  24.142 +    final_ptr = dest_msg ? dest_msg : msg_ptr;
  24.143 +  
  24.144 +    cout << "shortmsg: " << final_ptr->shortmsg << endl << endl;
  24.145 +    cout << "longmsg: " << final_ptr->longmsg << endl << endl;
  24.146 +    cout << "longmsg_formatted: " << (final_ptr->longmsg_formatted ? final_ptr->longmsg_formatted : "(empty)") << endl << endl;
  24.147 +
  24.148 +    assert(strcmp("pEp", final_ptr->shortmsg) == 0);
  24.149 +
  24.150 +    cout << "Test 3: Subject remains intact as desired." << endl << endl;
  24.151 +
  24.152 +    if (final_ptr == dest_msg)
  24.153 +        free_message(dest_msg);
  24.154 +    free_message(msg_ptr);
  24.155 +    free_stringlist(keylist);
  24.156 +
  24.157 +    cout << "-----------------------------------------------------------------------" << endl;
  24.158 +    cout << "Test 4: Encrypted mail, pEp as actual subject, pEp subject in body text." << endl;
  24.159 +    cout << "-----------------------------------------------------------------------" << endl;
  24.160 +
  24.161 +    msg_ptr = nullptr;
  24.162 +    dest_msg = nullptr;
  24.163 +    final_ptr = nullptr;
  24.164 +    keylist = nullptr;
  24.165 +    rating = PEP_rating_unreliable;
  24.166 +    
  24.167 +    mailtext = slurp(mailfiles[4]);
  24.168 +    
  24.169 +    status = mime_decode_message(mailtext.c_str(), mailtext.length(), &msg_ptr);
  24.170 +    assert(status == PEP_STATUS_OK);
  24.171 +    assert(msg_ptr);
  24.172 +    final_ptr = msg_ptr;
  24.173 +    status = decrypt_message(session, msg_ptr, &dest_msg, &keylist, &rating, &flags);
  24.174 +    final_ptr = dest_msg ? dest_msg : msg_ptr;
  24.175 +  
  24.176 +    cout << "shortmsg: " << final_ptr->shortmsg << endl << endl;
  24.177 +    cout << "longmsg: " << final_ptr->longmsg << endl << endl;
  24.178 +    cout << "longmsg_formatted: " << (final_ptr->longmsg_formatted ? final_ptr->longmsg_formatted : "(empty)") << endl << endl;
  24.179 +
  24.180 +    assert(strcmp("pEp", final_ptr->shortmsg) == 0);
  24.181 +
  24.182 +    cout << "Test 4: Subject correct, in any event." << endl << endl;
  24.183 +
  24.184 +    if (final_ptr == dest_msg)
  24.185 +        free_message(dest_msg);
  24.186 +    free_message(msg_ptr);
  24.187 +    free_stringlist(keylist);
  24.188 +
  24.189 +    cout << "-------------------------------------------------------------------------" << endl;
  24.190 +    cout << "Test 5: Unencrypted variant where pEp in the subject line is the subject." << endl;
  24.191 +    cout << "-------------------------------------------------------------------------" << endl;
  24.192 +
  24.193 +    msg_ptr = nullptr;
  24.194 +    dest_msg = nullptr;
  24.195 +    final_ptr = nullptr;
  24.196 +    keylist = nullptr;
  24.197 +    rating = PEP_rating_unreliable;
  24.198 +    
  24.199 +    mailtext = slurp(mailfiles[5]);
  24.200 +    
  24.201 +    status = mime_decode_message(mailtext.c_str(), mailtext.length(), &msg_ptr);
  24.202 +    assert(status == PEP_STATUS_OK);
  24.203 +    assert(msg_ptr);
  24.204 +    final_ptr = msg_ptr;
  24.205 +    status = decrypt_message(session, msg_ptr, &dest_msg, &keylist, &rating, &flags);
  24.206 +    final_ptr = dest_msg ? dest_msg : msg_ptr;
  24.207 +  
  24.208 +    cout << "shortmsg: " << final_ptr->shortmsg << endl << endl;
  24.209 +    cout << "longmsg: " << final_ptr->longmsg << endl << endl;
  24.210 +    cout << "longmsg_formatted: " << (final_ptr->longmsg_formatted ? final_ptr->longmsg_formatted : "(empty)") << endl << endl;
  24.211 +
  24.212 +    assert(strcmp("pEp", final_ptr->shortmsg) == 0);
  24.213 +
  24.214 +    cout << "Test 5: Subject remains intact." << endl << endl;
  24.215 +
  24.216 +    if (final_ptr == dest_msg)
  24.217 +        free_message(dest_msg);
  24.218 +    free_message(msg_ptr);
  24.219 +    free_stringlist(keylist);
  24.220 +
  24.221 +        
  24.222 +    cout << "calling release()\n";
  24.223 +    release(session);
  24.224 +    return 0;
  24.225 +}
    25.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    25.2 +++ b/test/test_keys/priv/pep.test.fenris-0x4F3D2900_priv.asc	Thu Jun 15 11:35:44 2017 +0200
    25.3 @@ -0,0 +1,57 @@
    25.4 +-----BEGIN PGP PRIVATE KEY BLOCK-----
    25.5 +
    25.6 +lQOYBFk6bQsBCACgrAoz+IlRnJD5RA3HdevO/9rJVgTQJ/9BJX8zWmySXIqR53j1
    25.7 +A0zaPt2ZaiaEcCTVpTeDyTY0SSbLnaoin3Aru3wyiuKGT9HQAi21yhg3KZQp4Jnx
    25.8 +UPbBPVEkW79+vu0skVcYDLIBA7abec+VK4oRtG+1Kl1IUPuHv5Bh0TWwXna7h0RT
    25.9 +WsYZBvgapwc33Ux6Sbc3HV7JiFhccHnEC4jYLA8UyTt/aQzcz1XbtBVGUHpxuaDT
   25.10 +s8RYQd0zN86Y67pgfiGqITqSn3NlZevKOJHP6pZQxQqjwcIaKkeS/zehNwMgkWTz
   25.11 +SYIuER3zkCZjKkmwvDjO/irXQxoqWNY2ucQhABEBAAEAB/kBHe5h5Jsob6nGqygG
   25.12 +XYXoCzlyjLAdYKh4A+JMZtdE4DL6vIIdKpVKRMVxF367jR+wbYTYhsRN8j6Rtp+e
   25.13 +vH7WNagxc2uLiqVXKGtiwrbO4VwykKlj9vpe0bCNS7xQeFQj6xcQ0iZwS93lMEsB
   25.14 +YDYGP/vGewwpdciogwF7sJg1M5FrErvSTzbIfvD2+Q9+VJTHTDp5T7PBe0jzMNhs
   25.15 +gmLGbdWwdsK3lRITf3SHwnwNwhL19285IehQTO20nS/+Dbp52Nj4kV3tqq3rHgb7
   25.16 +ODA7sEREo1hVUX0FdPACIuWSKOi4atN6oj1c63deKGvIogh1ll27fM9SrE12BGRv
   25.17 +MxaxBADAjQTeA93xP2g2eNMk6uMrtZ8kHeNlgYXlh5iw3udjg8d8EsJPNHR9h3GM
   25.18 +1gcXP13n8BJOQ0pJYhfFpZdAMColsxJIUwemLMU41Pujo8QoObqTrpPjje6N13BC
   25.19 +Xdvs7oMfpkdaH14pSAmAhA/S1OcuBdoX9f0+uHSJuGeHS0RtaQQA1Z3S9BOfnkXl
   25.20 +rHfPaFUVOeNtaDrjrolnNeyC9unWTQx/2rf5zbWyxfz8vr12B318rkxsitvSosmj
   25.21 +Co7znQYn+TfYfq9deufIMxeuK+pr6qme321C6n5lHJjpDbw9EgGdzpjXPECS/NeE
   25.22 +Dvd2noqSeUysSRthNdWv6UhNfWngcfkD/2l2+iZyphNKhkIty6AzZI3y9FNEnJ4x
   25.23 +Kn3SQ+KKSQlS8BhffJhCbF0sNZ7ydZheuA3l8cwE9YJuCJsXZtda7V4myyBHbUky
   25.24 +ZijB0yw0dUnOjXXhDFvcHhC9XhNeKLGaBYSy1xEKrxFHpvjeeGsDvj8ZjEIXlRbo
   25.25 +PE0jMNa3aFwgPkS0WkZlbnJpcyBIYXdrZSAoVGVzdCBrZXkgZm9yIGV4dGVybmFs
   25.26 +IHJldm9rZSB0ZXN0cykgPHBlcC50ZXN0LmZlbnJpc0B0aGlzc3RpbGxkb2VzbnR3
   25.27 +b3JrLmx1PokBOQQTAQgAIwUCWTptCwIbAwcLCQgHAwIBBhUIAgkKCwQWAgMBAh4B
   25.28 +AheAAAoJEBGxuYBPPSkAYxcH/0u2pwPSQ4J6LR449DaUI40gG6rTSn2xSL3bMfD8
   25.29 +P12rFx56vC1CFZUimA+Va5mTF7SuoEtAAnsiUcu9X7slq3YVm6w+lOeUAvHoWaTZ
   25.30 +F/cuKZTLiZ5qAfwtEbMqzaSLAuWqaCNwC0iROb7gXHGz6Fsqzi4HsQwOHGhn0zaL
   25.31 +a6uN0ExLbYvyc7+nVD64hvHCVNwwYMHTKHJ838RhnsBfLz5j2sVjIDWLwdljJK6s
   25.32 +yQDqkQz+FkY/5HOizE/MP4CTRTvKD5dNYVZU9OFun/IW3zJKCUPZHg6UhsL4JBd+
   25.33 +6UuC9t/icYA4qyd/XQ8qy89G2cu8JcDV3SYVgj3JUKnEOXSdA5gEWTptCwEIAMfv
   25.34 +xubJv0wf8spgvutX8VKL2WDKU/A62ILvTR2pzRe+8nnHkImNxuC7AGtMWaIZkupK
   25.35 +t+LFb1ovLaaqIPG/ibfscusAk+QJrIvxbD0x2u9ImFbfYMyPRrn7b9iP6u5bk7j0
   25.36 +ntvOAMzAdaLvgt5kDsf8CaWc2WwTZbmTD9qaimsLTf6rpnSD6D7G6uAEkayfhBIe
   25.37 +TC56LwAfnsK+eqxQYfOmL29pXM43rzB/SsCIvrwT/phhtxg8Jc9OLzNCTbsNiJNt
   25.38 +185G7fEZlo91GnhZwAk0wWfgpINbYo4/c28xShM74psCF1eix1eyEl76CzfKJg0D
   25.39 +GYfFy25TOKn76ofKcr0AEQEAAQAH/01rlmAw2DAgoPHn85YLOEnIGJVH06gPCV7u
   25.40 +TjTB10auLJOmiNwS9+N21is2ZfEEqSSraThZToyj/y/t6hLiofAEEd3ZG+tuKZAJ
   25.41 +HOo3X3lP6ZmeJwwfIPqMmBtKY2UINhQlOUyRITMoBYVh7JG0OhsLiCrGqVSV0ErD
   25.42 +XRy/wgC/sSw6t9wDtNIpMfwfnhzue7RwSBV2659jPeP6fBPPc8J0D1dm8JuBzIE7
   25.43 +5El88dIjrnd8YQWFnVmV747itdzfm3xGFUVZSlbWPKR1+7Z09wV0Y/thdDBYHdOO
   25.44 +epT6IGqxdinyDKlxV4UcSD0VjhwvocNBlnJnsEkI+5XB24lbeQsEAOAuKvZ327J6
   25.45 +fA86hUzFrt7YZQzeyXNIbEVsPdyGImUb1s1o/X43CiFwG6o7ogIt08XU+toVV5y+
   25.46 +ilCfRq0wfZW/vZ9JawvtY/EyMUBgLcyeKgoXYH8YKCOw4t+tRO5Zol+mWQIOIcR6
   25.47 +KCSw6TiUmwzjGyIKapOAjiIbroaYy55LBADkULAZP97fK6KsvuMEzKprLolZzdjH
   25.48 +zKyaQUJPiGxYC/CiS0bpxz8lgVEoAggUB7TauCAWjrTfV+aIx3UmnZ+OO9pfJoId
   25.49 +pDa7rR90LyzCEe2ftODugi6O4N561htK0y2dfgWv2wnvx6z9W4fKM6MWP95WBXfM
   25.50 +y6AcSxf/lZFuFwQAwmAZBfoDXklAQycg1jNNwCQzxSeXHfUlspjLXZAho3CMUqd9
   25.51 +Td8vCqyrI4xdSp7Ko7CpfK8vfBWkWQBjWLw4d5JCAUapoH5dNPPfyfFOJe93P7Dk
   25.52 +9i4jmsK9VOb1ROcW347TGMaSDe41cODZ/S8FixZepvOhEXcQIPSiMTM9l9oxyIkB
   25.53 +HwQYAQgACQUCWTptCwIbDAAKCRARsbmATz0pAD2VB/9g/0VAkD6IpQSoQWYtFq0t
   25.54 +plbVm1kM5gS0O2caomyKRV6kRVGIJKCFvh2tmwuHu7cWklcdcAywPt1PtzYFqi9g
   25.55 +PkSBwz++O9CArQph8ifTgoWdxyo6mn7hanBnE9GMK8UYIDk9JnXWyPGFOjYv0ce3
   25.56 +yNEGtk4OexGypKBuF4OkFEbo/Xd2TW2OVKqKSGbT6tNP16VhNDk3Gkuj0DjTsVqP
   25.57 +VR1SYEbM6ME4oEuo0yhnHDVAs4nnx8aHU+ehoj1awJY9N9vJVRweBlyoq3CwvrCH
   25.58 +3SvAmqWLainevUklVnCvga9Xo0vRe9La7ARSOkVDxmDjIt/P4ETvbEElFHdFSs6c
   25.59 +=Hjdj
   25.60 +-----END PGP PRIVATE KEY BLOCK-----
    26.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    26.2 +++ b/test/test_keys/pub/pep.test.fenris-0x4F3D2900_pub.asc	Thu Jun 15 11:35:44 2017 +0200
    26.3 @@ -0,0 +1,30 @@
    26.4 +-----BEGIN PGP PUBLIC KEY BLOCK-----
    26.5 +
    26.6 +mQENBFk6bQsBCACgrAoz+IlRnJD5RA3HdevO/9rJVgTQJ/9BJX8zWmySXIqR53j1
    26.7 +A0zaPt2ZaiaEcCTVpTeDyTY0SSbLnaoin3Aru3wyiuKGT9HQAi21yhg3KZQp4Jnx
    26.8 +UPbBPVEkW79+vu0skVcYDLIBA7abec+VK4oRtG+1Kl1IUPuHv5Bh0TWwXna7h0RT
    26.9 +WsYZBvgapwc33Ux6Sbc3HV7JiFhccHnEC4jYLA8UyTt/aQzcz1XbtBVGUHpxuaDT
   26.10 +s8RYQd0zN86Y67pgfiGqITqSn3NlZevKOJHP6pZQxQqjwcIaKkeS/zehNwMgkWTz
   26.11 +SYIuER3zkCZjKkmwvDjO/irXQxoqWNY2ucQhABEBAAG0WkZlbnJpcyBIYXdrZSAo
   26.12 +VGVzdCBrZXkgZm9yIGV4dGVybmFsIHJldm9rZSB0ZXN0cykgPHBlcC50ZXN0LmZl
   26.13 +bnJpc0B0aGlzc3RpbGxkb2VzbnR3b3JrLmx1PokBOQQTAQgAIwUCWTptCwIbAwcL
   26.14 +CQgHAwIBBhUIAgkKCwQWAgMBAh4BAheAAAoJEBGxuYBPPSkAYxcH/0u2pwPSQ4J6
   26.15 +LR449DaUI40gG6rTSn2xSL3bMfD8P12rFx56vC1CFZUimA+Va5mTF7SuoEtAAnsi
   26.16 +Ucu9X7slq3YVm6w+lOeUAvHoWaTZF/cuKZTLiZ5qAfwtEbMqzaSLAuWqaCNwC0iR
   26.17 +Ob7gXHGz6Fsqzi4HsQwOHGhn0zaLa6uN0ExLbYvyc7+nVD64hvHCVNwwYMHTKHJ8
   26.18 +38RhnsBfLz5j2sVjIDWLwdljJK6syQDqkQz+FkY/5HOizE/MP4CTRTvKD5dNYVZU
   26.19 +9OFun/IW3zJKCUPZHg6UhsL4JBd+6UuC9t/icYA4qyd/XQ8qy89G2cu8JcDV3SYV
   26.20 +gj3JUKnEOXS5AQ0EWTptCwEIAMfvxubJv0wf8spgvutX8VKL2WDKU/A62ILvTR2p
   26.21 +zRe+8nnHkImNxuC7AGtMWaIZkupKt+LFb1ovLaaqIPG/ibfscusAk+QJrIvxbD0x
   26.22 +2u9ImFbfYMyPRrn7b9iP6u5bk7j0ntvOAMzAdaLvgt5kDsf8CaWc2WwTZbmTD9qa
   26.23 +imsLTf6rpnSD6D7G6uAEkayfhBIeTC56LwAfnsK+eqxQYfOmL29pXM43rzB/SsCI
   26.24 +vrwT/phhtxg8Jc9OLzNCTbsNiJNt185G7fEZlo91GnhZwAk0wWfgpINbYo4/c28x
   26.25 +ShM74psCF1eix1eyEl76CzfKJg0DGYfFy25TOKn76ofKcr0AEQEAAYkBHwQYAQgA
   26.26 +CQUCWTptCwIbDAAKCRARsbmATz0pAD2VB/9g/0VAkD6IpQSoQWYtFq0tplbVm1kM
   26.27 +5gS0O2caomyKRV6kRVGIJKCFvh2tmwuHu7cWklcdcAywPt1PtzYFqi9gPkSBwz++
   26.28 +O9CArQph8ifTgoWdxyo6mn7hanBnE9GMK8UYIDk9JnXWyPGFOjYv0ce3yNEGtk4O
   26.29 +exGypKBuF4OkFEbo/Xd2TW2OVKqKSGbT6tNP16VhNDk3Gkuj0DjTsVqPVR1SYEbM
   26.30 +6ME4oEuo0yhnHDVAs4nnx8aHU+ehoj1awJY9N9vJVRweBlyoq3CwvrCH3SvAmqWL
   26.31 +ainevUklVnCvga9Xo0vRe9La7ARSOkVDxmDjIt/P4ETvbEElFHdFSs6c
   26.32 +=umG7
   26.33 +-----END PGP PUBLIC KEY BLOCK-----
    27.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    27.2 +++ b/test/test_mails/pEp_encrypted_subject_IS_pEp.eml	Thu Jun 15 11:35:44 2017 +0200
    27.3 @@ -0,0 +1,121 @@
    27.4 +Return-Path: <pep.test.alice@pep-project.org>
    27.5 +X-Original-To: krista@gnunet.org
    27.6 +Delivered-To: krista@gnunet.org
    27.7 +Received: from vmmailrelay1.informatik.tu-muenchen.de (mailrelay1.informatik.tu-muenchen.de [131.159.254.14])
    27.8 +	by sam.net.in.tum.de (Postfix) with ESMTP id BE55A1C00BC
    27.9 +	for <krista@gnunet.org>; Mon, 12 Jun 2017 15:27:51 +0200 (CEST)
   27.10 +Received: by vmmailrelay1.informatik.tu-muenchen.de (Postfix, from userid 109)
   27.11 +	id 94D2F1C0394; Mon, 12 Jun 2017 15:27:52 +0200 (CEST)
   27.12 +Received: from vmmailrelay1.informatik.tu-muenchen.de (localhost [127.0.0.1])
   27.13 +	by vmmailrelay1.informatik.tu-muenchen.de (Postfix) with ESMTP id 6D2E21C037A
   27.14 +	for <krista@gnunet.org>; Mon, 12 Jun 2017 15:27:52 +0200 (CEST)
   27.15 +Received: from vmmaildmz1.informatik.tu-muenchen.de (vmmaildmz1.informatik.tu-muenchen.de [131.159.0.87])
   27.16 +	by vmmailrelay1.informatik.tu-muenchen.de (Postfix) with ESMTP id 5876E1C0383
   27.17 +	for <krista@gnunet.org>; Mon, 12 Jun 2017 15:27:52 +0200 (CEST)
   27.18 +Received: by vmmaildmz1.informatik.tu-muenchen.de (Postfix, from userid 109)
   27.19 +	id 56F1F1C2D9D; Mon, 12 Jun 2017 15:27:52 +0200 (CEST)
   27.20 +X-Spam-Checker-Version: SpamAssassin 3.4.0-tuminfo_1 (2014-02-07) on
   27.21 +	vmmaildmz1.informatik.tu-muenchen.de
   27.22 +X-Spam-Level: 
   27.23 +X-Spam-Status: No, score=-3.4 required=7.0 tests=AWL,BAYES_00,
   27.24 +	ENCRYPTED_MESSAGE,RCVD_IN_DNSWL_LOW,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,
   27.25 +	TVD_RCVD_SPACE_BRACKET,UNPARSEABLE_RELAY autolearn=no autolearn_force=no
   27.26 +	version=3.4.0-tuminfo_1
   27.27 +Received: from vmmaildmz1.informatik.tu-muenchen.de (localhost [127.0.0.1])
   27.28 +	by vmmaildmz1.informatik.tu-muenchen.de (Postfix) with ESMTP id DE3C31C2D9E
   27.29 +	for <krista@gnunet.org>; Mon, 12 Jun 2017 15:27:50 +0200 (CEST)
   27.30 +Received: from mi4-p00-ob.smtp.rzone.de (mi4-p00-ob.smtp.rzone.de [81.169.146.149])
   27.31 +	(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
   27.32 +	(No client certificate requested)
   27.33 +	by vmmaildmz1.informatik.tu-muenchen.de (Postfix) with ESMTPS id CDD481C2D9B
   27.34 +	for <krista@gnunet.org>; Mon, 12 Jun 2017 15:27:50 +0200 (CEST)
   27.35 +X-RZG-FWD-BY: pep.test.recip@kgrothoff.org
   27.36 +Received: from mailin.rzone.de ([unix socket])
   27.37 +	by mailin.rzone.de (RZmta 40.9) with LMTPA;
   27.38 +	Mon, 12 Jun 2017 15:27:46 +0200 (CEST)
   27.39 +Authentication-Results: strato.com 1;
   27.40 +	spf=none
   27.41 +		smtp.mailfrom="pep.test.alice@pep-project.org";
   27.42 +	dkim=none;
   27.43 +	domainkeys=none;
   27.44 +	dkim-adsp=none
   27.45 +		header.from="pep.test.alice@pep-project.org"
   27.46 +X-Strato-MessageType: email
   27.47 +X-RZG-CLASS-ID: mi00
   27.48 +Received-SPF: none
   27.49 +	client-ip=131.159.0.8;
   27.50 +	helo="mail-out1.informatik.tu-muenchen.de";
   27.51 +	envelope-from="pep.test.alice@pep-project.org";
   27.52 +	receiver=smtpin.rzone.de;
   27.53 +	identity=mailfrom;
   27.54 +Received: from mail-out1.informatik.tu-muenchen.de ([131.159.0.8])
   27.55 +	by smtpin.rzone.de (RZmta 40.9 OK)
   27.56 +	with ESMTPS id w03564t5CDRkYmx
   27.57 +	(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (curve secp521r1 with 521 ECDH bits, eq. 15360 bits RSA))
   27.58 +	(Client did not present a certificate)
   27.59 +	for <pep.test.recip@kgrothoff.org>;
   27.60 +	Mon, 12 Jun 2017 15:27:46 +0200 (CEST)
   27.61 +Received: from [192.168.178.22] (ip5f584089.dynamic.kabel-deutschland.de [95.88.64.137])
   27.62 +	by services.sec.in.tum.de (Postfix) with ESMTPSA id A8EC11013AE47
   27.63 +	for <pep.test.recip@kgrothoff.org>; Mon, 12 Jun 2017 15:27:40 +0200 (CEST)
   27.64 +To: pep.test.recip@kgrothoff.org
   27.65 +Reply-To: krista@pep-project.org
   27.66 +From: pEp Test Alice <pep.test.alice@pep-project.org>
   27.67 +Subject: pEp
   27.68 +Organization: pEp
   27.69 +Message-ID: <5d37b6c2-9e5e-7217-c80e-1359da8faa5c@pep-project.org>
   27.70 +Date: Mon, 12 Jun 2017 15:27:40 +0200
   27.71 +User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101
   27.72 + Thunderbird/45.8.0
   27.73 +MIME-Version: 1.0
   27.74 +Content-Type: multipart/encrypted;
   27.75 + protocol="application/pgp-encrypted";
   27.76 + boundary="7vTKNA25GePB6VqgrM1km3gCfpFonmKj3"
   27.77 +
   27.78 +This is an OpenPGP/MIME encrypted message (RFC 4880 and 3156)
   27.79 +--7vTKNA25GePB6VqgrM1km3gCfpFonmKj3
   27.80 +Content-Type: application/pgp-encrypted
   27.81 +Content-Description: PGP/MIME version identification
   27.82 +
   27.83 +Version: 1
   27.84 +
   27.85 +--7vTKNA25GePB6VqgrM1km3gCfpFonmKj3
   27.86 +Content-Type: application/octet-stream; name="encrypted.asc"
   27.87 +Content-Description: OpenPGP encrypted message
   27.88 +Content-Disposition: inline; filename="encrypted.asc"
   27.89 +
   27.90 +-----BEGIN PGP MESSAGE-----
   27.91 +
   27.92 +hQEMA4FHqvEumyRHAQf6AkV51E1/uffFSc++oIPAoNCJU71NseNgW3s3XIQ/7TIQ
   27.93 +pDi6a6ksNdN+cJyMhfM7HnO06LjrUDYtgYPkZBHcTDZMWivW/7+5g8z60V3biIpw
   27.94 +mdUqhb+mZb4A0akMk+Ix8paoR8D7y4jmeLHwj/vbQ1J/E64rob9XPDWrLOW63chR
   27.95 +pg+XAo3VbkDKCms8PSuKehzMoTpZUcEVP47TF1OxuKZE0k7yJQ354RlPGxsl/6zM
   27.96 +O1+cJ7XdclkZj9gdeJAWzqCx6kTmDy2DA4e80BwMXXJnQtFIp4B55gTHvfbmxBRL
   27.97 +V8KDHOlvY/YSFV9sikjyaXbiweuqgiycsLb+qRziG4UBDANaAgXZcwg/TQEIAMg9
   27.98 +CVCJiYqS+ke1Zw0VNbb4BccrSBWL5iiQsPPUFOBld8jCFCGFZVBiik7O/XzRGWQh
   27.99 +qsYb2BNb0267viJS+IhTvihFybvR/l/gkzRLRfznFxbsRKgYAI6ipPr4wdAxvRkE
  27.100 +k0LvL3ckRgKtc2UORvfmhKRXu8Hj8dkYD0Asewnx7+p+s685MpyJ3zhhyifPzqKw
  27.101 +VH/6D7g26t3DjjQkvTvkiIMEvxT3beQN6QspdRtoDhHqAH0JhrZjEZyenneXE/AB
  27.102 +2CrnIfEU6V7S1EWP4Ond647K/F89ZG9LfTBpfmYuTXMKM39hmQaNcIsr8dr+mBif
  27.103 +nO2xRkyTMHAtyEk1dQnS6QFdLynwNLfsOvecztOBNBE/j6gH3dqKgZMg2e7ojK/Z
  27.104 +rNohpLMfZqzN37sfopm8htzK0Wg/l0CcgR8S4cUln06UzUm89GF9pokHYTnXYNYb
  27.105 +S2BMMVQ7gTpGDBfBFHVCK8xtCSFJJmxoxIzC9Ojl4JYfqJycip1QdWCWhXJDo0m9
  27.106 +4S+57m1UHAeyfT8v4ggEffVg2fgHF5VF58S3FC3HCtASAqljtmYVlHQSK0hSY00U
  27.107 +t9y/McqDXYuXXtT5O056q2VoYkWjTpvbvuk/TI3IU2np9owZwgHJwiA8I+BMQitd
  27.108 +LWRmSmoRBBHNsaORuEUZYMugZzcTD81C2v5PNDvawB7mcSFqrtI6K30TnZ5iu8DI
  27.109 +qJ9BdP7Htphqk9nusLT7XTYve/6/NC6rmnnEpQhrdXdzPDsyGe0H/s24xU3wFKBY
  27.110 +JdKyfKSJUkXjmCrqJrkq0wAHCaZYK5hLiobhYLGfxxjPpx2UFk33lYXL5R659Gjh
  27.111 +oIgZW5NWOxNRE1GRd2js+WaZy2dwvxeqNGEdEHgi6UN6JRf588lSYjbz+8u2TW21
  27.112 +whH5x5VfDpIqimPdknQwM/w8N2fYEhI4bWv0rp+D0m27hZaVXjInShEQq6YsjAs5
  27.113 +aP19C7WT+VK+FuvOEQ3nxPl+/fGOF5EoceuscxjCxkVu8Ijq4+xdu7Hl6ycJUu40
  27.114 +wGTKOy/rGg0TZ232SyUE83VyxAPtU0fTLvbZAcQaT+YTHqk/c4hdzPW/Ho8L1aZ0
  27.115 +Ax9PpkUHmm7+JS3sbfxyLMQ9Zz2GcE+SCIEyGuFTqO/ESmJUXTNQjDRmLuleOhZt
  27.116 +VmOezek2BEcvWZd5/0w6pd6UBjzXdSdTJA38nBr8Ao217xDMZiLoxg6xZbsG12et
  27.117 +mqWG9m/5dQRECrcN0lRdQqFovSkw7/Az7jOIm0v4ey+i6wmEblg3M0vm7Ky19l7Z
  27.118 +lm0+nC5XwR56n4VPtyRbGgLkI8w//NChYZJJOVpyVpfP57pKPhvhLNcaOk2d5gNU
  27.119 +KDg2bKXilzkMflVqw5eYN2EKCMlLx+hW5U1oSJJlQKqKXQ0qglUfSEzPmBt9Y0g1
  27.120 +DN+blh+m
  27.121 +=UZkH
  27.122 +-----END PGP MESSAGE-----
  27.123 +
  27.124 +--7vTKNA25GePB6VqgrM1km3gCfpFonmKj3--
    28.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    28.2 +++ b/test/test_mails/pEp_subject_normal.eml	Thu Jun 15 11:35:44 2017 +0200
    28.3 @@ -0,0 +1,112 @@
    28.4 +Return-Path: <pep.test.alice@pep-project.org>
    28.5 +X-Original-To: krista@gnunet.org
    28.6 +Delivered-To: krista@gnunet.org
    28.7 +Received: from vmmailrelay1.informatik.tu-muenchen.de (mailrelay1.informatik.tu-muenchen.de [131.159.254.14])
    28.8 +	by sam.net.in.tum.de (Postfix) with ESMTP id 98B571C00BC
    28.9 +	for <krista@gnunet.org>; Mon, 12 Jun 2017 15:25:44 +0200 (CEST)
   28.10 +Received: by vmmailrelay1.informatik.tu-muenchen.de (Postfix, from userid 109)
   28.11 +	id 620431C0383; Mon, 12 Jun 2017 15:25:45 +0200 (CEST)
   28.12 +Received: from vmmailrelay1.informatik.tu-muenchen.de (localhost [127.0.0.1])
   28.13 +	by vmmailrelay1.informatik.tu-muenchen.de (Postfix) with ESMTP id 3F4961C037C
   28.14 +	for <krista@gnunet.org>; Mon, 12 Jun 2017 15:25:45 +0200 (CEST)
   28.15 +Received: from vmmaildmz1.informatik.tu-muenchen.de (vmmaildmz1.informatik.tu-muenchen.de [131.159.0.87])
   28.16 +	by vmmailrelay1.informatik.tu-muenchen.de (Postfix) with ESMTP id 2BCE31C037A
   28.17 +	for <krista@gnunet.org>; Mon, 12 Jun 2017 15:25:45 +0200 (CEST)
   28.18 +Received: by vmmaildmz1.informatik.tu-muenchen.de (Postfix, from userid 109)
   28.19 +	id 2A4741C2D9D; Mon, 12 Jun 2017 15:25:45 +0200 (CEST)
   28.20 +X-Spam-Checker-Version: SpamAssassin 3.4.0-tuminfo_1 (2014-02-07) on
   28.21 +	vmmaildmz1.informatik.tu-muenchen.de
   28.22 +X-Spam-Level: 
   28.23 +X-Spam-Status: No, score=-3.6 required=7.0 tests=BAYES_00,ENCRYPTED_MESSAGE,
   28.24 +	RCVD_IN_DNSWL_LOW,TVD_RCVD_SPACE_BRACKET,UNPARSEABLE_RELAY autolearn=no
   28.25 +	autolearn_force=no version=3.4.0-tuminfo_1
   28.26 +Received: from vmmaildmz1.informatik.tu-muenchen.de (localhost [127.0.0.1])
   28.27 +	by vmmaildmz1.informatik.tu-muenchen.de (Postfix) with ESMTP id 6EF791C2D9E
   28.28 +	for <krista@gnunet.org>; Mon, 12 Jun 2017 15:25:43 +0200 (CEST)
   28.29 +Received: from mi4-p00-ob.smtp.rzone.de (mi4-p00-ob.smtp.rzone.de [81.169.146.144])
   28.30 +	(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
   28.31 +	(No client certificate requested)
   28.32 +	by vmmaildmz1.informatik.tu-muenchen.de (Postfix) with ESMTPS id 5E75D1C2D9B
   28.33 +	for <krista@gnunet.org>; Mon, 12 Jun 2017 15:25:43 +0200 (CEST)
   28.34 +X-RZG-FWD-BY: pep.test.recip@kgrothoff.org
   28.35 +Received: from mailin.rzone.de ([unix socket])
   28.36 +	by mailin.rzone.de (RZmta 40.9) with LMTPA;
   28.37 +	Mon, 12 Jun 2017 15:25:24 +0200 (CEST)
   28.38 +Authentication-Results: strato.com 1;
   28.39 +	spf=none
   28.40 +		smtp.mailfrom="pep.test.alice@pep-project.org";
   28.41 +	dkim=none;
   28.42 +	domainkeys=none;
   28.43 +	dkim-adsp=none
   28.44 +		header.from="pep.test.alice@pep-project.org"
   28.45 +X-Strato-MessageType: email
   28.46 +X-RZG-CLASS-ID: mi00
   28.47 +Received-SPF: none
   28.48 +	client-ip=131.159.0.8;
   28.49 +	helo="mail-out1.informatik.tu-muenchen.de";
   28.50 +	envelope-from="pep.test.alice@pep-project.org";
   28.51 +	receiver=smtpin.rzone.de;
   28.52 +	identity=mailfrom;
   28.53 +Received: from mail-out1.informatik.tu-muenchen.de ([131.159.0.8])
   28.54 +	by smtpin.rzone.de (RZmta 40.9 OK)
   28.55 +	with ESMTPS id v06d9ft5CDPHXhF
   28.56 +	(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (curve secp521r1 with 521 ECDH bits, eq. 15360 bits RSA))
   28.57 +	(Client did not present a certificate)
   28.58 +	for <pep.test.recip@kgrothoff.org>;
   28.59 +	Mon, 12 Jun 2017 15:25:17 +0200 (CEST)
   28.60 +Received: from [192.168.178.22] (ip5f584089.dynamic.kabel-deutschland.de [95.88.64.137])
   28.61 +	by services.sec.in.tum.de (Postfix) with ESMTPSA id 4697F1013AE47
   28.62 +	for <pep.test.recip@kgrothoff.org>; Mon, 12 Jun 2017 15:25:11 +0200 (CEST)
   28.63 +Reply-To: krista@pep-project.org
   28.64 +To: pep.test.recip@kgrothoff.org
   28.65 +From: pEp Test Alice <pep.test.alice@pep-project.org>
   28.66 +Subject: pEp
   28.67 +Organization: pEp
   28.68 +Message-ID: <92ee4ca2-17cd-bcf1-377c-3367470bb571@pep-project.org>
   28.69 +Date: Mon, 12 Jun 2017 15:25:10 +0200
   28.70 +User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101
   28.71 + Thunderbird/45.8.0
   28.72 +MIME-Version: 1.0
   28.73 +Content-Type: multipart/encrypted;
   28.74 + protocol="application/pgp-encrypted";
   28.75 + boundary="e7R73MXx31oWAX8HMqNvMDNt9cAMWtSTV"
   28.76 +
   28.77 +This is an OpenPGP/MIME encrypted message (RFC 4880 and 3156)
   28.78 +--e7R73MXx31oWAX8HMqNvMDNt9cAMWtSTV
   28.79 +Content-Type: application/pgp-encrypted
   28.80 +Content-Description: PGP/MIME version identification
   28.81 +
   28.82 +Version: 1
   28.83 +
   28.84 +--e7R73MXx31oWAX8HMqNvMDNt9cAMWtSTV
   28.85 +Content-Type: application/octet-stream; name="encrypted.asc"
   28.86 +Content-Description: OpenPGP encrypted message
   28.87 +Content-Disposition: inline; filename="encrypted.asc"
   28.88 +
   28.89 +-----BEGIN PGP MESSAGE-----
   28.90 +
   28.91 +hQEMA4FHqvEumyRHAQf+KW54G6f25yDJs6MdhWSs/766uFEIy8pq+j49AykOBsh2
   28.92 +W8BeB7yBqwjVFsBYPwGFNza187QHQVQlOHGRtxkXSX/iSym/O82YPvSwZj7GkKS9
   28.93 +sMgX2/dOMaEoTitn72f26ww5PvAqltJLD5TGhSM0RxK+0OemSrI0wDZxUb2Ll8DT
   28.94 +aVwpuKnLYFMcnk8SQLa3eZ/YpFV3TCMDFUgtIEqmHoh74dwemQjpP+qhbExZvY/k
   28.95 +rSZuJoU8siuLJ72vbEn8n2x8UCCfyTpacBZkC6Ukhsm/XrSg2GjqqzjSeR0T0Nbr
   28.96 +y/sFblbE8fbmouAf5k670oUot+j5aoHV79Rntcdm1oUBDANaAgXZcwg/TQEH/jhF
   28.97 +1ayYCROI8xEhj01Qbn60OtG+iKO+3B5/+uwizYgyW5mhKjrdgA/wsKMTMXj1BG+J
   28.98 +JJJ1TdEbxbL2UCai6nuHd0CbqJWSuTAicteKudUclAJHnpm2Qv+Yq2t/8JwJllMR
   28.99 +Wum8Cj4WuD0K3te5uHDZuu7Vfj9r3+7WYJ7FUkSYp2DUIFMM+hG+8OJtdjKd6kAA
  28.100 +FtAOijws+1r4jYFGYkCMRfnQatiFXf0n6Nr8qjSskkMtNQk41AG4LauYFTphR/G+
  28.101 +ayXPd8buDyBh3XuyoMcg5vLMJfWVTfiKM/wxv1jBBrQwFd5JpqCNr9dHYWMJ0gg9
  28.102 +aMdvaDEEd7I4VlwU+4DSwQMBF7R9V3cYj1XOxHjX2EikIxR/kviUrB8vDE4LAYJE
  28.103 +UFvoXgKRe4lQbQlLwoBp6R8L6mPTytLzlQnjQ4AJhPWhXkJUeCetURr5BzNCEfOy
  28.104 ++2Nq+9XLGM0wSCY09BOsGAQSL56kIGL61AnhvhpPUi9w9SOVjLHge6pzSzAW3h5E
  28.105 +vf8a8oGyLjyHR9VWBUqrMQ0tTWdHkoeHenXpwA+rckr0kzJXW1RJt2oQJEE0LI2I
  28.106 +0p9j7o6imaYWdtbHS7Kcbg2DxbT63QVOoO4OTPLHjYj0eqf1NDlwKBzQYaknNScI
  28.107 +LHnXrzMqqylU3ki8hUIh0K1ULernaA8LEIuegKMuguHCs2B/Xgee+Hor6l4XBRzD
  28.108 +V/8WFIU1lxthnYEceik/OD2U+LDKT4i+AogJAA+rCw0WbUC8f1HXQeV/8CVarcUn
  28.109 +GrS7AjjZlwQfiE8R/CtKdNaiJa4Z8GuQZJD/AqOe5zH0HLBykaheHS6ynw9yuNb7
  28.110 +d6lArIYdW5S8D0RDYRwu7z/lI3sgVgwiuoAk1OiYtrYUUNiXcpO59aE59iXjMW61
  28.111 +EvUAZzgfRyuzYdZtYNaM3FvUSm2aAsQRP+NJFW3YkqkbLvyo
  28.112 +=VpGy
  28.113 +-----END PGP MESSAGE-----
  28.114 +
  28.115 +--e7R73MXx31oWAX8HMqNvMDNt9cAMWtSTV--
    29.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    29.2 +++ b/test/test_mails/pEp_subject_normal_signed.eml	Thu Jun 15 11:35:44 2017 +0200
    29.3 @@ -0,0 +1,119 @@
    29.4 +Return-Path: <pep.test.alice@pep-project.org>
    29.5 +X-Original-To: krista@gnunet.org
    29.6 +Delivered-To: krista@gnunet.org
    29.7 +Received: from vmmailrelay1.informatik.tu-muenchen.de (mailrelay1.informatik.tu-muenchen.de [131.159.254.14])
    29.8 +	by sam.net.in.tum.de (Postfix) with ESMTP id 768301C00BC
    29.9 +	for <krista@gnunet.org>; Mon, 12 Jun 2017 15:26:24 +0200 (CEST)
   29.10 +Received: by vmmailrelay1.informatik.tu-muenchen.de (Postfix, from userid 109)
   29.11 +	id 4DD7D1C0383; Mon, 12 Jun 2017 15:26:25 +0200 (CEST)
   29.12 +Received: from vmmailrelay1.informatik.tu-muenchen.de (localhost [127.0.0.1])
   29.13 +	by vmmailrelay1.informatik.tu-muenchen.de (Postfix) with ESMTP id 2AD621C037C
   29.14 +	for <krista@gnunet.org>; Mon, 12 Jun 2017 15:26:25 +0200 (CEST)
   29.15 +Received: from vmmaildmz2.informatik.tu-muenchen.de (vmmaildmz2.informatik.tu-muenchen.de [131.159.0.88])
   29.16 +	by vmmailrelay1.informatik.tu-muenchen.de (Postfix) with ESMTP id 15DA11C037A
   29.17 +	for <krista@gnunet.org>; Mon, 12 Jun 2017 15:26:25 +0200 (CEST)
   29.18 +Received: by vmmaildmz2.informatik.tu-muenchen.de (Postfix, from userid 109)
   29.19 +	id 13FCC1C2AE2; Mon, 12 Jun 2017 15:26:25 +0200 (CEST)
   29.20 +X-Spam-Checker-Version: SpamAssassin 3.4.0-tuminfo_1 (2014-02-07) on
   29.21 +	vmmaildmz2.informatik.tu-muenchen.de
   29.22 +X-Spam-Level: 
   29.23 +X-Spam-Status: No, score=-2.6 required=7.0 tests=AWL,BAYES_00,
   29.24 +	ENCRYPTED_MESSAGE,RCVD_IN_DNSWL_LOW,TVD_RCVD_SPACE_BRACKET,UNPARSEABLE_RELAY
   29.25 +	autolearn=no autolearn_force=no version=3.4.0-tuminfo_1
   29.26 +Received: from vmmaildmz2.informatik.tu-muenchen.de (localhost [127.0.0.1])
   29.27 +	by vmmaildmz2.informatik.tu-muenchen.de (Postfix) with ESMTP id 953971C2AE1
   29.28 +	for <krista@gnunet.org>; Mon, 12 Jun 2017 15:26:23 +0200 (CEST)
   29.29 +Received: from mi4-p00-ob.smtp.rzone.de (mi4-p00-ob.smtp.rzone.de [81.169.146.144])
   29.30 +	(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
   29.31 +	(No client certificate requested)
   29.32 +	by vmmaildmz2.informatik.tu-muenchen.de (Postfix) with ESMTPS id 8540A1C2AE0
   29.33 +	for <krista@gnunet.org>; Mon, 12 Jun 2017 15:26:23 +0200 (CEST)
   29.34 +X-RZG-FWD-BY: pep.test.recip@kgrothoff.org
   29.35 +Received: from mailin.rzone.de ([unix socket])
   29.36 +	by mailin.rzone.de (RZmta 40.9) with LMTPA;
   29.37 +	Mon, 12 Jun 2017 15:26:02 +0200 (CEST)
   29.38 +Authentication-Results: strato.com 1;
   29.39 +	spf=none
   29.40 +		smtp.mailfrom="pep.test.alice@pep-project.org";
   29.41 +	dkim=none;
   29.42 +	domainkeys=none;
   29.43 +	dkim-adsp=none
   29.44 +		header.from="pep.test.alice@pep-project.org"
   29.45 +X-Strato-MessageType: email
   29.46 +X-RZG-CLASS-ID: mi00
   29.47 +Received-SPF: none
   29.48 +	client-ip=131.159.0.8;
   29.49 +	helo="mail-out1.informatik.tu-muenchen.de";
   29.50 +	envelope-from="pep.test.alice@pep-project.org";
   29.51 +	receiver=smtpin.rzone.de;
   29.52 +	identity=mailfrom;
   29.53 +Received: from mail-out1.informatik.tu-muenchen.de ([131.159.0.8])
   29.54 +	by smtpin.rzone.de (RZmta 40.9 OK)
   29.55 +	with ESMTPS id v06d9ft5CDQ2Xj1
   29.56 +	(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (curve secp521r1 with 521 ECDH bits, eq. 15360 bits RSA))
   29.57 +	(Client did not present a certificate)
   29.58 +	for <pep.test.recip@kgrothoff.org>;
   29.59 +	Mon, 12 Jun 2017 15:26:02 +0200 (CEST)
   29.60 +Received: from [192.168.178.22] (ip5f584089.dynamic.kabel-deutschland.de [95.88.64.137])
   29.61 +	by services.sec.in.tum.de (Postfix) with ESMTPSA id BEAA21013AE47
   29.62 +	for <pep.test.recip@kgrothoff.org>; Mon, 12 Jun 2017 15:25:56 +0200 (CEST)
   29.63 +To: pep.test.recip@kgrothoff.org
   29.64 +Reply-To: krista@pep-project.org
   29.65 +From: pEp Test Alice <pep.test.alice@pep-project.org>
   29.66 +Subject: pEp
   29.67 +Organization: pEp
   29.68 +Message-ID: <988e71f4-df80-906e-8bbb-68d48069d4ac@pep-project.org>
   29.69 +Date: Mon, 12 Jun 2017 15:25:56 +0200
   29.70 +User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101
   29.71 + Thunderbird/45.8.0
   29.72 +MIME-Version: 1.0
   29.73 +Content-Type: multipart/encrypted;
   29.74 + protocol="application/pgp-encrypted";
   29.75 + boundary="hcW81WNiFhQC1SNIcls8J07V1b1sXtfCA"
   29.76 +
   29.77 +This is an OpenPGP/MIME encrypted message (RFC 4880 and 3156)
   29.78 +--hcW81WNiFhQC1SNIcls8J07V1b1sXtfCA
   29.79 +Content-Type: application/pgp-encrypted
   29.80 +Content-Description: PGP/MIME version identification
   29.81 +
   29.82 +Version: 1
   29.83 +
   29.84 +--hcW81WNiFhQC1SNIcls8J07V1b1sXtfCA
   29.85 +Content-Type: application/octet-stream; name="encrypted.asc"
   29.86 +Content-Description: OpenPGP encrypted message
   29.87 +Content-Disposition: inline; filename="encrypted.asc"
   29.88 +
   29.89 +-----BEGIN PGP MESSAGE-----
   29.90 +
   29.91 +hQEMA4FHqvEumyRHAQf+OCG4FM0n6pVREVP2kAUzJWy6NAgRYs4cj7pr5hDoUqZY
   29.92 +lBIfVPqNM2rG2xaSpNLfe1iY5mySKL42M+s/QM0cvfnOlS6p3U58EamslElZ9UhD
   29.93 +hBUrX/1NJwdoKyR07Wq3A1UFFYQMYsszPwoC82SCFOhYjEmdZ8/nppViUk3aAUvq
   29.94 +do80ZzvNnlJqgwPEUmMEy9p19XJxQQwG75yHmUsoTvgi9ELvJpEzAjeYFABNzuNE
   29.95 +lh5whuMqmVbEafAYtopB+dwxQxSUdQUHntLU2MrbH8QXGtP98ZaDTHg/Zj24zkUG
   29.96 +Ur/5DZJgzDMrAttorpp/2/NMmakIezy7JaoGQtyYRYUBDANaAgXZcwg/TQEIALLR
   29.97 +7OlIlUYelrktOnrkTy8BrrEuUj95uBM5TkkvWIfR2b3ylC5iWwa/RlIU4RC0VH3j
   29.98 +epwLQNJJKFi/qKwxReE+RMKZW00loUuYnVWeaj58ExTNsdpFJDut35AIp8FNzTmy
   29.99 +C4xv5VVZZnolRd6CW0GUuxEe1zXq1MiyuGHu5AwFgWl728KaRXF2tEVyrQt/okXx
  29.100 +kF7yWkO4oo25VZWCrboUc1FND/7dbfP/PtLKIj05l+xwNaIEt1gb1IM7SxjN+2Tx
  29.101 +Ayp/w1npFhugBkSV3JaIk9dfHpMlLP5URZn30dXElK0an7aB8IwZWwdObo4zlevI
  29.102 +K4nN+UU1Z/kN1guxYDbS6QGOo2Y8829kaOXkBC3HDQEkef631jj1FuVB6VJvhb0u
  29.103 +5EKaxyw8aVxodRQaK9CcKCqwDlnyhHqd4fdMjPk9zTV9xrnqSdC5yKoAhBJ9sFef
  29.104 +Qv5qjYiBUhB+7uGMvRifvO+bT+8q44IS7z/bdXJFjbImgtx57yKvujyvrZlDe6q3
  29.105 +1nzS1jqMQ8NCDP/CKs5WUlaH9LIQ/NWF10EulTjaZ0QZ6iNU0MTqmhs4ZJIsPmBo
  29.106 +g6Qz9x8imV37cC9lHhw/vp99Dal9YulTxdYZnWSfTh289bHqaMEXGYJUsDh3IEYx
  29.107 +UP1bzza+N2dqeiysDmeTNhbZvwk54VmaKMrj/ut/3WIrsulBY7YxE/azle78Ydab
  29.108 +/tKu5YUbVydnVJ6y1s4yASjaOG7ycMIaXggWKUIfWh5Y7BLFHYbcMMltPrspftW7
  29.109 +tjtbL1SUHw0NTfCkBqRv4GpvIAXTCmlxvLw//ee1JZ0nuLnQZBF2GQ0wJVsbunT9
  29.110 +dUschdnIWLfWlueldt+5wOkB6L4quoZ7LWefMQu/b3bg/GWoBtuC3fJDnCsbJO07
  29.111 +nJxZTPxsI3iFUGGtXkg4jGC+yDMlQu3a7LwEkKzx9LT/S1OUndpaBQr6YjyrnET6
  29.112 +w1Hz6jLb5t/2fzrBwkKw1TCu4+pkevIGaGxgQY6TB15jcmWRkUF3sakTrH0UOCSq
  29.113 +wEzFoPF4+WjtXNk/wHw8zkrW7QCe+wbjLjwcUUK/ulKT9/II/k/aUwTt+GzWCGVq
  29.114 +KWq7VLtwa8lrJ74R+XISks9/Hv/nJ8Ay1DfpcQU2HQSnQpSrXupXIA+VoHU/b8xD
  29.115 +YcgqaRKsGYHUANjNs4PpplXlEHp5bpF/ZOpfVAJNnGQ96Cj182DLQgiB0j7Ishjv
  29.116 +XoNDVL45KKW0uWjimZbCauWrD6tjZfBmydymezbPLCB9R+tE68TA/XmpXzInXWML
  29.117 +YDK7tS8TYEkodzSkfDeB7BtXBRIxH4vm2M0E0OdJuLxjrOYeIH4xToUslS9pdog0
  29.118 +z3aqPQbXF4hFc8Fso83dmoc26mQd3H0LrP7yF4HR
  29.119 +=gLhG
  29.120 +-----END PGP MESSAGE-----
  29.121 +
  29.122 +--hcW81WNiFhQC1SNIcls8J07V1b1sXtfCA--
    30.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    30.2 +++ b/test/test_mails/pEp_subject_normal_unencrypted.eml	Thu Jun 15 11:35:44 2017 +0200
    30.3 @@ -0,0 +1,75 @@
    30.4 +Return-Path: <pep.test.alice@pep-project.org>
    30.5 +X-Original-To: krista@gnunet.org
    30.6 +Delivered-To: krista@gnunet.org
    30.7 +Received: from vmmailrelay1.informatik.tu-muenchen.de (mailrelay1.informatik.tu-muenchen.de [131.159.254.14])
    30.8 +	by sam.net.in.tum.de (Postfix) with ESMTP id 140C01C00BC
    30.9 +	for <krista@gnunet.org>; Mon, 12 Jun 2017 15:27:21 +0200 (CEST)
   30.10 +Received: by vmmailrelay1.informatik.tu-muenchen.de (Postfix, from userid 109)
   30.11 +	id DAE901C0390; Mon, 12 Jun 2017 15:27:21 +0200 (CEST)
   30.12 +Received: from vmmailrelay1.informatik.tu-muenchen.de (localhost [127.0.0.1])
   30.13 +	by vmmailrelay1.informatik.tu-muenchen.de (Postfix) with ESMTP id B86091C0383
   30.14 +	for <krista@gnunet.org>; Mon, 12 Jun 2017 15:27:21 +0200 (CEST)
   30.15 +Received: from vmmaildmz1.informatik.tu-muenchen.de (vmmaildmz1.informatik.tu-muenchen.de [131.159.0.87])
   30.16 +	by vmmailrelay1.informatik.tu-muenchen.de (Postfix) with ESMTP id AE13F1C037A
   30.17 +	for <krista@gnunet.org>; Mon, 12 Jun 2017 15:27:21 +0200 (CEST)
   30.18 +Received: by vmmaildmz1.informatik.tu-muenchen.de (Postfix, from userid 109)
   30.19 +	id AC51F1C2D9F; Mon, 12 Jun 2017 15:27:21 +0200 (CEST)
   30.20 +X-Spam-Checker-Version: SpamAssassin 3.4.0-tuminfo_1 (2014-02-07) on
   30.21 +	vmmaildmz1.informatik.tu-muenchen.de
   30.22 +X-Spam-Level: 
   30.23 +X-Spam-Status: No, score=-3.1 required=7.0 tests=AWL,BAYES_00,
   30.24 +	RCVD_IN_DNSWL_LOW,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,TVD_RCVD_SPACE_BRACKET,
   30.25 +	UNPARSEABLE_RELAY autolearn=no autolearn_force=no version=3.4.0-tuminfo_1
   30.26 +Received: from vmmaildmz1.informatik.tu-muenchen.de (localhost [127.0.0.1])
   30.27 +	by vmmaildmz1.informatik.tu-muenchen.de (Postfix) with ESMTP id 3B30C1C2D9E
   30.28 +	for <krista@gnunet.org>; Mon, 12 Jun 2017 15:27:20 +0200 (CEST)
   30.29 +Received: from mi4-p00-ob.smtp.rzone.de (mi4-p00-ob.smtp.rzone.de [81.169.146.148])
   30.30 +	(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
   30.31 +	(No client certificate requested)
   30.32 +	by vmmaildmz1.informatik.tu-muenchen.de (Postfix) with ESMTPS id 2AEF61C2D9B
   30.33 +	for <krista@gnunet.org>; Mon, 12 Jun 2017 15:27:20 +0200 (CEST)
   30.34 +X-RZG-FWD-BY: pep.test.recip@kgrothoff.org
   30.35 +Received: from mailin.rzone.de ([unix socket])
   30.36 +	by mailin.rzone.de (RZmta 40.9) with LMTPA;
   30.37 +	Mon, 12 Jun 2017 15:27:00 +0200 (CEST)
   30.38 +Authentication-Results: strato.com 1;
   30.39 +	spf=none
   30.40 +		smtp.mailfrom="pep.test.alice@pep-project.org";
   30.41 +	dkim=none;
   30.42 +	domainkeys=none;
   30.43 +	dkim-adsp=none
   30.44 +		header.from="pep.test.alice@pep-project.org"
   30.45 +X-Strato-MessageType: email
   30.46 +X-RZG-CLASS-ID: mi00
   30.47 +Received-SPF: none
   30.48 +	client-ip=131.159.0.8;
   30.49 +	helo="mail-out1.informatik.tu-muenchen.de";
   30.50 +	envelope-from="pep.test.alice@pep-project.org";
   30.51 +	receiver=smtpin.rzone.de;
   30.52 +	identity=mailfrom;
   30.53 +Received: from mail-out1.informatik.tu-muenchen.de ([131.159.0.8])
   30.54 +	by smtpin.rzone.de (RZmta 40.9 OK)
   30.55 +	with ESMTPS id T01d0bt5CDR0XKI
   30.56 +	(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (curve secp521r1 with 521 ECDH bits, eq. 15360 bits RSA))
   30.57 +	(Client did not present a certificate)
   30.58 +	for <pep.test.recip@kgrothoff.org>;
   30.59 +	Mon, 12 Jun 2017 15:27:00 +0200 (CEST)
   30.60 +Received: from [192.168.178.22] (ip5f584089.dynamic.kabel-deutschland.de [95.88.64.137])
   30.61 +	by services.sec.in.tum.de (Postfix) with ESMTPSA id 1DF211013AE47
   30.62 +	for <pep.test.recip@kgrothoff.org>; Mon, 12 Jun 2017 15:26:55 +0200 (CEST)
   30.63 +Reply-To: krista@pep-project.org
   30.64 +To: pep.test.recip@kgrothoff.org
   30.65 +From: pEp Test Alice <pep.test.alice@pep-project.org>
   30.66 +Subject: pEp
   30.67 +Organization: pEp
   30.68 +Message-ID: <6205efbe-684d-9f21-8a2e-887d46a145e6@pep-project.org>
   30.69 +Date: Mon, 12 Jun 2017 15:26:54 +0200
   30.70 +User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101
   30.71 + Thunderbird/45.8.0
   30.72 +MIME-Version: 1.0
   30.73 +Content-Type: text/plain; charset=utf-8
   30.74 +Content-Transfer-Encoding: 7bit
   30.75 +
   30.76 +Subject: Unencrypted try...
   30.77 +
   30.78 +La la la...
    31.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    31.2 +++ b/test/test_mails/pEp_subject_pEp.eml	Thu Jun 15 11:35:44 2017 +0200
    31.3 @@ -0,0 +1,120 @@
    31.4 +Return-Path: <pep.test.alice@pep-project.org>
    31.5 +X-Original-To: krista@gnunet.org
    31.6 +Delivered-To: krista@gnunet.org
    31.7 +Received: from vmmailrelay1.informatik.tu-muenchen.de (mailrelay1.informatik.tu-muenchen.de [131.159.254.14])
    31.8 +	by sam.net.in.tum.de (Postfix) with ESMTP id 1C8731C00BC
    31.9 +	for <krista@gnunet.org>; Mon, 12 Jun 2017 15:28:42 +0200 (CEST)
   31.10 +Received: by vmmailrelay1.informatik.tu-muenchen.de (Postfix, from userid 109)
   31.11 +	id E78B01C0383; Mon, 12 Jun 2017 15:28:42 +0200 (CEST)
   31.12 +Received: from vmmailrelay1.informatik.tu-muenchen.de (localhost [127.0.0.1])
   31.13 +	by vmmailrelay1.informatik.tu-muenchen.de (Postfix) with ESMTP id C414C1C037C
   31.14 +	for <krista@gnunet.org>; Mon, 12 Jun 2017 15:28:42 +0200 (CEST)
   31.15 +Received: from vmmaildmz2.informatik.tu-muenchen.de (vmmaildmz2.informatik.tu-muenchen.de [131.159.0.88])
   31.16 +	by vmmailrelay1.informatik.tu-muenchen.de (Postfix) with ESMTP id AFA401C037A
   31.17 +	for <krista@gnunet.org>; Mon, 12 Jun 2017 15:28:42 +0200 (CEST)
   31.18 +Received: by vmmaildmz2.informatik.tu-muenchen.de (Postfix, from userid 109)
   31.19 +	id AE03E1C2AE1; Mon, 12 Jun 2017 15:28:42 +0200 (CEST)
   31.20 +X-Spam-Checker-Version: SpamAssassin 3.4.0-tuminfo_1 (2014-02-07) on
   31.21 +	vmmaildmz2.informatik.tu-muenchen.de
   31.22 +X-Spam-Level: 
   31.23 +X-Spam-Status: No, score=-2.9 required=7.0 tests=AWL,BAYES_00,
   31.24 +	ENCRYPTED_MESSAGE,RCVD_IN_DNSWL_LOW,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,
   31.25 +	TVD_RCVD_SPACE_BRACKET,UNPARSEABLE_RELAY autolearn=no autolearn_force=no
   31.26 +	version=3.4.0-tuminfo_1
   31.27 +Received: from vmmaildmz2.informatik.tu-muenchen.de (localhost [127.0.0.1])
   31.28 +	by vmmaildmz2.informatik.tu-muenchen.de (Postfix) with ESMTP id 441B11C2AE0
   31.29 +	for <krista@gnunet.org>; Mon, 12 Jun 2017 15:28:41 +0200 (CEST)
   31.30 +Received: from mi4-p00-ob.smtp.rzone.de (mi4-p00-ob.smtp.rzone.de [81.169.146.149])
   31.31 +	(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
   31.32 +	(No client certificate requested)
   31.33 +	by vmmaildmz2.informatik.tu-muenchen.de (Postfix) with ESMTPS id 3420F1C2ADF
   31.34 +	for <krista@gnunet.org>; Mon, 12 Jun 2017 15:28:41 +0200 (CEST)
   31.35 +X-RZG-FWD-BY: pep.test.recip@kgrothoff.org
   31.36 +Received: from mailin.rzone.de ([unix socket])
   31.37 +	by mailin.rzone.de (RZmta 40.9) with LMTPA;
   31.38 +	Mon, 12 Jun 2017 15:28:27 +0200 (CEST)
   31.39 +Authentication-Results: strato.com 1;
   31.40 +	spf=none
   31.41 +		smtp.mailfrom="pep.test.alice@pep-project.org";
   31.42 +	dkim=none;
   31.43 +	domainkeys=none;
   31.44 +	dkim-adsp=none
   31.45 +		header.from="pep.test.alice@pep-project.org"
   31.46 +X-Strato-MessageType: email
   31.47 +X-RZG-CLASS-ID: mi00
   31.48 +Received-SPF: none
   31.49 +	client-ip=131.159.0.8;
   31.50 +	helo="mail-out1.informatik.tu-muenchen.de";
   31.51 +	envelope-from="pep.test.alice@pep-project.org";
   31.52 +	receiver=smtpin.rzone.de;
   31.53 +	identity=mailfrom;
   31.54 +Received: from mail-out1.informatik.tu-muenchen.de ([131.159.0.8])
   31.55 +	by smtpin.rzone.de (RZmta 40.9 OK)
   31.56 +	with ESMTPS id R04db2t5CDSRaBk
   31.57 +	(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (curve secp521r1 with 521 ECDH bits, eq. 15360 bits RSA))
   31.58 +	(Client did not present a certificate)
   31.59 +	for <pep.test.recip@kgrothoff.org>;
   31.60 +	Mon, 12 Jun 2017 15:28:27 +0200 (CEST)
   31.61 +Received: from [192.168.178.22] (ip5f584089.dynamic.kabel-deutschland.de [95.88.64.137])
   31.62 +	by services.sec.in.tum.de (Postfix) with ESMTPSA id E7A551013AE47
   31.63 +	for <pep.test.recip@kgrothoff.org>; Mon, 12 Jun 2017 15:28:20 +0200 (CEST)
   31.64 +Reply-To: krista@pep-project.org
   31.65 +To: pep.test.recip@kgrothoff.org
   31.66 +From: pEp Test Alice <pep.test.alice@pep-project.org>
   31.67 +Subject: pEp
   31.68 +Organization: pEp
   31.69 +Message-ID: <1779982d-d48e-6d8c-2dcb-a2c337c496cb@pep-project.org>
   31.70 +Date: Mon, 12 Jun 2017 15:28:20 +0200
   31.71 +User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101
   31.72 + Thunderbird/45.8.0
   31.73 +MIME-Version: 1.0
   31.74 +Content-Type: multipart/encrypted;
   31.75 + protocol="application/pgp-encrypted";
   31.76 + boundary="xNhsqki3RTDSnTgiBbeAIkT3t5whv1bAM"
   31.77 +
   31.78 +This is an OpenPGP/MIME encrypted message (RFC 4880 and 3156)
   31.79 +--xNhsqki3RTDSnTgiBbeAIkT3t5whv1bAM
   31.80 +Content-Type: application/pgp-encrypted
   31.81 +Content-Description: PGP/MIME version identification
   31.82 +
   31.83 +Version: 1
   31.84 +
   31.85 +--xNhsqki3RTDSnTgiBbeAIkT3t5whv1bAM
   31.86 +Content-Type: application/octet-stream; name="encrypted.asc"
   31.87 +Content-Description: OpenPGP encrypted message
   31.88 +Content-Disposition: inline; filename="encrypted.asc"
   31.89 +
   31.90 +-----BEGIN PGP MESSAGE-----
   31.91 +
   31.92 +hQEMA4FHqvEumyRHAQgAjsyn0zCm0jHAp+SshDzqhMFNPuRc8VhDK9DpxiA1jLy8
   31.93 +bH2CKJIZEWApyfmwX5xLEXhfr0wb4BthHDXLzHCDqLSFo5FoavTwNL44kaX83yPv
   31.94 +Ts2WrvOcXGRpNLD94tvyDBqngtk3yKYaSkKKPok4Ou5gHrIDJaNZf/mybmPa0aTX
   31.95 +BEOxgAaRZJoPhgeVF8/twwiDv+ixFtdnPx9gGUXvgc5tPyrIkFkWtwrsoS2RmtJT
   31.96 +QqdsMmPbTFrsZ+d7qhdkcedeoKRg84SlXgtFpXkkbKHB/NU2ZQ2h2xTeUqdkFGN7
   31.97 +vBv17C+5jv8wzYlrlni9P1Mbc+dVBZTal9gYtBGwxIUBDANaAgXZcwg/TQEH/0vs
   31.98 +xQCJEdqbHKLz+xOmrpQEoFLdf2W9B7z2jGQe9F0K+gnPE3E+1wVf/IQgLj4YDXtN
   31.99 +Gkzc6J3UPBN9b1WSTPcJQ47hU5IXO/Sb39dU9X1s01JtCorTKmHlefosg6YaZ8CX
  31.100 +OhTkGYHqcJa9xE8kOMi4xnhP2Z3xaSkPSQvQ4WDWSapOwDkcM2a59Nwbu5PIGZpj
  31.101 +FM9WVLawN1/SVbaKOUEhFKdbl7UYW64JNWE6ZaLa0sfigt4QaXd5GrQcP2vmVVGz
  31.102 +WOuCaEb/HnxgiUvLQI2tCnW8aWluc6PnNk3HwLydvCL0tHSXPJno4Wbs1GzRJ4G7
  31.103 +CleoojpLytgTfIlZ7anS6QEAXXAuWGT3jddP4hcTnsfX40bQnIH1m49RX/4OHuMY
  31.104 +n7RyzSfyVghBQeA3fEQ48ep3WHuFHEn0Kn9rvcr/JZRO2NM4nBv1FjOIBTUMTlX+
  31.105 +hf0F/mYz1ycNg/rt6Taf9xcIP0IzRfQEa/dFqnEnBYCxGvRSr+EnMzg+ETT1p+aa
  31.106 +YAyjsbikhOqmle9G4LFUyblMmIlwFvAklAAlXTUJAEn3pc5mxH6vz0JitDpLdFDM
  31.107 +pW51y0HYgUNKS+9+qoVK2WXhkK/+hCbLzWVwzN5FlsIPucH+L+afquR6W5IKA8uZ
  31.108 +ixDPokbP1H608f/TobwX988nWby54kihoxaMvmEDbqT5Ivi5hHDhj5e79mxhUoZx
  31.109 +wb6fsm+d2vewDRhSIUF6/iioPaQt2AhmHNMBUYS5RrlOY8mc9BP8PwKym5SgkpE4
  31.110 +NKxoMjbQwUi3SHseA1hluMBieV+d7nYHqwBtSgMC/ax/AcDwmoLusXlf3OiBytdL
  31.111 +2v4OtPu6kt/QIlEABEDlqDK70wM6BChzWYrc5ErsixZ9NHunNshAjYsVeNtStOFV
  31.112 +TPGiy7a8rKB3xJhqzZhhLh9ly8JxVNfkb2LVXP/yzBS8LJpCluzyXZZpH2Q2a8lP
  31.113 +t71tjf/R/Uff2ZeF5yWO7zldyoEfx00yQWDyfmM6zHm17moXH5Mql2ZvTI0C0mk6
  31.114 +wDYNVEFe9YIXvxhdu5ym67ba8t5eV2t3c4zdhFy5YHZOC/KvpcZBLcvLY2jgVmNr
  31.115 +UYNqKpGK9m03jHRT2ZuG6F19QrxKqUIvgnYWsenecCvjjOIcWH7KqqNp+d4RyNRr
  31.116 +4VyoJk9nxzlUT/wKQJ6d5OtY5wytCCxpv8ihBFS3R2f0Sk2yXOgKE2sq0DEicWe+
  31.117 +x8Yqg3C/47hrtiUnEwwmp3VEYHfBTaaXMUkpmoRJ066u+8K2Jfo/pQnX6vcyUpvY
  31.118 +tJNqH+SMYKMXVBigU0ayWQFwVcoNEqFNVTm9K3MBQlIQiYqumBptG8rYhzF/eSUC
  31.119 +doDA15Ibgsk=
  31.120 +=P9h8
  31.121 +-----END PGP MESSAGE-----
  31.122 +
  31.123 +--xNhsqki3RTDSnTgiBbeAIkT3t5whv1bAM--
    32.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    32.2 +++ b/test/test_mails/pEp_unencrypted_pEp_subject.eml	Thu Jun 15 11:35:44 2017 +0200
    32.3 @@ -0,0 +1,73 @@
    32.4 +Return-Path: <pep.test.alice@pep-project.org>
    32.5 +X-Original-To: krista@gnunet.org
    32.6 +Delivered-To: krista@gnunet.org
    32.7 +Received: from vmmailrelay1.informatik.tu-muenchen.de (mailrelay1.informatik.tu-muenchen.de [131.159.254.14])
    32.8 +	by sam.net.in.tum.de (Postfix) with ESMTP id 39CD11C00BC
    32.9 +	for <krista@gnunet.org>; Mon, 12 Jun 2017 15:36:35 +0200 (CEST)
   32.10 +Received: by vmmailrelay1.informatik.tu-muenchen.de (Postfix, from userid 109)
   32.11 +	id 0CEA81C0390; Mon, 12 Jun 2017 15:36:36 +0200 (CEST)
   32.12 +Received: from vmmailrelay1.informatik.tu-muenchen.de (localhost [127.0.0.1])
   32.13 +	by vmmailrelay1.informatik.tu-muenchen.de (Postfix) with ESMTP id DE7711C0383
   32.14 +	for <krista@gnunet.org>; Mon, 12 Jun 2017 15:36:35 +0200 (CEST)
   32.15 +Received: from vmmaildmz1.informatik.tu-muenchen.de (vmmaildmz1.informatik.tu-muenchen.de [131.159.0.87])
   32.16 +	by vmmailrelay1.informatik.tu-muenchen.de (Postfix) with ESMTP id D3D7A1C037A
   32.17 +	for <krista@gnunet.org>; Mon, 12 Jun 2017 15:36:35 +0200 (CEST)
   32.18 +Received: by vmmaildmz1.informatik.tu-muenchen.de (Postfix, from userid 109)
   32.19 +	id D22771C2D9E; Mon, 12 Jun 2017 15:36:35 +0200 (CEST)
   32.20 +X-Spam-Checker-Version: SpamAssassin 3.4.0-tuminfo_1 (2014-02-07) on
   32.21 +	vmmaildmz1.informatik.tu-muenchen.de
   32.22 +X-Spam-Level: 
   32.23 +X-Spam-Status: No, score=-2.9 required=7.0 tests=AWL,BAYES_00,
   32.24 +	RCVD_IN_DNSWL_LOW,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,TVD_RCVD_SPACE_BRACKET,
   32.25 +	UNPARSEABLE_RELAY autolearn=no autolearn_force=no version=3.4.0-tuminfo_1
   32.26 +Received: from vmmaildmz1.informatik.tu-muenchen.de (localhost [127.0.0.1])
   32.27 +	by vmmaildmz1.informatik.tu-muenchen.de (Postfix) with ESMTP id 615241C2D9E
   32.28 +	for <krista@gnunet.org>; Mon, 12 Jun 2017 15:36:34 +0200 (CEST)
   32.29 +Received: from mi4-p00-ob.smtp.rzone.de (mi4-p00-ob.smtp.rzone.de [81.169.146.146])
   32.30 +	(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
   32.31 +	(No client certificate requested)
   32.32 +	by vmmaildmz1.informatik.tu-muenchen.de (Postfix) with ESMTPS id 50C3E1C2D9B
   32.33 +	for <krista@gnunet.org>; Mon, 12 Jun 2017 15:36:34 +0200 (CEST)
   32.34 +X-RZG-FWD-BY: pep.test.recip@kgrothoff.org
   32.35 +Received: from mailin.rzone.de ([unix socket])
   32.36 +	by mailin.rzone.de (RZmta 40.9) with LMTPA;
   32.37 +	Mon, 12 Jun 2017 15:36:18 +0200 (CEST)
   32.38 +Authentication-Results: strato.com 1;
   32.39 +	spf=none
   32.40 +		smtp.mailfrom="pep.test.alice@pep-project.org";
   32.41 +	dkim=none;
   32.42 +	domainkeys=none;
   32.43 +	dkim-adsp=none
   32.44 +		header.from="pep.test.alice@pep-project.org"
   32.45 +X-Strato-MessageType: email
   32.46 +X-RZG-CLASS-ID: mi00
   32.47 +Received-SPF: none
   32.48 +	client-ip=131.159.0.8;
   32.49 +	helo="mail-out1.informatik.tu-muenchen.de";
   32.50 +	envelope-from="pep.test.alice@pep-project.org";
   32.51 +	receiver=smtpin.rzone.de;
   32.52 +	identity=mailfrom;
   32.53 +Received: from mail-out1.informatik.tu-muenchen.de ([131.159.0.8])
   32.54 +	by smtpin.rzone.de (RZmta 40.9 OK)
   32.55 +	with ESMTPS id p044e9t5CDaIXCz
   32.56 +	(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (curve secp521r1 with 521 ECDH bits, eq. 15360 bits RSA))
   32.57 +	(Client did not present a certificate)
   32.58 +	for <pep.test.recip@kgrothoff.org>;
   32.59 +	Mon, 12 Jun 2017 15:36:18 +0200 (CEST)
   32.60 +Received: from [192.168.178.22] (ip5f584089.dynamic.kabel-deutschland.de [95.88.64.137])
   32.61 +	by services.sec.in.tum.de (Postfix) with ESMTPSA id D40EB1013AE4F
   32.62 +	for <pep.test.recip@kgrothoff.org>; Mon, 12 Jun 2017 15:36:12 +0200 (CEST)
   32.63 +To: pep.test.recip@kgrothoff.org
   32.64 +Reply-To: krista@pep-project.org
   32.65 +From: pEp Test Alice <pep.test.alice@pep-project.org>
   32.66 +Subject: pEp
   32.67 +Organization: pEp
   32.68 +Message-ID: <7b251ab6-f1c0-163b-0891-574d4eb095e1@pep-project.org>
   32.69 +Date: Mon, 12 Jun 2017 15:36:12 +0200
   32.70 +User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101
   32.71 + Thunderbird/45.8.0
   32.72 +MIME-Version: 1.0
   32.73 +Content-Type: text/plain; charset=utf-8
   32.74 +Content-Transfer-Encoding: 7bit
   32.75 +
   32.76 +Unencrypted variable where pEp is the actual subject.
    33.1 --- a/test/test_util.cc	Fri Jun 02 11:55:04 2017 +0200
    33.2 +++ b/test/test_util.cc	Thu Jun 15 11:35:44 2017 +0200
    33.3 @@ -1,4 +1,6 @@
    33.4  #include "pEpEngine_test.h"
    33.5 +#include "pEpEngine.h"
    33.6 +#include "message_api.h"
    33.7  #include <fstream>
    33.8  #include <sstream>
    33.9  #include <stdexcept>
   33.10 @@ -15,3 +17,237 @@
   33.11  	sstr << input.rdbuf();
   33.12  	return sstr.str();
   33.13  }
   33.14 +
   33.15 +const char* tl_status_string(PEP_STATUS status) {
   33.16 +    switch (status) {
   33.17 +        case PEP_STATUS_OK:
   33.18 +            return "PEP_STATUS_OK";
   33.19 +        case PEP_INIT_CANNOT_LOAD_GPGME:
   33.20 +            return "PEP_INIT_CANNOT_LOAD_GPGME";
   33.21 +        case PEP_INIT_GPGME_INIT_FAILED:
   33.22 +            return "PEP_INIT_GPGME_INIT_FAILED";
   33.23 +        case PEP_INIT_NO_GPG_HOME:
   33.24 +            return "PEP_INIT_NO_GPG_HOME";
   33.25 +        case PEP_INIT_NETPGP_INIT_FAILED:
   33.26 +            return "PEP_INIT_NETPGP_INIT_FAILED";
   33.27 +        case PEP_INIT_SQLITE3_WITHOUT_MUTEX:
   33.28 +            return "PEP_INIT_SQLITE3_WITHOUT_MUTEX";
   33.29 +        case PEP_INIT_CANNOT_OPEN_DB:
   33.30 +            return "PEP_INIT_CANNOT_OPEN_DB";
   33.31 +        case PEP_INIT_CANNOT_OPEN_SYSTEM_DB:
   33.32 +            return "PEP_INIT_CANNOT_OPEN_SYSTEM_DB";
   33.33 +        case PEP_KEY_NOT_FOUND:
   33.34 +            return "PEP_KEY_NOT_FOUND";
   33.35 +        case PEP_KEY_HAS_AMBIG_NAME:
   33.36 +            return "PEP_KEY_HAS_AMBIG_NAME";
   33.37 +        case PEP_GET_KEY_FAILED:
   33.38 +            return "PEP_GET_KEY_FAILED";
   33.39 +        case PEP_CANNOT_EXPORT_KEY:
   33.40 +            return "PEP_CANNOT_EXPORT_KEY";
   33.41 +        case PEP_CANNOT_EDIT_KEY:
   33.42 +            return "PEP_CANNOT_EDIT_KEY";
   33.43 +        case PEP_CANNOT_FIND_IDENTITY:
   33.44 +            return "PEP_CANNOT_FIND_IDENTITY";
   33.45 +        case PEP_CANNOT_SET_PERSON:
   33.46 +            return "PEP_CANNOT_SET_PERSON";
   33.47 +        case PEP_CANNOT_SET_PGP_KEYPAIR:
   33.48 +            return "PEP_CANNOT_SET_PGP_KEYPAIR";
   33.49 +        case PEP_CANNOT_SET_IDENTITY:
   33.50 +            return "PEP_CANNOT_SET_IDENTITY";
   33.51 +        case PEP_CANNOT_SET_TRUST:
   33.52 +            return "PEP_CANNOT_SET_TRUST";
   33.53 +        case PEP_KEY_BLACKLISTED:
   33.54 +            return "PEP_KEY_BLACKLISTED";
   33.55 +        case PEP_UNENCRYPTED:
   33.56 +            return "PEP_UNENCRYPTED";
   33.57 +        case PEP_VERIFIED:
   33.58 +            return "PEP_VERIFIED";
   33.59 +        case PEP_DECRYPTED:
   33.60 +            return "PEP_DECRYPTED";
   33.61 +        case PEP_DECRYPTED_AND_VERIFIED:
   33.62 +            return "PEP_DECRYPTED_AND_VERIFIED";
   33.63 +        case PEP_DECRYPT_WRONG_FORMAT:
   33.64 +            return "PEP_DECRYPT_WRONG_FORMAT";
   33.65 +        case PEP_DECRYPT_NO_KEY:
   33.66 +            return "PEP_DECRYPT_NO_KEY";
   33.67 +        case PEP_DECRYPT_SIGNATURE_DOES_NOT_MATCH:
   33.68 +            return "PEP_DECRYPT_SIGNATURE_DOES_NOT_MATCH";
   33.69 +        case PEP_VERIFY_NO_KEY:
   33.70 +            return "PEP_VERIFY_NO_KEY";
   33.71 +        case PEP_VERIFIED_AND_TRUSTED:
   33.72 +            return "PEP_VERIFIED_AND_TRUSTED";
   33.73 +        case PEP_CANNOT_DECRYPT_UNKNOWN:
   33.74 +            return "PEP_CANNOT_DECRYPT_UNKNOWN";
   33.75 +        case PEP_TRUSTWORD_NOT_FOUND:
   33.76 +            return "PEP_TRUSTWORD_NOT_FOUND";
   33.77 +        case PEP_TRUSTWORDS_FPR_WRONG_LENGTH:
   33.78 +            return "PEP_TRUSTWORDS_FPR_WRONG_LENGTH";
   33.79 +        case PEP_CANNOT_CREATE_KEY:
   33.80 +            return "PEP_CANNOT_CREATE_KEY";
   33.81 +        case PEP_CANNOT_SEND_KEY:
   33.82 +            return "PEP_CANNOT_SEND_KEY";
   33.83 +        case PEP_PHRASE_NOT_FOUND:
   33.84 +            return "PEP_PHRASE_NOT_FOUND";
   33.85 +        case PEP_SEND_FUNCTION_NOT_REGISTERED:
   33.86 +            return "PEP_SEND_FUNCTION_NOT_REGISTERED";
   33.87 +        case PEP_CONTRAINTS_VIOLATED:
   33.88 +            return "PEP_CONTRAINTS_VIOLATED";
   33.89 +        case PEP_CANNOT_ENCODE:
   33.90 +            return "PEP_CANNOT_ENCODE";
   33.91 +        case PEP_SYNC_NO_NOTIFY_CALLBACK:
   33.92 +            return "PEP_SYNC_NO_NOTIFY_CALLBACK";
   33.93 +        case PEP_SYNC_ILLEGAL_MESSAGE:
   33.94 +            return "PEP_SYNC_ILLEGAL_MESSAGE";
   33.95 +        case PEP_SYNC_NO_INJECT_CALLBACK:
   33.96 +            return "PEP_SYNC_NO_INJECT_CALLBACK";
   33.97 +        case PEP_SEQUENCE_VIOLATED:
   33.98 +            return "PEP_SEQUENCE_VIOLATED";
   33.99 +        case PEP_CANNOT_INCREASE_SEQUENCE:
  33.100 +            return "PEP_CANNOT_INCREASE_SEQUENCE";
  33.101 +        case PEP_CANNOT_SET_SEQUENCE_VALUE:
  33.102 +            return "PEP_CANNOT_SET_SEQUENCE_VALUE";
  33.103 +        case PEP_OWN_SEQUENCE:
  33.104 +            return "PEP_OWN_SEQUENCE";
  33.105 +        case PEP_SYNC_STATEMACHINE_ERROR:
  33.106 +            return "PEP_SYNC_STATEMACHINE_ERROR";
  33.107 +        case PEP_SYNC_NO_TRUST:
  33.108 +            return "PEP_SYNC_NO_TRUST";
  33.109 +        case PEP_STATEMACHINE_INVALID_STATE:
  33.110 +            return "PEP_STATEMACHINE_INVALID_STATE";
  33.111 +        case PEP_STATEMACHINE_INVALID_EVENT:
  33.112 +            return "PEP_STATEMACHINE_INVALID_EVENT";
  33.113 +        case PEP_STATEMACHINE_INVALID_CONDITION:
  33.114 +            return "PEP_STATEMACHINE_INVALID_CONDITION";
  33.115 +        case PEP_STATEMACHINE_INVALID_ACTION:
  33.116 +            return "PEP_STATEMACHINE_INVALID_ACTION";
  33.117 +        case PEP_STATEMACHINE_INHIBITED_EVENT:
  33.118 +            return "PEP_STATEMACHINE_INHIBITED_EVENT";
  33.119 +        case PEP_COMMIT_FAILED:
  33.120 +            return "PEP_COMMIT_FAILED";
  33.121 +        case PEP_MESSAGE_CONSUME:
  33.122 +            return "PEP_MESSAGE_CONSUME";
  33.123 +        case PEP_MESSAGE_IGNORE:
  33.124 +            return "PEP_MESSAGE_IGNORE";
  33.125 +        case PEP_RECORD_NOT_FOUND:
  33.126 +            return "PEP_RECORD_NOT_FOUND";
  33.127 +        case PEP_CANNOT_CREATE_TEMP_FILE:
  33.128 +            return "PEP_CANNOT_CREATE_TEMP_FILE";
  33.129 +        case PEP_ILLEGAL_VALUE:
  33.130 +            return "PEP_ILLEGAL_VALUE";
  33.131 +        case PEP_BUFFER_TOO_SMALL:
  33.132 +            return "PEP_BUFFER_TOO_SMALL";
  33.133 +        case PEP_OUT_OF_MEMORY:
  33.134 +            return "PEP_OUT_OF_MEMORY";
  33.135 +        case PEP_UNKNOWN_ERROR:
  33.136 +            return "PEP_UNKNOWN_ERROR";
  33.137 +        default:
  33.138 +            return "PEP_STATUS_OMGWTFBBQ - This means you're using a status the test lib doesn't know about!";
  33.139 +    }
  33.140 +}
  33.141 +const char* tl_rating_string(PEP_rating rating) {
  33.142 +    switch (rating) {
  33.143 +        case PEP_rating_undefined:
  33.144 +            return "PEP_rating_undefined";
  33.145 +        case PEP_rating_cannot_decrypt:
  33.146 +            return "PEP_rating_cannot_decrypt";
  33.147 +        case PEP_rating_have_no_key:
  33.148 +            return "PEP_rating_have_no_key";
  33.149 +        case PEP_rating_unencrypted:
  33.150 +            return "PEP_rating_unencrypted";
  33.151 +        case PEP_rating_unencrypted_for_some:
  33.152 +            return "PEP_rating_unencrypted_for_some";
  33.153 +        case PEP_rating_unreliable:
  33.154 +            return "PEP_rating_unreliable";
  33.155 +        case PEP_rating_reliable:
  33.156 +            return "PEP_rating_reliable";
  33.157 +        case PEP_rating_trusted:
  33.158 +            return "PEP_rating_trusted";
  33.159 +        case PEP_rating_trusted_and_anonymized:
  33.160 +            return "PEP_rating_trusted_and_anonymized";
  33.161 +        case PEP_rating_fully_anonymous:
  33.162 +            return "PEP_rating_fully_anonymous";
  33.163 +        case PEP_rating_mistrust:
  33.164 +            return "PEP_rating_mistrust";
  33.165 +        case PEP_rating_b0rken:
  33.166 +            return "PEP_rating_b0rken";
  33.167 +        case PEP_rating_under_attack:
  33.168 +            return "PEP_rating_under_attack";
  33.169 +        default:
  33.170 +            return "PEP_rating_OMGWTFBBQ - in other words, INVALID RATING VALUE!!!\n\nSomething bad is going on here, or a new rating value has been added to the enum and not the test function.";
  33.171 +    }
  33.172 +}
  33.173 +
  33.174 +const char* tl_ct_string(PEP_comm_type ct) {
  33.175 +    switch (ct) {
  33.176 +        case PEP_ct_unknown:
  33.177 +            return "PEP_ct_unknown";
  33.178 +        case PEP_ct_no_encryption:
  33.179 +            return "PEP_ct_no_encryption";
  33.180 +        case PEP_ct_no_encrypted_channel:
  33.181 +            return "PEP_ct_no_encrypted_channel";
  33.182 +        case PEP_ct_key_not_found:
  33.183 +            return "PEP_ct_key_not_found";
  33.184 +        case PEP_ct_key_expired:
  33.185 +            return "PEP_ct_key_expired";
  33.186 +        case PEP_ct_key_revoked:
  33.187 +            return "PEP_ct_key_revoked";
  33.188 +        case PEP_ct_key_b0rken:
  33.189 +            return "PEP_ct_key_b0rken";
  33.190 +        case PEP_ct_my_key_not_included:
  33.191 +            return "PEP_ct_my_key_not_included";
  33.192 +        case PEP_ct_security_by_obscurity:
  33.193 +            return "PEP_ct_security_by_obscurity";
  33.194 +        case PEP_ct_b0rken_crypto:
  33.195 +            return "PEP_ct_b0rken_crypto";
  33.196 +        case PEP_ct_key_too_short:
  33.197 +            return "PEP_ct_key_too_short";
  33.198 +        case PEP_ct_compromized:
  33.199 +            return "PEP_ct_compromized";
  33.200 +        case PEP_ct_mistrusted:
  33.201 +            return "PEP_ct_mistrusted";
  33.202 +        case PEP_ct_unconfirmed_encryption:
  33.203 +            return "PEP_ct_unconfirmed_encryption";
  33.204 +        case PEP_ct_OpenPGP_weak_unconfirmed:
  33.205 +            return "PEP_ct_OpenPGP_weak_unconfirmed";
  33.206 +        case PEP_ct_to_be_checked:
  33.207 +            return "PEP_ct_to_be_checked";
  33.208 +        case PEP_ct_SMIME_unconfirmed:
  33.209 +            return "PEP_ct_SMIME_unconfirmed";
  33.210 +        case PEP_ct_CMS_unconfirmed:
  33.211 +            return "PEP_ct_CMS_unconfirmed";
  33.212 +        case PEP_ct_strong_but_unconfirmed:
  33.213 +            return "PEP_ct_strong_but_unconfirmed";
  33.214 +        case PEP_ct_OpenPGP_unconfirmed:
  33.215 +            return "PEP_ct_OpenPGP_unconfirmed";
  33.216 +        case PEP_ct_OTR_unconfirmed:
  33.217 +            return "PEP_ct_OTR_unconfirmed";
  33.218 +        case PEP_ct_unconfirmed_enc_anon:
  33.219 +            return "PEP_ct_unconfirmed_enc_anon";
  33.220 +        case PEP_ct_pEp_unconfirmed:
  33.221 +            return "PEP_ct_pEp_unconfirmed";
  33.222 +        case PEP_ct_confirmed:
  33.223 +            return "PEP_ct_pEp_confirmed";
  33.224 +        case PEP_ct_confirmed_encryption:
  33.225 +            return "PEP_ct_confirmed_encryption";
  33.226 +        case PEP_ct_OpenPGP_weak:
  33.227 +            return "PEP_ct_OpenPGP_weak";
  33.228 +        case PEP_ct_to_be_checked_confirmed:
  33.229 +            return "PEP_ct_to_be_checked_confirmed";
  33.230 +        case PEP_ct_SMIME:
  33.231 +            return "PEP_ct_SMIME";
  33.232 +        case PEP_ct_CMS:
  33.233 +            return "PEP_ct_CMS";
  33.234 +        case PEP_ct_strong_encryption:
  33.235 +            return "PEP_ct_strong_encryption";
  33.236 +        case PEP_ct_OpenPGP:
  33.237 +            return "PEP_ct_OpenPGP";
  33.238 +        case PEP_ct_OTR:
  33.239 +            return "PEP_ct_OTR";
  33.240 +        case PEP_ct_confirmed_enc_anon:
  33.241 +            return "PEP_ct_confirmed_enc_anon";
  33.242 +        case PEP_ct_pEp:
  33.243 +            return "PEP_ct_pEp";
  33.244 +        default:
  33.245 +            return "PEP_ct_OMGWTFBBQ\n\nIn other words, comm type is invalid. Either something's corrupt or a new ct value has been added to the enum but not to the test function.";
  33.246 +    }
  33.247 +}
    34.1 --- a/test/test_util.h	Fri Jun 02 11:55:04 2017 +0200
    34.2 +++ b/test/test_util.h	Thu Jun 15 11:35:44 2017 +0200
    34.3 @@ -1,5 +1,16 @@
    34.4  #include <string>
    34.5 +#include "pEpEngine.h"
    34.6 +#include "message_api.h"
    34.7  
    34.8  // reads a whole file and returns it as std::string
    34.9  // throws std::runtime_error() if the file cannot be read. Empty file is not an error.
   34.10  std::string slurp(const std::string& filename);
   34.11 +
   34.12 +// Returns the string value of the input rating enum value. 
   34.13 +const char* tl_rating_string(PEP_rating rating);
   34.14 +
   34.15 +// Returns the string value of the input comm_type enum value. 
   34.16 +const char* tl_ct_string(PEP_comm_type ct);
   34.17 +
   34.18 +// Returns the string value of the input status enum value. 
   34.19 +const char* tl_status_string(PEP_STATUS status);