src/aux_mime_msg.h
author Krista 'DarthMama' Bennett <krista@pep.foundation>
Thu, 04 Jun 2020 11:18:45 +0200
changeset 4729 3df9a2a67597
parent 3630 21530e16b1ed
child 4792 7056435ab9e7
child 5246 67016f508d40
permissions -rw-r--r--
forgot test files
     1 // This file is under GNU General Public License 3.0
     2 // see LICENSE.txt
     3 
     4 #pragma once
     5 
     6 #ifdef ENIGMAIL_MAY_USE_THIS
     7 
     8 #include "pEpEngine.h"
     9 #include "keymanagement.h"
    10 #include "message.h"
    11 #include "cryptotech.h"
    12 
    13 #ifdef __cplusplus
    14 extern "C" {
    15 #endif
    16 
    17 // MIME_encrypt_message() - encrypt a MIME message, with MIME output
    18 //
    19 //  parameters:
    20 //      session (in)            session handle
    21 //      mimetext (in)           MIME encoded text to encrypt
    22 //      size (in)               size of input mime text
    23 //      extra (in)              extra keys for encryption
    24 //      mime_ciphertext (out)   encrypted, encoded message
    25 //      enc_format (in)         encrypted format
    26 //      flags (in)              flags to set special encryption features
    27 //
    28 //  return value:
    29 //      PEP_STATUS_OK           if everything worked
    30 //      PEP_BUFFER_TOO_SMALL    if encoded message size is too big to handle
    31 //      PEP_CANNOT_CREATE_TEMP_FILE
    32 //                              if there are issues with temp files; in
    33 //                              this case errno will contain the underlying
    34 //                              error
    35 //      PEP_OUT_OF_MEMORY       if not enough memory could be allocated
    36 //
    37 //  caveat:
    38 //      the encrypted, encoded mime text will go to the ownership of the caller; mimetext
    39 //      will remain in the ownership of the caller
    40 DYNAMIC_API PEP_STATUS MIME_encrypt_message(
    41     PEP_SESSION session,
    42     const char *mimetext,
    43     size_t size,
    44     stringlist_t* extra,
    45     char** mime_ciphertext,
    46     PEP_enc_format enc_format,
    47     PEP_encrypt_flags_t flags
    48 );
    49 
    50 
    51 // MIME_encrypt_message_for_self() - encrypt MIME message for user's identity only,
    52 //                              ignoring recipients and other identities from
    53 //                              the message, with MIME output
    54 //  parameters:
    55 //      session (in)            session handle
    56 //      target_id (in)          self identity this message should be encrypted for
    57 //      mimetext (in)           MIME encoded text to encrypt
    58 //      size (in)               size of input mime text
    59 //      extra (in)              extra keys for encryption
    60 //      mime_ciphertext (out)   encrypted, encoded message
    61 //      enc_format (in)         encrypted format
    62 //      flags (in)              flags to set special encryption features
    63 //
    64 //  return value:
    65 //      PEP_STATUS_OK           if everything worked
    66 //      PEP_BUFFER_TOO_SMALL    if encoded message size is too big to handle
    67 //      PEP_CANNOT_CREATE_TEMP_FILE
    68 //                              if there are issues with temp files; in
    69 //                              this case errno will contain the underlying
    70 //                              error
    71 //      PEP_OUT_OF_MEMORY       if not enough memory could be allocated
    72 //
    73 //  caveat:
    74 //      the encrypted, encoded mime text will go to the ownership of the caller; mimetext
    75 //      will remain in the ownership of the caller
    76 DYNAMIC_API PEP_STATUS MIME_encrypt_message_for_self(
    77     PEP_SESSION session,
    78     pEp_identity* target_id,
    79     const char *mimetext,
    80     size_t size,
    81     stringlist_t* extra,
    82     char** mime_ciphertext,
    83     PEP_enc_format enc_format,
    84     PEP_encrypt_flags_t flags
    85 );
    86 
    87 
    88 
    89 // MIME_decrypt_message() - decrypt a MIME message, with MIME output
    90 //
    91 //  parameters:
    92 //      session (in)            session handle
    93 //      mimetext (in)           MIME encoded text to decrypt
    94 //      size (in)               size of mime text to decode (in order to decrypt)
    95 //      mime_plaintext (out)    decrypted, encoded message
    96 //      keylist (inout)         in: stringlist with additional keyids for reencryption if needed
    97 //                                  (will be freed and replaced with output keylist)
    98 //                              out: stringlist with keyids
    99 //      rating (out)            rating for the message
   100 //      flags (inout)           flags to signal special decryption features (see below)
   101 //      modified_src (out)      modified source string, if decrypt had reason to change it
   102 //
   103 //  return value:
   104 //      decrypt status          if everything worked with MIME encode/decode, 
   105 //                              the status of the decryption is returned 
   106 //                              (PEP_STATUS_OK or decryption error status)
   107 //      PEP_BUFFER_TOO_SMALL    if encoded message size is too big to handle
   108 //      PEP_CANNOT_CREATE_TEMP_FILE
   109 //                              if there are issues with temp files; in
   110 //                              this case errno will contain the underlying
   111 //                              error
   112 //      PEP_OUT_OF_MEMORY       if not enough memory could be allocated
   113 //
   114 //  flag values:
   115 //      in:
   116 //          PEP_decrypt_flag_untrusted_server
   117 //              used to signal that decrypt function should engage in behaviour
   118 //              specified for when the server storing the source is untrusted.
   119 //      out:
   120 //          PEP_decrypt_flag_own_private_key
   121 //              private key was imported for one of our addresses (NOT trusted
   122 //              or set to be used - handshake/trust is required for that)
   123 //          PEP_decrypt_flag_src_modified
   124 //              indicates that the modified_src field should contain a modified
   125 //              version of the source, at the moment always as a result of the
   126 //              input flags. 
   127 //          PEP_decrypt_flag_consume
   128 //              used by sync 
   129 //          PEP_decrypt_flag_ignore
   130 //              used by sync 
   131 // 
   132 //  caveat:
   133 //      the decrypted, encoded mime text will go to the ownership of the caller; mimetext
   134 //      will remain in the ownership of the caller
   135 DYNAMIC_API PEP_STATUS MIME_decrypt_message(
   136     PEP_SESSION session,
   137     const char *mimetext,
   138     size_t size,
   139     char** mime_plaintext,
   140     stringlist_t **keylist,
   141     PEP_rating *rating,
   142     PEP_decrypt_flags_t *flags,
   143     char** modified_src
   144 );
   145 
   146 #ifdef __cplusplus
   147 }
   148 #endif
   149 
   150 #endif