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 |
|
krista@1034
|
50 |
// encrypt_message_for_self() - encrypt message in memory for user's identity only,
|
krista@1034
|
51 |
// ignoring recipients and other identities from
|
krista@1034
|
52 |
// the message
|
krista@994
|
53 |
// parameters:
|
krista@994
|
54 |
// session (in) session handle
|
krista@995
|
55 |
// target_id (in) self identity this message should be encrypted for
|
krista@994
|
56 |
// src (in) message to encrypt
|
krista@994
|
57 |
// dst (out) pointer to new encrypted message or NULL on failure
|
krista@994
|
58 |
// enc_format (in) encrypted format
|
krista@994
|
59 |
//
|
krista@994
|
60 |
// return value: (FIXME: This may not be correct or complete)
|
krista@994
|
61 |
// PEP_STATUS_OK on success
|
krista@994
|
62 |
// PEP_KEY_NOT_FOUND at least one of the receipient keys
|
krista@994
|
63 |
// could not be found
|
krista@994
|
64 |
// PEP_KEY_HAS_AMBIG_NAME at least one of the receipient keys has
|
krista@994
|
65 |
// an ambiguous name
|
krista@994
|
66 |
// PEP_GET_KEY_FAILED cannot retrieve key
|
krista@994
|
67 |
//
|
krista@994
|
68 |
// caveat:
|
krista@994
|
69 |
// the ownership of src remains with the caller
|
krista@994
|
70 |
// the ownership of target_id remains w/ caller
|
krista@994
|
71 |
// the ownership of dst goes to the caller
|
krista@995
|
72 |
// message is NOT encrypted for identities other than the target_id (and then,
|
krista@995
|
73 |
// only if the target_id refers to self!)
|
krista@994
|
74 |
|
krista@995
|
75 |
DYNAMIC_API PEP_STATUS encrypt_message_for_self(
|
krista@994
|
76 |
PEP_SESSION session,
|
krista@994
|
77 |
pEp_identity* target_id,
|
krista@994
|
78 |
message *src,
|
krista@994
|
79 |
message **dst,
|
krista@994
|
80 |
PEP_enc_format enc_format
|
krista@994
|
81 |
);
|
vb@39
|
82 |
|
vb@232
|
83 |
typedef enum _PEP_color {
|
vb@237
|
84 |
PEP_rating_undefined = 0,
|
vb@256
|
85 |
PEP_rating_cannot_decrypt,
|
vb@267
|
86 |
PEP_rating_have_no_key,
|
vb@237
|
87 |
PEP_rating_unencrypted,
|
vb@486
|
88 |
PEP_rating_unencrypted_for_some,
|
vb@237
|
89 |
PEP_rating_unreliable,
|
vb@237
|
90 |
PEP_rating_reliable,
|
vb@237
|
91 |
PEP_rating_yellow = PEP_rating_reliable,
|
vb@237
|
92 |
PEP_rating_trusted,
|
vb@237
|
93 |
PEP_rating_green = PEP_rating_trusted,
|
vb@237
|
94 |
PEP_rating_trusted_and_anonymized,
|
vb@237
|
95 |
PEP_rating_fully_anonymous,
|
vb@189
|
96 |
|
Edouard@442
|
97 |
PEP_rating_mistrust = -1,
|
Edouard@442
|
98 |
PEP_rating_red = PEP_rating_mistrust,
|
Edouard@442
|
99 |
PEP_rating_b0rken = -2,
|
vb@436
|
100 |
PEP_rating_under_attack = -3
|
vb@232
|
101 |
} PEP_color;
|
vb@189
|
102 |
|
Edouard@728
|
103 |
typedef enum _PEP_decrypt_flags {
|
Edouard@728
|
104 |
PEP_decrypt_flag_own_private_key = 0x1
|
Edouard@728
|
105 |
} PEP_decrypt_flags;
|
Edouard@728
|
106 |
|
Edouard@728
|
107 |
typedef uint32_t PEP_decrypt_flags_t;
|
Edouard@728
|
108 |
|
vb@251
|
109 |
// decrypt_message() - decrypt message in memory
|
vb@251
|
110 |
//
|
vb@251
|
111 |
// parameters:
|
vb@251
|
112 |
// session (in) session handle
|
vb@251
|
113 |
// src (in) message to decrypt
|
vb@251
|
114 |
// dst (out) pointer to new decrypted message or NULL on failure
|
vb@251
|
115 |
// keylist (out) stringlist with keyids
|
vb@251
|
116 |
// color (out) color for the message
|
Edouard@728
|
117 |
// flags (out) flags to signal special message features
|
vb@251
|
118 |
//
|
vb@251
|
119 |
// return value:
|
vb@251
|
120 |
// error status or PEP_STATUS_OK on success
|
vb@251
|
121 |
//
|
vb@251
|
122 |
// caveat:
|
vb@251
|
123 |
// the ownership of src remains with the caller
|
vb@251
|
124 |
// the ownership of dst goes to the caller
|
vb@251
|
125 |
// the ownership of keylist goes to the caller
|
vb@330
|
126 |
// if src is unencrypted this function returns PEP_UNENCRYPTED and sets
|
vb@330
|
127 |
// dst to NULL
|
vb@251
|
128 |
|
vb@251
|
129 |
DYNAMIC_API PEP_STATUS decrypt_message(
|
vb@251
|
130 |
PEP_SESSION session,
|
vb@251
|
131 |
message *src,
|
vb@251
|
132 |
message **dst,
|
vb@251
|
133 |
stringlist_t **keylist,
|
Edouard@728
|
134 |
PEP_color *color,
|
Edouard@728
|
135 |
PEP_decrypt_flags_t *flags
|
Edouard@728
|
136 |
);
|
vb@251
|
137 |
|
Edouard@728
|
138 |
// own_message_private_key_details() - details on own key in own message
|
Edouard@728
|
139 |
//
|
Edouard@728
|
140 |
// parameters:
|
Edouard@728
|
141 |
// session (in) session handle
|
Edouard@728
|
142 |
// msg (in) message to decrypt
|
Edouard@728
|
143 |
// ident (out) identity containing uid, address and fpr of key
|
Edouard@728
|
144 |
//
|
Edouard@728
|
145 |
// note:
|
Edouard@728
|
146 |
// In order to obtain details about key to be possibly imported
|
Edouard@728
|
147 |
// as a replacement of key currently used as own identity,
|
Edouard@728
|
148 |
// application passes message that have been previously flagged by
|
Edouard@728
|
149 |
// decrypt_message() as own message containing own key to this function
|
Edouard@728
|
150 |
//
|
Edouard@728
|
151 |
// return value:
|
Edouard@728
|
152 |
// error status or PEP_STATUS_OK on success
|
Edouard@728
|
153 |
//
|
Edouard@728
|
154 |
// caveat:
|
Edouard@728
|
155 |
// the ownership of msg remains with the caller
|
Edouard@728
|
156 |
// the ownership of ident goes to the caller
|
Edouard@728
|
157 |
// msg MUST be encrypted so that this function can check own signature
|
Edouard@728
|
158 |
|
Edouard@728
|
159 |
DYNAMIC_API PEP_STATUS own_message_private_key_details(
|
Edouard@728
|
160 |
PEP_SESSION session,
|
Edouard@728
|
161 |
message *msg,
|
Edouard@728
|
162 |
pEp_identity **ident
|
Edouard@728
|
163 |
);
|
vb@251
|
164 |
|
vb@251
|
165 |
// outgoing_message_color() - get color for an outgoing message
|
vb@189
|
166 |
//
|
vb@189
|
167 |
// parameters:
|
vb@189
|
168 |
// session (in) session handle
|
vb@189
|
169 |
// msg (in) message to get the color for
|
vb@189
|
170 |
// color (out) color for the message
|
vb@189
|
171 |
//
|
vb@189
|
172 |
// return value:
|
vb@189
|
173 |
// error status or PEP_STATUS_OK on success
|
vb@190
|
174 |
//
|
vb@190
|
175 |
// caveat:
|
vb@190
|
176 |
// msg->from must point to a valid pEp_identity
|
vb@251
|
177 |
// msg->dir must be PEP_dir_outgoing
|
vb@251
|
178 |
// the ownership of msg remains with the caller
|
vb@189
|
179 |
|
vb@251
|
180 |
DYNAMIC_API PEP_STATUS outgoing_message_color(
|
vb@189
|
181 |
PEP_SESSION session,
|
vb@190
|
182 |
message *msg,
|
vb@232
|
183 |
PEP_color *color
|
vb@189
|
184 |
);
|
vb@189
|
185 |
|
vb@239
|
186 |
|
vb@240
|
187 |
// identity_color() - get color for a single identity
|
vb@239
|
188 |
//
|
vb@239
|
189 |
// parameters:
|
vb@239
|
190 |
// session (in) session handle
|
vb@239
|
191 |
// ident (in) identity to get the color for
|
vb@239
|
192 |
// color (out) color for the identity
|
vb@239
|
193 |
//
|
vb@239
|
194 |
// return value:
|
vb@239
|
195 |
// error status or PEP_STATUS_OK on success
|
vb@251
|
196 |
//
|
vb@251
|
197 |
// caveat:
|
vb@251
|
198 |
// the ownership of ident remains with the caller
|
vb@239
|
199 |
|
vb@240
|
200 |
DYNAMIC_API PEP_STATUS identity_color(
|
vb@239
|
201 |
PEP_SESSION session,
|
vb@239
|
202 |
pEp_identity *ident,
|
vb@239
|
203 |
PEP_color *color
|
vb@239
|
204 |
);
|
vb@239
|
205 |
|
vb@239
|
206 |
|
vb@507
|
207 |
// get_binary_path() - retrieve path of cryptotech binary if available
|
vb@507
|
208 |
//
|
vb@507
|
209 |
// parameters:
|
vb@507
|
210 |
// tech (in) cryptotech to get the binary for
|
vb@507
|
211 |
// path (out) path to cryptotech binary or NULL if not available
|
roker@540
|
212 |
// **path is owned by the library, do not change it!
|
vb@507
|
213 |
DYNAMIC_API PEP_STATUS get_binary_path(PEP_cryptotech tech, const char **path);
|
vb@507
|
214 |
|
vb@507
|
215 |
|
vb@37
|
216 |
#ifdef __cplusplus
|
vb@37
|
217 |
}
|
vb@37
|
218 |
#endif
|
vb@37
|
219 |
|