re-add inline PGP sync
authorVolker Birk <vb@pep-project.org>
Wed, 15 May 2019 13:07:44 +0200
branchsync
changeset 367807aceb41d96e
parent 3676 6902ea2166cf
child 3679 0077eaafde26
re-add inline PGP
src/etpan_mime.c
src/message.h
src/message_api.c
     1.1 --- a/src/etpan_mime.c	Tue May 14 18:11:18 2019 +0200
     1.2 +++ b/src/etpan_mime.c	Wed May 15 13:07:44 2019 +0200
     1.3 @@ -1853,7 +1853,7 @@
     1.4              status = mime_encode_message_plain(msg, omit_fields, &mime, transport_encode);
     1.5              break;
     1.6  
     1.7 -        case PEP_enc_pieces:
     1.8 +        case PEP_enc_inline:
     1.9              status = mime_encode_message_plain(msg, omit_fields, &mime, transport_encode);
    1.10              break;
    1.11  
     2.1 --- a/src/message.h	Tue May 14 18:11:18 2019 +0200
     2.2 +++ b/src/message.h	Wed May 15 13:07:44 2019 +0200
     2.3 @@ -30,7 +30,8 @@
     2.4  
     2.5  typedef enum _PEP_enc_format {
     2.6      PEP_enc_none = 0,                       // message is not encrypted
     2.7 -    PEP_enc_pieces,                         // inline PGP + PGP extensions
     2.8 +//  PEP_enc_pieces = 1,                     // inline PGP + PGP extensions, was removed
     2.9 +    PEP_enc_inline = 1,                     // still there
    2.10      PEP_enc_S_MIME,                         // RFC5751
    2.11      PEP_enc_PGP_MIME,                       // RFC3156
    2.12      PEP_enc_PEP,                            // pEp encryption format
     3.1 --- a/src/message_api.c	Tue May 14 18:11:18 2019 +0200
     3.2 +++ b/src/message_api.c	Wed May 15 13:07:44 2019 +0200
     3.3 @@ -971,6 +971,32 @@
     3.4      return NULL;    
     3.5  }
     3.6  
     3.7 +static PEP_STATUS encrypt_PGP_inline(
     3.8 +        PEP_SESSION session,
     3.9 +        const message *src,
    3.10 +        stringlist_t *keys,
    3.11 +        message *dst
    3.12 +    )
    3.13 +{
    3.14 +    char *ctext = NULL;
    3.15 +    size_t csize = 0;
    3.16 +
    3.17 +    PEP_STATUS status = encrypt_and_sign(session, keys, src->longmsg,
    3.18 +            strlen(src->longmsg), &ctext, &csize);
    3.19 +    if (status)
    3.20 +        return status;
    3.21 +
    3.22 +    if (src->shortmsg) {
    3.23 +        dst->shortmsg = strdup(src->shortmsg);
    3.24 +        assert(dst->shortmsg);
    3.25 +        if (!dst->shortmsg)
    3.26 +            return PEP_OUT_OF_MEMORY;
    3.27 +    }
    3.28 +
    3.29 +    dst->longmsg = ctext;
    3.30 +    return PEP_STATUS_OK;
    3.31 +}
    3.32 +
    3.33  static PEP_STATUS encrypt_PGP_MIME(
    3.34      PEP_SESSION session,
    3.35      const message *src,
    3.36 @@ -1575,7 +1601,7 @@
    3.37      assert(msg);
    3.38  
    3.39      if (is_PGP_message_text(msg->longmsg)) {
    3.40 -        msg->enc_format = PEP_enc_pieces;
    3.41 +        msg->enc_format = PEP_enc_inline;
    3.42          return PEP_crypt_OpenPGP;
    3.43      }
    3.44      else if (msg->attachments && msg->attachments->next &&
    3.45 @@ -1914,9 +1940,9 @@
    3.46                  status = encrypt_PGP_MIME(session, _src, keys, msg, flags);
    3.47                  break;
    3.48  
    3.49 -            /* case PEP_enc_PEP:
    3.50 -                // TODO: implement
    3.51 -                NOT_IMPLEMENTED */
    3.52 +            case PEP_enc_inline:
    3.53 +                status = encrypt_PGP_inline(session, _src, keys, msg);
    3.54 +                break;
    3.55  
    3.56              default:
    3.57                  assert(0);
    3.58 @@ -2249,6 +2275,10 @@
    3.59                  _cleanup_src(src, false);
    3.60              break;
    3.61  
    3.62 +        case PEP_enc_inline:
    3.63 +            status = encrypt_PGP_inline(session, _src, keys, msg);
    3.64 +            break;
    3.65 +
    3.66          default:
    3.67              assert(0);
    3.68              status = PEP_ILLEGAL_VALUE;
    3.69 @@ -2589,7 +2619,7 @@
    3.70      
    3.71      switch (src->enc_format) {
    3.72          case PEP_enc_PGP_MIME:
    3.73 -        case PEP_enc_pieces:
    3.74 +        case PEP_enc_inline:
    3.75          case PEP_enc_PGP_MIME_Outlook1:
    3.76  //        case PEP_enc_none: // FIXME - this is wrong
    3.77  
    3.78 @@ -2681,7 +2711,7 @@
    3.79              *text_size = src->attachments->size;
    3.80              break;
    3.81  
    3.82 -        case PEP_enc_pieces:
    3.83 +        case PEP_enc_inline:
    3.84              *crypto_text = src->longmsg;
    3.85              *text_size = strlen(*crypto_text);
    3.86              break;
    3.87 @@ -3458,7 +3488,7 @@
    3.88                  }
    3.89                  break;
    3.90  
    3.91 -            case PEP_enc_pieces:
    3.92 +            case PEP_enc_inline:
    3.93                  status = PEP_STATUS_OK;
    3.94                  
    3.95                  _decrypt_in_pieces_status = _decrypt_in_pieces(session, src, &msg, ptext, psize);