ENGINE-416: added argument for extra key fprs to encrypt_message_for_self and MIME_encrypt_message_for_self
authorKrista Bennett <krista@pep-project.org>
Thu, 05 Apr 2018 14:13:20 +0200
changeset 2588858909bcf85b
parent 2587 b7eb979f90f5
child 2589 3c5db90b50e8
ENGINE-416: added argument for extra key fprs to encrypt_message_for_self and MIME_encrypt_message_for_self
src/message_api.c
src/message_api.h
test/encrypt_for_identity_test.cc
     1.1 --- a/src/message_api.c	Thu Mar 29 12:16:58 2018 +0200
     1.2 +++ b/src/message_api.c	Thu Apr 05 14:13:20 2018 +0200
     1.3 @@ -1816,6 +1816,7 @@
     1.4          PEP_SESSION session,
     1.5          pEp_identity* target_id,
     1.6          message *src,
     1.7 +        stringlist_t* extra,
     1.8          message **dst,
     1.9          PEP_enc_format enc_format,
    1.10          PEP_encrypt_flags_t flags
    1.11 @@ -1868,6 +1869,14 @@
    1.12   
    1.13      keys = new_stringlist(target_fpr);
    1.14      
    1.15 +    stringlist_t *_k = keys;
    1.16 +
    1.17 +    if (extra) {
    1.18 +        _k = stringlist_append(_k, extra);
    1.19 +        if (_k == NULL)
    1.20 +            goto enomem;
    1.21 +    }
    1.22 +
    1.23      /* KG: did we ever do this??? */
    1.24      if (!(flags & PEP_encrypt_flag_force_no_attached_key))
    1.25          _attach_key(session, target_fpr, src);
    1.26 @@ -3729,6 +3738,7 @@
    1.27      pEp_identity* target_id,
    1.28      const char *mimetext,
    1.29      size_t size,
    1.30 +    stringlist_t* extra,
    1.31      char** mime_ciphertext,
    1.32      PEP_enc_format enc_format,
    1.33      PEP_encrypt_flags_t flags
    1.34 @@ -3747,6 +3757,7 @@
    1.35      status = encrypt_message_for_self(session,
    1.36                                        target_id,
    1.37                                        tmp_msg,
    1.38 +                                      extra,
    1.39                                        &enc_msg,
    1.40                                        enc_format,
    1.41                                        flags);
     2.1 --- a/src/message_api.h	Thu Mar 29 12:16:58 2018 +0200
     2.2 +++ b/src/message_api.h	Thu Apr 05 14:13:20 2018 +0200
     2.3 @@ -82,6 +82,7 @@
     2.4  //      session (in)        session handle
     2.5  //      target_id (in)      self identity this message should be encrypted for
     2.6  //      src (in)            message to encrypt
     2.7 +//      extra (in)          extra keys for encryption
     2.8  //      dst (out)           pointer to new encrypted message or NULL on failure
     2.9  //      enc_format (in)     encrypted format
    2.10  //      flags (in)          flags to set special encryption features
    2.11 @@ -104,6 +105,7 @@
    2.12          PEP_SESSION session,
    2.13          pEp_identity* target_id,
    2.14          message *src,
    2.15 +        stringlist_t* extra,
    2.16          message **dst,
    2.17          PEP_enc_format enc_format,
    2.18          PEP_encrypt_flags_t flags
    2.19 @@ -152,6 +154,7 @@
    2.20  //      target_id (in)          self identity this message should be encrypted for
    2.21  //      mimetext (in)           MIME encoded text to encrypt
    2.22  //      size (in)               size of input mime text
    2.23 +//      extra (in)              extra keys for encryption
    2.24  //      mime_ciphertext (out)   encrypted, encoded message
    2.25  //      enc_format (in)         encrypted format
    2.26  //      flags (in)              flags to set special encryption features
    2.27 @@ -173,6 +176,7 @@
    2.28      pEp_identity* target_id,
    2.29      const char *mimetext,
    2.30      size_t size,
    2.31 +    stringlist_t* extra,
    2.32      char** mime_ciphertext,
    2.33      PEP_enc_format enc_format,
    2.34      PEP_encrypt_flags_t flags
     3.1 --- a/test/encrypt_for_identity_test.cc	Thu Mar 29 12:16:58 2018 +0200
     3.2 +++ b/test/encrypt_for_identity_test.cc	Thu Apr 05 14:13:20 2018 +0200
     3.3 @@ -66,7 +66,7 @@
     3.4      cout << "encrypting message as MIME multipart…\n";
     3.5      message* encrypted_msg = nullptr;
     3.6      cout << "calling encrypt_message_for_identity()\n";
     3.7 -    status = encrypt_message_for_self(session, alice, outgoing_message, &encrypted_msg, PEP_enc_PGP_MIME, PEP_encrypt_flag_force_unsigned | PEP_encrypt_flag_force_no_attached_key);
     3.8 +    status = encrypt_message_for_self(session, alice, outgoing_message, NULL, &encrypted_msg, PEP_enc_PGP_MIME, PEP_encrypt_flag_force_unsigned | PEP_encrypt_flag_force_no_attached_key);
     3.9      cout << "encrypt_message() returns " << std::hex << status << '.' << endl;
    3.10      assert(status == PEP_STATUS_OK);
    3.11      assert(encrypted_msg);
    3.12 @@ -142,6 +142,7 @@
    3.13      cout << "Calling MIME_encrypt_message_for_self" << endl;
    3.14      status = MIME_encrypt_message_for_self(session, alice, mimetext.c_str(),
    3.15                                             mimetext.size(), 
    3.16 +                                           NULL,
    3.17                                             &encrypted_mimetext, 
    3.18                                             PEP_enc_PGP_MIME, 
    3.19                                             PEP_encrypt_flag_force_unsigned | PEP_encrypt_flag_force_no_attached_key);