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