src/message_api.h
author Krista Bennett <krista@pep-project.org>
Mon, 23 Apr 2018 16:59:27 +0200
branchENGINE-423
changeset 2625 d7dd538d402b
parent 2624 06472aa7727d
child 2643 ec3bb2ae2fdf
permissions -rw-r--r--
Added docs for ENGINE-420's encrypt_message_and_add_priv_key for key import
vb@1513
     1
// This file is under GNU General Public License 3.0
vb@1513
     2
// see LICENSE.txt
vb@1513
     3
vb@39
     4
#pragma once
vb@39
     5
vb@102
     6
#include "pEpEngine.h"
vb@102
     7
#include "keymanagement.h"
vb@101
     8
#include "message.h"
vb@259
     9
#include "cryptotech.h"
vb@101
    10
vb@37
    11
#ifdef __cplusplus
vb@37
    12
extern "C" {
vb@37
    13
#endif
vb@37
    14
vb@39
    15
Edouard@734
    16
bool import_attached_keys(
Edouard@728
    17
        PEP_SESSION session, 
Edouard@728
    18
        const message *msg,
Edouard@728
    19
        identity_list **private_idents
Edouard@728
    20
    );
roker@1869
    21
vb@236
    22
void attach_own_key(PEP_SESSION session, message *msg);
roker@1869
    23
vb@258
    24
PEP_cryptotech determine_encryption_format(message *msg);
roker@1869
    25
vb@952
    26
void add_opt_field(message *msg, const char *name, const char *value);
Edouard@736
    27
vb@939
    28
typedef enum _PEP_encrypt_flags {
krista@1639
    29
    // "default" means whatever the default behaviour for the function is.
krista@1639
    30
    PEP_encrypt_flag_default = 0x0,
markus@1633
    31
    PEP_encrypt_flag_force_encryption = 0x1,
markus@1633
    32
markus@1633
    33
    // This flag is for special use cases and should not be used
markus@1633
    34
    // by normal pEp clients!
krista@1640
    35
    PEP_encrypt_flag_force_unsigned = 0x2,
krista@2121
    36
    PEP_encrypt_flag_force_no_attached_key = 0x4,
krista@2121
    37
    
krista@2121
    38
    // This is used for outer messages (used to wrap the real message)
krista@2121
    39
    // This is only used internally and (eventually) by transport functions
krista@2147
    40
    PEP_encrypt_flag_inner_message = 0x8
krista@2612
    41
    
vb@939
    42
} PEP_encrypt_flags; 
vb@939
    43
vb@939
    44
typedef unsigned int PEP_encrypt_flags_t;
vb@235
    45
roker@1869
    46
vb@39
    47
// encrypt_message() - encrypt message in memory
vb@39
    48
//
vb@39
    49
//  parameters:
vb@48
    50
//      session (in)        session handle
vb@48
    51
//      src (in)            message to encrypt
vb@48
    52
//      extra (in)          extra keys for encryption
vb@2338
    53
//      dst (out)           pointer to new encrypted message or NULL if no
vb@2338
    54
//                          encryption could take place
vb@84
    55
//      enc_format (in)     encrypted format
vb@939
    56
//      flags (in)          flags to set special encryption features
vb@39
    57
//
vb@39
    58
//  return value:
vb@48
    59
//      PEP_STATUS_OK                   on success
edouard@1854
    60
//      PEP_KEY_HAS_AMBIG_NAME          at least one of the receipient keys has
edouard@1854
    61
//                                      an ambiguous name
vb@2338
    62
//      PEP_UNENCRYPTED                 on demand or no recipients with usable
vb@2338
    63
//                                      key, is left unencrypted, and key is
vb@2338
    64
//                                      attached to it
vb@83
    65
//
roker@1869
    66
//  caveat:
roker@1869
    67
//      the ownershop of src remains with the caller
roker@1869
    68
//      the ownership of dst goes to the caller
vb@44
    69
DYNAMIC_API PEP_STATUS encrypt_message(
vb@37
    70
        PEP_SESSION session,
vb@113
    71
        message *src,
vb@37
    72
        stringlist_t *extra,
vb@38
    73
        message **dst,
vb@939
    74
        PEP_enc_format enc_format,
vb@939
    75
        PEP_encrypt_flags_t flags
vb@37
    76
    );
vb@37
    77
roker@1869
    78
krista@2625
    79
// encrypt_message_and_add_priv_key() - encrypt message in memory, adding an encrypted private
krista@2625
    80
//                                      key (encrypted separately and sent within the inner message)
krista@2625
    81
//
krista@2625
    82
//  parameters:
krista@2625
    83
//      session (in)        session handle
krista@2625
    84
//      src (in)            message to encrypt
krista@2625
    85
//      extra (in)          extra keys for encryption
krista@2625
    86
//      dst (out)           pointer to new encrypted message or NULL if no
krista@2625
    87
//                          encryption could take place
krista@2625
    88
//      to_fpr              fingerprint of the private key that should
krista@2625
    89
//                          be encrypted and attached to the message
krista@2625
    90
//      enc_format (in)     encrypted format
krista@2625
    91
//      flags (in)          flags to set special encryption features
krista@2625
    92
//
krista@2625
    93
//  return value:
krista@2625
    94
//      PEP_STATUS_OK                   on success
krista@2625
    95
//      PEP_KEY_HAS_AMBIG_NAME          at least one of the receipient keys has
krista@2625
    96
//                                      an ambiguous name
krista@2625
    97
//      PEP_UNENCRYPTED                 on demand or no recipients with usable
krista@2625
    98
//                                      key, is left unencrypted, and key is
krista@2625
    99
//                                      attached to it
krista@2625
   100
//
krista@2625
   101
//  caveat:
krista@2625
   102
//      the ownershop of src remains with the caller
krista@2625
   103
//      the ownership of dst goes to the caller
krista@2592
   104
DYNAMIC_API PEP_STATUS encrypt_message_and_add_priv_key(
krista@2592
   105
        PEP_SESSION session,
krista@2592
   106
        message *src,
krista@2592
   107
        message **dst,
krista@2592
   108
        const char* to_fpr,
krista@2594
   109
        PEP_enc_format enc_format,
krista@2594
   110
        PEP_encrypt_flags_t flags
krista@2592
   111
    );
krista@2592
   112
krista@2592
   113
krista@1034
   114
// encrypt_message_for_self() - encrypt message in memory for user's identity only,
krista@1034
   115
//                              ignoring recipients and other identities from
krista@1034
   116
//                              the message
krista@994
   117
//  parameters:
krista@994
   118
//      session (in)        session handle
krista@995
   119
//      target_id (in)      self identity this message should be encrypted for
krista@994
   120
//      src (in)            message to encrypt
krista@2588
   121
//      extra (in)          extra keys for encryption
krista@994
   122
//      dst (out)           pointer to new encrypted message or NULL on failure
krista@994
   123
//      enc_format (in)     encrypted format
markus@1634
   124
//      flags (in)          flags to set special encryption features
krista@994
   125
//
krista@994
   126
//  return value:       (FIXME: This may not be correct or complete)
roker@1869
   127
//      PEP_STATUS_OK            on success
roker@1869
   128
//      PEP_KEY_NOT_FOUND        at least one of the receipient keys
roker@1869
   129
//                               could not be found
roker@1869
   130
//      PEP_KEY_HAS_AMBIG_NAME   at least one of the receipient keys has
roker@1869
   131
//                               an ambiguous name
roker@1869
   132
//      PEP_GET_KEY_FAILED       cannot retrieve key
krista@994
   133
//
roker@1869
   134
//  caveat:
roker@1869
   135
//      the ownership of src remains with the caller
krista@994
   136
//      the ownership of target_id remains w/ caller            
roker@1869
   137
//      the ownership of dst goes to the caller
krista@995
   138
//      message is NOT encrypted for identities other than the target_id (and then,
roker@1869
   139
//      only if the target_id refers to self!)
krista@995
   140
DYNAMIC_API PEP_STATUS encrypt_message_for_self(
krista@994
   141
        PEP_SESSION session,
krista@994
   142
        pEp_identity* target_id,
krista@994
   143
        message *src,
krista@2588
   144
        stringlist_t* extra,
krista@994
   145
        message **dst,
markus@1633
   146
        PEP_enc_format enc_format,
markus@1633
   147
        PEP_encrypt_flags_t flags
krista@994
   148
    );
vb@39
   149
roker@1869
   150
krista@1325
   151
// MIME_encrypt_message() - encrypt a MIME message, with MIME output
krista@1325
   152
//
krista@1325
   153
//  parameters:
krista@1325
   154
//      session (in)            session handle
krista@1325
   155
//      mimetext (in)           MIME encoded text to encrypt
krista@1331
   156
//      size (in)               size of input mime text
krista@1325
   157
//      extra (in)              extra keys for encryption
krista@1325
   158
//      mime_ciphertext (out)   encrypted, encoded message
krista@1325
   159
//      enc_format (in)         encrypted format
krista@1325
   160
//      flags (in)              flags to set special encryption features
krista@1325
   161
//
krista@1325
   162
//  return value:
krista@1325
   163
//      PEP_STATUS_OK           if everything worked
krista@1325
   164
//      PEP_BUFFER_TOO_SMALL    if encoded message size is too big to handle
krista@1325
   165
//      PEP_CANNOT_CREATE_TEMP_FILE
krista@1325
   166
//                              if there are issues with temp files; in
krista@1325
   167
//                              this case errno will contain the underlying
krista@1325
   168
//                              error
krista@1325
   169
//      PEP_OUT_OF_MEMORY       if not enough memory could be allocated
krista@1325
   170
//
krista@1325
   171
//  caveat:
krista@1325
   172
//      the encrypted, encoded mime text will go to the ownership of the caller; mimetext
krista@1325
   173
//      will remain in the ownership of the caller
krista@1325
   174
DYNAMIC_API PEP_STATUS MIME_encrypt_message(
krista@1325
   175
    PEP_SESSION session,
krista@1325
   176
    const char *mimetext,
krista@1325
   177
    size_t size,
krista@1325
   178
    stringlist_t* extra,
krista@1325
   179
    char** mime_ciphertext,
krista@1325
   180
    PEP_enc_format enc_format,
krista@1325
   181
    PEP_encrypt_flags_t flags
krista@1325
   182
);
krista@1325
   183
roker@1869
   184
krista@1641
   185
// MIME_encrypt_message_for_self() - encrypt MIME message for user's identity only,
krista@1641
   186
//                              ignoring recipients and other identities from
krista@1641
   187
//                              the message, with MIME output
krista@1641
   188
//  parameters:
krista@1641
   189
//      session (in)            session handle
roker@1869
   190
//      target_id (in)          self identity this message should be encrypted for
krista@1641
   191
//      mimetext (in)           MIME encoded text to encrypt
krista@1641
   192
//      size (in)               size of input mime text
krista@2588
   193
//      extra (in)              extra keys for encryption
krista@1641
   194
//      mime_ciphertext (out)   encrypted, encoded message
krista@1641
   195
//      enc_format (in)         encrypted format
krista@1641
   196
//      flags (in)              flags to set special encryption features
krista@1641
   197
//
krista@1641
   198
//  return value:
krista@1641
   199
//      PEP_STATUS_OK           if everything worked
krista@1641
   200
//      PEP_BUFFER_TOO_SMALL    if encoded message size is too big to handle
krista@1641
   201
//      PEP_CANNOT_CREATE_TEMP_FILE
krista@1641
   202
//                              if there are issues with temp files; in
krista@1641
   203
//                              this case errno will contain the underlying
krista@1641
   204
//                              error
krista@1641
   205
//      PEP_OUT_OF_MEMORY       if not enough memory could be allocated
krista@1641
   206
//
krista@1641
   207
//  caveat:
krista@1641
   208
//      the encrypted, encoded mime text will go to the ownership of the caller; mimetext
krista@1641
   209
//      will remain in the ownership of the caller
krista@1641
   210
DYNAMIC_API PEP_STATUS MIME_encrypt_message_for_self(
krista@1641
   211
    PEP_SESSION session,
krista@1641
   212
    pEp_identity* target_id,
krista@1641
   213
    const char *mimetext,
krista@1641
   214
    size_t size,
krista@2588
   215
    stringlist_t* extra,
krista@1641
   216
    char** mime_ciphertext,
krista@1641
   217
    PEP_enc_format enc_format,
krista@1641
   218
    PEP_encrypt_flags_t flags
krista@1641
   219
);
krista@1641
   220
krista@1641
   221
vb@1004
   222
typedef enum _PEP_rating {
vb@237
   223
    PEP_rating_undefined = 0,
vb@256
   224
    PEP_rating_cannot_decrypt,
vb@267
   225
    PEP_rating_have_no_key,
vb@237
   226
    PEP_rating_unencrypted,
vb@486
   227
    PEP_rating_unencrypted_for_some,
vb@237
   228
    PEP_rating_unreliable,
vb@237
   229
    PEP_rating_reliable,
vb@237
   230
    PEP_rating_trusted,
vb@237
   231
    PEP_rating_trusted_and_anonymized,
vb@237
   232
    PEP_rating_fully_anonymous,   
vb@189
   233
Edouard@442
   234
    PEP_rating_mistrust = -1,
Edouard@442
   235
    PEP_rating_b0rken = -2,
vb@436
   236
    PEP_rating_under_attack = -3
vb@1004
   237
} PEP_rating;
vb@1004
   238
vb@1004
   239
typedef enum _PEP_color {
vb@1004
   240
    PEP_color_no_color = 0,
vb@1004
   241
    PEP_color_yellow,
vb@1004
   242
    PEP_color_green,
vb@1004
   243
    PEP_color_red = -1,
vb@232
   244
} PEP_color;
vb@189
   245
roker@1869
   246
vb@1007
   247
// color_from_rating - calculate color from rating
vb@1007
   248
//
vb@1007
   249
//  parameters:
vb@1007
   250
//      rating (in)         rating
vb@1007
   251
//
vb@1007
   252
//  return value:           color representing that rating
vb@1004
   253
DYNAMIC_API PEP_color color_from_rating(PEP_rating rating);
vb@1004
   254
Edouard@728
   255
typedef enum _PEP_decrypt_flags {
edouard@1355
   256
    PEP_decrypt_flag_own_private_key = 0x1,
edouard@1369
   257
    PEP_decrypt_flag_consume = 0x2,
krista@2623
   258
    PEP_decrypt_flag_ignore = 0x4,
krista@2623
   259
    PEP_decrypt_flag_src_modified = 0x8,
krista@2623
   260
    // input flags    
krista@2623
   261
    PEP_decrypt_flag_untrusted_server = 0x100
Edouard@728
   262
} PEP_decrypt_flags; 
Edouard@728
   263
vb@939
   264
typedef unsigned int PEP_decrypt_flags_t;
Edouard@728
   265
roker@1869
   266
vb@251
   267
// decrypt_message() - decrypt message in memory
vb@251
   268
//
vb@251
   269
//  parameters:
vb@251
   270
//      session (in)        session handle
krista@2624
   271
//      src (inout)         message to decrypt
vb@251
   272
//      dst (out)           pointer to new decrypted message or NULL on failure
vb@251
   273
//      keylist (out)       stringlist with keyids
roker@1218
   274
//      rating (out)        rating for the message
krista@2624
   275
//      flags (inout)       flags to signal special decryption features
vb@251
   276
//
vb@251
   277
//  return value:
edouard@1858
   278
//      error status 
edouard@1858
   279
//      or PEP_DECRYPTED if message decrypted but not verified
krista@2624
   280
//      or PEP_CANNOT_REENCRYPT if message was decrypted (and possibly
krista@2624
   281
//         verified) but a reencryption operation is expected by the caller
krista@2624
   282
//         and failed
edouard@1858
   283
//      or PEP_STATUS_OK on success
vb@251
   284
//
krista@2624
   285
//  flag values:
krista@2624
   286
//      in:
krista@2624
   287
//          PEP_decrypt_flag_untrusted_server
krista@2624
   288
//              used to signal that decrypt function should engage in behaviour
krista@2624
   289
//              specified for when the server storing the source is untrusted
krista@2624
   290
//      out:
krista@2624
   291
//          PEP_decrypt_flag_own_private_key
krista@2624
   292
//              private key was imported for one of our addresses (NOT trusted
krista@2624
   293
//              or set to be used - handshake/trust is required for that)
krista@2624
   294
//          PEP_decrypt_flag_src_modified
krista@2624
   295
//              indicates that the src object has been modified. At the moment,
krista@2624
   296
//              this is always as a direct result of the behaviour driven
krista@2624
   297
//              by the input flags. This flag is the ONLY value that should be
krista@2624
   298
//              relied upon to see if such changes have taken place.
krista@2624
   299
//          PEP_decrypt_flag_consume
krista@2624
   300
//              used by sync 
krista@2624
   301
//          PEP_decrypt_flag_ignore
krista@2624
   302
//              used by sync 
krista@2624
   303
//
krista@2624
   304
//
roker@1869
   305
// caveat:
krista@2624
   306
//      the ownership of src remains with the caller - however, the contents 
krista@2624
   307
//          might be modified (strings freed and allocated anew or set to NULL,
krista@2624
   308
//          etc) intentionally; when this happens, PEP_decrypt_flag_src_modified
krista@2624
   309
//          is set.
roker@1869
   310
//      the ownership of dst goes to the caller
roker@1869
   311
//      the ownership of keylist goes to the caller
roker@1869
   312
//      if src is unencrypted this function returns PEP_UNENCRYPTED and sets
krista@2624
   313
//         dst to NULL
vb@251
   314
DYNAMIC_API PEP_STATUS decrypt_message(
vb@251
   315
        PEP_SESSION session,
vb@251
   316
        message *src,
vb@251
   317
        message **dst,
vb@251
   318
        stringlist_t **keylist,
vb@1004
   319
        PEP_rating *rating,
vb@939
   320
        PEP_decrypt_flags_t *flags
Edouard@728
   321
);
vb@251
   322
roker@1869
   323
krista@1325
   324
// MIME_decrypt_message() - decrypt a MIME message, with MIME output
krista@1325
   325
//
krista@1325
   326
//  parameters:
krista@1325
   327
//      session (in)            session handle
krista@1325
   328
//      mimetext (in)           MIME encoded text to decrypt
krista@1331
   329
//      size (in)               size of mime text to decode (in order to decrypt)
krista@1325
   330
//      mime_plaintext (out)    decrypted, encoded message
krista@1325
   331
//      keylist (out)           stringlist with keyids
krista@1325
   332
//      rating (out)            rating for the message
krista@2624
   333
//      flags (inout)           flags to signal special decryption features (see below)
krista@2623
   334
//      modified_src (out)      modified source string, if decrypt had reason to change it
krista@1325
   335
//
krista@1325
   336
//  return value:
krista@1644
   337
//      decrypt status          if everything worked with MIME encode/decode, 
krista@1644
   338
//                              the status of the decryption is returned 
krista@1644
   339
//                              (PEP_STATUS_OK or decryption error status)
krista@1325
   340
//      PEP_BUFFER_TOO_SMALL    if encoded message size is too big to handle
krista@1325
   341
//      PEP_CANNOT_CREATE_TEMP_FILE
krista@1325
   342
//                              if there are issues with temp files; in
krista@1325
   343
//                              this case errno will contain the underlying
krista@1325
   344
//                              error
krista@1325
   345
//      PEP_OUT_OF_MEMORY       if not enough memory could be allocated
krista@1325
   346
//
krista@2624
   347
//  flag values:
krista@2624
   348
//      in:
krista@2624
   349
//          PEP_decrypt_flag_untrusted_server
krista@2624
   350
//              used to signal that decrypt function should engage in behaviour
krista@2624
   351
//              specified for when the server storing the source is untrusted.
krista@2624
   352
//      out:
krista@2624
   353
//          PEP_decrypt_flag_own_private_key
krista@2624
   354
//              private key was imported for one of our addresses (NOT trusted
krista@2624
   355
//              or set to be used - handshake/trust is required for that)
krista@2624
   356
//          PEP_decrypt_flag_src_modified
krista@2624
   357
//              indicates that the modified_src field should contain a modified
krista@2624
   358
//              version of the source, at the moment always as a result of the
krista@2624
   359
//              input flags. 
krista@2624
   360
//          PEP_decrypt_flag_consume
krista@2624
   361
//              used by sync 
krista@2624
   362
//          PEP_decrypt_flag_ignore
krista@2624
   363
//              used by sync 
krista@2624
   364
// 
krista@1325
   365
//  caveat:
krista@1325
   366
//      the decrypted, encoded mime text will go to the ownership of the caller; mimetext
krista@1325
   367
//      will remain in the ownership of the caller
krista@1325
   368
DYNAMIC_API PEP_STATUS MIME_decrypt_message(
krista@1325
   369
    PEP_SESSION session,
krista@1325
   370
    const char *mimetext,
krista@1325
   371
    size_t size,
krista@1325
   372
    char** mime_plaintext,
krista@1325
   373
    stringlist_t **keylist,
krista@1325
   374
    PEP_rating *rating,
krista@2623
   375
    PEP_decrypt_flags_t *flags,
krista@2623
   376
    char** modified_src
krista@1325
   377
);
krista@1325
   378
krista@1325
   379
Edouard@728
   380
// own_message_private_key_details() - details on own key in own message
Edouard@728
   381
//
Edouard@728
   382
//  parameters:
Edouard@728
   383
//      session (in)        session handle
Edouard@728
   384
//      msg (in)            message to decrypt
Edouard@728
   385
//      ident (out)         identity containing uid, address and fpr of key
Edouard@728
   386
//
Edouard@728
   387
//  note:
Edouard@728
   388
//      In order to obtain details about key to be possibly imported
Edouard@728
   389
//      as a replacement of key currently used as own identity, 
Edouard@728
   390
//      application passes message that have been previously flagged by 
Edouard@728
   391
//      decrypt_message() as own message containing own key to this function
Edouard@728
   392
//
Edouard@728
   393
//  return value:
Edouard@728
   394
//      error status or PEP_STATUS_OK on success
Edouard@728
   395
//
roker@1869
   396
//  caveat:
roker@1869
   397
//      the ownership of msg remains with the caller
roker@1869
   398
//      the ownership of ident goes to the caller
roker@1869
   399
//      msg MUST be encrypted so that this function can check own signature
Edouard@728
   400
DYNAMIC_API PEP_STATUS own_message_private_key_details(
Edouard@728
   401
        PEP_SESSION session,
Edouard@728
   402
        message *msg,
Edouard@728
   403
        pEp_identity **ident 
Edouard@728
   404
);
vb@251
   405
roker@1869
   406
vb@1009
   407
// outgoing_message_rating() - get rating for an outgoing message
vb@189
   408
//
vb@189
   409
//  parameters:
vb@189
   410
//      session (in)        session handle
vb@1009
   411
//      msg (in)            message to get the rating for
vb@1009
   412
//      rating (out)        rating for the message
vb@189
   413
//
vb@189
   414
//  return value:
vb@189
   415
//      error status or PEP_STATUS_OK on success
vb@190
   416
//
vb@190
   417
//  caveat:
vb@190
   418
//      msg->from must point to a valid pEp_identity
vb@251
   419
//      msg->dir must be PEP_dir_outgoing
vb@251
   420
//      the ownership of msg remains with the caller
vb@1009
   421
DYNAMIC_API PEP_STATUS outgoing_message_rating(
vb@189
   422
        PEP_SESSION session,
vb@190
   423
        message *msg,
vb@1004
   424
        PEP_rating *rating
vb@189
   425
    );
vb@189
   426
vb@239
   427
vb@1009
   428
// identity_rating() - get rating for a single identity
vb@239
   429
//
vb@239
   430
//  parameters:
vb@239
   431
//      session (in)        session handle
vb@1009
   432
//      ident (in)          identity to get the rating for
vb@1009
   433
//      rating (out)        rating for the identity
vb@239
   434
//
vb@239
   435
//  return value:
vb@239
   436
//      error status or PEP_STATUS_OK on success
vb@251
   437
//
vb@251
   438
//  caveat:
vb@251
   439
//      the ownership of ident remains with the caller
vb@1009
   440
DYNAMIC_API PEP_STATUS identity_rating(
vb@239
   441
        PEP_SESSION session,
vb@239
   442
        pEp_identity *ident,
vb@1004
   443
        PEP_rating *rating
vb@239
   444
    );
vb@239
   445
vb@239
   446
vb@507
   447
// get_binary_path() - retrieve path of cryptotech binary if available
vb@507
   448
//
vb@507
   449
//  parameters:
vb@507
   450
//      tech (in)           cryptotech to get the binary for
vb@507
   451
//      path (out)          path to cryptotech binary or NULL if not available
roker@540
   452
//                          **path is owned by the library, do not change it!
vb@507
   453
DYNAMIC_API PEP_STATUS get_binary_path(PEP_cryptotech tech, const char **path);
vb@507
   454
roker@1869
   455
krista@1307
   456
// get_trustwords() - get full trustwords string for a *pair* of identities
krista@1307
   457
//
krista@1307
   458
//    parameters:
krista@1307
   459
//        session (in)        session handle
krista@1307
   460
//        id1 (in)            identity of first party in communication - fpr can't be NULL  
krista@1307
   461
//        id2 (in)            identity of second party in communication - fpr can't be NULL
krista@1307
   462
//        lang (in)           C string with ISO 639-1 language code
krista@1307
   463
//        words (out)         pointer to C string with all trustwords UTF-8 encoded,
krista@1307
   464
//                            separated by a blank each
krista@1307
   465
//                            NULL if language is not supported or trustword
krista@1307
   466
//                            wordlist is damaged or unavailable
krista@1307
   467
//        wsize (out)         length of full trustwords string
krista@1307
   468
//        full (in)           if true, generate ALL trustwords for these identities.
krista@1307
   469
//                            else, generate a fixed-size subset. (TODO: fixed-minimum-entropy
krista@1307
   470
//                            subset in next version)
krista@1307
   471
//
krista@1307
   472
//    return value:
krista@1307
   473
//        PEP_STATUS_OK            trustwords retrieved
krista@1307
   474
//        PEP_OUT_OF_MEMORY        out of memory
krista@1307
   475
//        PEP_TRUSTWORD_NOT_FOUND  at least one trustword not found
krista@1307
   476
//
krista@1307
   477
//    caveat:
krista@1307
   478
//        the word pointer goes to the ownership of the caller
krista@1307
   479
//        the caller is responsible to free() it (on Windoze use pEp_free())
krista@1307
   480
//
krista@1307
   481
DYNAMIC_API PEP_STATUS get_trustwords(
roker@1509
   482
    PEP_SESSION session, const pEp_identity* id1, const pEp_identity* id2,
krista@1307
   483
    const char* lang, char **words, size_t *wsize, bool full
krista@1307
   484
);
vb@507
   485
roker@1869
   486
edouard@1553
   487
// get_message_trustwords() - get full trustwords string for message sender and reciever identities 
edouard@1553
   488
//
edouard@1553
   489
//    parameters:
edouard@1553
   490
//        session (in)        session handle
edouard@1553
   491
//        msg (in)            message to get sender identity from
edouard@1553
   492
//        keylist (in)        NULL if message to be decrypted,
edouard@1553
   493
//                            keylist returned by decrypt_message() otherwise
edouard@1553
   494
//        received_by (in)    identity for account receiving message can't be NULL
edouard@1553
   495
//        lang (in)           C string with ISO 639-1 language code
edouard@1553
   496
//        words (out)         pointer to C string with all trustwords UTF-8 encoded,
edouard@1553
   497
//                            separated by a blank each
edouard@1553
   498
//                            NULL if language is not supported or trustword
edouard@1553
   499
//                            wordlist is damaged or unavailable
edouard@1553
   500
//        full (in)           if true, generate ALL trustwords for these identities.
edouard@1553
   501
//                            else, generate a fixed-size subset. (TODO: fixed-minimum-entropy
edouard@1553
   502
//                            subset in next version)
edouard@1553
   503
//
edouard@1553
   504
//    return value:
edouard@1553
   505
//        PEP_STATUS_OK            trustwords retrieved
edouard@1553
   506
//        PEP_OUT_OF_MEMORY        out of memory
edouard@1553
   507
//        PEP_TRUSTWORD_NOT_FOUND  at least one trustword not found
edouard@1553
   508
//        error status of decrypt_message() if decryption fails.
edouard@1553
   509
//
edouard@1553
   510
//    caveat:
edouard@1553
   511
//        the word pointer goes to the ownership of the caller
edouard@1553
   512
//        the caller is responsible to free() it (on Windoze use pEp_free())
edouard@1553
   513
//
edouard@1553
   514
DYNAMIC_API PEP_STATUS get_message_trustwords(
edouard@1553
   515
    PEP_SESSION session, 
edouard@1553
   516
    message *msg,
edouard@1553
   517
    stringlist_t *keylist,
edouard@1553
   518
    pEp_identity* received_by,
edouard@1553
   519
    const char* lang, char **words, bool full
edouard@1553
   520
);
edouard@1553
   521
edouard@1815
   522
// re_evaluate_message_rating() - re-evaluate already decrypted message rating
edouard@1815
   523
//
edouard@1815
   524
//  parameters:
edouard@1815
   525
//      session (in)            session handle
edouard@1815
   526
//      msg (in)                message to get the rating for
edouard@1815
   527
//      x_keylist (in)          decrypted message recipients keys fpr
edouard@1815
   528
//      x_enc_status (in)       original rating for the decrypted message
edouard@1815
   529
//      rating (out)            rating for the message
edouard@1815
   530
//
edouard@1815
   531
//  return value:
edouard@1815
   532
//      PEP_ILLEGAL_VALUE       if decrypted message doesn't contain 
edouard@1815
   533
//                              X-EncStatus optional field and x_enc_status is 
edouard@1815
   534
//                              pEp_rating_udefined
edouard@1815
   535
//                              or if decrypted message doesn't contain 
edouard@1815
   536
//                              X-Keylist optional field and x_keylist is NULL
edouard@1815
   537
//      PEP_OUT_OF_MEMORY       if not enough memory could be allocated
edouard@1815
   538
//
edouard@1815
   539
//  caveat:
edouard@1815
   540
//      msg->from must point to a valid pEp_identity
edouard@1815
   541
//      the ownership of msg remains with the caller
edouard@1815
   542
//	    the ownership of x_keylist remains with to the caller
edouard@1815
   543
edouard@1815
   544
DYNAMIC_API PEP_STATUS re_evaluate_message_rating(
edouard@1815
   545
    PEP_SESSION session,
edouard@1815
   546
    message *msg,
edouard@1815
   547
    stringlist_t *x_keylist,
edouard@1815
   548
    PEP_rating x_enc_status,
edouard@1815
   549
    PEP_rating *rating
edouard@1815
   550
);
vb@37
   551
#ifdef __cplusplus
vb@37
   552
}
vb@37
   553
#endif