src/message_api.h
author Edouard Tisserant
Sun, 12 Jun 2016 20:20:45 +0200
branchimport_own_key
changeset 734 bd9a3eb1d707
parent 728 80b966277620
parent 731 6f7c688e0fd4
child 736 496905895282
permissions -rw-r--r--
merged remove_attached_keys
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
Edouard@734
    13
bool import_attached_keys(
Edouard@728
    14
        PEP_SESSION session, 
Edouard@728
    15
        const message *msg,
Edouard@728
    16
        identity_list **private_idents
Edouard@728
    17
    );
vb@236
    18
void attach_own_key(PEP_SESSION session, message *msg);
vb@258
    19
PEP_cryptotech determine_encryption_format(message *msg);
vb@235
    20
vb@39
    21
// encrypt_message() - encrypt message in memory
vb@39
    22
//
vb@39
    23
//  parameters:
vb@48
    24
//      session (in)        session handle
vb@48
    25
//      src (in)            message to encrypt
vb@48
    26
//      extra (in)          extra keys for encryption
vb@83
    27
//      dst (out)           pointer to new encrypted message or NULL on failure
vb@84
    28
//      enc_format (in)     encrypted format
vb@39
    29
//
vb@39
    30
//  return value:
vb@48
    31
//      PEP_STATUS_OK                   on success
vb@48
    32
//		PEP_KEY_NOT_FOUND	            at least one of the receipient keys
vb@48
    33
//		                                could not be found
vb@48
    34
//		PEP_KEY_HAS_AMBIG_NAME          at least one of the receipient keys has
vb@48
    35
//		                                an ambiguous name
vb@48
    36
//		PEP_GET_KEY_FAILED		        cannot retrieve key
vb@83
    37
//
vb@83
    38
//	caveat:
vb@251
    39
//	    the ownershop of src remains with the caller
vb@251
    40
//	    the ownership of dst goes to the caller
vb@38
    41
vb@44
    42
DYNAMIC_API PEP_STATUS encrypt_message(
vb@37
    43
        PEP_SESSION session,
vb@113
    44
        message *src,
vb@37
    45
        stringlist_t *extra,
vb@38
    46
        message **dst,
vb@81
    47
        PEP_enc_format enc_format
vb@37
    48
    );
vb@37
    49
vb@39
    50
vb@232
    51
typedef enum _PEP_color {
vb@237
    52
    PEP_rating_undefined = 0,
vb@256
    53
    PEP_rating_cannot_decrypt,
vb@267
    54
    PEP_rating_have_no_key,
vb@237
    55
    PEP_rating_unencrypted,
vb@486
    56
    PEP_rating_unencrypted_for_some,
vb@237
    57
    PEP_rating_unreliable,
vb@237
    58
    PEP_rating_reliable,
vb@237
    59
    PEP_rating_yellow = PEP_rating_reliable,
vb@237
    60
    PEP_rating_trusted,
vb@237
    61
    PEP_rating_green = PEP_rating_trusted,
vb@237
    62
    PEP_rating_trusted_and_anonymized,
vb@237
    63
    PEP_rating_fully_anonymous,   
vb@189
    64
Edouard@442
    65
    PEP_rating_mistrust = -1,
Edouard@442
    66
    PEP_rating_red = PEP_rating_mistrust,
Edouard@442
    67
    PEP_rating_b0rken = -2,
vb@436
    68
    PEP_rating_under_attack = -3
vb@232
    69
} PEP_color;
vb@189
    70
Edouard@728
    71
typedef enum _PEP_decrypt_flags {
Edouard@728
    72
    PEP_decrypt_flag_own_private_key = 0x1
Edouard@728
    73
} PEP_decrypt_flags; 
Edouard@728
    74
Edouard@728
    75
typedef uint32_t PEP_decrypt_flags_t;
Edouard@728
    76
vb@251
    77
// decrypt_message() - decrypt message in memory
vb@251
    78
//
vb@251
    79
//  parameters:
vb@251
    80
//      session (in)        session handle
vb@251
    81
//      src (in)            message to decrypt
vb@251
    82
//      dst (out)           pointer to new decrypted message or NULL on failure
vb@251
    83
//      keylist (out)       stringlist with keyids
vb@251
    84
//      color (out)         color for the message
Edouard@728
    85
//      flags (out)         flags to signal special message features
vb@251
    86
//
vb@251
    87
//  return value:
vb@251
    88
//      error status or PEP_STATUS_OK on success
vb@251
    89
//
vb@251
    90
//	caveat:
vb@251
    91
//	    the ownership of src remains with the caller
vb@251
    92
//	    the ownership of dst goes to the caller
vb@251
    93
//	    the ownership of keylist goes to the caller
vb@330
    94
