src/message_api.c
branchENGINE-552
changeset 3707 5e780ba44426
parent 3675 c724fa64eb56
parent 3678 07aceb41d96e
child 3708 42c376229484
     1.1 --- a/src/message_api.c	Tue May 14 08:08:59 2019 +0200
     1.2 +++ b/src/message_api.c	Wed May 15 14:35:45 2019 +0200
     1.3 @@ -977,6 +977,32 @@
     1.4      return NULL;    
     1.5  }
     1.6  
     1.7 +static PEP_STATUS encrypt_PGP_inline(
     1.8 +        PEP_SESSION session,
     1.9 +        const message *src,
    1.10 +        stringlist_t *keys,
    1.11 +        message *dst
    1.12 +    )
    1.13 +{
    1.14 +    char *ctext = NULL;
    1.15 +    size_t csize = 0;
    1.16 +
    1.17 +    PEP_STATUS status = encrypt_and_sign(session, keys, src->longmsg,
    1.18 +            strlen(src->longmsg), &ctext, &csize);
    1.19 +    if (status)
    1.20 +        return status;
    1.21 +
    1.22 +    if (src->shortmsg) {
    1.23 +        dst->shortmsg = strdup(src->shortmsg);
    1.24 +        assert(dst->shortmsg);
    1.25 +        if (!dst->shortmsg)
    1.26 +            return PEP_OUT_OF_MEMORY;
    1.27 +    }
    1.28 +
    1.29 +    dst->longmsg = ctext;
    1.30 +    return PEP_STATUS_OK;
    1.31 +}
    1.32 +
    1.33  static PEP_STATUS encrypt_PGP_MIME(
    1.34      PEP_SESSION session,
    1.35      const message *src,
    1.36 @@ -1581,7 +1607,7 @@
    1.37      assert(msg);
    1.38  
    1.39      if (is_PGP_message_text(msg->longmsg)) {
    1.40 -        msg->enc_format = PEP_enc_pieces;
    1.41 +        msg->enc_format = PEP_enc_inline;
    1.42          return PEP_crypt_OpenPGP;
    1.43      }
    1.44      else if (msg->attachments && msg->attachments->next &&
    1.45 @@ -1923,9 +1949,9 @@
    1.46                  status = encrypt_PGP_MIME(session, _src, keys, msg, flags);
    1.47                  break;
    1.48  
    1.49 -            /* case PEP_enc_PEP:
    1.50 -                // TODO: implement
    1.51 -                NOT_IMPLEMENTED */
    1.52 +            case PEP_enc_inline:
    1.53 +                status = encrypt_PGP_inline(session, _src, keys, msg);
    1.54 +                break;
    1.55  
    1.56              default:
    1.57                  assert(0);
    1.58 @@ -2258,6 +2284,10 @@
    1.59                  _cleanup_src(src, false);
    1.60              break;
    1.61  
    1.62 +        case PEP_enc_inline:
    1.63 +            status = encrypt_PGP_inline(session, _src, keys, msg);
    1.64 +            break;
    1.65 +
    1.66          default:
    1.67              assert(0);
    1.68              status = PEP_ILLEGAL_VALUE;
    1.69 @@ -2598,7 +2628,7 @@
    1.70      
    1.71      switch (src->enc_format) {
    1.72          case PEP_enc_PGP_MIME:
    1.73 -        case PEP_enc_pieces:
    1.74 +        case PEP_enc_inline:
    1.75          case PEP_enc_PGP_MIME_Outlook1:
    1.76  //        case PEP_enc_none: // FIXME - this is wrong
    1.77  
    1.78 @@ -2690,7 +2720,7 @@
    1.79              *text_size = src->attachments->size;
    1.80              break;
    1.81  
    1.82 -        case PEP_enc_pieces:
    1.83 +        case PEP_enc_inline:
    1.84              *crypto_text = src->longmsg;
    1.85              *text_size = strlen(*crypto_text);
    1.86              break;
    1.87 @@ -3512,7 +3542,7 @@
    1.88                  }
    1.89                  break;
    1.90  
    1.91 -            case PEP_enc_pieces:
    1.92 +            case PEP_enc_inline:
    1.93                  status = PEP_STATUS_OK;
    1.94                  
    1.95                  _decrypt_in_pieces_status = _decrypt_in_pieces(session, src, &msg, ptext, psize);