Attach own key on unencrypted message with encrypt_message() when given enc_format is PEP_enc_none
authorEdouard Tisserant
Wed, 27 Apr 2016 19:44:53 +0200
changeset 550df0ef2b26196
parent 546 7371c6c92133
child 551 d38e02d535de
Attach own key on unencrypted message with encrypt_message() when given enc_format is PEP_enc_none
src/message_api.c
     1.1 --- a/src/message_api.c	Wed Apr 27 01:10:30 2016 +0200
     1.2 +++ b/src/message_api.c	Wed Apr 27 19:44:53 2016 +0200
     1.3 @@ -877,9 +877,6 @@
     1.4      assert(session);
     1.5      assert(msg);
     1.6  
     1.7 -    if (msg->dir == PEP_dir_incoming)
     1.8 -        return;
     1.9 -
    1.10      assert(msg->from && msg->from->fpr);
    1.11      if (msg->from == NULL || msg->from->fpr == NULL)
    1.12          return;
    1.13 @@ -932,11 +929,13 @@
    1.14      assert(session);
    1.15      assert(src);
    1.16      assert(dst);
    1.17 -    assert(enc_format != PEP_enc_none);
    1.18  
    1.19 -    if (!(session && src && dst && enc_format != PEP_enc_none))
    1.20 +    if (!(session && src && dst))
    1.21          return PEP_ILLEGAL_VALUE;
    1.22  
    1.23 +    if (src->dir == PEP_dir_incoming)
    1.24 +        return PEP_ILLEGAL_VALUE;
    1.25 +    
    1.26      determine_encryption_format(src);
    1.27      if (src->enc_format != PEP_enc_none)
    1.28          return PEP_ILLEGAL_VALUE;
    1.29 @@ -946,7 +945,13 @@
    1.30      status = myself(session, src->from);
    1.31      if (status != PEP_STATUS_OK)
    1.32          goto pep_error;
    1.33 -
    1.34 +    
    1.35 +    if (enc_format == PEP_enc_none)
    1.36 +    {
    1.37 +        attach_own_key(session, src);
    1.38 +        return PEP_UNENCRYPTED;
    1.39 +    }
    1.40 +    
    1.41      keys = new_stringlist(src->from->fpr);
    1.42      if (keys == NULL)
    1.43          goto enomem;