vb@23
|
1 |
#pragma once
|
vb@23
|
2 |
|
vb@0
|
3 |
#ifdef __cplusplus
|
vb@0
|
4 |
extern "C" {
|
vb@0
|
5 |
#endif
|
vb@0
|
6 |
|
vb@25
|
7 |
#include <stddef.h>
|
vb@0
|
8 |
#include <stdint.h>
|
vb@0
|
9 |
#include <stdbool.h>
|
vb@0
|
10 |
|
vb@98
|
11 |
#include "dynamic_api.h"
|
vb@98
|
12 |
#include "stringlist.h"
|
vb@201
|
13 |
#include "timestamp.h"
|
vb@0
|
14 |
|
vb@94
|
15 |
#define PEP_VERSION "1.0"
|
vb@94
|
16 |
|
vb@0
|
17 |
// pEp Engine API
|
vb@0
|
18 |
|
vb@0
|
19 |
// caveat:
|
vb@0
|
20 |
// Unicode data has to be normalized to NFC before calling
|
vb@0
|
21 |
// UTF-8 strings are UTF-8 encoded C strings (zero terminated)
|
vb@0
|
22 |
|
vb@0
|
23 |
|
vb@46
|
24 |
struct _pEpSession;
|
vb@46
|
25 |
typedef struct _pEpSession * PEP_SESSION;
|
vb@0
|
26 |
|
vb@0
|
27 |
typedef enum {
|
vb@0
|
28 |
PEP_STATUS_OK = 0,
|
vb@0
|
29 |
|
vb@0
|
30 |
PEP_INIT_CANNOT_LOAD_GPGME = 0x0110,
|
vb@0
|
31 |
PEP_INIT_GPGME_INIT_FAILED = 0x0111,
|
Edouard@175
|
32 |
PEP_INIT_NO_GPG_HOME = 0x0112,
|
Edouard@175
|
33 |
PEP_INIT_NETPGP_INIT_FAILED = 0x0113,
|
vb@0
|
34 |
|
vb@0
|
35 |
PEP_INIT_SQLITE3_WITHOUT_MUTEX = 0x0120,
|
vb@0
|
36 |
PEP_INIT_CANNOT_OPEN_DB = 0x0121,
|
vb@0
|
37 |
PEP_INIT_CANNOT_OPEN_SYSTEM_DB = 0x0122,
|
vb@0
|
38 |
|
vb@0
|
39 |
PEP_KEY_NOT_FOUND = 0x0201,
|
vb@0
|
40 |
PEP_KEY_HAS_AMBIG_NAME = 0x0202,
|
vb@0
|
41 |
PEP_GET_KEY_FAILED = 0x0203,
|
vb@0
|
42 |
|
vb@0
|
43 |
PEP_CANNOT_FIND_IDENTITY = 0x0301,
|
vb@0
|
44 |
PEP_CANNOT_SET_PERSON = 0x0381,
|
vb@0
|
45 |
PEP_CANNOT_SET_PGP_KEYPAIR = 0x0382,
|
vb@0
|
46 |
PEP_CANNOT_SET_IDENTITY = 0x0383,
|
vb@0
|
47 |
|
vb@0
|
48 |
PEP_UNENCRYPTED = 0x0400,
|
vb@0
|
49 |
PEP_VERIFIED = 0x0401,
|
vb@0
|
50 |
PEP_DECRYPTED = 0x0402,
|
vb@0
|
51 |
PEP_DECRYPTED_AND_VERIFIED = 0x0403,
|
vb@0
|
52 |
PEP_DECRYPT_WRONG_FORMAT = 0x0404,
|
vb@0
|
53 |
PEP_DECRYPT_NO_KEY = 0x0405,
|
vb@0
|
54 |
PEP_DECRYPT_SIGNATURE_DOES_NOT_MATCH = 0x0406,
|
vb@0
|
55 |
PEP_VERIFY_NO_KEY = 0x0407,
|
vb@0
|
56 |
PEP_VERIFIED_AND_TRUSTED = 0x0408,
|
vb@0
|
57 |
PEP_CANNOT_DECRYPT_UNKNOWN = 0x04ff,
|
vb@0
|
58 |
|
vb@251
|
59 |
PEP_TRUSTWORD_NOT_FOUND = 0x0501,
|
vb@0
|
60 |
|
vb@0
|
61 |
PEP_CANNOT_CREATE_KEY = 0x0601,
|
vb@0
|
62 |
PEP_CANNOT_SEND_KEY = 0x0602,
|
vb@0
|
63 |
|
vb@0
|
64 |
PEP_COMMIT_FAILED = 0xff01,
|
vb@0
|
65 |
|
vb@44
|
66 |
PEP_CANNOT_CREATE_TEMP_FILE = -5,
|
vb@0
|
67 |
PEP_ILLEGAL_VALUE = -4,
|
vb@0
|
68 |
PEP_BUFFER_TOO_SMALL = -3,
|
vb@0
|
69 |
PEP_OUT_OF_MEMORY = -2,
|
vb@0
|
70 |
PEP_UNKNOWN_ERROR = -1
|
vb@0
|
71 |
} PEP_STATUS;
|
vb@0
|
72 |
|
vb@0
|
73 |
|
vb@0
|
74 |
// INIT_STATUS init() - initialize pEpEngine for a thread
|
vb@0
|
75 |
//
|
vb@0
|
76 |
// parameters:
|
vb@0
|
77 |
// session (out) init() allocates session memory and returns a pointer
|
vb@0
|
78 |
// as a handle
|
vb@0
|
79 |
//
|
vb@0
|
80 |
// return value:
|
vb@0
|
81 |
// PEP_STATUS_OK = 0 if init() succeeds
|
vb@0
|
82 |
// PEP_INIT_SQLITE3_WITHOUT_MUTEX if SQLite3 was compiled with
|
vb@0
|
83 |
// SQLITE_THREADSAFE 0
|
vb@0
|
84 |
// PEP_INIT_CANNOT_LOAD_GPGME if libgpgme.dll cannot be found
|
vb@0
|
85 |
// PEP_INIT_GPGME_INIT_FAILED if GPGME init fails
|
vb@0
|
86 |
// PEP_INIT_CANNOT_OPEN_DB if user's management db cannot be
|
vb@0
|
87 |
// opened
|
vb@0
|
88 |
// PEP_INIT_CANNOT_OPEN_SYSTEM_DB if system's management db cannot be
|
vb@0
|
89 |
// opened
|
vb@0
|
90 |
//
|
vb@0
|
91 |
// caveat:
|
vb@0
|
92 |
// the pointer is valid only if the return value is PEP_STATUS_OK
|
vb@0
|
93 |
// in other case a NULL pointer will be returned; a valid handle must
|
vb@0
|
94 |
// be released using release() when it's no longer needed
|
vb@62
|
95 |
//
|
vb@62
|
96 |
// the caller has to guarantee that the first call to this function
|
vb@62
|
97 |
// will succeed before further calls can be done
|
vb@0
|
98 |
|
vb@0
|
99 |
DYNAMIC_API PEP_STATUS init(PEP_SESSION *session);
|
vb@0
|
100 |
|
vb@0
|
101 |
|
vb@0
|
102 |
// void release() - release thread session handle
|
vb@0
|
103 |
//
|
vb@0
|
104 |
// parameters:
|
vb@0
|
105 |
// session (in) session handle to release
|
vb@62
|
106 |
//
|
vb@62
|
107 |
// caveat:
|
vb@62
|
108 |
// the last release() can be called only when all other release() calls
|
vb@62
|
109 |
// are done
|
vb@0
|
110 |
|
vb@0
|
111 |
DYNAMIC_API void release(PEP_SESSION session);
|
vb@0
|
112 |
|
vb@0
|
113 |
|
vb@0
|
114 |
// decrypt_and_verify() - decrypt and/or verify a message
|
vb@0
|
115 |
//
|
vb@0
|
116 |
// parameters:
|
vb@0
|
117 |
// session (in) session handle
|
vb@0
|
118 |
// ctext (in) cipher text to decrypt and/or verify
|
vb@0
|
119 |
// csize (in) size of cipher text
|
vb@0
|
120 |
// ptext (out) pointer to internal buffer with plain text
|
vb@0
|
121 |
// psize (out) size of plain text
|
vb@15
|
122 |
// keylist (out) list of key ids which where used to encrypt
|
vb@0
|
123 |
//
|
vb@0
|
124 |
// return value:
|
vb@0
|
125 |
// PEP_UNENCRYPTED message was unencrypted and not signed
|
vb@0
|
126 |
// PEP_VERIFIED message was unencrypted, signature matches
|
vb@0
|
127 |
// PEP_DECRYPTED message is decrypted now, no signature
|
vb@0
|
128 |
// PEP_DECRYPTED_AND_VERIFIED message is decrypted now and verified
|
vb@0
|
129 |
// PEP_DECRYPT_WRONG_FORMAT message has wrong format to handle
|
vb@0
|
130 |
// PEP_DECRYPT_NO_KEY key not available to decrypt and/or verify
|
vb@0
|
131 |
// PEP_DECRYPT_SIGNATURE_DOES_NOT_MATCH wrong signature
|
vb@0
|
132 |
//
|
vb@0
|
133 |
// caveat:
|
vb@0
|
134 |
// the ownerships of ptext as well as keylist are going to the caller
|
vb@0
|
135 |
// the caller must use free() (or an Windoze pEp_free()) and
|
vb@0
|
136 |
// free_stringlist() to free them
|
vb@15
|
137 |
//
|
vb@15
|
138 |
// if this function failes an error message may be the first element of
|
vb@15
|
139 |
// keylist and the other elements may be the keys used for encryption
|
vb@0
|
140 |
|
vb@0
|
141 |
DYNAMIC_API PEP_STATUS decrypt_and_verify(
|
vb@0
|
142 |
PEP_SESSION session, const char *ctext, size_t csize,
|
vb@0
|
143 |
char **ptext, size_t *psize, stringlist_t **keylist
|
vb@0
|
144 |
);
|
vb@0
|
145 |
|
vb@0
|
146 |
|
vb@0
|
147 |
// verify_text() - verfy plain text with a digital signature
|
vb@0
|
148 |
//
|
vb@0
|
149 |
// parameters:
|
vb@0
|
150 |
// session (in) session handle
|
vb@0
|
151 |
// text (in) text to verify
|
vb@0
|
152 |
// size (in) size of text
|
vb@0
|
153 |
// signature (in) signature text
|
vb@0
|
154 |
// sig_size (in) size of signature
|
vb@6
|
155 |
// keylist (out) list of key ids which where used to encrypt or NULL on
|
vb@0
|
156 |
// error
|
vb@0
|
157 |
//
|
vb@0
|
158 |
// return value:
|
vb@0
|
159 |
// PEP_VERIFIED message was unencrypted, signature matches
|
vb@0
|
160 |
// PEP_DECRYPT_NO_KEY key not available to decrypt and/or verify
|
vb@0
|
161 |
// PEP_DECRYPT_SIGNATURE_DOES_NOT_MATCH wrong signature
|
vb@0
|
162 |
|
vb@0
|
163 |
DYNAMIC_API PEP_STATUS verify_text(
|
vb@0
|
164 |
PEP_SESSION session, const char *text, size_t size,
|
vb@0
|
165 |
const char *signature, size_t sig_size, stringlist_t **keylist
|
vb@0
|
166 |
);
|
vb@0
|
167 |
|
vb@0
|
168 |
|
vb@0
|
169 |
// encrypt_and_sign() - encrypt and sign a message
|
vb@0
|
170 |
//
|
vb@0
|
171 |
// parameters:
|
vb@0
|
172 |
// session (in) session handle
|
vb@6
|
173 |
// keylist (in) list of key ids to encrypt with as C strings
|
vb@0
|
174 |
// ptext (in) plain text to decrypt and/or verify
|
vb@0
|
175 |
// psize (in) size of plain text
|
vb@0
|
176 |
// ctext (out) pointer to internal buffer with cipher text
|
vb@0
|
177 |
// csize (out) size of cipher text
|
vb@0
|
178 |
//
|
vb@0
|
179 |
// return value:
|
vb@0
|
180 |
// PEP_STATUS_OK = 0 encryption and signing succeeded
|
vb@0
|
181 |
// PEP_KEY_NOT_FOUND at least one of the receipient keys
|
vb@0
|
182 |
// could not be found
|
vb@0
|
183 |
// PEP_KEY_HAS_AMBIG_NAME at least one of the receipient keys has
|
vb@0
|
184 |
// an ambiguous name
|
vb@0
|
185 |
// PEP_GET_KEY_FAILED cannot retrieve key
|
vb@0
|
186 |
//
|
vb@0
|
187 |
// caveat:
|
vb@0
|
188 |
// the ownership of ctext is going to the caller
|
vb@0
|
189 |
// the caller is responsible to free() it (on Windoze use pEp_free())
|
vb@20
|
190 |
// the first key in keylist is being used to sign the message
|
vb@20
|
191 |
// this implies there has to be a private key for that keypair
|
vb@0
|
192 |
|
vb@0
|
193 |
DYNAMIC_API PEP_STATUS encrypt_and_sign(
|
vb@0
|
194 |
PEP_SESSION session, const stringlist_t *keylist, const char *ptext,
|
vb@0
|
195 |
size_t psize, char **ctext, size_t *csize
|
vb@0
|
196 |
);
|
vb@0
|
197 |
|
vb@0
|
198 |
|
vb@0
|
199 |
// log_event() - log a user defined event defined by UTF-8 encoded strings into
|
vb@0
|
200 |
// management log
|
vb@0
|
201 |
//
|
vb@0
|
202 |
// parameters:
|
vb@0
|
203 |
// session (in) session handle
|
vb@0
|
204 |
// title (in) C string with event name
|
vb@0
|
205 |
// entity (in) C string with name of entity which is logging
|
vb@0
|
206 |
// description (in) C string with long description for event or NULL if
|
vb@0
|
207 |
// omitted
|
vb@0
|
208 |
// comment (in) C string with user defined comment or NULL if
|
vb@0
|
209 |
// omitted
|
vb@0
|
210 |
//
|
vb@0
|
211 |
// return value:
|
vb@0
|
212 |
// PEP_STATUS_OK log entry created
|
vb@0
|
213 |
|
vb@0
|
214 |
DYNAMIC_API PEP_STATUS log_event(
|
vb@0
|
215 |
PEP_SESSION session, const char *title, const char *entity,
|
vb@0
|
216 |
const char *description, const char *comment
|
vb@0
|
217 |
);
|
vb@0
|
218 |
|
vb@0
|
219 |
|
vb@233
|
220 |
// trustword() - get the corresponding trustword for a 16 bit value
|
vb@0
|
221 |
//
|
vb@0
|
222 |
// parameters:
|
vb@0
|
223 |
// session (in) session handle
|
vb@233
|
224 |
// value (in) value to find a trustword for
|
vb@0
|
225 |
// lang (in) C string with ISO 3166-1 ALPHA-2 language code
|
vb@233
|
226 |
// word (out) pointer to C string with trustword UTF-8 encoded
|
vb@233
|
227 |
// NULL if language is not supported or trustword
|
vb@0
|
228 |
// wordlist is damaged or unavailable
|
vb@233
|
229 |
// wsize (out) length of trustword
|
vb@0
|
230 |
//
|
vb@0
|
231 |
// return value:
|
vb@233
|
232 |
// PEP_STATUS_OK trustword retrieved
|
vb@251
|
233 |
// PEP_TRUSTWORD_NOT_FOUND trustword not found
|
vb@0
|
234 |
//
|
vb@0
|
235 |
// caveat:
|
vb@0
|
236 |
// the word pointer goes to the ownership of the caller
|
vb@0
|
237 |
// the caller is responsible to free() it (on Windoze use pEp_free())
|
vb@0
|
238 |
|
vb@233
|
239 |
DYNAMIC_API PEP_STATUS trustword(
|
vb@0
|
240 |
PEP_SESSION session, uint16_t value, const char *lang,
|
vb@0
|
241 |
char **word, size_t *wsize
|
vb@0
|
242 |
);
|
vb@0
|
243 |
|
vb@0
|
244 |
|
vb@233
|
245 |
// trustwords() - get trustwords for a string of hex values of a fingerprint
|
vb@0
|
246 |
//
|
vb@0
|
247 |
// parameters:
|
vb@0
|
248 |
// session (in) session handle
|
vb@233
|
249 |
// fingerprint (in) C string with hex values to find trustwords for
|
vb@0
|
250 |
// lang (in) C string with ISO 3166-1 ALPHA-2 language code
|
vb@233
|
251 |
// words (out) pointer to C string with trustwords UTF-8 encoded,
|
vb@0
|
252 |
// separated by a blank each
|
vb@233
|
253 |
// NULL if language is not supported or trustword
|
vb@0
|
254 |
// wordlist is damaged or unavailable
|
vb@233
|
255 |
// wsize (out) length of trustwords string
|
vb@0
|
256 |
// max_words (in) only generate a string with max_words;
|
vb@0
|
257 |
// if max_words == 0 there is no such limit
|
vb@0
|
258 |
//
|
vb@0
|
259 |
// return value:
|
vb@233
|
260 |
// PEP_STATUS_OK trustwords retrieved
|
vb@0
|
261 |
// PEP_OUT_OF_MEMORY out of memory
|
vb@251
|
262 |
// PEP_TRUSTWORD_NOT_FOUND at least one trustword not found
|
vb@0
|
263 |
//
|
vb@0
|
264 |
// caveat:
|
vb@0
|
265 |
// the word pointer goes to the ownership of the caller
|
vb@0
|
266 |
// the caller is responsible to free() it (on Windoze use pEp_free())
|
vb@0
|
267 |
//
|
vb@0
|
268 |
// DON'T USE THIS FUNCTION FROM HIGH LEVEL LANGUAGES!
|
vb@0
|
269 |
//
|
vb@233
|
270 |
// Better implement a simple one in the adapter yourself using trustword(), and
|
vb@233
|
271 |
// return a list of trustwords.
|
vb@0
|
272 |
// This function is provided for being used by C and C++ programs only.
|
vb@0
|
273 |
|
vb@233
|
274 |
DYNAMIC_API PEP_STATUS trustwords(
|
vb@0
|
275 |
PEP_SESSION session, const char *fingerprint, const char *lang,
|
vb@0
|
276 |
char **words, size_t *wsize, int max_words
|
vb@0
|
277 |
);
|
vb@0
|
278 |
|
vb@0
|
279 |
|
vb@0
|
280 |
typedef enum _PEP_comm_type {
|
vb@9
|
281 |
PEP_ct_unknown = 0,
|
vb@0
|
282 |
|
vb@9
|
283 |
// range 0x01 to 0x09: no encryption, 0x0a to 0x0e: nothing reasonable
|
vb@0
|
284 |
|
vb@9
|
285 |
PEP_ct_no_encryption = 0x01, // generic
|
vb@9
|
286 |
PEP_ct_no_encrypted_channel = 0x02,
|
vb@9
|
287 |
PEP_ct_key_not_found = 0x03,
|
vb@9
|
288 |
PEP_ct_key_expired = 0x04,
|
vb@9
|
289 |
PEP_ct_key_revoked = 0x05,
|
vb@9
|
290 |
PEP_ct_key_b0rken = 0x06,
|
vb@9
|
291 |
PEP_ct_my_key_not_included = 0x09,
|
vb@9
|
292 |
|
vb@9
|
293 |
PEP_ct_security_by_obscurity = 0x0a,
|
vb@9
|
294 |
PEP_ct_b0rken_crypto = 0x0b,
|
vb@9
|
295 |
PEP_ct_key_too_short = 0x0e,
|
vb@9
|
296 |
|
vb@0
|
297 |
PEP_ct_compromized = 0x0f, // known compromized connection
|
vb@0
|
298 |
|
vb@9
|
299 |
// range 0x10 to 0x3f: unconfirmed encryption
|
vb@0
|
300 |
|
vb@0
|
301 |
PEP_ct_unconfirmed_encryption = 0x10, // generic
|
vb@122
|
302 |
PEP_ct_OpenPGP_weak_unconfirmed = 0x11, // RSA 1024 is weak
|
vb@190
|
303 |
|
vb@190
|
304 |
PEP_ct_to_be_checked = 0x20, // generic
|
vb@190
|
305 |
PEP_ct_SMIME_unconfirmed = 0x21,
|
vb@190
|
306 |
PEP_ct_CMS_unconfirmed = 0x22,
|
vb@190
|
307 |
|
vb@190
|
308 |
PEP_ct_strong_but_unconfirmed = 0x30, // generic
|
vb@122
|
309 |
PEP_ct_OpenPGP_unconfirmed = 0x38, // key at least 2048 bit RSA or EC
|
vb@122
|
310 |
PEP_ct_OTR_unconfirmed = 0x3a,
|
vb@0
|
311 |
|
vb@9
|
312 |
// range 0x40 to 0x7f: unconfirmed encryption and anonymization
|
vb@0
|
313 |
|
vb@0
|
314 |
PEP_ct_unconfirmed_enc_anon = 0x40, // generic
|
vb@9
|
315 |
PEP_ct_PEP_unconfirmed = 0x7f,
|
vb@0
|
316 |
|
vb@9
|
317 |
PEP_ct_confirmed = 0x80, // this bit decides if trust is confirmed
|
vb@9
|
318 |
|
vb@9
|
319 |
// range 0x81 to 0x8f: reserved
|
vb@9
|
320 |
// range 0x90 to 0xbf: confirmed encryption
|
vb@0
|
321 |
|
vb@0
|
322 |
PEP_ct_confirmed_encryption = 0x90, // generic
|
vb@122
|
323 |
PEP_ct_OpenPGP_weak = 0x91, // RSA 1024 is weak
|
vb@190
|
324 |
|
vb@190
|
325 |
PEP_ct_to_be_checked_confirmed = 0xa0, //generic
|
vb@190
|
326 |
PEP_ct_SMIME = 0xa1,
|
vb@190
|
327 |
PEP_ct_CMS = 0xa2,
|
vb@190
|
328 |
|
vb@190
|
329 |
PEP_ct_strong_encryption = 0xb0, // generic
|
vb@122
|
330 |
PEP_ct_OpenPGP = 0xb8, // key at least 2048 bit RSA or EC
|
vb@122
|
331 |
PEP_ct_OTR = 0xba,
|
vb@0
|
332 |
|
vb@0
|
333 |
// range 0xc0 to 0xff: confirmed encryption and anonymization
|
vb@0
|
334 |
|
vb@0
|
335 |
PEP_ct_confirmed_enc_anon = 0xc0, // generic
|
vb@0
|
336 |
PEP_ct_pEp = 0xff
|
vb@0
|
337 |
} PEP_comm_type;
|
vb@0
|
338 |
|
vb@0
|
339 |
typedef struct _pEp_identity {
|
vb@0
|
340 |
size_t struct_size; // size of whole struct
|
vb@0
|
341 |
char *address; // C string with address UTF-8 encoded
|
vb@0
|
342 |
size_t address_size; // size of address
|
vb@0
|
343 |
char *fpr; // C string with fingerprint UTF-8 encoded
|
vb@0
|
344 |
size_t fpr_size; // size of fingerprint
|
vb@0
|
345 |
char *user_id; // C string with user ID UTF-8 encoded
|
vb@0
|
346 |
size_t user_id_size; // size of user ID
|
vb@0
|
347 |
char *username; // C string with user name UTF-8 encoded
|
vb@0
|
348 |
size_t username_size; // size of user name
|
vb@0
|
349 |
PEP_comm_type comm_type; // type of communication with this ID
|
vb@0
|
350 |
char lang[3]; // language of conversation
|
vb@0
|
351 |
// ISO 639-1 ALPHA-2, last byte is 0
|
vb@0
|
352 |
bool me; // if this is the local user herself/himself
|
vb@0
|
353 |
} pEp_identity;
|
vb@0
|
354 |
|
vb@0
|
355 |
|
vb@0
|
356 |
// new_identity() - allocate memory and set the string and size fields
|
vb@0
|
357 |
//
|
vb@0
|
358 |
// parameters:
|
vb@0
|
359 |
// address (in) UTF-8 string or NULL
|
vb@0
|
360 |
// fpr (in) UTF-8 string or NULL
|
vb@0
|
361 |
// user_id (in) UTF-8 string or NULL
|
vb@0
|
362 |
// username (in) UTF-8 string or NULL
|
vb@0
|
363 |
//
|
vb@0
|
364 |
// return value:
|
vb@0
|
365 |
// pEp_identity struct with correct size values or NULL if out of memory
|
vb@0
|
366 |
//
|
vb@0
|
367 |
// caveat:
|
vb@0
|
368 |
// the strings are copied; the original strings are still being owned by
|
vb@0
|
369 |
// the caller
|
vb@0
|
370 |
|
vb@0
|
371 |
DYNAMIC_API pEp_identity *new_identity(
|
vb@0
|
372 |
const char *address, const char *fpr, const char *user_id,
|
vb@0
|
373 |
const char *username
|
vb@0
|
374 |
);
|
vb@0
|
375 |
|
vb@0
|
376 |
|
vb@37
|
377 |
// identity_dup() - allocate memory and set the string and size fields
|
vb@37
|
378 |
//
|
vb@37
|
379 |
// parameters:
|
vb@37
|
380 |
// src (in) identity to duplicate
|
vb@37
|
381 |
//
|
vb@37
|
382 |
// return value:
|
vb@37
|
383 |
// pEp_identity struct with correct size values or NULL if out of memory
|
vb@37
|
384 |
//
|
vb@37
|
385 |
// caveat:
|
vb@37
|
386 |
// the strings are copied; the original strings are still being owned by
|
vb@37
|
387 |
// the caller
|
vb@37
|
388 |
|
vb@37
|
389 |
DYNAMIC_API pEp_identity *identity_dup(const pEp_identity *src);
|
vb@37
|
390 |
|
vb@37
|
391 |
|
vb@0
|
392 |
// free_identity() - free all memory being occupied by a pEp_identity struct
|
vb@0
|
393 |
//
|
vb@0
|
394 |
// parameters:
|
vb@0
|
395 |
// identity (in) struct to release
|
vb@0
|
396 |
//
|
vb@0
|
397 |
// caveat:
|
vb@0
|
398 |
// not only the struct but also all string memory referenced by the
|
vb@0
|
399 |
// struct is being freed; all pointers inside are invalid afterwards
|
vb@0
|
400 |
|
vb@0
|
401 |
DYNAMIC_API void free_identity(pEp_identity *identity);
|
vb@0
|
402 |
|
vb@0
|
403 |
|
vb@0
|
404 |
// get_identity() - get identity information
|
vb@0
|
405 |
//
|
vb@0
|
406 |
// parameters:
|
vb@0
|
407 |
// session (in) session handle
|
vb@0
|
408 |
// address (in) C string with communication address, UTF-8 encoded
|
vb@0
|
409 |
// identity (out) pointer to pEp_identity structure with results or
|
vb@0
|
410 |
// NULL if failure
|
vb@0
|
411 |
//
|
vb@0
|
412 |
// caveat:
|
vb@0
|
413 |
// the address string is being copied; the original string remains in the
|
vb@0
|
414 |
// ownership of the caller
|
vb@0
|
415 |
// the resulting pEp_identity structure goes to the ownership of the
|
vb@0
|
416 |
// caller and has to be freed with free_identity() when not in use any
|
vb@0
|
417 |
// more
|
vb@0
|
418 |
|
vb@0
|
419 |
DYNAMIC_API PEP_STATUS get_identity(
|
vb@0
|
420 |
PEP_SESSION session, const char *address,
|
vb@0
|
421 |
pEp_identity **identity
|
vb@0
|
422 |
);
|
vb@0
|
423 |
|
vb@0
|
424 |
|
vb@0
|
425 |
// set_identity() - set identity information
|
vb@0
|
426 |
//
|
vb@0
|
427 |
// parameters:
|
vb@0
|
428 |
// session (in) session handle
|
vb@0
|
429 |
// identity (in) pointer to pEp_identity structure
|
vb@0
|
430 |
//
|
vb@0
|
431 |
// return value:
|
vb@0
|
432 |
// PEP_STATUS_OK = 0 encryption and signing succeeded
|
vb@0
|
433 |
// PEP_CANNOT_SET_PERSON writing to table person failed
|
vb@0
|
434 |
// PEP_CANNOT_SET_PGP_KEYPAIR writing to table pgp_keypair failed
|
vb@0
|
435 |
// PEP_CANNOT_SET_IDENTITY writing to table identity failed
|
vb@0
|
436 |
// PEP_COMMIT_FAILED SQL commit failed
|
vb@0
|
437 |
//
|
vb@0
|
438 |
// caveat:
|
vb@0
|
439 |
// in the identity structure you need to set the const char * fields to
|
vb@0
|
440 |
// UTF-8 C strings
|
vb@0
|
441 |
// the size fields are ignored
|
vb@0
|
442 |
|
vb@0
|
443 |
DYNAMIC_API PEP_STATUS set_identity(
|
vb@0
|
444 |
PEP_SESSION session, const pEp_identity *identity
|
vb@0
|
445 |
);
|
vb@0
|
446 |
|
vb@0
|
447 |
|
vb@0
|
448 |
// generate_keypair() - generate a new key pair and add it to the key ring
|
vb@0
|
449 |
//
|
vb@0
|
450 |
// parameters:
|
vb@0
|
451 |
// session (in) session handle
|
vb@0
|
452 |
// identity (inout) pointer to pEp_identity structure
|
vb@0
|
453 |
//
|
vb@0
|
454 |
// return value:
|
vb@0
|
455 |
// PEP_STATUS_OK = 0 encryption and signing succeeded
|
vb@0
|
456 |
// PEP_ILLEGAL_VALUE illegal values for identity fields given
|
vb@0
|
457 |
// PEP_CANNOT_CREATE_KEY key engine is on strike
|
vb@0
|
458 |
//
|
vb@0
|
459 |
// caveat:
|
vb@0
|
460 |
// address and username fields must be set to UTF-8 strings
|
vb@0
|
461 |
// the fpr field must be set to NULL
|
vb@0
|
462 |
//
|
vb@0
|
463 |
// this function allocates a string and sets set fpr field of identity
|
vb@0
|
464 |
// the caller is responsible to call free() for that string or use
|
vb@0
|
465 |
// free_identity() on the struct
|
vb@0
|
466 |
|
vb@0
|
467 |
DYNAMIC_API PEP_STATUS generate_keypair(
|
vb@0
|
468 |
PEP_SESSION session, pEp_identity *identity
|
vb@0
|
469 |
);
|
vb@0
|
470 |
|
vb@0
|
471 |
|
vb@0
|
472 |
// delete_keypair() - delete a public key or a key pair from the key ring
|
vb@0
|
473 |
//
|
vb@0
|
474 |
// parameters:
|
vb@0
|
475 |
// session (in) session handle
|
vb@0
|
476 |
// fpr (in) C string with key id or fingerprint of the
|
vb@0
|
477 |
// public key
|
vb@0
|
478 |
//
|
vb@0
|
479 |
// return value:
|
vb@0
|
480 |
// PEP_STATUS_OK = 0 key was successfully deleted
|
vb@0
|
481 |
// PEP_KEY_NOT_FOUND key not found
|
vb@0
|
482 |
// PEP_ILLEGAL_VALUE not a valid key id or fingerprint
|
vb@0
|
483 |
// PEP_KEY_HAS_AMBIG_NAME fpr does not uniquely identify a key
|
vb@0
|
484 |
// PEP_OUT_OF_MEMORY out of memory
|
vb@0
|
485 |
|
vb@0
|
486 |
DYNAMIC_API PEP_STATUS delete_keypair(PEP_SESSION session, const char *fpr);
|
vb@0
|
487 |
|
vb@0
|
488 |
|
vb@0
|
489 |
// import_key() - import key from data
|
vb@0
|
490 |
//
|
vb@0
|
491 |
// parameters:
|
vb@0
|
492 |
// session (in) session handle
|
vb@0
|
493 |
// key_data (in) key data, i.e. ASCII armored OpenPGP key
|
vb@0
|
494 |
// size (in) amount of data to handle
|
vb@0
|
495 |
//
|
vb@0
|
496 |
// return value:
|
vb@0
|
497 |
// PEP_STATUS_OK = 0 key was successfully imported
|
vb@0
|
498 |
// PEP_OUT_OF_MEMORY out of memory
|
vb@0
|
499 |
// PEP_ILLEGAL_VALUE there is no key data to import
|
vb@0
|
500 |
|
vb@0
|
501 |
DYNAMIC_API PEP_STATUS import_key(PEP_SESSION session, const char *key_data, size_t size);
|
vb@0
|
502 |
|
vb@0
|
503 |
|
vb@0
|
504 |
// export_key() - export ascii armored key
|
vb@0
|
505 |
//
|
vb@0
|
506 |
// parameters:
|
vb@0
|
507 |
// session (in) session handle
|
vb@0
|
508 |
// fpr (in) key id or fingerprint of key
|
vb@0
|
509 |
// key_data (out) ASCII armored OpenPGP key
|
vb@0
|
510 |
// size (out) amount of data to handle
|
vb@0
|
511 |
//
|
vb@0
|
512 |
// return value:
|
vb@0
|
513 |
// PEP_STATUS_OK = 0 key was successfully exported
|
vb@0
|
514 |
// PEP_OUT_OF_MEMORY out of memory
|
vb@0
|
515 |
// PEP_KEY_NOT_FOUND key not found
|
vb@0
|
516 |
//
|
vb@0
|
517 |
// caveat:
|
vb@0
|
518 |
// the key_data goes to the ownership of the caller
|
vb@0
|
519 |
// the caller is responsible to free() it (on Windoze use pEp_free())
|
vb@0
|
520 |
|
vb@0
|
521 |
DYNAMIC_API PEP_STATUS export_key(
|
vb@0
|
522 |
PEP_SESSION session, const char *fpr, char **key_data, size_t *size
|
vb@0
|
523 |
);
|
vb@0
|
524 |
|
vb@0
|
525 |
|
vb@0
|
526 |
// recv_key() - update key(s) from keyserver
|
vb@0
|
527 |
//
|
vb@0
|
528 |
// parameters:
|
vb@0
|
529 |
// session (in) session handle
|
vb@0
|
530 |
// pattern (in) key id, user id or address to search for as
|
vb@0
|
531 |
// UTF-8 string
|
vb@0
|
532 |
|
vb@0
|
533 |
DYNAMIC_API PEP_STATUS recv_key(PEP_SESSION session, const char *pattern);
|
vb@0
|
534 |
|
vb@0
|
535 |
|
vb@0
|
536 |
// find_keys() - find keys in keyring
|
vb@0
|
537 |
//
|
vb@0
|
538 |
// parameters:
|
vb@0
|
539 |
// session (in) session handle
|
vb@0
|
540 |
// pattern (in) key id, user id or address to search for as
|
vb@0
|
541 |
// UTF-8 string
|
vb@0
|
542 |
// keylist (out) list of fingerprints found or NULL on error
|
vb@0
|
543 |
//
|
vb@0
|
544 |
// caveat:
|
vb@0
|
545 |
// the ownerships of keylist isgoing to the caller
|
vb@0
|
546 |
// the caller must use free_stringlist() to free it
|
vb@0
|
547 |
|
vb@0
|
548 |
|
vb@0
|
549 |
DYNAMIC_API PEP_STATUS find_keys(
|
vb@0
|
550 |
PEP_SESSION session, const char *pattern, stringlist_t **keylist
|
vb@0
|
551 |
);
|
vb@0
|
552 |
|
vb@0
|
553 |
|
vb@0
|
554 |
// send_key() - send key(s) to keyserver
|
vb@0
|
555 |
//
|
vb@0
|
556 |
// parameters:
|
vb@0
|
557 |
// session (in) session handle
|
vb@0
|
558 |
// pattern (in) key id, user id or address to search for as
|
vb@0
|
559 |
// UTF-8 string
|
vb@0
|
560 |
|
vb@0
|
561 |
DYNAMIC_API PEP_STATUS send_key(PEP_SESSION session, const char *pattern);
|
vb@0
|
562 |
|
vb@0
|
563 |
|
vb@0
|
564 |
// pEp_free() - free memory allocated by pEp engine
|
vb@0
|
565 |
//
|
vb@0
|
566 |
// parameters:
|
vb@0
|
567 |
// p (in) pointer to free
|
vb@0
|
568 |
//
|
vb@0
|
569 |
// The reason for this function is that heap management can be a pretty
|
vb@0
|
570 |
// complex task with Windoze. This free() version calls the free()
|
vb@0
|
571 |
// implementation of the C runtime library which was used to build pEp engine,
|
vb@0
|
572 |
// so you're using the correct heap. For more information, see:
|
vb@0
|
573 |
// <http://msdn.microsoft.com/en-us/library/windows/desktop/aa366711(v=vs.85).aspx>
|
vb@0
|
574 |
|
vb@0
|
575 |
DYNAMIC_API void pEp_free(void *p);
|
vb@0
|
576 |
|
vb@8
|
577 |
|
vb@8
|
578 |
// get_trust() - get the trust level a key has for a person
|
vb@8
|
579 |
//
|
vb@8
|
580 |
// parameters:
|
vb@8
|
581 |
// session (in) session handle
|
vb@8
|
582 |
// identity (inout) user_id and fpr to check as UTF-8 strings (in)
|
vb@8
|
583 |
// user_id and comm_type as result (out)
|
vb@8
|
584 |
//
|
vb@14
|
585 |
// this function modifies the given identity struct; the struct remains in
|
vb@251
|
586 |
// the ownership of the caller
|
vb@14
|
587 |
// if the trust level cannot be determined identity->comm_type is set
|
vb@14
|
588 |
// to PEP_ct_unknown
|
vb@8
|
589 |
|
vb@8
|
590 |
DYNAMIC_API PEP_STATUS get_trust(PEP_SESSION session, pEp_identity *identity);
|
vb@8
|
591 |
|
vb@8
|
592 |
|
vb@251
|
593 |
// least_trust() - get the least known trust level for a key in the database
|
vb@251
|
594 |
//
|
vb@251
|
595 |
// parameters:
|
vb@251
|
596 |
// session (in) session handle
|
vb@251
|
597 |
// fpr (in) fingerprint of key to check
|
vb@251
|
598 |
// comm_type (out) least comm_type as result (out)
|
vb@251
|
599 |
//
|
vb@251
|
600 |
// if the trust level cannot be determined comm_type is set to PEP_ct_unknown
|
vb@251
|
601 |
|
vb@251
|
602 |
DYNAMIC_API PEP_STATUS least_trust(
|
vb@251
|
603 |
PEP_SESSION session,
|
vb@251
|
604 |
const char *fpr,
|
vb@251
|
605 |
PEP_comm_type *comm_type
|
vb@251
|
606 |
);
|
vb@251
|
607 |
|
vb@251
|
608 |
|
vb@9
|
609 |
// get_key_rating() - get the rating a bare key has
|
vb@9
|
610 |
//
|
vb@9
|
611 |
// parameters:
|
vb@9
|
612 |
// session (in) session handle
|
vb@9
|
613 |
// fpr (in) unique identifyer for key as UTF-8 string
|
vb@9
|
614 |
// comm_type (out) key rating
|
vb@10
|
615 |
//
|
vb@14
|
616 |
// if an error occurs, *comm_type is set to PEP_ct_unknown and an error
|
vb@10
|
617 |
// is returned
|
vb@9
|
618 |
|
vb@9
|
619 |
DYNAMIC_API PEP_STATUS get_key_rating(
|
vb@14
|
620 |
PEP_SESSION session,
|
vb@14
|
621 |
const char *fpr,
|
vb@14
|
622 |
PEP_comm_type *comm_type
|
vb@9
|
623 |
);
|
vb@9
|
624 |
|
vb@9
|
625 |
|
vb@198
|
626 |
// renew_key() - renew an expired key
|
vb@196
|
627 |
//
|
vb@196
|
628 |
// parameters:
|
vb@196
|
629 |
// session (in) session handle
|
vb@214
|
630 |
// fpr (in) ID of key to renew as UTF-8 string
|
vb@201
|
631 |
// ts (in) timestamp when key should expire or NULL for
|
vb@201
|
632 |
// default
|
vb@196
|
633 |
|
vb@201
|
634 |
DYNAMIC_API PEP_STATUS renew_key(
|
vb@201
|
635 |
PEP_SESSION session,
|
vb@201
|
636 |
const char *fpr,
|
vb@201
|
637 |
const timestamp *ts
|
vb@201
|
638 |
);
|
vb@196
|
639 |
|
vb@196
|
640 |
|
vb@224
|
641 |
// revoke_key() - revoke a key
|
vb@197
|
642 |
//
|
vb@197
|
643 |
// parameters:
|
vb@197
|
644 |
// session (in) session handle
|
vb@214
|
645 |
// fpr (in) ID of key to revoke as UTF-8 string
|
vb@211
|
646 |
// reason (in) text with reason for revoke as UTF-8 string
|
vb@211
|
647 |
// or NULL if reason unknown
|
vb@211
|
648 |
//
|
vb@211
|
649 |
// caveat:
|
vb@211
|
650 |
// reason text must not include empty lines
|
vb@224
|
651 |
// this function is meant for internal use only; better use
|
vb@224
|
652 |
// key_compromized() of keymanagement API
|
vb@197
|
653 |
|
vb@211
|
654 |
DYNAMIC_API PEP_STATUS revoke_key(
|
vb@211
|
655 |
PEP_SESSION session,
|
vb@211
|
656 |
const char *fpr,
|
vb@211
|
657 |
const char *reason
|
vb@211
|
658 |
);
|
vb@197
|
659 |
|
vb@197
|
660 |
|
vb@214
|
661 |
// key_expired() - flags if a key is already expired
|
vb@214
|
662 |
//
|
vb@214
|
663 |
// parameters:
|
vb@214
|
664 |
// session (in) session handle
|
vb@214
|
665 |
// fpr (in) ID of key to check as UTF-8 string
|
vb@214
|
666 |
// expired (out) flag if key expired
|
vb@214
|
667 |
|
vb@214
|
668 |
DYNAMIC_API PEP_STATUS key_expired(
|
vb@214
|
669 |
PEP_SESSION session,
|
vb@214
|
670 |
const char *fpr,
|
vb@214
|
671 |
bool *expired
|
vb@214
|
672 |
);
|
vb@214
|
673 |
|
vb@214
|
674 |
|
vb@0
|
675 |
#ifdef __cplusplus
|
vb@0
|
676 |
}
|
vb@0
|
677 |
#endif
|