merged in default ENGINE-9
authorKrista Bennett <krista@pep-project.org>
Fri, 16 Jun 2017 15:34:34 +0200
branchENGINE-9
changeset 18704334908a5f9f
parent 1849 8b7bed853a1f
parent 1866 cc57e29989a4
child 1871 51337eb65533
merged in default
src/message_api.c
test/encrypt_for_identity_test.cc
     1.1 --- a/src/keymanagement.c	Mon Jun 12 09:30:39 2017 +0200
     1.2 +++ b/src/keymanagement.c	Fri Jun 16 15:34:34 2017 +0200
     1.3 @@ -91,7 +91,7 @@
     1.4      assert(!EMPTYSTR(identity->address));
     1.5  
     1.6      if (!(session && identity && !EMPTYSTR(identity->address)))
     1.7 -        return ERROR(PEP_ILLEGAL_VALUE);
     1.8 +        return ADD_TO_LOG(PEP_ILLEGAL_VALUE);
     1.9  
    1.10      if (identity->me || (identity->user_id && strcmp(identity->user_id, PEP_OWN_USERID) == 0)) {
    1.11          identity->me = true;
    1.12 @@ -326,7 +326,7 @@
    1.13      free_identity(stored_identity);
    1.14      free_identity(temp_id);
    1.15      
    1.16 -    return ERROR(status);
    1.17 +    return ADD_TO_LOG(status);
    1.18  }
    1.19  
    1.20  PEP_STATUS elect_ownkey(
    1.21 @@ -416,7 +416,7 @@
    1.22      
    1.23      *is_usable = !dont_use_fpr;
    1.24      
    1.25 -    return ERROR(status);
    1.26 +    return ADD_TO_LOG(status);
    1.27  }
    1.28  
    1.29  PEP_STATUS _myself(PEP_SESSION session, pEp_identity * identity, bool do_keygen, bool ignore_flags)
    1.30 @@ -434,7 +434,7 @@
    1.31      if (!(session && identity && !EMPTYSTR(identity->address) &&
    1.32              (EMPTYSTR(identity->user_id) ||
    1.33              strcmp(identity->user_id, PEP_OWN_USERID) == 0)))
    1.34 -        return ERROR(PEP_ILLEGAL_VALUE);
    1.35 +        return ADD_TO_LOG(PEP_ILLEGAL_VALUE);
    1.36  
    1.37      identity->comm_type = PEP_ct_pEp;
    1.38      identity->me = true;
    1.39 @@ -522,7 +522,7 @@
    1.40          status = elect_ownkey(session, identity);
    1.41          assert(status == PEP_STATUS_OK);
    1.42          if (status != PEP_STATUS_OK) {
    1.43 -            return ERROR(status);
    1.44 +            return ADD_TO_LOG(status);
    1.45          }
    1.46  
    1.47          bool has_private = false;
    1.48 @@ -554,7 +554,7 @@
    1.49  
    1.50          if (status != PEP_STATUS_OK) 
    1.51          {
    1.52 -            return ERROR(status);
    1.53 +            return ADD_TO_LOG(status);
    1.54          }
    1.55      }
    1.56     
    1.57 @@ -563,7 +563,7 @@
    1.58      if (EMPTYSTR(identity->fpr) || revoked)
    1.59      {
    1.60          if(!do_keygen){
    1.61 -            return ERROR(PEP_GET_KEY_FAILED);
    1.62 +            return ADD_TO_LOG(PEP_GET_KEY_FAILED);
    1.63          }
    1.64  
    1.65          if(revoked)
    1.66 @@ -581,7 +581,7 @@
    1.67              DEBUG_LOG("generating key pair failed", "debug", buf);
    1.68              if(revoked && r_fpr)
    1.69                  free(r_fpr);
    1.70 -            return ERROR(status);
    1.71 +            return ADD_TO_LOG(status);
    1.72          }
    1.73  
    1.74          new_key_generated = true;
    1.75 @@ -592,7 +592,7 @@
    1.76                                   identity->fpr, time(NULL));
    1.77              free(r_fpr);
    1.78              if (status != PEP_STATUS_OK) {
    1.79 -                return ERROR(status);
    1.80 +                return ADD_TO_LOG(status);
    1.81              }
    1.82          }
    1.83      }
    1.84 @@ -605,7 +605,7 @@
    1.85  
    1.86          assert(status == PEP_STATUS_OK);
    1.87          if (status != PEP_STATUS_OK) {
    1.88 -            return ERROR(status);
    1.89 +            return ADD_TO_LOG(status);
    1.90          }
    1.91  
    1.92          if (status == PEP_STATUS_OK && expired) {
    1.93 @@ -633,12 +633,12 @@
    1.94          }
    1.95      }
    1.96  
    1.97 -    return ERROR(PEP_STATUS_OK);
    1.98 +    return ADD_TO_LOG(PEP_STATUS_OK);
    1.99  }
   1.100  
   1.101  DYNAMIC_API PEP_STATUS myself(PEP_SESSION session, pEp_identity * identity)
   1.102  {
   1.103 -    return ERROR(_myself(session, identity, true, false));
   1.104 +    return ADD_TO_LOG(_myself(session, identity, true, false));
   1.105  }
   1.106  
   1.107  DYNAMIC_API PEP_STATUS register_examine_function(
     2.1 --- a/src/keymanagement.h	Mon Jun 12 09:30:39 2017 +0200
     2.2 +++ b/src/keymanagement.h	Fri Jun 16 15:34:34 2017 +0200
     2.3 @@ -15,6 +15,11 @@
     2.4  //      session (in)        session to use
     2.5  //      identity (inout)    identity information of communication partner
     2.6  //                          (identity->fpr is OUT ONLY)
     2.7 +//  return value:
     2.8 +//      PEP_STATUS_OK if identity could be updated,
     2.9 +//      PEP_GET_KEY_FAILED for own identity that must be completed (myself())
    2.10 +//      any other value on error
    2.11 +//
    2.12  //  caveat:
    2.13  //      if this function returns PEP_ct_unknown or PEP_ct_key_expired in
    2.14  //      identity->comm_type, the caller must insert the identity into the
     3.1 --- a/src/message_api.c	Mon Jun 12 09:30:39 2017 +0200
     3.2 +++ b/src/message_api.c	Fri Jun 16 15:34:34 2017 +0200
     3.3 @@ -169,19 +169,22 @@
     3.4                      goto enomem;
     3.5              }
     3.6          }
     3.7 +        *shortmsg = _shortmsg;
     3.8      }
     3.9      else {
    3.10 -        _shortmsg = strdup("");
    3.11 -        assert(_shortmsg);
    3.12 -        if (_shortmsg == NULL)
    3.13 -            goto enomem;
    3.14 +        // If there's no "Subject: " and the shortmsg is
    3.15 +        // pEp (or anything else), then we shouldn't be replacing it.
    3.16 +        // Chances are that the message wasn't encrypted
    3.17 +        // using pEp and that the actually subject IS pEp. In any event,
    3.18 +        // erasing the subject line when we don't have one in the plaintext
    3.19 +        // isn't the right behaviour.
    3.20 +        // _shortmsg = strdup("");
    3.21          _longmsg = strdup(src);
    3.22          assert(_longmsg);
    3.23          if (_longmsg == NULL)
    3.24              goto enomem;
    3.25      }
    3.26 -
    3.27 -    *shortmsg = _shortmsg;
    3.28 +    
    3.29      *longmsg = _longmsg;
    3.30  
    3.31      return 0;
    3.32 @@ -994,8 +997,13 @@
    3.33          if (bl && bl->value && bl->size && bl->size < MAX_KEY_SIZE
    3.34                  && is_key(bl))
    3.35          {
    3.36 -            import_key(session, bl->value, bl->size, private_idents);
    3.37 +            identity_list *local_private_idents = NULL;
    3.38 +            import_key(session, bl->value, bl->size, &local_private_idents);
    3.39              remove = true;
    3.40 +            if (private_idents && *private_idents == NULL && local_private_idents != NULL)
    3.41 +                *private_idents = local_private_idents;
    3.42 +            else
    3.43 +                free_identity_list(local_private_idents);
    3.44          }
    3.45      }
    3.46      return remove;
    3.47 @@ -1103,14 +1111,14 @@
    3.48      assert(enc_format != PEP_enc_none);
    3.49  
    3.50      if (!(session && src && dst && enc_format != PEP_enc_none))
    3.51 -        return ERROR(PEP_ILLEGAL_VALUE);
    3.52 +        return ADD_TO_LOG(PEP_ILLEGAL_VALUE);
    3.53  
    3.54      if (src->dir == PEP_dir_incoming)
    3.55 -        return ERROR(PEP_ILLEGAL_VALUE);
    3.56 +        return ADD_TO_LOG(PEP_ILLEGAL_VALUE);
    3.57  
    3.58      determine_encryption_format(src);
    3.59      if (src->enc_format != PEP_enc_none)
    3.60 -        return ERROR(PEP_ILLEGAL_VALUE);
    3.61 +        return ADD_TO_LOG(PEP_ILLEGAL_VALUE);
    3.62  
    3.63      *dst = NULL;
    3.64  
    3.65 @@ -1217,7 +1225,7 @@
    3.66          free_stringlist(keys);
    3.67          if (!session->passive_mode && !(flags & PEP_encrypt_flag_force_no_attached_key))
    3.68              attach_own_key(session, src);
    3.69 -        return ERROR(PEP_UNENCRYPTED);
    3.70 +        return ADD_TO_LOG(PEP_UNENCRYPTED);
    3.71      }
    3.72      else {
    3.73          msg = clone_to_empty_message(src);
    3.74 @@ -1274,7 +1282,7 @@
    3.75      }
    3.76  
    3.77      *dst = msg;
    3.78 -    return ERROR(status);
    3.79 +    return ADD_TO_LOG(status);
    3.80  
    3.81  enomem:
    3.82      status = PEP_OUT_OF_MEMORY;
    3.83 @@ -1283,7 +1291,7 @@
    3.84      free_stringlist(keys);
    3.85      free_message(msg);
    3.86  
    3.87 -    return ERROR(status);
    3.88 +    return ADD_TO_LOG(status);
    3.89  }
    3.90  
    3.91  DYNAMIC_API PEP_STATUS encrypt_message_for_self(
    3.92 @@ -1305,14 +1313,14 @@
    3.93      assert(enc_format != PEP_enc_none);
    3.94  
    3.95      if (!(session && src && dst && enc_format != PEP_enc_none))
    3.96 -        return ERROR(PEP_ILLEGAL_VALUE);
    3.97 +        return ADD_TO_LOG(PEP_ILLEGAL_VALUE);
    3.98  
    3.99      if (src->dir == PEP_dir_incoming)
   3.100 -        return ERROR(PEP_ILLEGAL_VALUE);
   3.101 +        return ADD_TO_LOG(PEP_ILLEGAL_VALUE);
   3.102  
   3.103      determine_encryption_format(src);
   3.104      if (src->enc_format != PEP_enc_none)
   3.105 -        return ERROR(PEP_ILLEGAL_VALUE);
   3.106 +        return ADD_TO_LOG(PEP_ILLEGAL_VALUE);
   3.107  
   3.108      status = myself(session, target_id);
   3.109      if (status != PEP_STATUS_OK)
   3.110 @@ -1393,7 +1401,7 @@
   3.111      free_stringlist(keys);
   3.112      free_message(msg);
   3.113  
   3.114 -    return ERROR(status);
   3.115 +    return ADD_TO_LOG(status);
   3.116  }
   3.117  
   3.118  static bool is_a_pEpmessage(const message *msg)
   3.119 @@ -1668,7 +1676,7 @@
   3.120      assert(flags);
   3.121  
   3.122      if (!(session && src && dst && keylist && rating && flags))
   3.123 -        return ERROR(PEP_ILLEGAL_VALUE);
   3.124 +        return ADD_TO_LOG(PEP_ILLEGAL_VALUE);
   3.125  
   3.126      *flags = 0;
   3.127  
   3.128 @@ -1679,7 +1687,7 @@
   3.129      // we would need to check signature
   3.130      status = _update_identity_for_incoming_message(session, src);
   3.131      if(status != PEP_STATUS_OK)
   3.132 -        return ERROR(status);
   3.133 +        return ADD_TO_LOG(status);
   3.134  
   3.135      // Get detached signature, if any
   3.136      bloblist_t* detached_sig = NULL;
   3.137 @@ -1713,7 +1721,7 @@
   3.138                                  PEP_decrypt_flag_consume;
   3.139                  }
   3.140                  else if (status != PEP_STATUS_OK) {
   3.141 -                    return ERROR(status);
   3.142 +                    return ADD_TO_LOG(status);
   3.143                  }
   3.144              }
   3.145              
   3.146 @@ -1745,7 +1753,7 @@
   3.147                  }
   3.148              }
   3.149              
   3.150 -            return ERROR(PEP_UNENCRYPTED);
   3.151 +            return ADD_TO_LOG(PEP_UNENCRYPTED);
   3.152  
   3.153          case PEP_enc_PGP_MIME:
   3.154              ctext = src->attachments->next->value;
   3.155 @@ -1959,9 +1967,24 @@
   3.156  
   3.157                      int r = separate_short_and_long(msg->longmsg, &shortmsg,
   3.158                              &longmsg);
   3.159 +                    
   3.160                      if (r == -1)
   3.161                          goto enomem;
   3.162  
   3.163 +                    if (shortmsg == NULL) {
   3.164 +                        if (src->shortmsg == NULL)
   3.165 +                            shortmsg = strdup("");
   3.166 +                        else {
   3.167 +                            // FIXME: is msg->shortmsg always a copy of
   3.168 +                            // src->shortmsg already?
   3.169 +                            // if so, we need to change the logic so
   3.170 +                            // that in this case, we don't free msg->shortmsg
   3.171 +                            // and do this strdup, etc.
   3.172 +                            shortmsg = strdup(src->shortmsg);
   3.173 +                        }
   3.174 +                    }
   3.175 +
   3.176 +
   3.177                      free(msg->shortmsg);
   3.178                      free(msg->longmsg);
   3.179  
   3.180 @@ -2075,7 +2098,6 @@
   3.181                              PEP_decrypt_flag_ignore :
   3.182                              PEP_decrypt_flag_consume;
   3.183  
   3.184 -                status = decrypt_status;
   3.185              }
   3.186              else if (status != PEP_STATUS_OK){
   3.187                  goto pep_error;
   3.188 @@ -2094,7 +2116,10 @@
   3.189      *dst = msg;
   3.190      *keylist = _keylist;
   3.191  
   3.192 -    return PEP_STATUS_OK;
   3.193 +    if(decrypt_status == PEP_DECRYPTED_AND_VERIFIED)
   3.194 +        return ADD_TO_LOG(PEP_STATUS_OK);
   3.195 +    else
   3.196 +        return ADD_TO_LOG(decrypt_status);
   3.197  
   3.198  enomem:
   3.199      status = PEP_OUT_OF_MEMORY;
   3.200 @@ -2104,7 +2129,7 @@
   3.201      free_message(msg);
   3.202      free_stringlist(_keylist);
   3.203  
   3.204 -    return ERROR(status);
   3.205 +    return ADD_TO_LOG(status);
   3.206  }
   3.207  
   3.208  DYNAMIC_API PEP_STATUS decrypt_message(
   3.209 @@ -2153,7 +2178,7 @@
   3.210  
   3.211      free_identity_list(private_il);
   3.212  
   3.213 -    return ERROR(status);
   3.214 +    return ADD_TO_LOG(status);
   3.215  }
   3.216  
   3.217  static void _max_comm_type_from_identity_list(
   3.218 @@ -2194,10 +2219,10 @@
   3.219      assert(rating);
   3.220  
   3.221      if (!(session && msg && rating))
   3.222 -        return ERROR(PEP_ILLEGAL_VALUE);
   3.223 +        return ADD_TO_LOG(PEP_ILLEGAL_VALUE);
   3.224  
   3.225      if (msg->dir != PEP_dir_outgoing)
   3.226 -        return ERROR(PEP_ILLEGAL_VALUE);
   3.227 +        return ADD_TO_LOG(PEP_ILLEGAL_VALUE);
   3.228  
   3.229      *rating = PEP_rating_undefined;
   3.230  
   3.231 @@ -2284,6 +2309,74 @@
   3.232      return PEP_color_no_color;
   3.233  }
   3.234  
   3.235 +/* [0-9]: 0x30 - 0x39; [A-F] = 0x41 - 0x46; [a-f] = 0x61 - 0x66 */
   3.236 +static short asciihex_to_num(char a) {
   3.237 +    short conv_num = -1;
   3.238 +    if (a >= 0x30 && a <= 0x39)
   3.239 +        conv_num = a - 0x30;
   3.240 +    else {
   3.241 +        // convert case, subtract offset, get number
   3.242 +        conv_num = ((a | 0x20) - 0x61) + 10;
   3.243 +        if (conv_num < 0xa || conv_num > 0xf)
   3.244 +            conv_num = -1;
   3.245 +    }
   3.246 +    return conv_num;
   3.247 +}
   3.248 +
   3.249 +static char num_to_asciihex(short h) {
   3.250 +    if (h < 0 || h > 16)
   3.251 +        return '\0';
   3.252 +    if (h < 10)
   3.253 +        return (char)(h + 0x30);
   3.254 +    return (char)((h - 10) + 0x41); // for readability
   3.255 +}
   3.256 +
   3.257 +static char xor_hex_chars(char a, char b) {
   3.258 +    short a_num = asciihex_to_num(a);
   3.259 +    short b_num = asciihex_to_num(b);
   3.260 +    if (a_num < 0 || b_num < 0)
   3.261 +        return '\0';
   3.262 +    short xor_num = a_num^b_num;
   3.263 +    return num_to_asciihex(xor_num);
   3.264 +}
   3.265 +
   3.266 +static char* skip_separators(char* current, char* begin) {
   3.267 +    while (current >= begin) {
   3.268 +        /* .:,;-_ ' ' - [2c-2e] [3a-3b] [20] [5f] */
   3.269 +        char check_char = *current;
   3.270 +        switch (check_char) {
   3.271 +            case '.':
   3.272 +            case ':':
   3.273 +            case ',':
   3.274 +            case ';':
   3.275 +            case '-':
   3.276 +            case '_':
   3.277 +            case ' ':
   3.278 +                current--;
   3.279 +                continue;
   3.280 +            default:
   3.281 +                break;
   3.282 +        }
   3.283 +        break;
   3.284 +    }
   3.285 +    return current;
   3.286 +}
   3.287 +
   3.288 +PEP_STATUS check_for_zero_fpr(char* fpr) {
   3.289 +    PEP_STATUS status = PEP_TRUSTWORDS_DUPLICATE_FPR;
   3.290 +    
   3.291 +    while (*fpr) {
   3.292 +        if (*fpr != '0') {
   3.293 +            status = PEP_STATUS_OK;
   3.294 +            break;
   3.295 +        }
   3.296 +        fpr++;    
   3.297 +    }
   3.298 +    
   3.299 +    return status;
   3.300 +    
   3.301 +}
   3.302 +
   3.303  DYNAMIC_API PEP_STATUS get_trustwords(
   3.304      PEP_SESSION session, const pEp_identity* id1, const pEp_identity* id2,
   3.305      const char* lang, char **words, size_t *wsize, bool full
   3.306 @@ -2297,96 +2390,114 @@
   3.307      assert(words);
   3.308      assert(wsize);
   3.309  
   3.310 +    int SHORT_NUM_TWORDS = 5; 
   3.311 +    
   3.312 +    PEP_STATUS status = PEP_STATUS_OK;
   3.313 +    
   3.314      if (!(session && id1 && id2 && words && wsize) ||
   3.315          !(id1->fpr) || (!id2->fpr))
   3.316          return PEP_ILLEGAL_VALUE;
   3.317  
   3.318 -    const char *source1 = id1->fpr;
   3.319 -    const char *source2 = id2->fpr;
   3.320 -
   3.321 -    *words = NULL;
   3.322 +    char *source1 = id1->fpr;
   3.323 +    char *source2 = id2->fpr;
   3.324 +
   3.325 +    int source1_len = strlen(source1);
   3.326 +    int source2_len = strlen(source2);
   3.327 +    int max_len;
   3.328 +        
   3.329 +    *words = NULL;    
   3.330      *wsize = 0;
   3.331  
   3.332 -    const size_t SHORT_NUM_TWORDS = 5;
   3.333 -
   3.334 -    // N.B. THIS will have to be changed once we start checking trustword entropy.
   3.335 -    // For now, full is ALL, and otherwise it's 5-per-id.
   3.336 -    size_t max_words_per_id = (full ? 0 : SHORT_NUM_TWORDS);
   3.337 -
   3.338 -    char* first_set = NULL;
   3.339 -    char* second_set = NULL;
   3.340 -    size_t first_wsize = 0;
   3.341 -    size_t second_wsize = 0;
   3.342 -
   3.343 -    int fpr_comparison = -255;
   3.344 -    PEP_STATUS status = _compare_fprs(source1, strlen(source1), source2, strlen(source2), &fpr_comparison);
   3.345 -    if (status != PEP_STATUS_OK)
   3.346 -        return status;
   3.347 -
   3.348 -    char* _retstr = NULL;
   3.349 -
   3.350 -    switch (fpr_comparison) {
   3.351 -        case 1: // source1 > source2
   3.352 -            status = trustwords(session, source2, lang, &first_set, &first_wsize, max_words_per_id);
   3.353 -            if (status != PEP_STATUS_OK)
   3.354 -                goto error_release;
   3.355 -            status = trustwords(session, source1, lang, &second_set, &second_wsize, max_words_per_id);
   3.356 -            if (status != PEP_STATUS_OK)
   3.357 -                goto error_release;
   3.358 +    max_len = (source1_len > source2_len ? source1_len : source2_len);
   3.359 +    
   3.360 +    char* XORed_fpr = (char*)(calloc(1,max_len + 1));
   3.361 +    *(XORed_fpr + max_len) = '\0';
   3.362 +    char* result_curr = XORed_fpr + max_len - 1;
   3.363 +    char* source1_curr = source1 + source1_len - 1;
   3.364 +    char* source2_curr = source2 + source2_len - 1;
   3.365 +
   3.366 +    while (source1 <= source1_curr && source2 <= source2_curr) {
   3.367 +        source1_curr = skip_separators(source1_curr, source1);
   3.368 +        source2_curr = skip_separators(source2_curr, source2);
   3.369 +        
   3.370 +        if (source1_curr < source1 || source2_curr < source2)
   3.371              break;
   3.372 -        case 0:
   3.373 -        case -1: // source1 <= source2
   3.374 -            status = trustwords(session, source1, lang, &first_set, &first_wsize, max_words_per_id);
   3.375 -            if (status != PEP_STATUS_OK)
   3.376 -                goto error_release;
   3.377 -            status = trustwords(session, source2, lang, &second_set, &second_wsize, max_words_per_id);
   3.378 -            if (status != PEP_STATUS_OK)
   3.379 -                goto error_release;
   3.380 -            break;
   3.381 -        default:
   3.382 -            return ERROR(PEP_UNKNOWN_ERROR); // shouldn't be possible
   3.383 -    }
   3.384 -
   3.385 -    size_t _wsize = first_wsize + second_wsize;
   3.386 -
   3.387 -    bool needs_space = (first_set[first_wsize - 1] != ' ');
   3.388 -
   3.389 -    if (needs_space)
   3.390 -        _wsize++;
   3.391 -
   3.392 -    _retstr = calloc(1, _wsize + 1);
   3.393 -
   3.394 -    size_t len = strlcpy(_retstr, first_set, _wsize);
   3.395 -    if (len >= _wsize) {
   3.396 -        status = PEP_UNKNOWN_ERROR;
   3.397 -        goto error_release;
   3.398 -    }
   3.399 -    if (needs_space) {
   3.400 -        strlcat(_retstr, " ", _wsize);
   3.401 -        if (len >= _wsize) {
   3.402 -            status = PEP_UNKNOWN_ERROR;
   3.403 +            
   3.404 +        char xor_hex = xor_hex_chars(*source1_curr, *source2_curr);
   3.405 +        if (xor_hex == '\0') {
   3.406 +            status = PEP_ILLEGAL_VALUE;
   3.407              goto error_release;
   3.408          }
   3.409 +        
   3.410 +        *result_curr = xor_hex;
   3.411 +        result_curr--; source1_curr--; source2_curr--;
   3.412      }
   3.413 -    strlcat(_retstr, second_set, _wsize);
   3.414 -    if (len >= _wsize){
   3.415 -        status = PEP_UNKNOWN_ERROR;
   3.416 +
   3.417 +    char* remainder_start = NULL;
   3.418 +    char* remainder_curr = NULL;
   3.419 +    
   3.420 +    if (source1 <= source1_curr) {
   3.421 +        remainder_start = source1;
   3.422 +        remainder_curr = source1_curr;
   3.423 +    }
   3.424 +    else if (source2 <= source2_curr) {
   3.425 +        remainder_start = source2;
   3.426 +        remainder_curr = source2_curr;
   3.427 +    }
   3.428 +    if (remainder_curr) {
   3.429 +        while (remainder_start <= remainder_curr) {
   3.430 +            remainder_curr = skip_separators(remainder_curr, remainder_start);
   3.431 +            
   3.432 +            if (remainder_curr < remainder_start)
   3.433 +                break;
   3.434 +            
   3.435 +            char the_char = *remainder_curr;
   3.436 +            
   3.437 +            if (asciihex_to_num(the_char) < 0) {
   3.438 +                status = PEP_ILLEGAL_VALUE;
   3.439 +                goto error_release;
   3.440 +            }
   3.441 +            
   3.442 +            *result_curr = the_char;                
   3.443 +            result_curr--;
   3.444 +            remainder_curr--;
   3.445 +        }
   3.446 +    }
   3.447 +    
   3.448 +    result_curr++;
   3.449 +
   3.450 +    if (result_curr > XORed_fpr) {
   3.451 +        char* tempstr = strdup(result_curr);
   3.452 +        free(XORed_fpr);
   3.453 +        XORed_fpr = tempstr;
   3.454 +    }
   3.455 +    
   3.456 +    status = check_for_zero_fpr(XORed_fpr);
   3.457 +    
   3.458 +    if (status != PEP_STATUS_OK)
   3.459          goto error_release;
   3.460 -    }
   3.461 -
   3.462 -    *words = _retstr;
   3.463 -    *wsize = _wsize;
   3.464 +    
   3.465 +    size_t max_words_per_id = (full ? 0 : SHORT_NUM_TWORDS);
   3.466 +
   3.467 +    char* the_words = NULL;
   3.468 +    size_t the_size = 0;
   3.469 +
   3.470 +    status = trustwords(session, XORed_fpr, lang, &the_words, &the_size, max_words_per_id);
   3.471 +    if (status != PEP_STATUS_OK)
   3.472 +        goto error_release;
   3.473 +
   3.474 +    *words = the_words;
   3.475 +    *wsize = the_size;
   3.476 +    
   3.477      status = PEP_STATUS_OK;
   3.478  
   3.479      goto the_end;
   3.480  
   3.481      error_release:
   3.482 -    free(_retstr);
   3.483 -
   3.484 +        free (XORed_fpr);
   3.485 +        
   3.486      the_end:
   3.487 -    free(first_set);
   3.488 -    free(second_set);
   3.489 -    return ERROR(status);
   3.490 +    return ADD_TO_LOG(status);
   3.491  }
   3.492  
   3.493  DYNAMIC_API PEP_STATUS get_message_trustwords(
   3.494 @@ -2472,7 +2583,7 @@
   3.495  
   3.496      if (status != PEP_STATUS_OK) {
   3.497          free_identity(partner);
   3.498 -        return ERROR(status);
   3.499 +        return ADD_TO_LOG(status);
   3.500      }
   3.501     
   3.502      // Find own identity corresponding to given account address.
   3.503 @@ -2485,7 +2596,7 @@
   3.504  
   3.505      if (status != PEP_STATUS_OK) {
   3.506          free_identity(stored_identity);
   3.507 -        return ERROR(status);
   3.508 +        return ADD_TO_LOG(status);
   3.509      }
   3.510  
   3.511      // get the trustwords
   3.512 @@ -2494,7 +2605,7 @@
   3.513                              partner, received_by, 
   3.514                              lang, words, &wsize, full);
   3.515  
   3.516 -    return ERROR(status);
   3.517 +    return ADD_TO_LOG(status);
   3.518  }
   3.519  
   3.520  DYNAMIC_API PEP_STATUS MIME_decrypt_message(
   3.521 @@ -2545,14 +2656,14 @@
   3.522      {
   3.523          free(tmp_msg);
   3.524          free(dec_msg);
   3.525 -        return ERROR(decrypt_status);
   3.526 +        return ADD_TO_LOG(decrypt_status);
   3.527      }
   3.528      
   3.529  pep_error:
   3.530      free_message(tmp_msg);
   3.531      free_message(dec_msg);
   3.532  
   3.533 -    return ERROR(status);
   3.534 +    return ADD_TO_LOG(status);
   3.535  }
   3.536  
   3.537  
   3.538 @@ -2597,7 +2708,7 @@
   3.539      free_message(tmp_msg);
   3.540      free_message(enc_msg);
   3.541  
   3.542 -    return ERROR(status);
   3.543 +    return ADD_TO_LOG(status);
   3.544  
   3.545  }
   3.546  
   3.547 @@ -2641,7 +2752,7 @@
   3.548      free_message(tmp_msg);
   3.549      free_message(enc_msg);
   3.550  
   3.551 -    return ERROR(status);
   3.552 +    return ADD_TO_LOG(status);
   3.553  }
   3.554  
   3.555  static PEP_rating string_to_rating(const char * rating)
   3.556 @@ -2734,7 +2845,7 @@
   3.557      assert(rating);
   3.558  
   3.559      if (!(session && msg && rating))
   3.560 -        return ERROR(PEP_ILLEGAL_VALUE);
   3.561 +        return ADD_TO_LOG(PEP_ILLEGAL_VALUE);
   3.562  
   3.563      *rating = PEP_rating_undefined;
   3.564  
   3.565 @@ -2745,7 +2856,7 @@
   3.566                  goto got_rating;
   3.567              }
   3.568          }
   3.569 -        return ERROR(PEP_ILLEGAL_VALUE);
   3.570 +        return ADD_TO_LOG(PEP_ILLEGAL_VALUE);
   3.571      }
   3.572  
   3.573  got_rating:
   3.574 @@ -2762,7 +2873,7 @@
   3.575                  goto got_keylist;
   3.576              }
   3.577          }
   3.578 -        return ERROR(PEP_ILLEGAL_VALUE);
   3.579 +        return ADD_TO_LOG(PEP_ILLEGAL_VALUE);
   3.580      }
   3.581  got_keylist:
   3.582  
   3.583 @@ -2781,5 +2892,5 @@
   3.584      if (must_free_keylist)
   3.585          free_stringlist(_keylist);
   3.586  
   3.587 -    return ERROR(status);
   3.588 +    return ADD_TO_LOG(status);
   3.589  }
     4.1 --- a/src/message_api.h	Mon Jun 12 09:30:39 2017 +0200
     4.2 +++ b/src/message_api.h	Fri Jun 16 15:34:34 2017 +0200
     4.3 @@ -47,11 +47,14 @@
     4.4  //
     4.5  //  return value:
     4.6  //      PEP_STATUS_OK                   on success
     4.7 -//		PEP_KEY_NOT_FOUND	            at least one of the receipient keys
     4.8 -//		                                could not be found
     4.9 -//		PEP_KEY_HAS_AMBIG_NAME          at least one of the receipient keys has
    4.10 -//		                                an ambiguous name
    4.11 -//		PEP_GET_KEY_FAILED		        cannot retrieve key
    4.12 +//      PEP_KEY_NOT_FOUND	            at least one of the receipient keys
    4.13 +//                                      could not be found
    4.14 +//      PEP_KEY_HAS_AMBIG_NAME          at least one of the receipient keys has
    4.15 +//                                      an ambiguous name
    4.16 +//      PEP_GET_KEY_FAILED		        cannot retrieve key
    4.17 +//      PEP_UNENCRYPTED                 no recipients with usable key, 
    4.18 +//                                      message is left unencrypted,
    4.19 +//                                      and key is attached to it
    4.20  //
    4.21  //	caveat:
    4.22  //	    the ownershop of src remains with the caller
    4.23 @@ -224,7 +227,9 @@
    4.24  //      flags (out)         flags to signal special decryption features
    4.25  //
    4.26  //  return value:
    4.27 -//      error status or PEP_STATUS_OK on success
    4.28 +//      error status 
    4.29 +//      or PEP_DECRYPTED if message decrypted but not verified
    4.30 +//      or PEP_STATUS_OK on success
    4.31  //
    4.32  //	caveat:
    4.33  //	    the ownership of src remains with the caller
     5.1 --- a/src/pEpEngine.c	Mon Jun 12 09:30:39 2017 +0200
     5.2 +++ b/src/pEpEngine.c	Fri Jun 16 15:34:34 2017 +0200
     5.3 @@ -886,7 +886,7 @@
     5.4      } while (result == SQLITE_BUSY);
     5.5      sqlite3_reset(session->log);
     5.6  
     5.7 -    return ERROR(status);
     5.8 +    return ADD_TO_LOG(status);
     5.9  }
    5.10  
    5.11  DYNAMIC_API PEP_STATUS log_service(
    5.12 @@ -1988,7 +1988,7 @@
    5.13      status = PEP_OUT_OF_MEMORY;
    5.14  
    5.15  the_end:
    5.16 -    return ERROR(status);
    5.17 +    return ADD_TO_LOG(status);
    5.18  }
    5.19  
    5.20  DYNAMIC_API PEP_STATUS get_languagelist(
     6.1 --- a/src/pEpEngine.h	Mon Jun 12 09:30:39 2017 +0200
     6.2 +++ b/src/pEpEngine.h	Fri Jun 16 15:34:34 2017 +0200
     6.3 @@ -68,6 +68,7 @@
     6.4  
     6.5      PEP_TRUSTWORD_NOT_FOUND                         = 0x0501,
     6.6      PEP_TRUSTWORDS_FPR_WRONG_LENGTH                 = 0x0502,
     6.7 +    PEP_TRUSTWORDS_DUPLICATE_FPR                    = 0x0503,
     6.8  
     6.9      PEP_CANNOT_CREATE_KEY                           = 0x0601,
    6.10      PEP_CANNOT_SEND_KEY                             = 0x0602,
     7.1 --- a/src/pEp_internal.h	Mon Jun 12 09:30:39 2017 +0200
     7.2 +++ b/src/pEp_internal.h	Fri Jun 16 15:34:34 2017 +0200
     7.3 @@ -316,9 +316,9 @@
     7.4  
     7.5  #ifdef DEBUG_ERRORSTACK
     7.6      PEP_STATUS session_add_error(PEP_SESSION session, const char* file, unsigned line, PEP_STATUS status);
     7.7 -    #define ERROR(status)   session_add_error(session, __FILE__, __LINE__, (status))
     7.8 -    #define GOTO(label)     do{ (void)session_add_error(session, __FILE__, __LINE__, status); goto label; }while(0)
     7.9 +    #define ADD_TO_LOG(status)   session_add_error(session, __FILE__, __LINE__, (status))
    7.10 +    #define GOTO(label)          do{ (void)session_add_error(session, __FILE__, __LINE__, status); goto label; }while(0)
    7.11  #else
    7.12 -    #define ERROR(status)   (status)
    7.13 -    #define GOTO(label)     goto label
    7.14 +    #define ADD_TO_LOG(status)   (status)
    7.15 +    #define GOTO(label)          goto label
    7.16  #endif
     8.1 --- a/test/Makefile	Mon Jun 12 09:30:39 2017 +0200
     8.2 +++ b/test/Makefile	Fri Jun 16 15:34:34 2017 +0200
     8.3 @@ -41,8 +41,10 @@
     8.4  
     8.5  ifeq ($(shell uname), Darwin)
     8.6      LIBPATH = DYLD_LIBRARY_PATH
     8.7 +    LLDB_BIN = /Applications/Xcode.app/Contents/Developer/usr/bin/lldb
     8.8  else
     8.9      LIBPATH = LD_LIBRARY_PATH
    8.10 +    LLDB_BIN = lldb
    8.11  endif
    8.12  
    8.13  TEST_CMD_PFX = $(LIBPATH)=$(HOME)/lib:../src HOME=$(TEST_HOME)
    8.14 @@ -69,7 +71,7 @@
    8.15  	$(TEST_CMD_PFX) ./$<
    8.16  
    8.17  %_lldb : % test_home_
    8.18 -	$(TEST_CMD_PFX) lldb ./$<
    8.19 +	$(TEST_CMD_PFX) $(LLDB_BIN) ./$<
    8.20  
    8.21  %_valgrind : % test_home_
    8.22  	$(TEST_CMD_PFX) valgrind --leak-check=yes ./$<
     9.1 --- a/test/encrypt_for_identity_test.cc	Mon Jun 12 09:30:39 2017 +0200
     9.2 +++ b/test/encrypt_for_identity_test.cc	Fri Jun 16 15:34:34 2017 +0200
     9.3 @@ -99,7 +99,7 @@
     9.4      assert(decrypted_msg);
     9.5      assert(keylist_used);
     9.6      assert(rating);
     9.7 -    assert(status == PEP_STATUS_OK && rating == PEP_rating_unreliable);
     9.8 +    assert(status == PEP_DECRYPTED && rating == PEP_rating_unreliable);
     9.9      PEP_comm_type ct = encrypted_msg->from->comm_type;
    9.10      assert(ct == PEP_ct_pEp || ct == PEP_ct_pEp_unconfirmed || ct == PEP_ct_OpenPGP || ct == PEP_ct_OpenPGP_unconfirmed );
    9.11  
    9.12 @@ -169,7 +169,7 @@
    9.13      assert(keylist_used);
    9.14      assert(mimerating);
    9.15                               
    9.16 -    assert(status == PEP_STATUS_OK && mimerating == PEP_rating_unreliable);
    9.17 +    assert(status == PEP_DECRYPTED && mimerating == PEP_rating_unreliable);
    9.18  
    9.19      cout << "Decrypted message:" << endl;
    9.20      cout << decrypted_mimetext << endl;
    10.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    10.2 +++ b/test/pEp_subject_received_test.cc	Fri Jun 16 15:34:34 2017 +0200
    10.3 @@ -0,0 +1,222 @@
    10.4 +#include <iostream>
    10.5 +#include <iostream>
    10.6 +#include <fstream>
    10.7 +#include <string>
    10.8 +#include <cstring> // for strcmp()
    10.9 +#include <assert.h>
   10.10 +#include "blacklist.h"
   10.11 +#include "keymanagement.h"
   10.12 +#include "message_api.h"
   10.13 +#include "mime.h"
   10.14 +#include "test_util.h" // for slurp()
   10.15 +
   10.16 +using namespace std;
   10.17 +
   10.18 +int main(int argc, char** argv) {
   10.19 +
   10.20 +    cout << "\n*** check that pEp subject is handled properly in received mails ***\n\n";
   10.21 +
   10.22 +    PEP_SESSION session;
   10.23 +    
   10.24 +    cout << "calling init()\n";
   10.25 +    PEP_STATUS status1 = init(&session);   
   10.26 +    assert(status1 == PEP_STATUS_OK);
   10.27 +    assert(session);
   10.28 +    cout << "init() completed.\n";
   10.29 +
   10.30 +    const char* keytexts[3];
   10.31 +
   10.32 +    const string keytextkey1 = slurp("test_keys/pub/pep-test-alice-0x6FF00E97_pub.asc");
   10.33 +    const string keytextkey2 = slurp("test_keys/priv/pep-test-recip-0x08DB0AEE_priv.asc");
   10.34 +    const string keytextkey3 = slurp("test_keys/pub/pep-test-recip-0x08DB0AEE_pub.asc");
   10.35 +    PEP_STATUS statuskey1 = import_key(session, keytextkey1.c_str(), keytextkey1.length(), NULL);
   10.36 +    PEP_STATUS statuskey2 = import_key(session, keytextkey2.c_str(), keytextkey2.length(), NULL);
   10.37 +    PEP_STATUS statuskey3 = import_key(session, keytextkey3.c_str(), keytextkey3.length(), NULL);
   10.38 +
   10.39 +    pEp_identity * me = new_identity("pep.test.recip@kgrothoff.org", "93D19F24AD6F4C4BA9134AAF84D9217908DB0AEE", PEP_OWN_USERID, "pEp Test Recipient");    
   10.40 +    me->me = true;    
   10.41 +    PEP_STATUS status = myself(session, me);
   10.42 +    
   10.43 +    pEp_identity * you = new_identity("pep.test.apple@pep-project.org", NULL, "TOFU_pep.test.apple@pep-project.org", "pEp Test Recipient");    
   10.44 +    you->me = false;    
   10.45 +    
   10.46 +    status = update_identity(session, you);
   10.47 +    trust_personal_key(session, you);
   10.48 +    status = update_identity(session, you);
   10.49 +
   10.50 +
   10.51 +    
   10.52 +    const char* mailfiles[] = {"test_mails/pEp_encrypted_subject_IS_pEp.eml",
   10.53 +                                "test_mails/pEp_subject_normal.eml",
   10.54 +                                "test_mails/pEp_subject_normal_signed.eml",
   10.55 +                                "test_mails/pEp_subject_normal_unencrypted.eml",
   10.56 +                                "test_mails/pEp_subject_pEp.eml",
   10.57 +                                "test_mails/pEp_unencrypted_pEp_subject.eml"};
   10.58 +                                
   10.59 +
   10.60 +    cout << "------------------------------------------------------------------------------------------" << endl;
   10.61 +    cout << "Test 1: Normal encrypted mail, pEp as substitute subject, regular subject in crypto text." << endl;
   10.62 +    cout << "------------------------------------------------------------------------------------------" << endl;
   10.63 +        
   10.64 +    string mailtext = slurp(mailfiles[1]);
   10.65 +    
   10.66 +    message* msg_ptr = nullptr;
   10.67 +    message* dest_msg = nullptr;
   10.68 +    message* final_ptr = nullptr;
   10.69 +    stringlist_t* keylist = nullptr;
   10.70 +    PEP_rating rating;
   10.71 +    PEP_decrypt_flags_t flags;
   10.72 +    
   10.73 +    status = mime_decode_message(mailtext.c_str(), mailtext.length(), &msg_ptr);
   10.74 +    assert(status == PEP_STATUS_OK);
   10.75 +    assert(msg_ptr);
   10.76 +    final_ptr = msg_ptr;
   10.77 +    status = decrypt_message(session, msg_ptr, &dest_msg, &keylist, &rating, &flags);
   10.78 +    final_ptr = dest_msg ? dest_msg : msg_ptr;
   10.79 +  
   10.80 +    cout << "shortmsg: " << final_ptr->shortmsg << endl << endl;
   10.81 +    cout << "longmsg: " << final_ptr->longmsg << endl << endl;
   10.82 +    cout << "longmsg_formatted: " << (final_ptr->longmsg_formatted ? final_ptr->longmsg_formatted : "(empty)") << endl << endl;
   10.83 +
   10.84 +    assert(strcmp("This is the usual pEp subject that should replace the above.", final_ptr->shortmsg) == 0);
   10.85 +
   10.86 +    cout << "Test 1: Subject replaced as expected." << endl << endl;
   10.87 +
   10.88 +    if (final_ptr == dest_msg)
   10.89 +    	free_message(dest_msg);
   10.90 +    free_message(msg_ptr);
   10.91 +    free_stringlist(keylist);
   10.92 +
   10.93 +    cout << "-------------------------------------------------------------------------------------------------" << endl;
   10.94 +    cout << "Test 2: Normal encrypted/signed mail, pEp as substitute subject, regular subject in crypto text." << endl;
   10.95 +    cout << "-------------------------------------------------------------------------------------------------" << endl;
   10.96 +
   10.97 +    msg_ptr = nullptr;
   10.98 +    dest_msg = nullptr;
   10.99 +    final_ptr = nullptr;
  10.100 +    keylist = nullptr;
  10.101 +    rating = PEP_rating_unreliable;
  10.102 +    
  10.103 +    mailtext = slurp(mailfiles[2]);
  10.104 +    
  10.105 +    status = mime_decode_message(mailtext.c_str(), mailtext.length(), &msg_ptr);
  10.106 +    assert(status == PEP_STATUS_OK);
  10.107 +    assert(msg_ptr);
  10.108 +    final_ptr = msg_ptr;
  10.109 +    status = decrypt_message(session, msg_ptr, &dest_msg, &keylist, &rating, &flags);
  10.110 +    final_ptr = dest_msg ? dest_msg : msg_ptr;
  10.111 +  
  10.112 +    cout << "shortmsg: " << final_ptr->shortmsg << endl << endl;
  10.113 +    cout << "longmsg: " << final_ptr->longmsg << endl << endl;
  10.114 +    cout << "longmsg_formatted: " << (final_ptr->longmsg_formatted ? final_ptr->longmsg_formatted : "(empty)") << endl << endl;
  10.115 +
  10.116 +    assert(strcmp("Now signed!", final_ptr->shortmsg) == 0);
  10.117 +
  10.118 +    cout << "Test 2: Subject replaced as expected." << endl << endl;
  10.119 +
  10.120 +    if (final_ptr == dest_msg)
  10.121 +        free_message(dest_msg);
  10.122 +    free_message(msg_ptr);
  10.123 +    free_stringlist(keylist);
  10.124 +    
  10.125 +    cout << "-----------------------------------------------------------------------" << endl;
  10.126 +    cout << "Test 3: Encrypted mail, pEp as actual subject, no subject in body text." << endl;
  10.127 +    cout << "-----------------------------------------------------------------------" << endl;
  10.128 +
  10.129 +    msg_ptr = nullptr;
  10.130 +    dest_msg = nullptr;
  10.131 +    final_ptr = nullptr;
  10.132 +    keylist = nullptr;
  10.133 +    rating = PEP_rating_unreliable;
  10.134 +    
  10.135 +    mailtext = slurp(mailfiles[0]);
  10.136 +    
  10.137 +    status = mime_decode_message(mailtext.c_str(), mailtext.length(), &msg_ptr);
  10.138 +    assert(status == PEP_STATUS_OK);
  10.139 +    assert(msg_ptr);
  10.140 +    final_ptr = msg_ptr;
  10.141 +    status = decrypt_message(session, msg_ptr, &dest_msg, &keylist, &rating, &flags);
  10.142 +    final_ptr = dest_msg ? dest_msg : msg_ptr;
  10.143 +  
  10.144 +    cout << "shortmsg: " << final_ptr->shortmsg << endl << endl;
  10.145 +    cout << "longmsg: " << final_ptr->longmsg << endl << endl;
  10.146 +    cout << "longmsg_formatted: " << (final_ptr->longmsg_formatted ? final_ptr->longmsg_formatted : "(empty)") << endl << endl;
  10.147 +
  10.148 +    assert(strcmp("pEp", final_ptr->shortmsg) == 0);
  10.149 +
  10.150 +    cout << "Test 3: Subject remains intact as desired." << endl << endl;
  10.151 +
  10.152 +    if (final_ptr == dest_msg)
  10.153 +        free_message(dest_msg);
  10.154 +    free_message(msg_ptr);
  10.155 +    free_stringlist(keylist);
  10.156 +
  10.157 +    cout << "-----------------------------------------------------------------------" << endl;
  10.158 +    cout << "Test 4: Encrypted mail, pEp as actual subject, pEp subject in body text." << endl;
  10.159 +    cout << "-----------------------------------------------------------------------" << endl;
  10.160 +
  10.161 +    msg_ptr = nullptr;
  10.162 +    dest_msg = nullptr;
  10.163 +    final_ptr = nullptr;
  10.164 +    keylist = nullptr;
  10.165 +    rating = PEP_rating_unreliable;
  10.166 +    
  10.167 +    mailtext = slurp(mailfiles[4]);
  10.168 +    
  10.169 +    status = mime_decode_message(mailtext.c_str(), mailtext.length(), &msg_ptr);
  10.170 +    assert(status == PEP_STATUS_OK);
  10.171 +    assert(msg_ptr);
  10.172 +    final_ptr = msg_ptr;
  10.173 +    status = decrypt_message(session, msg_ptr, &dest_msg, &keylist, &rating, &flags);
  10.174 +    final_ptr = dest_msg ? dest_msg : msg_ptr;
  10.175 +  
  10.176 +    cout << "shortmsg: " << final_ptr->shortmsg << endl << endl;
  10.177 +    cout << "longmsg: " << final_ptr->longmsg << endl << endl;
  10.178 +    cout << "longmsg_formatted: " << (final_ptr->longmsg_formatted ? final_ptr->longmsg_formatted : "(empty)") << endl << endl;
  10.179 +
  10.180 +    assert(strcmp("pEp", final_ptr->shortmsg) == 0);
  10.181 +
  10.182 +    cout << "Test 4: Subject correct, in any event." << endl << endl;
  10.183 +
  10.184 +    if (final_ptr == dest_msg)
  10.185 +        free_message(dest_msg);
  10.186 +    free_message(msg_ptr);
  10.187 +    free_stringlist(keylist);
  10.188 +
  10.189 +    cout << "-------------------------------------------------------------------------" << endl;
  10.190 +    cout << "Test 5: Unencrypted variant where pEp in the subject line is the subject." << endl;
  10.191 +    cout << "-------------------------------------------------------------------------" << endl;
  10.192 +
  10.193 +    msg_ptr = nullptr;
  10.194 +    dest_msg = nullptr;
  10.195 +    final_ptr = nullptr;
  10.196 +    keylist = nullptr;
  10.197 +    rating = PEP_rating_unreliable;
  10.198 +    
  10.199 +    mailtext = slurp(mailfiles[5]);
  10.200 +    
  10.201 +    status = mime_decode_message(mailtext.c_str(), mailtext.length(), &msg_ptr);
  10.202 +    assert(status == PEP_STATUS_OK);
  10.203 +    assert(msg_ptr);
  10.204 +    final_ptr = msg_ptr;
  10.205 +    status = decrypt_message(session, msg_ptr, &dest_msg, &keylist, &rating, &flags);
  10.206 +    final_ptr = dest_msg ? dest_msg : msg_ptr;
  10.207 +  
  10.208 +    cout << "shortmsg: " << final_ptr->shortmsg << endl << endl;
  10.209 +    cout << "longmsg: " << final_ptr->longmsg << endl << endl;
  10.210 +    cout << "longmsg_formatted: " << (final_ptr->longmsg_formatted ? final_ptr->longmsg_formatted : "(empty)") << endl << endl;
  10.211 +
  10.212 +    assert(strcmp("pEp", final_ptr->shortmsg) == 0);
  10.213 +
  10.214 +    cout << "Test 5: Subject remains intact." << endl << endl;
  10.215 +
  10.216 +    if (final_ptr == dest_msg)
  10.217 +        free_message(dest_msg);
  10.218 +    free_message(msg_ptr);
  10.219 +    free_stringlist(keylist);
  10.220 +
  10.221 +        
  10.222 +    cout << "calling release()\n";
  10.223 +    release(session);
  10.224 +    return 0;
  10.225 +}
    11.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    11.2 +++ b/test/test_mails/pEp_encrypted_subject_IS_pEp.eml	Fri Jun 16 15:34:34 2017 +0200
    11.3 @@ -0,0 +1,121 @@
    11.4 +Return-Path: <pep.test.alice@pep-project.org>
    11.5 +X-Original-To: krista@gnunet.org
    11.6 +Delivered-To: krista@gnunet.org
    11.7 +Received: from vmmailrelay1.informatik.tu-muenchen.de (mailrelay1.informatik.tu-muenchen.de [131.159.254.14])
    11.8 +	by sam.net.in.tum.de (Postfix) with ESMTP id BE55A1C00BC
    11.9 +	for <krista@gnunet.org>; Mon, 12 Jun 2017 15:27:51 +0200 (CEST)
   11.10 +Received: by vmmailrelay1.informatik.tu-muenchen.de (Postfix, from userid 109)
   11.11 +	id 94D2F1C0394; Mon, 12 Jun 2017 15:27:52 +0200 (CEST)
   11.12 +Received: from vmmailrelay1.informatik.tu-muenchen.de (localhost [127.0.0.1])
   11.13 +	by vmmailrelay1.informatik.tu-muenchen.de (Postfix) with ESMTP id 6D2E21C037A
   11.14 +	for <krista@gnunet.org>; Mon, 12 Jun 2017 15:27:52 +0200 (CEST)
   11.15 +Received: from vmmaildmz1.informatik.tu-muenchen.de (vmmaildmz1.informatik.tu-muenchen.de [131.159.0.87])
   11.16 +	by vmmailrelay1.informatik.tu-muenchen.de (Postfix) with ESMTP id 5876E1C0383
   11.17 +	for <krista@gnunet.org>; Mon, 12 Jun 2017 15:27:52 +0200 (CEST)
   11.18 +Received: by vmmaildmz1.informatik.tu-muenchen.de (Postfix, from userid 109)
   11.19 +	id 56F1F1C2D9D; Mon, 12 Jun 2017 15:27:52 +0200 (CEST)
   11.20 +X-Spam-Checker-Version: SpamAssassin 3.4.0-tuminfo_1 (2014-02-07) on
   11.21 +	vmmaildmz1.informatik.tu-muenchen.de
   11.22 +X-Spam-Level: 
   11.23 +X-Spam-Status: No, score=-3.4 required=7.0 tests=AWL,BAYES_00,
   11.24 +	ENCRYPTED_MESSAGE,RCVD_IN_DNSWL_LOW,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,
   11.25 +	TVD_RCVD_SPACE_BRACKET,UNPARSEABLE_RELAY autolearn=no autolearn_force=no
   11.26 +	version=3.4.0-tuminfo_1
   11.27 +Received: from vmmaildmz1.informatik.tu-muenchen.de (localhost [127.0.0.1])
   11.28 +	by vmmaildmz1.informatik.tu-muenchen.de (Postfix) with ESMTP id DE3C31C2D9E
   11.29 +	for <krista@gnunet.org>; Mon, 12 Jun 2017 15:27:50 +0200 (CEST)
   11.30 +Received: from mi4-p00-ob.smtp.rzone.de (mi4-p00-ob.smtp.rzone.de [81.169.146.149])
   11.31 +	(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
   11.32 +	(No client certificate requested)
   11.33 +	by vmmaildmz1.informatik.tu-muenchen.de (Postfix) with ESMTPS id CDD481C2D9B
   11.34 +	for <krista@gnunet.org>; Mon, 12 Jun 2017 15:27:50 +0200 (CEST)
   11.35 +X-RZG-FWD-BY: pep.test.recip@kgrothoff.org
   11.36 +Received: from mailin.rzone.de ([unix socket])
   11.37 +	by mailin.rzone.de (RZmta 40.9) with LMTPA;
   11.38 +	Mon, 12 Jun 2017 15:27:46 +0200 (CEST)
   11.39 +Authentication-Results: strato.com 1;
   11.40 +	spf=none
   11.41 +		smtp.mailfrom="pep.test.alice@pep-project.org";
   11.42 +	dkim=none;
   11.43 +	domainkeys=none;
   11.44 +	dkim-adsp=none
   11.45 +		header.from="pep.test.alice@pep-project.org"
   11.46 +X-Strato-MessageType: email
   11.47 +X-RZG-CLASS-ID: mi00
   11.48 +Received-SPF: none
   11.49 +	client-ip=131.159.0.8;
   11.50 +	helo="mail-out1.informatik.tu-muenchen.de";
   11.51 +	envelope-from="pep.test.alice@pep-project.org";
   11.52 +	receiver=smtpin.rzone.de;
   11.53 +	identity=mailfrom;
   11.54 +Received: from mail-out1.informatik.tu-muenchen.de ([131.159.0.8])
   11.55 +	by smtpin.rzone.de (RZmta 40.9 OK)
   11.56 +	with ESMTPS id w03564t5CDRkYmx
   11.57 +	(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (curve secp521r1 with 521 ECDH bits, eq. 15360 bits RSA))
   11.58 +	(Client did not present a certificate)
   11.59 +	for <pep.test.recip@kgrothoff.org>;
   11.60 +	Mon, 12 Jun 2017 15:27:46 +0200 (CEST)
   11.61 +Received: from [192.168.178.22] (ip5f584089.dynamic.kabel-deutschland.de [95.88.64.137])
   11.62 +	by services.sec.in.tum.de (Postfix) with ESMTPSA id A8EC11013AE47
   11.63 +	for <pep.test.recip@kgrothoff.org>; Mon, 12 Jun 2017 15:27:40 +0200 (CEST)
   11.64 +To: pep.test.recip@kgrothoff.org
   11.65 +Reply-To: krista@pep-project.org
   11.66 +From: pEp Test Alice <pep.test.alice@pep-project.org>
   11.67 +Subject: pEp
   11.68 +Organization: pEp
   11.69 +Message-ID: <5d37b6c2-9e5e-7217-c80e-1359da8faa5c@pep-project.org>
   11.70 +Date: Mon, 12 Jun 2017 15:27:40 +0200
   11.71 +User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101
   11.72 + Thunderbird/45.8.0
   11.73 +MIME-Version: 1.0
   11.74 +Content-Type: multipart/encrypted;
   11.75 + protocol="application/pgp-encrypted";
   11.76 + boundary="7vTKNA25GePB6VqgrM1km3gCfpFonmKj3"
   11.77 +
   11.78 +This is an OpenPGP/MIME encrypted message (RFC 4880 and 3156)
   11.79 +--7vTKNA25GePB6VqgrM1km3gCfpFonmKj3
   11.80 +Content-Type: application/pgp-encrypted
   11.81 +Content-Description: PGP/MIME version identification
   11.82 +
   11.83 +Version: 1
   11.84 +
   11.85 +--7vTKNA25GePB6VqgrM1km3gCfpFonmKj3
   11.86 +Content-Type: application/octet-stream; name="encrypted.asc"
   11.87 +Content-Description: OpenPGP encrypted message
   11.88 +Content-Disposition: inline; filename="encrypted.asc"
   11.89 +
   11.90 +-----BEGIN PGP MESSAGE-----
   11.91 +
   11.92 +hQEMA4FHqvEumyRHAQf6AkV51E1/uffFSc++oIPAoNCJU71NseNgW3s3XIQ/7TIQ
   11.93 +pDi6a6ksNdN+cJyMhfM7HnO06LjrUDYtgYPkZBHcTDZMWivW/7+5g8z60V3biIpw
   11.94 +mdUqhb+mZb4A0akMk+Ix8paoR8D7y4jmeLHwj/vbQ1J/E64rob9XPDWrLOW63chR
   11.95 +pg+XAo3VbkDKCms8PSuKehzMoTpZUcEVP47TF1OxuKZE0k7yJQ354RlPGxsl/6zM
   11.96 +O1+cJ7XdclkZj9gdeJAWzqCx6kTmDy2DA4e80BwMXXJnQtFIp4B55gTHvfbmxBRL
   11.97 +V8KDHOlvY/YSFV9sikjyaXbiweuqgiycsLb+qRziG4UBDANaAgXZcwg/TQEIAMg9
   11.98 +CVCJiYqS+ke1Zw0VNbb4BccrSBWL5iiQsPPUFOBld8jCFCGFZVBiik7O/XzRGWQh
   11.99 +qsYb2BNb0267viJS+IhTvihFybvR/l/gkzRLRfznFxbsRKgYAI6ipPr4wdAxvRkE
  11.100 +k0LvL3ckRgKtc2UORvfmhKRXu8Hj8dkYD0Asewnx7+p+s685MpyJ3zhhyifPzqKw
  11.101 +VH/6D7g26t3DjjQkvTvkiIMEvxT3beQN6QspdRtoDhHqAH0JhrZjEZyenneXE/AB
  11.102 +2CrnIfEU6V7S1EWP4Ond647K/F89ZG9LfTBpfmYuTXMKM39hmQaNcIsr8dr+mBif
  11.103 +nO2xRkyTMHAtyEk1dQnS6QFdLynwNLfsOvecztOBNBE/j6gH3dqKgZMg2e7ojK/Z
  11.104 +rNohpLMfZqzN37sfopm8htzK0Wg/l0CcgR8S4cUln06UzUm89GF9pokHYTnXYNYb
  11.105 +S2BMMVQ7gTpGDBfBFHVCK8xtCSFJJmxoxIzC9Ojl4JYfqJycip1QdWCWhXJDo0m9
  11.106 +4S+57m1UHAeyfT8v4ggEffVg2fgHF5VF58S3FC3HCtASAqljtmYVlHQSK0hSY00U
  11.107 +t9y/McqDXYuXXtT5O056q2VoYkWjTpvbvuk/TI3IU2np9owZwgHJwiA8I+BMQitd
  11.108 +LWRmSmoRBBHNsaORuEUZYMugZzcTD81C2v5PNDvawB7mcSFqrtI6K30TnZ5iu8DI
  11.109 +qJ9BdP7Htphqk9nusLT7XTYve/6/NC6rmnnEpQhrdXdzPDsyGe0H/s24xU3wFKBY
  11.110 +JdKyfKSJUkXjmCrqJrkq0wAHCaZYK5hLiobhYLGfxxjPpx2UFk33lYXL5R659Gjh
  11.111 +oIgZW5NWOxNRE1GRd2js+WaZy2dwvxeqNGEdEHgi6UN6JRf588lSYjbz+8u2TW21
  11.112 +whH5x5VfDpIqimPdknQwM/w8N2fYEhI4bWv0rp+D0m27hZaVXjInShEQq6YsjAs5
  11.113 +aP19C7WT+VK+FuvOEQ3nxPl+/fGOF5EoceuscxjCxkVu8Ijq4+xdu7Hl6ycJUu40
  11.114 +wGTKOy/rGg0TZ232SyUE83VyxAPtU0fTLvbZAcQaT+YTHqk/c4hdzPW/Ho8L1aZ0
  11.115 +Ax9PpkUHmm7+JS3sbfxyLMQ9Zz2GcE+SCIEyGuFTqO/ESmJUXTNQjDRmLuleOhZt
  11.116 +VmOezek2BEcvWZd5/0w6pd6UBjzXdSdTJA38nBr8Ao217xDMZiLoxg6xZbsG12et
  11.117 +mqWG9m/5dQRECrcN0lRdQqFovSkw7/Az7jOIm0v4ey+i6wmEblg3M0vm7Ky19l7Z
  11.118 +lm0+nC5XwR56n4VPtyRbGgLkI8w//NChYZJJOVpyVpfP57pKPhvhLNcaOk2d5gNU
  11.119 +KDg2bKXilzkMflVqw5eYN2EKCMlLx+hW5U1oSJJlQKqKXQ0qglUfSEzPmBt9Y0g1
  11.120 +DN+blh+m
  11.121 +=UZkH
  11.122 +-----END PGP MESSAGE-----
  11.123 +
  11.124 +--7vTKNA25GePB6VqgrM1km3gCfpFonmKj3--
    12.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    12.2 +++ b/test/test_mails/pEp_subject_normal.eml	Fri Jun 16 15:34:34 2017 +0200
    12.3 @@ -0,0 +1,112 @@
    12.4 +Return-Path: <pep.test.alice@pep-project.org>
    12.5 +X-Original-To: krista@gnunet.org
    12.6 +Delivered-To: krista@gnunet.org
    12.7 +Received: from vmmailrelay1.informatik.tu-muenchen.de (mailrelay1.informatik.tu-muenchen.de [131.159.254.14])
    12.8 +	by sam.net.in.tum.de (Postfix) with ESMTP id 98B571C00BC
    12.9 +	for <krista@gnunet.org>; Mon, 12 Jun 2017 15:25:44 +0200 (CEST)
   12.10 +Received: by vmmailrelay1.informatik.tu-muenchen.de (Postfix, from userid 109)
   12.11 +	id 620431C0383; Mon, 12 Jun 2017 15:25:45 +0200 (CEST)
   12.12 +Received: from vmmailrelay1.informatik.tu-muenchen.de (localhost [127.0.0.1])
   12.13 +	by vmmailrelay1.informatik.tu-muenchen.de (Postfix) with ESMTP id 3F4961C037C
   12.14 +	for <krista@gnunet.org>; Mon, 12 Jun 2017 15:25:45 +0200 (CEST)
   12.15 +Received: from vmmaildmz1.informatik.tu-muenchen.de (vmmaildmz1.informatik.tu-muenchen.de [131.159.0.87])
   12.16 +	by vmmailrelay1.informatik.tu-muenchen.de (Postfix) with ESMTP id 2BCE31C037A
   12.17 +	for <krista@gnunet.org>; Mon, 12 Jun 2017 15:25:45 +0200 (CEST)
   12.18 +Received: by vmmaildmz1.informatik.tu-muenchen.de (Postfix, from userid 109)
   12.19 +	id 2A4741C2D9D; Mon, 12 Jun 2017 15:25:45 +0200 (CEST)
   12.20 +X-Spam-Checker-Version: SpamAssassin 3.4.0-tuminfo_1 (2014-02-07) on
   12.21 +	vmmaildmz1.informatik.tu-muenchen.de
   12.22 +X-Spam-Level: 
   12.23 +X-Spam-Status: No, score=-3.6 required=7.0 tests=BAYES_00,ENCRYPTED_MESSAGE,
   12.24 +	RCVD_IN_DNSWL_LOW,TVD_RCVD_SPACE_BRACKET,UNPARSEABLE_RELAY autolearn=no
   12.25 +	autolearn_force=no version=3.4.0-tuminfo_1
   12.26 +Received: from vmmaildmz1.informatik.tu-muenchen.de (localhost [127.0.0.1])
   12.27 +	by vmmaildmz1.informatik.tu-muenchen.de (Postfix) with ESMTP id 6EF791C2D9E
   12.28 +	for <krista@gnunet.org>; Mon, 12 Jun 2017 15:25:43 +0200 (CEST)
   12.29 +Received: from mi4-p00-ob.smtp.rzone.de (mi4-p00-ob.smtp.rzone.de [81.169.146.144])
   12.30 +	(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
   12.31 +	(No client certificate requested)
   12.32 +	by vmmaildmz1.informatik.tu-muenchen.de (Postfix) with ESMTPS id 5E75D1C2D9B
   12.33 +	for <krista@gnunet.org>; Mon, 12 Jun 2017 15:25:43 +0200 (CEST)
   12.34 +X-RZG-FWD-BY: pep.test.recip@kgrothoff.org
   12.35 +Received: from mailin.rzone.de ([unix socket])
   12.36 +	by mailin.rzone.de (RZmta 40.9) with LMTPA;
   12.37 +	Mon, 12 Jun 2017 15:25:24 +0200 (CEST)
   12.38 +Authentication-Results: strato.com 1;
   12.39 +	spf=none
   12.40 +		smtp.mailfrom="pep.test.alice@pep-project.org";
   12.41 +	dkim=none;
   12.42 +	domainkeys=none;
   12.43 +	dkim-adsp=none
   12.44 +		header.from="pep.test.alice@pep-project.org"
   12.45 +X-Strato-MessageType: email
   12.46 +X-RZG-CLASS-ID: mi00
   12.47 +Received-SPF: none
   12.48 +	client-ip=131.159.0.8;
   12.49 +	helo="mail-out1.informatik.tu-muenchen.de";
   12.50 +	envelope-from="pep.test.alice@pep-project.org";
   12.51 +	receiver=smtpin.rzone.de;
   12.52 +	identity=mailfrom;
   12.53 +Received: from mail-out1.informatik.tu-muenchen.de ([131.159.0.8])
   12.54 +	by smtpin.rzone.de (RZmta 40.9 OK)
   12.55 +	with ESMTPS id v06d9ft5CDPHXhF
   12.56 +	(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (curve secp521r1 with 521 ECDH bits, eq. 15360 bits RSA))
   12.57 +	(Client did not present a certificate)
   12.58 +	for <pep.test.recip@kgrothoff.org>;
   12.59 +	Mon, 12 Jun 2017 15:25:17 +0200 (CEST)
   12.60 +Received: from [192.168.178.22] (ip5f584089.dynamic.kabel-deutschland.de [95.88.64.137])
   12.61 +	by services.sec.in.tum.de (Postfix) with ESMTPSA id 4697F1013AE47
   12.62 +	for <pep.test.recip@kgrothoff.org>; Mon, 12 Jun 2017 15:25:11 +0200 (CEST)
   12.63 +Reply-To: krista@pep-project.org
   12.64 +To: pep.test.recip@kgrothoff.org
   12.65 +From: pEp Test Alice <pep.test.alice@pep-project.org>
   12.66 +Subject: pEp
   12.67 +Organization: pEp
   12.68 +Message-ID: <92ee4ca2-17cd-bcf1-377c-3367470bb571@pep-project.org>
   12.69 +Date: Mon, 12 Jun 2017 15:25:10 +0200
   12.70 +User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101
   12.71 + Thunderbird/45.8.0
   12.72 +MIME-Version: 1.0
   12.73 +Content-Type: multipart/encrypted;
   12.74 + protocol="application/pgp-encrypted";
   12.75 + boundary="e7R73MXx31oWAX8HMqNvMDNt9cAMWtSTV"
   12.76 +
   12.77 +This is an OpenPGP/MIME encrypted message (RFC 4880 and 3156)
   12.78 +--e7R73MXx31oWAX8HMqNvMDNt9cAMWtSTV
   12.79 +Content-Type: application/pgp-encrypted
   12.80 +Content-Description: PGP/MIME version identification
   12.81 +
   12.82 +Version: 1
   12.83 +
   12.84 +--e7R73MXx31oWAX8HMqNvMDNt9cAMWtSTV
   12.85 +Content-Type: application/octet-stream; name="encrypted.asc"
   12.86 +Content-Description: OpenPGP encrypted message
   12.87 +Content-Disposition: inline; filename="encrypted.asc"
   12.88 +
   12.89 +-----BEGIN PGP MESSAGE-----
   12.90 +
   12.91 +hQEMA4FHqvEumyRHAQf+KW54G6f25yDJs6MdhWSs/766uFEIy8pq+j49AykOBsh2
   12.92 +W8BeB7yBqwjVFsBYPwGFNza187QHQVQlOHGRtxkXSX/iSym/O82YPvSwZj7GkKS9
   12.93 +sMgX2/dOMaEoTitn72f26ww5PvAqltJLD5TGhSM0RxK+0OemSrI0wDZxUb2Ll8DT
   12.94 +aVwpuKnLYFMcnk8SQLa3eZ/YpFV3TCMDFUgtIEqmHoh74dwemQjpP+qhbExZvY/k
   12.95 +rSZuJoU8siuLJ72vbEn8n2x8UCCfyTpacBZkC6Ukhsm/XrSg2GjqqzjSeR0T0Nbr
   12.96 +y/sFblbE8fbmouAf5k670oUot+j5aoHV79Rntcdm1oUBDANaAgXZcwg/TQEH/jhF
   12.97 +1ayYCROI8xEhj01Qbn60OtG+iKO+3B5/+uwizYgyW5mhKjrdgA/wsKMTMXj1BG+J
   12.98 +JJJ1TdEbxbL2UCai6nuHd0CbqJWSuTAicteKudUclAJHnpm2Qv+Yq2t/8JwJllMR
   12.99 +Wum8Cj4WuD0K3te5uHDZuu7Vfj9r3+7WYJ7FUkSYp2DUIFMM+hG+8OJtdjKd6kAA
  12.100 +FtAOijws+1r4jYFGYkCMRfnQatiFXf0n6Nr8qjSskkMtNQk41AG4LauYFTphR/G+
  12.101 +ayXPd8buDyBh3XuyoMcg5vLMJfWVTfiKM/wxv1jBBrQwFd5JpqCNr9dHYWMJ0gg9
  12.102 +aMdvaDEEd7I4VlwU+4DSwQMBF7R9V3cYj1XOxHjX2EikIxR/kviUrB8vDE4LAYJE
  12.103 +UFvoXgKRe4lQbQlLwoBp6R8L6mPTytLzlQnjQ4AJhPWhXkJUeCetURr5BzNCEfOy
  12.104 ++2Nq+9XLGM0wSCY09BOsGAQSL56kIGL61AnhvhpPUi9w9SOVjLHge6pzSzAW3h5E
  12.105 +vf8a8oGyLjyHR9VWBUqrMQ0tTWdHkoeHenXpwA+rckr0kzJXW1RJt2oQJEE0LI2I
  12.106 +0p9j7o6imaYWdtbHS7Kcbg2DxbT63QVOoO4OTPLHjYj0eqf1NDlwKBzQYaknNScI
  12.107 +LHnXrzMqqylU3ki8hUIh0K1ULernaA8LEIuegKMuguHCs2B/Xgee+Hor6l4XBRzD
  12.108 +V/8WFIU1lxthnYEceik/OD2U+LDKT4i+AogJAA+rCw0WbUC8f1HXQeV/8CVarcUn
  12.109 +GrS7AjjZlwQfiE8R/CtKdNaiJa4Z8GuQZJD/AqOe5zH0HLBykaheHS6ynw9yuNb7
  12.110 +d6lArIYdW5S8D0RDYRwu7z/lI3sgVgwiuoAk1OiYtrYUUNiXcpO59aE59iXjMW61
  12.111 +EvUAZzgfRyuzYdZtYNaM3FvUSm2aAsQRP+NJFW3YkqkbLvyo
  12.112 +=VpGy
  12.113 +-----END PGP MESSAGE-----
  12.114 +
  12.115 +--e7R73MXx31oWAX8HMqNvMDNt9cAMWtSTV--
    13.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    13.2 +++ b/test/test_mails/pEp_subject_normal_signed.eml	Fri Jun 16 15:34:34 2017 +0200
    13.3 @@ -0,0 +1,119 @@
    13.4 +Return-Path: <pep.test.alice@pep-project.org>
    13.5 +X-Original-To: krista@gnunet.org
    13.6 +Delivered-To: krista@gnunet.org
    13.7 +Received: from vmmailrelay1.informatik.tu-muenchen.de (mailrelay1.informatik.tu-muenchen.de [131.159.254.14])
    13.8 +	by sam.net.in.tum.de (Postfix) with ESMTP id 768301C00BC
    13.9 +	for <krista@gnunet.org>; Mon, 12 Jun 2017 15:26:24 +0200 (CEST)
   13.10 +Received: by vmmailrelay1.informatik.tu-muenchen.de (Postfix, from userid 109)
   13.11 +	id 4DD7D1C0383; Mon, 12 Jun 2017 15:26:25 +0200 (CEST)
   13.12 +Received: from vmmailrelay1.informatik.tu-muenchen.de (localhost [127.0.0.1])
   13.13 +	by vmmailrelay1.informatik.tu-muenchen.de (Postfix) with ESMTP id 2AD621C037C
   13.14 +	for <krista@gnunet.org>; Mon, 12 Jun 2017 15:26:25 +0200 (CEST)
   13.15 +Received: from vmmaildmz2.informatik.tu-muenchen.de (vmmaildmz2.informatik.tu-muenchen.de [131.159.0.88])
   13.16 +	by vmmailrelay1.informatik.tu-muenchen.de (Postfix) with ESMTP id 15DA11C037A
   13.17 +	for <krista@gnunet.org>; Mon, 12 Jun 2017 15:26:25 +0200 (CEST)
   13.18 +Received: by vmmaildmz2.informatik.tu-muenchen.de (Postfix, from userid 109)
   13.19 +	id 13FCC1C2AE2; Mon, 12 Jun 2017 15:26:25 +0200 (CEST)
   13.20 +X-Spam-Checker-Version: SpamAssassin 3.4.0-tuminfo_1 (2014-02-07) on
   13.21 +	vmmaildmz2.informatik.tu-muenchen.de
   13.22 +X-Spam-Level: 
   13.23 +X-Spam-Status: No, score=-2.6 required=7.0 tests=AWL,BAYES_00,
   13.24 +	ENCRYPTED_MESSAGE,RCVD_IN_DNSWL_LOW,TVD_RCVD_SPACE_BRACKET,UNPARSEABLE_RELAY
   13.25 +	autolearn=no autolearn_force=no version=3.4.0-tuminfo_1
   13.26 +Received: from vmmaildmz2.informatik.tu-muenchen.de (localhost [127.0.0.1])
   13.27 +	by vmmaildmz2.informatik.tu-muenchen.de (Postfix) with ESMTP id 953971C2AE1
   13.28 +	for <krista@gnunet.org>; Mon, 12 Jun 2017 15:26:23 +0200 (CEST)
   13.29 +Received: from mi4-p00-ob.smtp.rzone.de (mi4-p00-ob.smtp.rzone.de [81.169.146.144])
   13.30 +	(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
   13.31 +	(No client certificate requested)
   13.32 +	by vmmaildmz2.informatik.tu-muenchen.de (Postfix) with ESMTPS id 8540A1C2AE0
   13.33 +	for <krista@gnunet.org>; Mon, 12 Jun 2017 15:26:23 +0200 (CEST)
   13.34 +X-RZG-FWD-BY: pep.test.recip@kgrothoff.org
   13.35 +Received: from mailin.rzone.de ([unix socket])
   13.36 +	by mailin.rzone.de (RZmta 40.9) with LMTPA;
   13.37 +	Mon, 12 Jun 2017 15:26:02 +0200 (CEST)
   13.38 +Authentication-Results: strato.com 1;
   13.39 +	spf=none
   13.40 +		smtp.mailfrom="pep.test.alice@pep-project.org";
   13.41 +	dkim=none;
   13.42 +	domainkeys=none;
   13.43 +	dkim-adsp=none
   13.44 +		header.from="pep.test.alice@pep-project.org"
   13.45 +X-Strato-MessageType: email
   13.46 +X-RZG-CLASS-ID: mi00
   13.47 +Received-SPF: none
   13.48 +	client-ip=131.159.0.8;
   13.49 +	helo="mail-out1.informatik.tu-muenchen.de";
   13.50 +	envelope-from="pep.test.alice@pep-project.org";
   13.51 +	receiver=smtpin.rzone.de;
   13.52 +	identity=mailfrom;
   13.53 +Received: from mail-out1.informatik.tu-muenchen.de ([131.159.0.8])
   13.54 +	by smtpin.rzone.de (RZmta 40.9 OK)
   13.55 +	with ESMTPS id v06d9ft5CDQ2Xj1
   13.56 +	(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (curve secp521r1 with 521 ECDH bits, eq. 15360 bits RSA))
   13.57 +	(Client did not present a certificate)
   13.58 +	for <pep.test.recip@kgrothoff.org>;
   13.59 +	Mon, 12 Jun 2017 15:26:02 +0200 (CEST)
   13.60 +Received: from [192.168.178.22] (ip5f584089.dynamic.kabel-deutschland.de [95.88.64.137])
   13.61 +	by services.sec.in.tum.de (Postfix) with ESMTPSA id BEAA21013AE47
   13.62 +	for <pep.test.recip@kgrothoff.org>; Mon, 12 Jun 2017 15:25:56 +0200 (CEST)
   13.63 +To: pep.test.recip@kgrothoff.org
   13.64 +Reply-To: krista@pep-project.org
   13.65 +From: pEp Test Alice <pep.test.alice@pep-project.org>
   13.66 +Subject: pEp
   13.67 +Organization: pEp
   13.68 +Message-ID: <988e71f4-df80-906e-8bbb-68d48069d4ac@pep-project.org>
   13.69 +Date: Mon, 12 Jun 2017 15:25:56 +0200
   13.70 +User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101
   13.71 + Thunderbird/45.8.0
   13.72 +MIME-Version: 1.0
   13.73 +Content-Type: multipart/encrypted;
   13.74 + protocol="application/pgp-encrypted";
   13.75 + boundary="hcW81WNiFhQC1SNIcls8J07V1b1sXtfCA"
   13.76 +
   13.77 +This is an OpenPGP/MIME encrypted message (RFC 4880 and 3156)
   13.78 +--hcW81WNiFhQC1SNIcls8J07V1b1sXtfCA
   13.79 +Content-Type: application/pgp-encrypted
   13.80 +Content-Description: PGP/MIME version identification
   13.81 +
   13.82 +Version: 1
   13.83 +
   13.84 +--hcW81WNiFhQC1SNIcls8J07V1b1sXtfCA
   13.85 +Content-Type: application/octet-stream; name="encrypted.asc"
   13.86 +Content-Description: OpenPGP encrypted message
   13.87 +Content-Disposition: inline; filename="encrypted.asc"
   13.88 +
   13.89 +-----BEGIN PGP MESSAGE-----
   13.90 +
   13.91 +hQEMA4FHqvEumyRHAQf+OCG4FM0n6pVREVP2kAUzJWy6NAgRYs4cj7pr5hDoUqZY
   13.92 +lBIfVPqNM2rG2xaSpNLfe1iY5mySKL42M+s/QM0cvfnOlS6p3U58EamslElZ9UhD
   13.93 +hBUrX/1NJwdoKyR07Wq3A1UFFYQMYsszPwoC82SCFOhYjEmdZ8/nppViUk3aAUvq
   13.94 +do80ZzvNnlJqgwPEUmMEy9p19XJxQQwG75yHmUsoTvgi9ELvJpEzAjeYFABNzuNE
   13.95 +lh5whuMqmVbEafAYtopB+dwxQxSUdQUHntLU2MrbH8QXGtP98ZaDTHg/Zj24zkUG
   13.96 +Ur/5DZJgzDMrAttorpp/2/NMmakIezy7JaoGQtyYRYUBDANaAgXZcwg/TQEIALLR
   13.97 +7OlIlUYelrktOnrkTy8BrrEuUj95uBM5TkkvWIfR2b3ylC5iWwa/RlIU4RC0VH3j
   13.98 +epwLQNJJKFi/qKwxReE+RMKZW00loUuYnVWeaj58ExTNsdpFJDut35AIp8FNzTmy
   13.99 +C4xv5VVZZnolRd6CW0GUuxEe1zXq1MiyuGHu5AwFgWl728KaRXF2tEVyrQt/okXx
  13.100 +kF7yWkO4oo25VZWCrboUc1FND/7dbfP/PtLKIj05l+xwNaIEt1gb1IM7SxjN+2Tx
  13.101 +Ayp/w1npFhugBkSV3JaIk9dfHpMlLP5URZn30dXElK0an7aB8IwZWwdObo4zlevI
  13.102 +K4nN+UU1Z/kN1guxYDbS6QGOo2Y8829kaOXkBC3HDQEkef631jj1FuVB6VJvhb0u
  13.103 +5EKaxyw8aVxodRQaK9CcKCqwDlnyhHqd4fdMjPk9zTV9xrnqSdC5yKoAhBJ9sFef
  13.104 +Qv5qjYiBUhB+7uGMvRifvO+bT+8q44IS7z/bdXJFjbImgtx57yKvujyvrZlDe6q3
  13.105 +1nzS1jqMQ8NCDP/CKs5WUlaH9LIQ/NWF10EulTjaZ0QZ6iNU0MTqmhs4ZJIsPmBo
  13.106 +g6Qz9x8imV37cC9lHhw/vp99Dal9YulTxdYZnWSfTh289bHqaMEXGYJUsDh3IEYx
  13.107 +UP1bzza+N2dqeiysDmeTNhbZvwk54VmaKMrj/ut/3WIrsulBY7YxE/azle78Ydab
  13.108 +/tKu5YUbVydnVJ6y1s4yASjaOG7ycMIaXggWKUIfWh5Y7BLFHYbcMMltPrspftW7
  13.109 +tjtbL1SUHw0NTfCkBqRv4GpvIAXTCmlxvLw//ee1JZ0nuLnQZBF2GQ0wJVsbunT9
  13.110 +dUschdnIWLfWlueldt+5wOkB6L4quoZ7LWefMQu/b3bg/GWoBtuC3fJDnCsbJO07
  13.111 +nJxZTPxsI3iFUGGtXkg4jGC+yDMlQu3a7LwEkKzx9LT/S1OUndpaBQr6YjyrnET6
  13.112 +w1Hz6jLb5t/2fzrBwkKw1TCu4+pkevIGaGxgQY6TB15jcmWRkUF3sakTrH0UOCSq
  13.113 +wEzFoPF4+WjtXNk/wHw8zkrW7QCe+wbjLjwcUUK/ulKT9/II/k/aUwTt+GzWCGVq
  13.114 +KWq7VLtwa8lrJ74R+XISks9/Hv/nJ8Ay1DfpcQU2HQSnQpSrXupXIA+VoHU/b8xD
  13.115 +YcgqaRKsGYHUANjNs4PpplXlEHp5bpF/ZOpfVAJNnGQ96Cj182DLQgiB0j7Ishjv
  13.116 +XoNDVL45KKW0uWjimZbCauWrD6tjZfBmydymezbPLCB9R+tE68TA/XmpXzInXWML
  13.117 +YDK7tS8TYEkodzSkfDeB7BtXBRIxH4vm2M0E0OdJuLxjrOYeIH4xToUslS9pdog0
  13.118 +z3aqPQbXF4hFc8Fso83dmoc26mQd3H0LrP7yF4HR
  13.119 +=gLhG
  13.120 +-----END PGP MESSAGE-----
  13.121 +
  13.122 +--hcW81WNiFhQC1SNIcls8J07V1b1sXtfCA--
    14.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    14.2 +++ b/test/test_mails/pEp_subject_normal_unencrypted.eml	Fri Jun 16 15:34:34 2017 +0200
    14.3 @@ -0,0 +1,75 @@
    14.4 +Return-Path: <pep.test.alice@pep-project.org>
    14.5 +X-Original-To: krista@gnunet.org
    14.6 +Delivered-To: krista@gnunet.org
    14.7 +Received: from vmmailrelay1.informatik.tu-muenchen.de (mailrelay1.informatik.tu-muenchen.de [131.159.254.14])
    14.8 +	by sam.net.in.tum.de (Postfix) with ESMTP id 140C01C00BC
    14.9 +	for <krista@gnunet.org>; Mon, 12 Jun 2017 15:27:21 +0200 (CEST)
   14.10 +Received: by vmmailrelay1.informatik.tu-muenchen.de (Postfix, from userid 109)
   14.11 +	id DAE901C0390; Mon, 12 Jun 2017 15:27:21 +0200 (CEST)
   14.12 +Received: from vmmailrelay1.informatik.tu-muenchen.de (localhost [127.0.0.1])
   14.13 +	by vmmailrelay1.informatik.tu-muenchen.de (Postfix) with ESMTP id B86091C0383
   14.14 +	for <krista@gnunet.org>; Mon, 12 Jun 2017 15:27:21 +0200 (CEST)
   14.15 +Received: from vmmaildmz1.informatik.tu-muenchen.de (vmmaildmz1.informatik.tu-muenchen.de [131.159.0.87])
   14.16 +	by vmmailrelay1.informatik.tu-muenchen.de (Postfix) with ESMTP id AE13F1C037A
   14.17 +	for <krista@gnunet.org>; Mon, 12 Jun 2017 15:27:21 +0200 (CEST)
   14.18 +Received: by vmmaildmz1.informatik.tu-muenchen.de (Postfix, from userid 109)
   14.19 +	id AC51F1C2D9F; Mon, 12 Jun 2017 15:27:21 +0200 (CEST)
   14.20 +X-Spam-Checker-Version: SpamAssassin 3.4.0-tuminfo_1 (2014-02-07) on
   14.21 +	vmmaildmz1.informatik.tu-muenchen.de
   14.22 +X-Spam-Level: 
   14.23 +X-Spam-Status: No, score=-3.1 required=7.0 tests=AWL,BAYES_00,
   14.24 +	RCVD_IN_DNSWL_LOW,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,TVD_RCVD_SPACE_BRACKET,
   14.25 +	UNPARSEABLE_RELAY autolearn=no autolearn_force=no version=3.4.0-tuminfo_1
   14.26 +Received: from vmmaildmz1.informatik.tu-muenchen.de (localhost [127.0.0.1])
   14.27 +	by vmmaildmz1.informatik.tu-muenchen.de (Postfix) with ESMTP id 3B30C1C2D9E
   14.28 +	for <krista@gnunet.org>; Mon, 12 Jun 2017 15:27:20 +0200 (CEST)
   14.29 +Received: from mi4-p00-ob.smtp.rzone.de (mi4-p00-ob.smtp.rzone.de [81.169.146.148])
   14.30 +	(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
   14.31 +	(No client certificate requested)
   14.32 +	by vmmaildmz1.informatik.tu-muenchen.de (Postfix) with ESMTPS id 2AEF61C2D9B
   14.33 +	for <krista@gnunet.org>; Mon, 12 Jun 2017 15:27:20 +0200 (CEST)
   14.34 +X-RZG-FWD-BY: pep.test.recip@kgrothoff.org
   14.35 +Received: from mailin.rzone.de ([unix socket])
   14.36 +	by mailin.rzone.de (RZmta 40.9) with LMTPA;
   14.37 +	Mon, 12 Jun 2017 15:27:00 +0200 (CEST)
   14.38 +Authentication-Results: strato.com 1;
   14.39 +	spf=none
   14.40 +		smtp.mailfrom="pep.test.alice@pep-project.org";
   14.41 +	dkim=none;
   14.42 +	domainkeys=none;
   14.43 +	dkim-adsp=none
   14.44 +		header.from="pep.test.alice@pep-project.org"
   14.45 +X-Strato-MessageType: email
   14.46 +X-RZG-CLASS-ID: mi00
   14.47 +Received-SPF: none
   14.48 +	client-ip=131.159.0.8;
   14.49 +	helo="mail-out1.informatik.tu-muenchen.de";
   14.50 +	envelope-from="pep.test.alice@pep-project.org";
   14.51 +	receiver=smtpin.rzone.de;
   14.52 +	identity=mailfrom;
   14.53 +Received: from mail-out1.informatik.tu-muenchen.de ([131.159.0.8])
   14.54 +	by smtpin.rzone.de (RZmta 40.9 OK)
   14.55 +	with ESMTPS id T01d0bt5CDR0XKI
   14.56 +	(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (curve secp521r1 with 521 ECDH bits, eq. 15360 bits RSA))
   14.57 +	(Client did not present a certificate)
   14.58 +	for <pep.test.recip@kgrothoff.org>;
   14.59 +	Mon, 12 Jun 2017 15:27:00 +0200 (CEST)
   14.60 +Received: from [192.168.178.22] (ip5f584089.dynamic.kabel-deutschland.de [95.88.64.137])
   14.61 +	by services.sec.in.tum.de (Postfix) with ESMTPSA id 1DF211013AE47
   14.62 +	for <pep.test.recip@kgrothoff.org>; Mon, 12 Jun 2017 15:26:55 +0200 (CEST)
   14.63 +Reply-To: krista@pep-project.org
   14.64 +To: pep.test.recip@kgrothoff.org
   14.65 +From: pEp Test Alice <pep.test.alice@pep-project.org>
   14.66 +Subject: pEp
   14.67 +Organization: pEp
   14.68 +Message-ID: <6205efbe-684d-9f21-8a2e-887d46a145e6@pep-project.org>
   14.69 +Date: Mon, 12 Jun 2017 15:26:54 +0200
   14.70 +User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101
   14.71 + Thunderbird/45.8.0
   14.72 +MIME-Version: 1.0
   14.73 +Content-Type: text/plain; charset=utf-8
   14.74 +Content-Transfer-Encoding: 7bit
   14.75 +
   14.76 +Subject: Unencrypted try...
   14.77 +
   14.78 +La la la...
    15.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    15.2 +++ b/test/test_mails/pEp_subject_pEp.eml	Fri Jun 16 15:34:34 2017 +0200
    15.3 @@ -0,0 +1,120 @@
    15.4 +Return-Path: <pep.test.alice@pep-project.org>
    15.5 +X-Original-To: krista@gnunet.org
    15.6 +Delivered-To: krista@gnunet.org
    15.7 +Received: from vmmailrelay1.informatik.tu-muenchen.de (mailrelay1.informatik.tu-muenchen.de [131.159.254.14])
    15.8 +	by sam.net.in.tum.de (Postfix) with ESMTP id 1C8731C00BC
    15.9 +	for <krista@gnunet.org>; Mon, 12 Jun 2017 15:28:42 +0200 (CEST)
   15.10 +Received: by vmmailrelay1.informatik.tu-muenchen.de (Postfix, from userid 109)
   15.11 +	id E78B01C0383; Mon, 12 Jun 2017 15:28:42 +0200 (CEST)
   15.12 +Received: from vmmailrelay1.informatik.tu-muenchen.de (localhost [127.0.0.1])
   15.13 +	by vmmailrelay1.informatik.tu-muenchen.de (Postfix) with ESMTP id C414C1C037C
   15.14 +	for <krista@gnunet.org>; Mon, 12 Jun 2017 15:28:42 +0200 (CEST)
   15.15 +Received: from vmmaildmz2.informatik.tu-muenchen.de (vmmaildmz2.informatik.tu-muenchen.de [131.159.0.88])
   15.16 +	by vmmailrelay1.informatik.tu-muenchen.de (Postfix) with ESMTP id AFA401C037A
   15.17 +	for <krista@gnunet.org>; Mon, 12 Jun 2017 15:28:42 +0200 (CEST)
   15.18 +Received: by vmmaildmz2.informatik.tu-muenchen.de (Postfix, from userid 109)
   15.19 +	id AE03E1C2AE1; Mon, 12 Jun 2017 15:28:42 +0200 (CEST)
   15.20 +X-Spam-Checker-Version: SpamAssassin 3.4.0-tuminfo_1 (2014-02-07) on
   15.21 +	vmmaildmz2.informatik.tu-muenchen.de
   15.22 +X-Spam-Level: 
   15.23 +X-Spam-Status: No, score=-2.9 required=7.0 tests=AWL,BAYES_00,
   15.24 +	ENCRYPTED_MESSAGE,RCVD_IN_DNSWL_LOW,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,
   15.25 +	TVD_RCVD_SPACE_BRACKET,UNPARSEABLE_RELAY autolearn=no autolearn_force=no
   15.26 +	version=3.4.0-tuminfo_1
   15.27 +Received: from vmmaildmz2.informatik.tu-muenchen.de (localhost [127.0.0.1])
   15.28 +	by vmmaildmz2.informatik.tu-muenchen.de (Postfix) with ESMTP id 441B11C2AE0
   15.29 +	for <krista@gnunet.org>; Mon, 12 Jun 2017 15:28:41 +0200 (CEST)
   15.30 +Received: from mi4-p00-ob.smtp.rzone.de (mi4-p00-ob.smtp.rzone.de [81.169.146.149])
   15.31 +	(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
   15.32 +	(No client certificate requested)
   15.33 +	by vmmaildmz2.informatik.tu-muenchen.de (Postfix) with ESMTPS id 3420F1C2ADF
   15.34 +	for <krista@gnunet.org>; Mon, 12 Jun 2017 15:28:41 +0200 (CEST)
   15.35 +X-RZG-FWD-BY: pep.test.recip@kgrothoff.org
   15.36 +Received: from mailin.rzone.de ([unix socket])
   15.37 +	by mailin.rzone.de (RZmta 40.9) with LMTPA;
   15.38 +	Mon, 12 Jun 2017 15:28:27 +0200 (CEST)
   15.39 +Authentication-Results: strato.com 1;
   15.40 +	spf=none
   15.41 +		smtp.mailfrom="pep.test.alice@pep-project.org";
   15.42 +	dkim=none;
   15.43 +	domainkeys=none;
   15.44 +	dkim-adsp=none
   15.45 +		header.from="pep.test.alice@pep-project.org"
   15.46 +X-Strato-MessageType: email
   15.47 +X-RZG-CLASS-ID: mi00
   15.48 +Received-SPF: none
   15.49 +	client-ip=131.159.0.8;
   15.50 +	helo="mail-out1.informatik.tu-muenchen.de";
   15.51 +	envelope-from="pep.test.alice@pep-project.org";
   15.52 +	receiver=smtpin.rzone.de;
   15.53 +	identity=mailfrom;
   15.54 +Received: from mail-out1.informatik.tu-muenchen.de ([131.159.0.8])
   15.55 +	by smtpin.rzone.de (RZmta 40.9 OK)
   15.56 +	with ESMTPS id R04db2t5CDSRaBk
   15.57 +	(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (curve secp521r1 with 521 ECDH bits, eq. 15360 bits RSA))
   15.58 +	(Client did not present a certificate)
   15.59 +	for <pep.test.recip@kgrothoff.org>;
   15.60 +	Mon, 12 Jun 2017 15:28:27 +0200 (CEST)
   15.61 +Received: from [192.168.178.22] (ip5f584089.dynamic.kabel-deutschland.de [95.88.64.137])
   15.62 +	by services.sec.in.tum.de (Postfix) with ESMTPSA id E7A551013AE47
   15.63 +	for <pep.test.recip@kgrothoff.org>; Mon, 12 Jun 2017 15:28:20 +0200 (CEST)
   15.64 +Reply-To: krista@pep-project.org
   15.65 +To: pep.test.recip@kgrothoff.org
   15.66 +From: pEp Test Alice <pep.test.alice@pep-project.org>
   15.67 +Subject: pEp
   15.68 +Organization: pEp
   15.69 +Message-ID: <1779982d-d48e-6d8c-2dcb-a2c337c496cb@pep-project.org>
   15.70 +Date: Mon, 12 Jun 2017 15:28:20 +0200
   15.71 +User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101
   15.72 + Thunderbird/45.8.0
   15.73 +MIME-Version: 1.0
   15.74 +Content-Type: multipart/encrypted;
   15.75 + protocol="application/pgp-encrypted";
   15.76 + boundary="xNhsqki3RTDSnTgiBbeAIkT3t5whv1bAM"
   15.77 +
   15.78 +This is an OpenPGP/MIME encrypted message (RFC 4880 and 3156)
   15.79 +--xNhsqki3RTDSnTgiBbeAIkT3t5whv1bAM
   15.80 +Content-Type: application/pgp-encrypted
   15.81 +Content-Description: PGP/MIME version identification
   15.82 +
   15.83 +Version: 1
   15.84 +
   15.85 +--xNhsqki3RTDSnTgiBbeAIkT3t5whv1bAM
   15.86 +Content-Type: application/octet-stream; name="encrypted.asc"
   15.87 +Content-Description: OpenPGP encrypted message
   15.88 +Content-Disposition: inline; filename="encrypted.asc"
   15.89 +
   15.90 +-----BEGIN PGP MESSAGE-----
   15.91 +
   15.92 +hQEMA4FHqvEumyRHAQgAjsyn0zCm0jHAp+SshDzqhMFNPuRc8VhDK9DpxiA1jLy8
   15.93 +bH2CKJIZEWApyfmwX5xLEXhfr0wb4BthHDXLzHCDqLSFo5FoavTwNL44kaX83yPv
   15.94 +Ts2WrvOcXGRpNLD94tvyDBqngtk3yKYaSkKKPok4Ou5gHrIDJaNZf/mybmPa0aTX
   15.95 +BEOxgAaRZJoPhgeVF8/twwiDv+ixFtdnPx9gGUXvgc5tPyrIkFkWtwrsoS2RmtJT
   15.96 +QqdsMmPbTFrsZ+d7qhdkcedeoKRg84SlXgtFpXkkbKHB/NU2ZQ2h2xTeUqdkFGN7
   15.97 +vBv17C+5jv8wzYlrlni9P1Mbc+dVBZTal9gYtBGwxIUBDANaAgXZcwg/TQEH/0vs
   15.98 +xQCJEdqbHKLz+xOmrpQEoFLdf2W9B7z2jGQe9F0K+gnPE3E+1wVf/IQgLj4YDXtN
   15.99 +Gkzc6J3UPBN9b1WSTPcJQ47hU5IXO/Sb39dU9X1s01JtCorTKmHlefosg6YaZ8CX
  15.100 +OhTkGYHqcJa9xE8kOMi4xnhP2Z3xaSkPSQvQ4WDWSapOwDkcM2a59Nwbu5PIGZpj
  15.101 +FM9WVLawN1/SVbaKOUEhFKdbl7UYW64JNWE6ZaLa0sfigt4QaXd5GrQcP2vmVVGz
  15.102 +WOuCaEb/HnxgiUvLQI2tCnW8aWluc6PnNk3HwLydvCL0tHSXPJno4Wbs1GzRJ4G7
  15.103 +CleoojpLytgTfIlZ7anS6QEAXXAuWGT3jddP4hcTnsfX40bQnIH1m49RX/4OHuMY
  15.104 +n7RyzSfyVghBQeA3fEQ48ep3WHuFHEn0Kn9rvcr/JZRO2NM4nBv1FjOIBTUMTlX+
  15.105 +hf0F/mYz1ycNg/rt6Taf9xcIP0IzRfQEa/dFqnEnBYCxGvRSr+EnMzg+ETT1p+aa
  15.106 +YAyjsbikhOqmle9G4LFUyblMmIlwFvAklAAlXTUJAEn3pc5mxH6vz0JitDpLdFDM
  15.107 +pW51y0HYgUNKS+9+qoVK2WXhkK/+hCbLzWVwzN5FlsIPucH+L+afquR6W5IKA8uZ
  15.108 +ixDPokbP1H608f/TobwX988nWby54kihoxaMvmEDbqT5Ivi5hHDhj5e79mxhUoZx
  15.109 +wb6fsm+d2vewDRhSIUF6/iioPaQt2AhmHNMBUYS5RrlOY8mc9BP8PwKym5SgkpE4
  15.110 +NKxoMjbQwUi3SHseA1hluMBieV+d7nYHqwBtSgMC/ax/AcDwmoLusXlf3OiBytdL
  15.111 +2v4OtPu6kt/QIlEABEDlqDK70wM6BChzWYrc5ErsixZ9NHunNshAjYsVeNtStOFV
  15.112 +TPGiy7a8rKB3xJhqzZhhLh9ly8JxVNfkb2LVXP/yzBS8LJpCluzyXZZpH2Q2a8lP
  15.113 +t71tjf/R/Uff2ZeF5yWO7zldyoEfx00yQWDyfmM6zHm17moXH5Mql2ZvTI0C0mk6
  15.114 +wDYNVEFe9YIXvxhdu5ym67ba8t5eV2t3c4zdhFy5YHZOC/KvpcZBLcvLY2jgVmNr
  15.115 +UYNqKpGK9m03jHRT2ZuG6F19QrxKqUIvgnYWsenecCvjjOIcWH7KqqNp+d4RyNRr
  15.116 +4VyoJk9nxzlUT/wKQJ6d5OtY5wytCCxpv8ihBFS3R2f0Sk2yXOgKE2sq0DEicWe+
  15.117 +x8Yqg3C/47hrtiUnEwwmp3VEYHfBTaaXMUkpmoRJ066u+8K2Jfo/pQnX6vcyUpvY
  15.118 +tJNqH+SMYKMXVBigU0ayWQFwVcoNEqFNVTm9K3MBQlIQiYqumBptG8rYhzF/eSUC
  15.119 +doDA15Ibgsk=
  15.120 +=P9h8
  15.121 +-----END PGP MESSAGE-----
  15.122 +
  15.123 +--xNhsqki3RTDSnTgiBbeAIkT3t5whv1bAM--
    16.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    16.2 +++ b/test/test_mails/pEp_unencrypted_pEp_subject.eml	Fri Jun 16 15:34:34 2017 +0200
    16.3 @@ -0,0 +1,73 @@
    16.4 +Return-Path: <pep.test.alice@pep-project.org>
    16.5 +X-Original-To: krista@gnunet.org
    16.6 +Delivered-To: krista@gnunet.org
    16.7 +Received: from vmmailrelay1.informatik.tu-muenchen.de (mailrelay1.informatik.tu-muenchen.de [131.159.254.14])
    16.8 +	by sam.net.in.tum.de (Postfix) with ESMTP id 39CD11C00BC
    16.9 +	for <krista@gnunet.org>; Mon, 12 Jun 2017 15:36:35 +0200 (CEST)
   16.10 +Received: by vmmailrelay1.informatik.tu-muenchen.de (Postfix, from userid 109)
   16.11 +	id 0CEA81C0390; Mon, 12 Jun 2017 15:36:36 +0200 (CEST)
   16.12 +Received: from vmmailrelay1.informatik.tu-muenchen.de (localhost [127.0.0.1])
   16.13 +	by vmmailrelay1.informatik.tu-muenchen.de (Postfix) with ESMTP id DE7711C0383
   16.14 +	for <krista@gnunet.org>; Mon, 12 Jun 2017 15:36:35 +0200 (CEST)
   16.15 +Received: from vmmaildmz1.informatik.tu-muenchen.de (vmmaildmz1.informatik.tu-muenchen.de [131.159.0.87])
   16.16 +	by vmmailrelay1.informatik.tu-muenchen.de (Postfix) with ESMTP id D3D7A1C037A
   16.17 +	for <krista@gnunet.org>; Mon, 12 Jun 2017 15:36:35 +0200 (CEST)
   16.18 +Received: by vmmaildmz1.informatik.tu-muenchen.de (Postfix, from userid 109)
   16.19 +	id D22771C2D9E; Mon, 12 Jun 2017 15:36:35 +0200 (CEST)
   16.20 +X-Spam-Checker-Version: SpamAssassin 3.4.0-tuminfo_1 (2014-02-07) on
   16.21 +	vmmaildmz1.informatik.tu-muenchen.de
   16.22 +X-Spam-Level: 
   16.23 +X-Spam-Status: No, score=-2.9 required=7.0 tests=AWL,BAYES_00,
   16.24 +	RCVD_IN_DNSWL_LOW,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,TVD_RCVD_SPACE_BRACKET,
   16.25 +	UNPARSEABLE_RELAY autolearn=no autolearn_force=no version=3.4.0-tuminfo_1
   16.26 +Received: from vmmaildmz1.informatik.tu-muenchen.de (localhost [127.0.0.1])
   16.27 +	by vmmaildmz1.informatik.tu-muenchen.de (Postfix) with ESMTP id 615241C2D9E
   16.28 +	for <krista@gnunet.org>; Mon, 12 Jun 2017 15:36:34 +0200 (CEST)
   16.29 +Received: from mi4-p00-ob.smtp.rzone.de (mi4-p00-ob.smtp.rzone.de [81.169.146.146])
   16.30 +	(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
   16.31 +	(No client certificate requested)
   16.32 +	by vmmaildmz1.informatik.tu-muenchen.de (Postfix) with ESMTPS id 50C3E1C2D9B
   16.33 +	for <krista@gnunet.org>; Mon, 12 Jun 2017 15:36:34 +0200 (CEST)
   16.34 +X-RZG-FWD-BY: pep.test.recip@kgrothoff.org
   16.35 +Received: from mailin.rzone.de ([unix socket])
   16.36 +	by mailin.rzone.de (RZmta 40.9) with LMTPA;
   16.37 +	Mon, 12 Jun 2017 15:36:18 +0200 (CEST)
   16.38 +Authentication-Results: strato.com 1;
   16.39 +	spf=none
   16.40 +		smtp.mailfrom="pep.test.alice@pep-project.org";
   16.41 +	dkim=none;
   16.42 +	domainkeys=none;
   16.43 +	dkim-adsp=none
   16.44 +		header.from="pep.test.alice@pep-project.org"
   16.45 +X-Strato-MessageType: email
   16.46 +X-RZG-CLASS-ID: mi00
   16.47 +Received-SPF: none
   16.48 +	client-ip=131.159.0.8;
   16.49 +	helo="mail-out1.informatik.tu-muenchen.de";
   16.50 +	envelope-from="pep.test.alice@pep-project.org";
   16.51 +	receiver=smtpin.rzone.de;
   16.52 +	identity=mailfrom;
   16.53 +Received: from mail-out1.informatik.tu-muenchen.de ([131.159.0.8])
   16.54 +	by smtpin.rzone.de (RZmta 40.9 OK)
   16.55 +	with ESMTPS id p044e9t5CDaIXCz
   16.56 +	(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (curve secp521r1 with 521 ECDH bits, eq. 15360 bits RSA))
   16.57 +	(Client did not present a certificate)
   16.58 +	for <pep.test.recip@kgrothoff.org>;
   16.59 +	Mon, 12 Jun 2017 15:36:18 +0200 (CEST)
   16.60 +Received: from [192.168.178.22] (ip5f584089.dynamic.kabel-deutschland.de [95.88.64.137])
   16.61 +	by services.sec.in.tum.de (Postfix) with ESMTPSA id D40EB1013AE4F
   16.62 +	for <pep.test.recip@kgrothoff.org>; Mon, 12 Jun 2017 15:36:12 +0200 (CEST)
   16.63 +To: pep.test.recip@kgrothoff.org
   16.64 +Reply-To: krista@pep-project.org
   16.65 +From: pEp Test Alice <pep.test.alice@pep-project.org>
   16.66 +Subject: pEp
   16.67 +Organization: pEp
   16.68 +Message-ID: <7b251ab6-f1c0-163b-0891-574d4eb095e1@pep-project.org>
   16.69 +Date: Mon, 12 Jun 2017 15:36:12 +0200
   16.70 +User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101
   16.71 + Thunderbird/45.8.0
   16.72 +MIME-Version: 1.0
   16.73 +Content-Type: text/plain; charset=utf-8
   16.74 +Content-Transfer-Encoding: 7bit
   16.75 +
   16.76 +Unencrypted variable where pEp is the actual subject.
    17.1 --- a/test/trustwords_test.cc	Mon Jun 12 09:30:39 2017 +0200
    17.2 +++ b/test/trustwords_test.cc	Fri Jun 16 15:34:34 2017 +0200
    17.3 @@ -14,6 +14,7 @@
    17.4      cout << "\n*** get_trustwords test ***\n\n";
    17.5  
    17.6      PEP_SESSION session = nullptr;
    17.7 +    PEP_STATUS status;
    17.8      
    17.9      cout << "calling init()\n";
   17.10      PEP_STATUS status1 = init(&session);
   17.11 @@ -55,29 +56,33 @@
   17.12      assert(words1);
   17.13      cout << words1 << "\n";
   17.14  
   17.15 +    free(words1);
   17.16 +    words1 = nullptr;
   17.17 +    
   17.18      cout << "\nfinding German trustwords for " << fingerprint2 << "...\n";
   17.19      trustwords(session, fingerprint2.c_str(), "de", &words2, &wsize2, 5);
   17.20      assert(words2);
   17.21      cout << words2 << "\n";
   17.22  
   17.23 +    free(words2);
   17.24 +    words1 = nullptr;
   17.25 +
   17.26      cout << "\nfinding German trustwords for " << identity1->address << " and " << identity2->address << "...\n";
   17.27      get_trustwords(session, identity1, identity2, "de", &full_wordlist, &wsize_full, false);
   17.28      assert(full_wordlist);
   17.29      cout << full_wordlist << "\n";
   17.30  
   17.31 -    cout << "\nfinding Englis trustwords for " << identity1->address << " and " << identity2->address << "... with spaces\n";
   17.32 +    free(full_wordlist);
   17.33 +    full_wordlist = nullptr;
   17.34 +
   17.35 +    cout << "\nfinding English trustwords for " << identity1->address << " and " << identity2->address << "... with spaces\n";
   17.36      get_trustwords(session, identity1, identity2_with_spaces, "en", &full_wordlist, &wsize_full, false);
   17.37      assert(full_wordlist);
   17.38      cout << full_wordlist << "\n";
   17.39 +
   17.40 +    free(full_wordlist);
   17.41 +    full_wordlist = nullptr;
   17.42      
   17.43 -    
   17.44 -    pEp_free(words1);
   17.45 -    words1 = nullptr;
   17.46 -    pEp_free(words2);
   17.47 -    words2 = nullptr;
   17.48 -    pEp_free(full_wordlist);
   17.49 -    full_wordlist = nullptr;
   17.50 -
   17.51      cout << "\nTest 2: fpr1 == fpr1, short" << endl;
   17.52      
   17.53      cout << "\nfinding French trustwords for " << fingerprint2 << "...\n";
   17.54 @@ -86,14 +91,14 @@
   17.55      cout << words1 << "\n";
   17.56          
   17.57      cout << "\nfinding French trustwords for " << identity2->address << " and " << identity2->address << "...\n";
   17.58 -    get_trustwords(session, identity2, identity2, "fr", &full_wordlist, &wsize_full, false);
   17.59 -    assert(full_wordlist);
   17.60 -    cout << full_wordlist << "\n";
   17.61 +    status = get_trustwords(session, identity2, identity2, "fr", &full_wordlist, &wsize_full, false);
   17.62 +    assert(status == PEP_TRUSTWORDS_DUPLICATE_FPR);
   17.63 +    cout << "Discovered duplicate fprs as desired" << endl;
   17.64  
   17.65      cout << "\nfinding English trustwords for " << identity2->address << " and " << identity2->address << "... with spaces\n";
   17.66      get_trustwords(session, identity2, identity2_with_spaces, "en", &full_wordlist, &wsize_full, false);
   17.67 -    assert(full_wordlist);
   17.68 -    cout << full_wordlist << "\n";
   17.69 +    assert(status == PEP_TRUSTWORDS_DUPLICATE_FPR);
   17.70 +    cout << "Discovered duplicate fprs as desired" << endl;
   17.71  
   17.72      pEp_free(words1);
   17.73      words1 = nullptr;
   17.74 @@ -112,13 +117,13 @@
   17.75      assert(words2);
   17.76      cout << words2 << "\n";
   17.77      
   17.78 -    cout << "\nfinding English trustwords for " << identity2->address << " and " << identity2->address << "...\n";
   17.79 +    cout << "\nfinding English trustwords for " << identity2->address << " and " << identity1->address << "...\n";
   17.80      get_trustwords(session, identity2, identity1, "en", &full_wordlist, &wsize_full, true);
   17.81      assert(full_wordlist);
   17.82      cout << full_wordlist << "\n";
   17.83      
   17.84 -    cout << "\nfinding English trustwords for " << identity2->address << " and " << identity2->address << "... with spaces\n";
   17.85 -    get_trustwords(session, identity2_with_spaces, identity1, "en", &full_wordlist, &wsize_full, false);
   17.86 +    cout << "\nfinding English trustwords for " << identity2->address << " and " << identity1->address << "... with spaces\n";
   17.87 +    get_trustwords(session, identity2_with_spaces, identity1, "en", &full_wordlist, &wsize_full, true);
   17.88      assert(full_wordlist);
   17.89      cout << full_wordlist << "\n";
   17.90      
   17.91 @@ -199,18 +204,18 @@
   17.92      pEp_free(full_wordlist);
   17.93      full_wordlist = nullptr;
   17.94  
   17.95 -    cout << "\nTest 6: fpr2 is too short" << endl;
   17.96 +    cout << "\nTest 6: fpr2 is shorter" << endl;
   17.97      
   17.98      pEp_identity* identity6 = new_identity(
   17.99          "nobody4@kgrothoff.org",
  17.100 -        "01F932086185C15917B72D30571AFBCA5493553",
  17.101 +        "F1F932086185c15917B72D30571AFBCA5493553",
  17.102          "blargh",
  17.103          "Krista Grothoff");
  17.104      
  17.105      cout << "\nfinding Turkish trustwords for " << identity5->address << " and " << identity6->address << "...\n";
  17.106      PEP_STATUS status6 = get_trustwords(session, identity5, identity6, "tr", &full_wordlist, &wsize_full, false);
  17.107 -    assert(status6 == PEP_TRUSTWORDS_FPR_WRONG_LENGTH);
  17.108 -    cout << "Bad fpr length correctly recognised." << "\n";
  17.109 +    assert(status6 == PEP_STATUS_OK);
  17.110 +    cout << full_wordlist << endl;
  17.111      
  17.112      pEp_identity* identity7 = new_identity(
  17.113          "nobody5@kgrothoff.org",
  17.114 @@ -238,4 +243,3 @@
  17.115      release(session);
  17.116      return 0;
  17.117  }
  17.118 -