src/message_api.h
author Volker Birk <vb@pep-project.org>
Wed, 01 Jul 2015 16:29:02 +0200
changeset 330 fdc616fcbcaf
parent 267 31d89e1b5e08
child 436 97c432802667
child 442 e028f6d1d583
permissions -rw-r--r--
correcting docu
vb@39
     1
#pragma once
vb@39
     2
vb@102
     3
#include "pEpEngine.h"
vb@102
     4
#include "keymanagement.h"
vb@101
     5
#include "message.h"
vb@259
     6
#include "cryptotech.h"
vb@101
     7
vb@37
     8
#ifdef __cplusplus
vb@37
     9
extern "C" {
vb@37
    10
#endif
vb@37
    11
vb@39
    12
vb@235
    13
void import_attached_keys(PEP_SESSION session, const message *msg);
vb@236
    14
void attach_own_key(PEP_SESSION session, message *msg);
vb@258
    15
PEP_cryptotech determine_encryption_format(message *msg);
vb@235
    16
vb@39
    17
// encrypt_message() - encrypt message in memory
vb@39
    18
//
vb@39
    19
//  parameters:
vb@48
    20
//      session (in)        session handle
vb@48
    21
//      src (in)            message to encrypt
vb@48
    22
//      extra (in)          extra keys for encryption
vb@83
    23
//      dst (out)           pointer to new encrypted message or NULL on failure
vb@84
    24
//      enc_format (in)     encrypted format
vb@39
    25
//
vb@39
    26
//  return value:
vb@48
    27
//      PEP_STATUS_OK                   on success
vb@48
    28
//		PEP_KEY_NOT_FOUND	            at least one of the receipient keys
vb@48
    29
//		                                could not be found
vb@48
    30
//		PEP_KEY_HAS_AMBIG_NAME          at least one of the receipient keys has
vb@48
    31
//		                                an ambiguous name
vb@48
    32
//		PEP_GET_KEY_FAILED		        cannot retrieve key
vb@83
    33
//
vb@83
    34
//	caveat:
vb@251
    35
//	    the ownershop of src remains with the caller
vb@251
    36
//	    the ownership of dst goes to the caller
vb@38
    37
vb@44
    38
DYNAMIC_API PEP_STATUS encrypt_message(
vb@37
    39
        PEP_SESSION session,
vb@113
    40
        message *src,
vb@37
    41
        stringlist_t *extra,
vb@38
    42
        message **dst,
vb@81
    43
        PEP_enc_format enc_format
vb@37
    44
    );
vb@37
    45
vb@39
    46
vb@232
    47
typedef enum _PEP_color {
vb@237
    48
    PEP_rating_undefined = 0,
vb@256
    49
    PEP_rating_cannot_decrypt,
vb@267
    50
    PEP_rating_have_no_key,
vb@237
    51
    PEP_rating_unencrypted,
vb@237
    52
    PEP_rating_unreliable,
vb@237
    53
    PEP_rating_reliable,
vb@237
    54
    PEP_rating_yellow = PEP_rating_reliable,
vb@237
    55
    PEP_rating_trusted,
vb@237
    56
    PEP_rating_green = PEP_rating_trusted,
vb@237
    57
    PEP_rating_trusted_and_anonymized,
vb@237
    58
    PEP_rating_fully_anonymous,   
vb@189
    59
vb@237
    60
    PEP_rating_under_attack = -1,
vb@237
    61
    PEP_rating_red = PEP_rating_under_attack,
vb@237
    62
    PEP_rating_b0rken = -2
vb@232
    63
} PEP_color;
vb@189
    64
vb@251
    65
// decrypt_message() - decrypt message in memory
vb@251
    66
//
vb@251
    67
//  parameters:
vb@251
    68
//      session (in)        session handle
vb@251
    69
//      src (in)            message to decrypt
vb@251
    70
//      dst (out)           pointer to new decrypted message or NULL on failure
vb@251
    71
//      keylist (out)       stringlist with keyids
vb@251
    72
//      color (out)         color for the message
vb@251
    73
//
vb@251
    74
//  return value:
vb@251
    75
//      error status or PEP_STATUS_OK on success
vb@251
    76
//
vb@251
    77
//	caveat:
vb@251
    78
//	    the ownership of src remains with the caller
vb@251
    79
//	    the ownership of dst goes to the caller
vb@251
    80
//	    the ownership of keylist goes to the caller
vb@330
    81
//	    if src is unencrypted this function returns PEP_UNENCRYPTED and sets
vb@330
    82
//	    dst to NULL
vb@251
    83
vb@251
    84
DYNAMIC_API PEP_STATUS decrypt_message(
vb@251
    85
        PEP_SESSION session,
vb@251
    86
        message *src,
vb@251
    87
        message **dst,
vb@251
    88
        stringlist_t **keylist,
vb@251
    89
        PEP_color *color
vb@251
    90
    );
vb@251
    91
vb@251
    92
vb@251
    93
// outgoing_message_color() - get color for an outgoing message
vb@189
    94
//
vb@189
    95
//  parameters:
vb@189
    96
//      session (in)        session handle
vb@189
    97
//      msg (in)            message to get the color for
vb@189
    98
//      color (out)         color for the message
vb@189
    99
//
vb@189
   100
//  return value:
vb@189
   101
//      error status or PEP_STATUS_OK on success
vb@190
   102
//
vb@190
   103
//  caveat:
vb@190
   104
//      msg->from must point to a valid pEp_identity
vb@251
   105
//      msg->dir must be PEP_dir_outgoing
vb@251
   106
//      the ownership of msg remains with the caller
vb@189
   107
vb@251
   108
DYNAMIC_API PEP_STATUS outgoing_message_color(
vb@189
   109
        PEP_SESSION session,
vb@190
   110
        message *msg,
vb@232
   111
        PEP_color *color
vb@189
   112
    );
vb@189
   113
vb@239
   114
vb@240
   115
// identity_color() - get color for a single identity
vb@239
   116
//
vb@239
   117
//  parameters:
vb@239
   118
//      session (in)        session handle
vb@239
   119
//      ident (in)          identity to get the color for
vb@239
   120
//      color (out)         color for the identity
vb@239
   121
//
vb@239
   122
//  return value:
vb@239
   123
//      error status or PEP_STATUS_OK on success
vb@251
   124
//
vb@251
   125
//  caveat:
vb@251
   126
//      the ownership of ident remains with the caller
vb@239
   127
vb@240
   128
DYNAMIC_API PEP_STATUS identity_color(
vb@239
   129
        PEP_SESSION session,
vb@239
   130
        pEp_identity *ident,
vb@239
   131
        PEP_color *color
vb@239
   132
    );
vb@239
   133
vb@239
   134
vb@37
   135
#ifdef __cplusplus
vb@37
   136
}
vb@37
   137
#endif
vb@37
   138