Replace use of Sequoia's backend with a custom key store.
- Sequoia's key store doesn't meet pep's needs (in particular, the
ability to search on a key's user id) and trying to shoehorn pep's
needs onto Sequoia's key store abstractions is just introducing
overhead with no appreciable gain in functionality.
- This patch changes the Sequoia backend to use a local sqlite
database to store the public keys.
1 // This file is under GNU General Public License 3.0
14 #include "dynamic_api.h"
15 #include "stringlist.h"
16 #include "stringpair.h"
17 #include "labeled_int_list.h"
18 #include "timestamp.h"
20 #define PEP_VERSION "2.0" // protocol version
22 #define PEP_OWN_USERID "pEp_own_userId"
27 // Unicode data has to be normalized to NFC before calling
28 // UTF-8 strings are UTF-8 encoded C strings (zero terminated)
32 typedef struct _pEpSession * PEP_SESSION;
37 PEP_INIT_CANNOT_LOAD_GPGME = 0x0110,
38 PEP_INIT_GPGME_INIT_FAILED = 0x0111,
39 PEP_INIT_NO_GPG_HOME = 0x0112,
40 PEP_INIT_NETPGP_INIT_FAILED = 0x0113,
41 PEP_INIT_CANNOT_DETERMINE_GPG_VERSION = 0x0114,
42 PEP_INIT_UNSUPPORTED_GPG_VERSION = 0x0115,
43 PEP_INIT_CANNOT_CONFIG_GPG_AGENT = 0x0116,
45 PEP_INIT_SQLITE3_WITHOUT_MUTEX = 0x0120,
46 PEP_INIT_CANNOT_OPEN_DB = 0x0121,
47 PEP_INIT_CANNOT_OPEN_SYSTEM_DB = 0x0122,
48 PEP_UNKNOWN_DB_ERROR = 0x01ff,
50 PEP_KEY_NOT_FOUND = 0x0201,
51 PEP_KEY_HAS_AMBIG_NAME = 0x0202,
52 PEP_GET_KEY_FAILED = 0x0203,
53 PEP_CANNOT_EXPORT_KEY = 0x0204,
54 PEP_CANNOT_EDIT_KEY = 0x0205,
55 PEP_KEY_UNSUITABLE = 0x0206,
56 PEP_MALFORMED_KEY_RESET_MSG = 0x0210,
57 PEP_KEY_NOT_RESET = 0x0211,
59 PEP_CANNOT_FIND_IDENTITY = 0x0301,
60 PEP_CANNOT_SET_PERSON = 0x0381,
61 PEP_CANNOT_SET_PGP_KEYPAIR = 0x0382,
62 PEP_CANNOT_SET_IDENTITY = 0x0383,
63 PEP_CANNOT_SET_TRUST = 0x0384,
64 PEP_KEY_BLACKLISTED = 0x0385,
65 PEP_CANNOT_FIND_PERSON = 0x0386,
67 PEP_CANNOT_FIND_ALIAS = 0x0391,
68 PEP_CANNOT_SET_ALIAS = 0x0392,
70 PEP_UNENCRYPTED = 0x0400,
71 PEP_VERIFIED = 0x0401,
72 PEP_DECRYPTED = 0x0402,
73 PEP_DECRYPTED_AND_VERIFIED = 0x0403,
74 PEP_DECRYPT_WRONG_FORMAT = 0x0404,
75 PEP_DECRYPT_NO_KEY = 0x0405,
76 PEP_DECRYPT_SIGNATURE_DOES_NOT_MATCH = 0x0406,
77 PEP_VERIFY_NO_KEY = 0x0407,
78 PEP_VERIFIED_AND_TRUSTED = 0x0408,
79 PEP_CANNOT_REENCRYPT = 0x0409,
80 PEP_CANNOT_DECRYPT_UNKNOWN = 0x04ff,
82 PEP_TRUSTWORD_NOT_FOUND = 0x0501,
83 PEP_TRUSTWORDS_FPR_WRONG_LENGTH = 0x0502,
84 PEP_TRUSTWORDS_DUPLICATE_FPR = 0x0503,
86 PEP_CANNOT_CREATE_KEY = 0x0601,
87 PEP_CANNOT_SEND_KEY = 0x0602,
89 PEP_PHRASE_NOT_FOUND = 0x0701,
91 PEP_SEND_FUNCTION_NOT_REGISTERED = 0x0801,
92 PEP_CONTRAINTS_VIOLATED = 0x0802,
93 PEP_CANNOT_ENCODE = 0x0803,
95 PEP_SYNC_NO_NOTIFY_CALLBACK = 0x0901,
96 PEP_SYNC_ILLEGAL_MESSAGE = 0x0902,
97 PEP_SYNC_NO_INJECT_CALLBACK = 0x0903,
98 PEP_SYNC_NO_CHANNEL = 0x0904,
99 PEP_SYNC_CANNOT_ENCRYPT = 0x0905,
100 PEP_SYNC_NO_MESSAGE_SEND_CALLBACK = 0x0906,
102 PEP_CANNOT_INCREASE_SEQUENCE = 0x0971,
104 PEP_STATEMACHINE_ERROR = 0x0980,
105 PEP_NO_TRUST = 0x0981,
106 PEP_STATEMACHINE_INVALID_STATE = 0x0982,
107 PEP_STATEMACHINE_INVALID_EVENT = 0x0983,
108 PEP_STATEMACHINE_INVALID_CONDITION = 0x0984,
109 PEP_STATEMACHINE_INVALID_ACTION = 0x0985,
110 PEP_STATEMACHINE_INHIBITED_EVENT = 0x0986,
111 PEP_STATEMACHINE_CANNOT_SEND = 0x0987,
113 PEP_COMMIT_FAILED = 0xff01,
114 PEP_MESSAGE_CONSUME = 0xff02,
115 PEP_MESSAGE_IGNORE = 0xff03,
117 PEP_RECORD_NOT_FOUND = -6,
118 PEP_CANNOT_CREATE_TEMP_FILE = -5,
119 PEP_ILLEGAL_VALUE = -4,
120 PEP_BUFFER_TOO_SMALL = -3,
121 PEP_OUT_OF_MEMORY = -2,
122 PEP_UNKNOWN_ERROR = -1,
124 PEP_VERSION_MISMATCH = -7,
128 // messageToSend() - a message needs to be delivered by application
131 // msg (in) message struct with message to send
134 // PEP_STATUS_OK or any other value on error
137 // the ownership of msg goes to the callee
140 typedef PEP_STATUS (*messageToSend_t)(struct _message *msg);
144 typedef struct Sync_event *SYNC_EVENT;
146 // free_Sync_event() - free memory occupied by sync protocol message
149 // ev (in) event to free
151 void free_Sync_event(SYNC_EVENT ev);
154 // inject_sync_event - inject sync protocol message
157 // ev (in) event to inject
158 // management (in) application defined; usually a locked queue
161 // 0 if event could be stored successfully or nonzero otherwise
163 typedef int (*inject_sync_event_t)(SYNC_EVENT ev, void *management);
165 static inline const char *pep_status_to_string(PEP_STATUS status) {
167 case PEP_STATUS_OK: return "PEP_STATUS_OK";
169 case PEP_INIT_CANNOT_LOAD_GPGME: return "PEP_INIT_CANNOT_LOAD_GPGME";
170 case PEP_INIT_GPGME_INIT_FAILED: return "PEP_INIT_GPGME_INIT_FAILED";
171 case PEP_INIT_NO_GPG_HOME: return "PEP_INIT_NO_GPG_HOME";
172 case PEP_INIT_NETPGP_INIT_FAILED: return "PEP_INIT_NETPGP_INIT_FAILED";
173 case PEP_INIT_CANNOT_DETERMINE_GPG_VERSION: return "PEP_INIT_CANNOT_DETERMINE_GPG_VERSION";
174 case PEP_INIT_UNSUPPORTED_GPG_VERSION: return "PEP_INIT_UNSUPPORTED_GPG_VERSION";
175 case PEP_INIT_CANNOT_CONFIG_GPG_AGENT: return "PEP_INIT_CANNOT_CONFIG_GPG_AGENT";
176 case PEP_INIT_SQLITE3_WITHOUT_MUTEX: return "PEP_INIT_SQLITE3_WITHOUT_MUTEX";
177 case PEP_INIT_CANNOT_OPEN_DB: return "PEP_INIT_CANNOT_OPEN_DB";
178 case PEP_INIT_CANNOT_OPEN_SYSTEM_DB: return "PEP_INIT_CANNOT_OPEN_SYSTEM_DB";
179 case PEP_UNKNOWN_DB_ERROR: return "PEP_UNKNOWN_DB_ERROR";
180 case PEP_KEY_NOT_FOUND: return "PEP_KEY_NOT_FOUND";
181 case PEP_KEY_HAS_AMBIG_NAME: return "PEP_KEY_HAS_AMBIG_NAME";
182 case PEP_GET_KEY_FAILED: return "PEP_GET_KEY_FAILED";
183 case PEP_CANNOT_EXPORT_KEY: return "PEP_CANNOT_EXPORT_KEY";
184 case PEP_CANNOT_EDIT_KEY: return "PEP_CANNOT_EDIT_KEY";
185 case PEP_KEY_UNSUITABLE: return "PEP_KEY_UNSUITABLE";
186 case PEP_MALFORMED_KEY_RESET_MSG: return "PEP_MALFORMED_KEY_RESET_MSG";
187 case PEP_KEY_NOT_RESET: return "PEP_KEY_NOT_RESET";
189 case PEP_CANNOT_FIND_IDENTITY: return "PEP_CANNOT_FIND_IDENTITY";
190 case PEP_CANNOT_SET_PERSON: return "PEP_CANNOT_SET_PERSON";
191 case PEP_CANNOT_SET_PGP_KEYPAIR: return "PEP_CANNOT_SET_PGP_KEYPAIR";
192 case PEP_CANNOT_SET_IDENTITY: return "PEP_CANNOT_SET_IDENTITY";
193 case PEP_CANNOT_SET_TRUST: return "PEP_CANNOT_SET_TRUST";
194 case PEP_KEY_BLACKLISTED: return "PEP_KEY_BLACKLISTED";
195 case PEP_CANNOT_FIND_PERSON: return "PEP_CANNOT_FIND_PERSON";
197 case PEP_CANNOT_FIND_ALIAS: return "PEP_CANNOT_FIND_ALIAS";
198 case PEP_CANNOT_SET_ALIAS: return "PEP_CANNOT_SET_ALIAS";
200 case PEP_UNENCRYPTED: return "PEP_UNENCRYPTED";
201 case PEP_VERIFIED: return "PEP_VERIFIED";
202 case PEP_DECRYPTED: return "PEP_DECRYPTED";
203 case PEP_DECRYPTED_AND_VERIFIED: return "PEP_DECRYPTED_AND_VERIFIED";
204 case PEP_DECRYPT_WRONG_FORMAT: return "PEP_DECRYPT_WRONG_FORMAT";
205 case PEP_DECRYPT_NO_KEY: return "PEP_DECRYPT_NO_KEY";
206 case PEP_DECRYPT_SIGNATURE_DOES_NOT_MATCH: return "PEP_DECRYPT_SIGNATURE_DOES_NOT_MATCH";
207 case PEP_VERIFY_NO_KEY: return "PEP_VERIFY_NO_KEY";
208 case PEP_VERIFIED_AND_TRUSTED: return "PEP_VERIFIED_AND_TRUSTED";
209 case PEP_CANNOT_REENCRYPT: return "PEP_CANNOT_REENCRYPT";
210 case PEP_CANNOT_DECRYPT_UNKNOWN: return "PEP_CANNOT_DECRYPT_UNKNOWN";
212 case PEP_TRUSTWORD_NOT_FOUND: return "PEP_TRUSTWORD_NOT_FOUND";
213 case PEP_TRUSTWORDS_FPR_WRONG_LENGTH: return "PEP_TRUSTWORDS_FPR_WRONG_LENGTH";
214 case PEP_TRUSTWORDS_DUPLICATE_FPR: return "PEP_TRUSTWORDS_DUPLICATE_FPR";
216 case PEP_CANNOT_CREATE_KEY: return "PEP_CANNOT_CREATE_KEY";
217 case PEP_CANNOT_SEND_KEY: return "PEP_CANNOT_SEND_KEY";
219 case PEP_PHRASE_NOT_FOUND: return "PEP_PHRASE_NOT_FOUND";
221 case PEP_SEND_FUNCTION_NOT_REGISTERED: return "PEP_SEND_FUNCTION_NOT_REGISTERED";
222 case PEP_CONTRAINTS_VIOLATED: return "PEP_CONTRAINTS_VIOLATED";
223 case PEP_CANNOT_ENCODE: return "PEP_CANNOT_ENCODE";
225 case PEP_SYNC_NO_NOTIFY_CALLBACK: return "PEP_SYNC_NO_NOTIFY_CALLBACK";
226 case PEP_SYNC_ILLEGAL_MESSAGE: return "PEP_SYNC_ILLEGAL_MESSAGE";
227 case PEP_SYNC_NO_INJECT_CALLBACK: return "PEP_SYNC_NO_INJECT_CALLBACK";
228 case PEP_SYNC_NO_CHANNEL: return "PEP_SYNC_NO_CHANNEL";
229 case PEP_SYNC_CANNOT_ENCRYPT: return "PEP_SYNC_CANNOT_ENCRYPT";
230 case PEP_SYNC_NO_MESSAGE_SEND_CALLBACK: return "PEP_SYNC_NO_MESSAGE_SEND_CALLBACK";
232 case PEP_CANNOT_INCREASE_SEQUENCE: return "PEP_CANNOT_INCREASE_SEQUENCE";
234 case PEP_STATEMACHINE_ERROR: return "PEP_STATEMACHINE_ERROR";
235 case PEP_NO_TRUST: return "PEP_NO_TRUST";
236 case PEP_STATEMACHINE_INVALID_STATE: return "PEP_STATEMACHINE_INVALID_STATE";
237 case PEP_STATEMACHINE_INVALID_EVENT: return "PEP_STATEMACHINE_INVALID_EVENT";
238 case PEP_STATEMACHINE_INVALID_CONDITION: return "PEP_STATEMACHINE_INVALID_CONDITION";
239 case PEP_STATEMACHINE_INVALID_ACTION: return "PEP_STATEMACHINE_INVALID_ACTION";
240 case PEP_STATEMACHINE_INHIBITED_EVENT: return "PEP_STATEMACHINE_INHIBITED_EVENT";
241 case PEP_STATEMACHINE_CANNOT_SEND: return "PEP_STATEMACHINE_CANNOT_SEND";
243 case PEP_COMMIT_FAILED: return "PEP_COMMIT_FAILED";
244 case PEP_MESSAGE_CONSUME: return "PEP_MESSAGE_CONSUME";
245 case PEP_MESSAGE_IGNORE: return "PEP_MESSAGE_IGNORE";
247 case PEP_RECORD_NOT_FOUND: return "PEP_RECORD_NOT_FOUND";
248 case PEP_CANNOT_CREATE_TEMP_FILE: return "PEP_CANNOT_CREATE_TEMP_FILE";
249 case PEP_ILLEGAL_VALUE: return "PEP_ILLEGAL_VALUE";
250 case PEP_BUFFER_TOO_SMALL: return "PEP_BUFFER_TOO_SMALL";
251 case PEP_OUT_OF_MEMORY: return "PEP_OUT_OF_MEMORY";
252 case PEP_UNKNOWN_ERROR: return "PEP_UNKNOWN_ERROR";
254 case PEP_VERSION_MISMATCH: return "PEP_VERSION_MISMATCH";
256 default: return "unknown status code";
260 // INIT_STATUS init() - initialize pEpEngine for a thread
263 // session (out) init() allocates session memory and
264 // returns a pointer as a handle
265 // messageToSend (in) callback for sending message by the
267 // inject_sync_event (in) callback for injecting a sync event
270 // PEP_STATUS_OK = 0 if init() succeeds
271 // PEP_INIT_SQLITE3_WITHOUT_MUTEX if SQLite3 was compiled with
272 // SQLITE_THREADSAFE 0
273 // PEP_INIT_CANNOT_LOAD_GPGME if libgpgme.dll cannot be found
274 // PEP_INIT_GPGME_INIT_FAILED if GPGME init fails
275 // PEP_INIT_CANNOT_OPEN_DB if user's management db cannot be
277 // PEP_INIT_CANNOT_OPEN_SYSTEM_DB if system's management db cannot be
281 // THE CALLER MUST GUARD THIS CALL EXTERNALLY WITH A MUTEX. release()
282 // should be similarly guarded.
284 // the pointer is valid only if the return value is PEP_STATUS_OK
285 // in other case a NULL pointer will be returned; a valid handle must
286 // be released using release() when it's no longer needed
288 // the caller has to guarantee that the first call to this function
289 // will succeed before further calls can be done
291 // messageToSend can only be null if no transport is application based
292 // if transport system is not used it must not be NULL
294 DYNAMIC_API PEP_STATUS init(
295 PEP_SESSION *session,
296 messageToSend_t messageToSend,
297 inject_sync_event_t inject_sync_event
301 // void release() - release thread session handle
304 // session (in) session handle to release
307 // THE CALLER MUST GUARD THIS CALL EXTERNALLY WITH A MUTEX. init() should
308 // be similarly guarded.
310 // the last release() can be called only when all other release() calls
313 DYNAMIC_API void release(PEP_SESSION session);
316 // const stringlist_t* get_errorstack(PEP_SESSION) - get the error stack for that session, if any
319 // session (in) session handle
322 // To get a useful error stack you have to compile with -DDEBUG_ERRORSTACK
323 // The error stack belongs to the session. Do no not change it!
324 DYNAMIC_API const stringlist_t* get_errorstack(PEP_SESSION session);
327 // void clear_errorstack(PEP_SESSION) - clear the error stack for that session, if any
330 // session (in) session handle
332 DYNAMIC_API void clear_errorstack(PEP_SESSION session);
335 // config_passive_mode() - enable passive mode
338 // session (in) session handle
339 // enable (in) flag if enabled or disabled
341 DYNAMIC_API void config_passive_mode(PEP_SESSION session, bool enable);
344 // config_unencrypted_subject() - disable subject encryption
347 // session (in) session handle
348 // enable (in) flag if enabled or disabled
350 DYNAMIC_API void config_unencrypted_subject(PEP_SESSION session, bool enable);
353 // config_use_only_own_private_keys() - enable passive mode
356 // session (in) session handle
357 // enable (in) flag if enabled or disabled
359 DYNAMIC_API void config_use_only_own_private_keys(PEP_SESSION session, bool enable);
362 // config_keep_sync_msg() - do not remove sync messages (for debugging purposes)
364 // session (in) session handle
365 // enable (in) flag if enabled or disabled
367 DYNAMIC_API void config_keep_sync_msg(PEP_SESSION session, bool enable);
370 // config_service_log() - log more for service purposes
372 // session (in) session handle
373 // enable (in) flag if enabled or disabled
375 DYNAMIC_API void config_service_log(PEP_SESSION session, bool enable);
378 // decrypt_and_verify() - decrypt and/or verify a message
381 // session (in) session handle
382 // ctext (in) cipher text to decrypt and/or verify
383 // csize (in) size of cipher text
384 // dsigtext (in) if extant, *detached* signature text for this
385 // message (or NULL if not)
386 // dsize (in) size of *detached* signature text for this
387 // message (0, if no detached sig exists)
388 // ptext (out) pointer to internal buffer with plain text
389 // psize (out) size of plain text
390 // keylist (out) list of key ids which where used to encrypt
391 // filename_ptr (out) mails produced by certain PGP implementations
392 // may return a decrypted filename here for attachments.
393 // Externally, this can generally be NULL, and is an optional
397 // PEP_UNENCRYPTED message was unencrypted and not signed
398 // PEP_VERIFIED message was unencrypted, signature matches
399 // PEP_DECRYPTED message is decrypted now, no signature
400 // PEP_DECRYPTED_AND_VERIFIED message is decrypted now and verified
401 // PEP_DECRYPT_WRONG_FORMAT message has wrong format to handle
402 // PEP_DECRYPT_NO_KEY key not available to decrypt and/or verify
403 // PEP_DECRYPT_SIGNATURE_DOES_NOT_MATCH wrong signature
406 // the ownerships of ptext as well as keylist are going to the caller
407 // the caller must use free() (or an Windoze pEp_free()) and
408 // free_stringlist() to free them
410 // if this function failes an error message may be the first element of
411 // keylist and the other elements may be the keys used for encryption
413 DYNAMIC_API PEP_STATUS decrypt_and_verify(
414 PEP_SESSION session, const char *ctext, size_t csize,
415 const char *dsigtext, size_t dsigsize,
416 char **ptext, size_t *psize, stringlist_t **keylist,
421 // verify_text() - verfy plain text with a digital signature
424 // session (in) session handle
425 // text (in) text to verify
426 // size (in) size of text
427 // signature (in) signature text
428 // sig_size (in) size of signature
429 // keylist (out) list of key ids which where used to encrypt or NULL on
433 // PEP_VERIFIED message was unencrypted, signature matches
434 // PEP_DECRYPT_NO_KEY key not available to decrypt and/or verify
435 // PEP_DECRYPT_SIGNATURE_DOES_NOT_MATCH wrong signature
437 DYNAMIC_API PEP_STATUS verify_text(
438 PEP_SESSION session, const char *text, size_t size,
439 const char *signature, size_t sig_size, stringlist_t **keylist
443 // encrypt_and_sign() - encrypt and sign a message
446 // session (in) session handle
447 // keylist (in) list of key ids to encrypt with as C strings
448 // ptext (in) plain text to decrypt and/or verify
449 // psize (in) size of plain text
450 // ctext (out) pointer to internal buffer with cipher text
451 // csize (out) size of cipher text
454 // PEP_STATUS_OK = 0 encryption and signing succeeded
455 // PEP_KEY_NOT_FOUND at least one of the recipient keys
456 // could not be found
457 // PEP_KEY_HAS_AMBIG_NAME at least one of the recipient keys has
459 // PEP_GET_KEY_FAILED cannot retrieve key
462 // the ownership of ctext is going to the caller
463 // the caller is responsible to free() it (on Windoze use pEp_free())
464 // the first key in keylist is being used to sign the message
465 // this implies there has to be a private key for that keypair
467 DYNAMIC_API PEP_STATUS encrypt_and_sign(
468 PEP_SESSION session, const stringlist_t *keylist, const char *ptext,
469 size_t psize, char **ctext, size_t *csize
473 // log_event() - log a user defined event defined by UTF-8 encoded strings into
477 // session (in) session handle
478 // title (in) C string with event name
479 // entity (in) C string with name of entity which is logging
480 // description (in) C string with long description for event or NULL if
482 // comment (in) C string with user defined comment or NULL if
486 // PEP_STATUS_OK log entry created
488 DYNAMIC_API PEP_STATUS log_event(
492 const char *description,
497 DYNAMIC_API PEP_STATUS log_service(PEP_SESSION session, const char *title,
498 const char *entity, const char *description, const char *comment);
501 #define _D_STR_(x) _STR_(x)
502 #define S_LINE _D_STR_(__LINE__)
504 #define SERVICE_LOG(session, title, entity, desc) \
505 log_service((session), (title), (entity), (desc), "service " __FILE__ ":" S_LINE)
508 // trustword() - get the corresponding trustword for a 16 bit value
511 // session (in) session handle
512 // value (in) value to find a trustword for
513 // lang (in) C string with ISO 639-1 language code
514 // word (out) pointer to C string with trustword UTF-8 encoded
515 // NULL if language is not supported or trustword
516 // wordlist is damaged or unavailable
517 // wsize (out) length of trustword
520 // PEP_STATUS_OK trustword retrieved
521 // PEP_TRUSTWORD_NOT_FOUND trustword not found
524 // the word pointer goes to the ownership of the caller
525 // the caller is responsible to free() it (on Windoze use pEp_free())
527 DYNAMIC_API PEP_STATUS trustword(
528 PEP_SESSION session, uint16_t value, const char *lang,
529 char **word, size_t *wsize
533 // trustwords() - get trustwords for a string of hex values of a fingerprint
536 // session (in) session handle
537 // fingerprint (in) C string with hex values to find trustwords for
538 // lang (in) C string with ISO 639-1 language code
539 // words (out) pointer to C string with trustwords UTF-8 encoded,
540 // separated by a blank each
541 // NULL if language is not supported or trustword
542 // wordlist is damaged or unavailable
543 // wsize (out) length of trustwords string
544 // max_words (in) only generate a string with max_words;
545 // if max_words == 0 there is no such limit
548 // PEP_STATUS_OK trustwords retrieved
549 // PEP_OUT_OF_MEMORY out of memory
550 // PEP_TRUSTWORD_NOT_FOUND at least one trustword not found
553 // the word pointer goes to the ownership of the caller
554 // the caller is responsible to free() it (on Windoze use pEp_free())
556 // DON'T USE THIS FUNCTION FROM HIGH LEVEL LANGUAGES!
558 // Better implement a simple one in the adapter yourself using trustword(), and
559 // return a list of trustwords.
560 // This function is provided for being used by C and C++ programs only.
562 DYNAMIC_API PEP_STATUS trustwords(
563 PEP_SESSION session, const char *fingerprint, const char *lang,
564 char **words, size_t *wsize, int max_words
568 // TODO: increase versions in pEp.asn1 if rating changes
570 typedef enum _PEP_comm_type {
573 // range 0x01 to 0x09: no encryption, 0x0a to 0x0e: nothing reasonable
575 PEP_ct_no_encryption = 0x01, // generic
576 PEP_ct_no_encrypted_channel = 0x02,
577 PEP_ct_key_not_found = 0x03,
578 PEP_ct_key_expired = 0x04,
579 PEP_ct_key_revoked = 0x05,
580 PEP_ct_key_b0rken = 0x06,
581 PEP_ct_key_expired_but_confirmed = 0x07, // NOT with confirmed bit. Just retaining info here in case of renewal.
582 PEP_ct_my_key_not_included = 0x09,
584 PEP_ct_security_by_obscurity = 0x0a,
585 PEP_ct_b0rken_crypto = 0x0b,
586 PEP_ct_key_too_short = 0x0c,
588 PEP_ct_compromised = 0x0e, // known compromised connection
589 PEP_ct_compromized = 0x0e, // deprecated misspelling
590 PEP_ct_mistrusted = 0x0f, // known mistrusted key
592 // range 0x10 to 0x3f: unconfirmed encryption
594 PEP_ct_unconfirmed_encryption = 0x10, // generic
595 PEP_ct_OpenPGP_weak_unconfirmed = 0x11, // RSA 1024 is weak
597 PEP_ct_to_be_checked = 0x20, // generic
598 PEP_ct_SMIME_unconfirmed = 0x21,
599 PEP_ct_CMS_unconfirmed = 0x22,
601 PEP_ct_strong_but_unconfirmed = 0x30, // generic
602 PEP_ct_OpenPGP_unconfirmed = 0x38, // key at least 2048 bit RSA or EC
603 PEP_ct_OTR_unconfirmed = 0x3a,
605 // range 0x40 to 0x7f: unconfirmed encryption and anonymization
607 PEP_ct_unconfirmed_enc_anon = 0x40, // generic
608 PEP_ct_pEp_unconfirmed = 0x7f,
610 PEP_ct_confirmed = 0x80, // this bit decides if trust is confirmed
612 // range 0x81 to 0x8f: reserved
613 // range 0x90 to 0xbf: confirmed encryption
615 PEP_ct_confirmed_encryption = 0x90, // generic
616 PEP_ct_OpenPGP_weak = 0x91, // RSA 1024 is weak (unused)
618 PEP_ct_to_be_checked_confirmed = 0xa0, // generic
622 PEP_ct_strong_encryption = 0xb0, // generic
623 PEP_ct_OpenPGP = 0xb8, // key at least 2048 bit RSA or EC
626 // range 0xc0 to 0xff: confirmed encryption and anonymization
628 PEP_ct_confirmed_enc_anon = 0xc0, // generic
632 static inline const char *pep_comm_type_to_string(PEP_comm_type ct) {
634 case PEP_ct_unknown: return "unknown";
635 case PEP_ct_no_encryption: return "no_encryption";
636 case PEP_ct_no_encrypted_channel: return "no_encrypted_channel";
637 case PEP_ct_key_not_found: return "key_not_found";
638 case PEP_ct_key_expired: return "key_expired";
639 case PEP_ct_key_revoked: return "key_revoked";
640 case PEP_ct_key_b0rken: return "key_b0rken";
641 case PEP_ct_my_key_not_included: return "my_key_not_included";
642 case PEP_ct_security_by_obscurity: return "security_by_obscurity";
643 case PEP_ct_b0rken_crypto: return "b0rken_crypto";
644 case PEP_ct_key_too_short: return "key_too_short";
645 case PEP_ct_compromised: return "compromised";
646 case PEP_ct_mistrusted: return "mistrusted";
647 case PEP_ct_unconfirmed_encryption: return "unconfirmed_encryption";
648 case PEP_ct_OpenPGP_weak_unconfirmed: return "OpenPGP_weak_unconfirmed";
649 case PEP_ct_to_be_checked: return "to_be_checked";
650 case PEP_ct_SMIME_unconfirmed: return "SMIME_unconfirmed";
651 case PEP_ct_CMS_unconfirmed: return "CMS_unconfirmed";
652 case PEP_ct_strong_but_unconfirmed: return "strong_but_unconfirmed";
653 case PEP_ct_OpenPGP_unconfirmed: return "OpenPGP_unconfirmed";
654 case PEP_ct_OTR_unconfirmed: return "OTR_unconfirmed";
655 case PEP_ct_unconfirmed_enc_anon: return "unconfirmed_enc_anon";
656 case PEP_ct_pEp_unconfirmed: return "pEp_unconfirmed";
657 case PEP_ct_confirmed: return "confirmed";
658 case PEP_ct_confirmed_encryption: return "confirmed_encryption";
659 case PEP_ct_OpenPGP_weak: return "OpenPGP_weak";
660 case PEP_ct_to_be_checked_confirmed: return "to_be_checked_confirmed";
661 case PEP_ct_SMIME: return "SMIME";
662 case PEP_ct_CMS: return "CMS";
663 case PEP_ct_strong_encryption: return "strong_encryption";
664 case PEP_ct_OpenPGP: return "OpenPGP";
665 case PEP_ct_OTR: return "OTR";
666 case PEP_ct_confirmed_enc_anon: return "confirmed_enc_anon";
667 case PEP_ct_pEp: return "pEp";
668 default: return "invalid comm type";
673 typedef enum _identity_flags {
674 // the first octet flags are app defined settings
675 PEP_idf_not_for_sync = 0x0001, // don't use this identity for sync
676 PEP_idf_list = 0x0002, // identity of list of persons
677 // the second octet flags are calculated
678 PEP_idf_devicegroup = 0x0100 // identity of a device group member
681 typedef unsigned int identity_flags_t;
683 // typedef enum _keypair_flags {
686 typedef unsigned int keypair_flags_t;
688 typedef struct _pEp_identity {
689 char *address; // C string with address UTF-8 encoded
690 char *fpr; // C string with fingerprint UTF-8 encoded
691 char *user_id; // C string with user ID UTF-8 encoded
692 // user_id MIGHT be set to "pEp_own_userId"
693 // (use PEP_OWN_USERID preprocessor define)
694 // if this is own user's identity.
695 // But it is not REQUIRED to be.
696 char *username; // C string with user name UTF-8 encoded
697 PEP_comm_type comm_type; // type of communication with this ID
698 char lang[3]; // language of conversation
699 // ISO 639-1 ALPHA-2, last byte is 0
700 bool me; // if this is the local user herself/himself
701 identity_flags_t flags; // identity_flag1 | identity_flag2 | ...
704 typedef struct _identity_list {
706 struct _identity_list *next;
710 // new_identity() - allocate memory and set the string and size fields
713 // address (in) UTF-8 string or NULL
714 // fpr (in) UTF-8 string or NULL
715 // user_id (in) UTF-8 string or NULL
716 // username (in) UTF-8 string or NULL
719 // pEp_identity struct or NULL if out of memory
722 // the strings are copied; the original strings are still being owned by
725 DYNAMIC_API pEp_identity *new_identity(
726 const char *address, const char *fpr, const char *user_id,
731 // identity_dup() - allocate memory and duplicate
734 // src (in) identity to duplicate
737 // pEp_identity struct or NULL if out of memory
740 // the strings are copied; the original strings are still being owned by
743 DYNAMIC_API pEp_identity *identity_dup(const pEp_identity *src);
746 // free_identity() - free all memory being occupied by a pEp_identity struct
749 // identity (in) struct to release
752 // not only the struct but also all string memory referenced by the
753 // struct is being freed; all pointers inside are invalid afterwards
755 DYNAMIC_API void free_identity(pEp_identity *identity);
758 // get_identity() - get identity information
761 // session (in) session handle
762 // address (in) C string with communication address, UTF-8 encoded
763 // user_id (in) unique C string to identify person that identity
765 // identity (out) pointer to pEp_identity structure with results or
769 // address and user_id are being copied; the original strings remains in
770 // the ownership of the caller
771 // the resulting pEp_identity structure goes to the ownership of the
772 // caller and has to be freed with free_identity() when not in use any
775 DYNAMIC_API PEP_STATUS get_identity(
779 pEp_identity **identity
782 PEP_STATUS replace_identities_fpr(PEP_SESSION session,
784 const char* new_fpr);
787 // set_identity() - set identity information
790 // session (in) session handle
791 // identity (in) pointer to pEp_identity structure
794 // PEP_STATUS_OK = 0 encryption and signing succeeded
795 // PEP_CANNOT_SET_PERSON writing to table person failed
796 // PEP_CANNOT_SET_PGP_KEYPAIR writing to table pgp_keypair failed
797 // PEP_CANNOT_SET_IDENTITY writing to table identity failed
798 // PEP_COMMIT_FAILED SQL commit failed
801 // address, fpr, user_id and username must be given
803 DYNAMIC_API PEP_STATUS set_identity(
804 PEP_SESSION session, const pEp_identity *identity
807 // get_default own_userid() - get the user_id of the own user
810 // session (in) session handle
811 // userid (out) own user id (if it exists)
814 // PEP_STATUS_OK = 0 userid was found
815 // PEP_CANNOT_FIND_IDENTITY no own_user found in the DB
816 // PEP_UNKNOWN_ERROR results were returned, but no ID
817 // found (no reason this should ever occur)
819 // userid will be NULL if not found; otherwise, returned string
820 // belongs to the caller.
822 DYNAMIC_API PEP_STATUS get_default_own_userid(
827 // get_userid_alias_default() - get the default user_id which corresponds
830 // session (in) session handle
831 // alias_id (in) the user_id which may be an alias for a default id
832 // default_id (out) the default id for this alias, if the alias
833 // is in the DB as an alias, else NULL
835 // PEP_STATUS_OK = 0 userid was found
836 // PEP_CANNOT_FIND_ALIAS this userid is not listed as an
838 // PEP_UNKNOWN_ERROR results were returned, but no ID
839 // found (no reason this should ever occur)
841 // default_id will be NULL if not found; otherwise, returned string
842 // belongs to the caller.
843 // also, current implementation does NOT check to see if this userid
846 DYNAMIC_API PEP_STATUS get_userid_alias_default(
848 const char* alias_id,
851 // set_userid_alias() - set an alias to correspond to a default id
853 // session (in) session handle
854 // default_id (in) the default id for this alias. This must
855 // correspond to the default user_id for an
856 // entry in the person (user) table.
857 // alias_id (in) the alias to be set for this default id
859 // PEP_STATUS_OK = 0 userid was found
860 // PEP_CANNOT_SET_ALIAS there was an error setting this
862 DYNAMIC_API PEP_STATUS set_userid_alias (
864 const char* default_id,
865 const char* alias_id);
868 // set_device_group() - update own person's device group
871 // session (in) session handle
872 // group_name (in) new group name
875 // PEP_STATUS_OK = 0 device group was updated
876 // PEP_CANNOT_SET_PERSON update failed
878 DYNAMIC_API PEP_STATUS set_device_group(
880 const char *group_name
883 // get_device_group() - get own person's device group
886 // session (in) session handle
887 // group_name (in) new group name
890 // PEP_STATUS_OK = 0 couldn't get device group
891 // PEP_RECORD_NOT_FOUND update failed
894 // the ownerships of group_name is going to the caller
896 DYNAMIC_API PEP_STATUS get_device_group(
901 // set_identity_flags() - update identity flags on existing identity
904 // session (in) session handle
905 // identity (in,out) pointer to pEp_identity structure
906 // flags (in) new value for flags
909 // PEP_STATUS_OK = 0 encryption and signing succeeded
910 // PEP_CANNOT_SET_IDENTITY update of identity failed
913 // address and user_id must be given in identity
915 DYNAMIC_API PEP_STATUS set_identity_flags(
917 pEp_identity *identity,
918 identity_flags_t flags
921 // unset_identity_flags() - update identity flags on existing identity
924 // session (in) session handle
925 // identity (in,out) pointer to pEp_identity structure
926 // flags (in) new value for flags
929 // PEP_STATUS_OK = 0 encryption and signing succeeded
930 // PEP_CANNOT_SET_IDENTITY update of identity failed
933 // address and user_id must be given in identity
935 DYNAMIC_API PEP_STATUS unset_identity_flags(
937 pEp_identity *identity,
938 identity_flags_t flags
941 // mark_as_compromised() - mark key in trust db as compromised
944 // session (in) session handle
945 // fpr (in) fingerprint of key to mark
947 DYNAMIC_API PEP_STATUS mark_as_compromised(
953 // mark_as_compromized() - deprecated to fix misspelling. Please move to
954 // mark_as_compromised();
956 DYNAMIC_API PEP_STATUS mark_as_compromized(
962 // generate_keypair() - generate a new key pair and add it to the key ring
965 // session (in) session handle
966 // identity (inout) pointer to pEp_identity structure
969 // PEP_STATUS_OK = 0 encryption and signing succeeded
970 // PEP_ILLEGAL_VALUE illegal values for identity fields given
971 // PEP_CANNOT_CREATE_KEY key engine is on strike
974 // address and username fields must be set to UTF-8 strings
975 // the fpr field must be set to NULL
977 // this function allocates a string and sets set fpr field of identity
978 // the caller is responsible to call free() for that string or use
979 // free_identity() on the struct
981 DYNAMIC_API PEP_STATUS generate_keypair(
982 PEP_SESSION session, pEp_identity *identity
986 // delete_keypair() - delete a public key or a key pair from the key ring
989 // session (in) session handle
990 // fpr (in) C string with key id or fingerprint of the
994 // PEP_STATUS_OK = 0 key was successfully deleted
995 // PEP_KEY_NOT_FOUND key not found
996 // PEP_ILLEGAL_VALUE not a valid key id or fingerprint
997 // PEP_KEY_HAS_AMBIG_NAME fpr does not uniquely identify a key
998 // PEP_OUT_OF_MEMORY out of memory
1000 DYNAMIC_API PEP_STATUS delete_keypair(PEP_SESSION session, const char *fpr);
1003 // import_key() - import key from data
1006 // session (in) session handle
1007 // key_data (in) key data, i.e. ASCII armored OpenPGP key
1008 // size (in) amount of data to handle
1009 // private_keys (out) list of private keys that have been imported
1012 // PEP_STATUS_OK = 0 key was successfully imported
1013 // PEP_OUT_OF_MEMORY out of memory
1014 // PEP_ILLEGAL_VALUE there is no key data to import
1017 // private_keys goes to the ownership of the caller
1018 // private_keys can be left NULL, it is then ignored
1020 DYNAMIC_API PEP_STATUS import_key(
1021 PEP_SESSION session,
1022 const char *key_data,
1024 identity_list **private_keys
1028 // export_key() - export ascii armored key
1031 // session (in) session handle
1032 // fpr (in) key id or fingerprint of key
1033 // key_data (out) ASCII armored OpenPGP key
1034 // size (out) amount of data to handle
1037 // PEP_STATUS_OK = 0 key was successfully exported
1038 // PEP_OUT_OF_MEMORY out of memory
1039 // PEP_KEY_NOT_FOUND key not found
1042 // the key_data goes to the ownership of the caller
1043 // the caller is responsible to free() it (on Windoze use pEp_free())
1045 DYNAMIC_API PEP_STATUS export_key(
1046 PEP_SESSION session, const char *fpr, char **key_data, size_t *size
1050 // export_secret_key() - export secret key ascii armored
1053 // session (in) session handle
1054 // fpr (in) fingerprint of key, at least 16 hex digits
1055 // key_data (out) ASCII armored OpenPGP secret key
1056 // size (out) amount of data to handle
1059 // PEP_STATUS_OK = 0 key was successfully exported
1060 // PEP_OUT_OF_MEMORY out of memory
1061 // PEP_KEY_NOT_FOUND key not found
1062 // PEP_CANNOT_EXPORT_KEY cannot export secret key (i.e. it's on an HKS)
1065 // the key_data goes to the ownership of the caller
1066 // the caller is responsible to free() it (on Windoze use pEp_free())
1067 // beware of leaking secret key data - overwrite it in memory after use
1069 DYNAMIC_API PEP_STATUS export_secret_key(
1070 PEP_SESSION session, const char *fpr, char **key_data, size_t *size
1074 // export_secrect_key() - deprecated misspelled function. Please replace with
1075 // export_secret_key
1077 DYNAMIC_API PEP_STATUS export_secrect_key(
1078 PEP_SESSION session, const char *fpr, char **key_data, size_t *size
1082 // recv_key() - update key(s) from keyserver
1085 // session (in) session handle
1086 // pattern (in) key id, user id or address to search for as
1089 DYNAMIC_API PEP_STATUS recv_key(PEP_SESSION session, const char *pattern);
1092 // find_keys() - find keys in keyring
1095 // session (in) session handle
1096 // pattern (in) key id, user id or address to search for as
1098 // keylist (out) list of fingerprints found or NULL on error
1101 // the ownerships of keylist isgoing to the caller
1102 // the caller must use free_stringlist() to free it
1105 DYNAMIC_API PEP_STATUS find_keys(
1106 PEP_SESSION session, const char *pattern, stringlist_t **keylist
1109 // send_key() - send key(s) to keyserver
1112 // session (in) session handle
1113 // pattern (in) key id, user id or address to search for as
1116 DYNAMIC_API PEP_STATUS send_key(PEP_SESSION session, const char *pattern);
1119 // pEp_free() - free memory allocated by pEp engine
1122 // p (in) pointer to free
1124 // The reason for this function is that heap management can be a pretty
1125 // complex task with Windoze. This free() version calls the free()
1126 // implementation of the C runtime library which was used to build pEp engine,
1127 // so you're using the correct heap. For more information, see:
1128 // <http://msdn.microsoft.com/en-us/library/windows/desktop/aa366711(v=vs.85).aspx>
1130 DYNAMIC_API void pEp_free(void *p);
1133 // get_trust() - get the trust level a key has for a person
1136 // session (in) session handle
1137 // identity (inout) user_id and fpr to check as UTF-8 strings (in)
1138 // comm_type as result (out)
1140 // this function modifies the given identity struct; the struct remains in
1141 // the ownership of the caller
1142 // if the trust level cannot be determined identity->comm_type is set
1143 // to PEP_ct_unknown
1145 DYNAMIC_API PEP_STATUS get_trust(PEP_SESSION session, pEp_identity *identity);
1148 PEP_STATUS set_trust(PEP_SESSION session,
1149 pEp_identity* identity);
1151 PEP_STATUS update_trust_for_fpr(PEP_SESSION session,
1153 PEP_comm_type comm_type);
1155 // least_trust() - get the least known trust level for a key in the database
1158 // session (in) session handle
1159 // fpr (in) fingerprint of key to check
1160 // comm_type (out) least comm_type as result (out)
1162 // if the trust level cannot be determined comm_type is set to PEP_ct_unknown
1164 DYNAMIC_API PEP_STATUS least_trust(
1165 PEP_SESSION session,
1167 PEP_comm_type *comm_type
1171 // get_key_rating() - get the rating a bare key has
1174 // session (in) session handle
1175 // fpr (in) unique identifyer for key as UTF-8 string
1176 // comm_type (out) key rating
1178 // if an error occurs, *comm_type is set to PEP_ct_unknown and an error
1181 DYNAMIC_API PEP_STATUS get_key_rating(
1182 PEP_SESSION session,
1184 PEP_comm_type *comm_type
1188 // renew_key() - renew an expired key
1191 // session (in) session handle
1192 // fpr (in) ID of key to renew as UTF-8 string
1193 // ts (in) timestamp when key should expire or NULL for
1196 DYNAMIC_API PEP_STATUS renew_key(
1197 PEP_SESSION session,
1203 // revoke_key() - revoke a key
1206 // session (in) session handle
1207 // fpr (in) ID of key to revoke as UTF-8 string
1208 // reason (in) text with reason for revoke as UTF-8 string
1209 // or NULL if reason unknown
1212 // reason text must not include empty lines
1213 // this function is meant for internal use only; better use
1214 // key_mistrusted() of keymanagement API
1216 DYNAMIC_API PEP_STATUS revoke_key(
1217 PEP_SESSION session,
1223 // key_expired() - flags if a key is already expired
1226 // session (in) session handle
1227 // fpr (in) ID of key to check as UTF-8 string
1228 // when (in) UTC time of when should expiry be considered
1229 // expired (out) flag if key expired
1231 DYNAMIC_API PEP_STATUS key_expired(
1232 PEP_SESSION session,
1239 // key_revoked() - flags if a key is already revoked
1242 // session (in) session handle
1243 // fpr (in) ID of key to check as UTF-8 string
1244 // revoked (out) flag if key revoked
1246 DYNAMIC_API PEP_STATUS key_revoked(
1247 PEP_SESSION session,
1252 PEP_STATUS get_key_userids(
1253 PEP_SESSION session,
1255 stringlist_t** keylist
1259 // get_crashdump_log() - get the last log messages out
1262 // session (in) session handle
1263 // maxlines (in) maximum number of lines (0 for default)
1264 // logdata (out) logdata as string in double quoted CSV format
1266 // column2 is entity
1267 // column3 is description
1268 // column4 is comment
1271 // the ownership of logdata goes to the caller
1273 DYNAMIC_API PEP_STATUS get_crashdump_log(
1274 PEP_SESSION session,
1280 // get_languagelist() - get the list of languages
1283 // session (in) session handle
1284 // languages (out) languages as string in double quoted CSV format
1285 // column 1 is the ISO 639-1 language code
1286 // column 2 is the name of the language
1289 // the ownership of languages goes to the caller
1291 DYNAMIC_API PEP_STATUS get_languagelist(
1292 PEP_SESSION session,
1297 // get_phrase() - get phrase in a dedicated language through i18n
1300 // session (in) session handle
1301 // lang (in) C string with ISO 639-1 language code
1302 // phrase_id (in) id of phrase in i18n
1303 // phrase (out) phrase as UTF-8 string
1306 // the ownership of phrase goes to the caller
1308 DYNAMIC_API PEP_STATUS get_phrase(
1309 PEP_SESSION session,
1316 // sequence_value() - raise the value of a named sequence and retrieve it
1319 // session (in) session handle
1320 // name (in) name of sequence
1321 // value (out) value of sequence
1324 // PEP_STATUS_OK no error, not own sequence
1325 // PEP_SEQUENCE_VIOLATED if sequence violated
1326 // PEP_CANNOT_INCREASE_SEQUENCE if sequence cannot be increased
1327 // PEP_OWN_SEQUENCE if own sequence
1329 DYNAMIC_API PEP_STATUS sequence_value(
1330 PEP_SESSION session,
1336 // set_revoked() - records relation between a revoked key and its replacement
1339 // session (in) session handle
1340 // revoked_fpr (in) revoked fingerprint
1341 // replacement_fpr (in) replacement key fingerprint
1342 // revocation_date (in) revocation date
1344 DYNAMIC_API PEP_STATUS set_revoked(
1345 PEP_SESSION session,
1346 const char *revoked_fpr,
1347 const char *replacement_fpr,
1348 const uint64_t revocation_date
1352 // get_revoked() - find revoked key that may have been replaced by given key, if any
1355 // session (in) session handle
1356 // fpr (in) given fingerprint
1357 // revoked_fpr (out) revoked fingerprint
1358 // revocation_date (out) revocation date
1360 DYNAMIC_API PEP_STATUS get_revoked(
1361 PEP_SESSION session,
1364 uint64_t *revocation_date
1367 // key_created() - get creation date of a key
1370 // session (in) session handle
1371 // fpr (in) fingerprint of key
1372 // created (out) date of creation
1374 PEP_STATUS key_created(
1375 PEP_SESSION session,
1381 // find_private_keys() - find keys in keyring
1384 // session (in) session handle
1385 // pattern (in) key id, user id or address to search for as
1387 // keylist (out) list of fingerprints found or NULL on error
1390 // the ownerships of keylist isgoing to the caller
1391 // the caller must use free_stringlist() to free it
1392 PEP_STATUS find_private_keys(PEP_SESSION session, const char* pattern,
1393 stringlist_t **keylist);
1395 // get_engine_version() - returns the current version of pEpEngine (this is different
1396 // from the pEp protocol version!)
1400 // return_value: const char* to the engine version string constant
1402 DYNAMIC_API const char* get_engine_version();
1404 // is_pEp_user() - returns true if the USER corresponding to this identity
1405 // has been listed in the *person* table as a pEp user.
1408 // identity (in) - identity containing the user_id to check (this is
1409 // the only part of the struct we require to be set)
1410 // is_pEp (out) - boolean pointer - will return true or false by
1411 // reference with respect to whether or not user is
1414 // return_value: PEP_STATUS_OK if user found in person table
1415 // PEP_ILLEGAL_VALUE if no user_id in input
1416 // PEP_CANNOT_FIND_PERSON if user_id doesn't exist
1418 // caveat: This *does not check comm_type*
1420 DYNAMIC_API PEP_STATUS is_pEp_user(PEP_SESSION session,
1421 pEp_identity *identity,
1426 DYNAMIC_API PEP_STATUS reset_pEptest_hack(PEP_SESSION session);
1428 // This is used internally when there is a temporary identity to be retrieved
1429 // that may not yet have an FPR attached. See get_identity() for functionality,
1430 // params and caveats.
1431 PEP_STATUS get_identity_without_trust_check(
1432 PEP_SESSION session,
1433 const char *address,
1434 const char *user_id,
1435 pEp_identity **identity
1438 PEP_STATUS get_identities_by_address(
1439 PEP_SESSION session,
1440 const char *address,
1441 identity_list** id_list
1444 PEP_STATUS get_identities_by_userid(
1445 PEP_SESSION session,
1446 const char *user_id,
1447 identity_list **identities
1450 PEP_STATUS replace_userid(PEP_SESSION session, const char* old_uid,
1451 const char* new_uid);
1453 PEP_STATUS remove_key(PEP_SESSION session, const char* fpr);
1455 PEP_STATUS remove_fpr_as_default(PEP_SESSION session,
1459 PEP_STATUS get_main_user_fpr(PEP_SESSION session,
1460 const char* user_id,
1463 PEP_STATUS replace_main_user_fpr(PEP_SESSION session, const char* user_id,
1464 const char* new_fpr);
1466 DYNAMIC_API PEP_STATUS get_replacement_fpr(
1467 PEP_SESSION session,
1470 uint64_t *revocation_date
1473 PEP_STATUS refresh_userid_default_key(PEP_SESSION session, const char* user_id);
1475 // This ONLY sets the *user* flag, and creates a shell identity if necessary.
1476 DYNAMIC_API PEP_STATUS set_as_pEp_user(PEP_SESSION session, pEp_identity* user);
1478 // returns true (by reference) if a person with this user_id exists;
1479 // Also replaces aliased user_ids by defaults in identity.
1480 PEP_STATUS exists_person(PEP_SESSION session, pEp_identity* identity, bool* exists);
1482 PEP_STATUS set_pgp_keypair(PEP_SESSION session, const char* fpr);
1484 // exposed for testing
1485 PEP_STATUS set_person(PEP_SESSION session, pEp_identity* identity,
1486 bool guard_transaction);
1487 PEP_STATUS bind_own_ident_with_contact_ident(PEP_SESSION session,
1488 pEp_identity* own_ident,
1489 pEp_identity* contact_ident);
1491 PEP_STATUS get_last_contacted(
1492 PEP_SESSION session,
1493 identity_list** id_list
1496 PEP_STATUS get_own_ident_for_contact_id(PEP_SESSION session,
1497 const pEp_identity* contact,
1498 pEp_identity** own_ident);
1500 PEP_STATUS exists_trust_entry(PEP_SESSION session, pEp_identity* identity,
1503 PEP_STATUS is_own_key(PEP_SESSION session, const char* fpr, bool* own_key);
1505 PEP_STATUS get_identities_by_main_key_id(
1506 PEP_SESSION session,
1508 identity_list **identities);
1510 PEP_STATUS sign_only(PEP_SESSION session,