//	    if src is unencrypted this function returns PEP_UNENCRYPTED and sets
vb@330
    95
//	    dst to NULL
vb@251
    96
vb@251
    97
DYNAMIC_API PEP_STATUS decrypt_message(
vb@251
    98
        PEP_SESSION session,
vb@251
    99
        message *src,
vb@251
   100
        message **dst,
vb@251
   101
        stringlist_t **keylist,
Edouard@728
   102
        PEP_color *color,
Edouard@728
   103
        PEP_decrypt_flags_t *flags 
Edouard@728
   104
);
vb@251
   105
Edouard@728
   106
// own_message_private_key_details() - details on own key in own message
Edouard@728
   107
//
Edouard@728
   108
//  parameters:
Edouard@728
   109
//      session (in)        session handle
Edouard@728
   110
//      msg (in)            message to decrypt
Edouard@728
   111
//      details (out)       text describing details
Edouard@728
   112
//      ident (out)         identity containing uid, address and fpr of key
Edouard@728
   113
//
Edouard@728
   114
//  note:
Edouard@728
   115
//      In order to obtain details about key to be possibly imported
Edouard@728
   116
//      as a replacement of key currently used as own identity, 
Edouard@728
   117
//      application passes message that have been previously flagged by 
Edouard@728
   118
//      decrypt_message() as own message containing own key to this function
Edouard@728
   119
//
Edouard@728
   120
//  return value:
Edouard@728
   121
//      error status or PEP_STATUS_OK on success
Edouard@728
   122
//
Edouard@728
   123
//	caveat:
Edouard@728
   124
//	    the ownership of msg remains with the caller
Edouard@728
   125
//	    the ownership of details goes to the caller
Edouard@728
   126
//	    the ownership of ident goes to the caller
Edouard@728
   127
//	    msg MUST be encrypted so that this function can check own signature
Edouard@728
   128
Edouard@728
   129
DYNAMIC_API PEP_STATUS own_message_private_key_details(
Edouard@728
   130
        PEP_SESSION session,
Edouard@728
   131
        message *msg,
Edouard@728
   132
        char **details,
Edouard@728
   133
        pEp_identity **ident 
Edouard@728
   134
);
vb@251
   135
vb@251
   136
// outgoing_message_color() - get color for an outgoing message
vb@189
   137
//
vb@189
   138
//  parameters:
vb@189
   139
//      session (in)        session handle
vb@189
   140
//      msg (in)            message to get the color for
vb@189
   141
//      color (out)         color for the message
vb@189
   142
//
vb@189
   143
//  return value:
vb@189
   144
//      error status or PEP_STATUS_OK on success
vb@190
   145
//
vb@190
   146
//  caveat:
vb@190
   147
//      msg->from must point to a valid pEp_identity
vb@251
   148
//      msg->dir must be PEP_dir_outgoing
vb@251
   149
//      the ownership of msg remains with the caller
vb@189
   150
vb@251
   151
DYNAMIC_API PEP_STATUS outgoing_message_color(
vb@189
   152
        PEP_SESSION session,
vb@190
   153
        message *msg,
vb@232
   154
        PEP_color *color
vb@189
   155
    );
vb@189
   156
vb@239
   157
vb@240
   158
// identity_color() - get color for a single identity
vb@239
   159
//
vb@239
   160
//  parameters:
vb@239
   161
//      session (in)        session handle
vb@239
   162
//      ident (in)          identity to get the color for
vb@239
   163
//      color (out)         color for the identity
vb@239
   164
//
vb@239
   165
//  return value:
vb@239
   166
//      error status or PEP_STATUS_OK on success
vb@251
   167
//
vb@251
   168
//  caveat:
vb@251
   169
//      the ownership of ident remains with the caller
vb@239
   170
vb@240
   171
DYNAMIC_API PEP_STATUS identity_color(
vb@239
   172
        PEP_SESSION session,
vb@239
   173
        pEp_identity *ident,
vb@239
   174
        PEP_color *color
vb@239
   175
    );
vb@239
   176
vb@239
   177
vb@507
   178
// get_binary_path() - retrieve path of cryptotech binary if available
vb@507
   179
//
vb@507
   180
//  parameters:
vb@507
   181
//      tech (in)           cryptotech to get the binary for
vb@507
   182
//      path (out)          path to cryptotech binary or NULL if not available
roker@540
   183
//                          **path is owned by the library, do not change it!
vb@507
   184
DYNAMIC_API PEP_STATUS get_binary_path(PEP_cryptotech tech, const char **path);
vb@507
   185
vb@507
   186
vb@37
   187
#ifdef __cplusplus
vb@37
   188
}
vb@37
   189
#endif
vb@37
   190