src/pEpEngine.h
author Volker Birk <vb@pep.foundation>
Wed, 29 Aug 2018 17:10:23 +0200
branchsync
changeset 2899 63b619aef131
parent 2879 1b90ffed2d89
child 2927 bab83a0e7f46
permissions -rw-r--r--
somewhat bigger
     1 // This file is under GNU General Public License 3.0
     2 // see LICENSE.txt
     3 
     4 #pragma once
     5 
     6 #ifdef __cplusplus
     7 extern "C" {
     8 #endif
     9 
    10 #include <stddef.h>
    11 #include <stdint.h>
    12 #include <stdbool.h>
    13 
    14 #include "dynamic_api.h"
    15 #include "stringlist.h"
    16 #include "stringpair.h"    
    17 #include "timestamp.h"
    18 
    19 #define PEP_VERSION "2.0" // protocol version
    20 
    21 #define PEP_OWN_USERID "pEp_own_userId"
    22     
    23 // pEp Engine API
    24 
    25 //  caveat:
    26 //      Unicode data has to be normalized to NFC before calling
    27 //      UTF-8 strings are UTF-8 encoded C strings (zero terminated)
    28 
    29 
    30 struct _pEpSession;
    31 typedef struct _pEpSession * PEP_SESSION;
    32 
    33 typedef enum {
    34     PEP_STATUS_OK                                   = 0,
    35 
    36     PEP_INIT_CANNOT_LOAD_GPGME                      = 0x0110,
    37     PEP_INIT_GPGME_INIT_FAILED                      = 0x0111,
    38     PEP_INIT_NO_GPG_HOME                            = 0x0112,
    39     PEP_INIT_NETPGP_INIT_FAILED                     = 0x0113,
    40     PEP_INIT_CANNOT_DETERMINE_GPG_VERSION           = 0x0114,
    41     PEP_INIT_UNSUPPORTED_GPG_VERSION                = 0x0115,
    42     PEP_INIT_CANNOT_CONFIG_GPG_AGENT                = 0x0116,
    43 
    44     PEP_INIT_SQLITE3_WITHOUT_MUTEX                  = 0x0120,
    45     PEP_INIT_CANNOT_OPEN_DB                         = 0x0121,
    46     PEP_INIT_CANNOT_OPEN_SYSTEM_DB                  = 0x0122,
    47     
    48     PEP_KEY_NOT_FOUND                               = 0x0201,
    49     PEP_KEY_HAS_AMBIG_NAME                          = 0x0202,
    50     PEP_GET_KEY_FAILED                              = 0x0203,
    51     PEP_CANNOT_EXPORT_KEY                           = 0x0204,
    52     PEP_CANNOT_EDIT_KEY                             = 0x0205,
    53     PEP_KEY_UNSUITABLE                              = 0x0206,
    54     
    55     PEP_CANNOT_FIND_IDENTITY                        = 0x0301,
    56     PEP_CANNOT_SET_PERSON                           = 0x0381,
    57     PEP_CANNOT_SET_PGP_KEYPAIR                      = 0x0382,
    58     PEP_CANNOT_SET_IDENTITY                         = 0x0383,
    59     PEP_CANNOT_SET_TRUST                            = 0x0384,
    60     PEP_KEY_BLACKLISTED                             = 0x0385,
    61     PEP_CANNOT_FIND_PERSON                          = 0x0386,
    62     
    63     PEP_CANNOT_FIND_ALIAS                           = 0x0391,
    64     PEP_CANNOT_SET_ALIAS                            = 0x0392,
    65     
    66     PEP_UNENCRYPTED                                 = 0x0400,
    67     PEP_VERIFIED                                    = 0x0401,
    68     PEP_DECRYPTED                                   = 0x0402,
    69     PEP_DECRYPTED_AND_VERIFIED                      = 0x0403,
    70     PEP_DECRYPT_WRONG_FORMAT                        = 0x0404,
    71     PEP_DECRYPT_NO_KEY                              = 0x0405,
    72     PEP_DECRYPT_SIGNATURE_DOES_NOT_MATCH            = 0x0406,
    73     PEP_VERIFY_NO_KEY                               = 0x0407,
    74     PEP_VERIFIED_AND_TRUSTED                        = 0x0408,
    75     PEP_CANNOT_REENCRYPT                            = 0x0409,
    76     PEP_CANNOT_DECRYPT_UNKNOWN                      = 0x04ff,
    77 
    78     PEP_TRUSTWORD_NOT_FOUND                         = 0x0501,
    79     PEP_TRUSTWORDS_FPR_WRONG_LENGTH                 = 0x0502,
    80     PEP_TRUSTWORDS_DUPLICATE_FPR                    = 0x0503,
    81 
    82     PEP_CANNOT_CREATE_KEY                           = 0x0601,
    83     PEP_CANNOT_SEND_KEY                             = 0x0602,
    84 
    85     PEP_PHRASE_NOT_FOUND                            = 0x0701,
    86 
    87     PEP_SEND_FUNCTION_NOT_REGISTERED                = 0x0801,
    88     PEP_CONTRAINTS_VIOLATED                         = 0x0802,
    89     PEP_CANNOT_ENCODE                               = 0x0803,
    90 
    91     PEP_SYNC_NO_NOTIFY_CALLBACK                     = 0x0901,
    92     PEP_SYNC_ILLEGAL_MESSAGE                        = 0x0902,
    93     PEP_SYNC_NO_INJECT_CALLBACK                     = 0x0903,
    94     PEP_SYNC_NO_CHANNEL                             = 0x0904,
    95     PEP_SYNC_CANNOT_ENCRYPT                         = 0x0905,
    96 
    97     PEP_CANNOT_INCREASE_SEQUENCE                    = 0x0971,
    98 
    99     PEP_STATEMACHINE_ERROR                          = 0x0980,
   100     PEP_NO_TRUST                                    = 0x0981,
   101     PEP_STATEMACHINE_INVALID_STATE                  = 0x0982,
   102     PEP_STATEMACHINE_INVALID_EVENT                  = 0x0983,
   103     PEP_STATEMACHINE_INVALID_CONDITION              = 0x0984,
   104     PEP_STATEMACHINE_INVALID_ACTION                 = 0x0985,
   105     PEP_STATEMACHINE_INHIBITED_EVENT                = 0x0986,
   106 
   107     PEP_COMMIT_FAILED                               = 0xff01,
   108     PEP_MESSAGE_CONSUME                             = 0xff02,
   109     PEP_MESSAGE_IGNORE                              = 0xff03,
   110 
   111     PEP_RECORD_NOT_FOUND                            = -6,
   112     PEP_CANNOT_CREATE_TEMP_FILE                     = -5,
   113     PEP_ILLEGAL_VALUE                               = -4,
   114     PEP_BUFFER_TOO_SMALL                            = -3,
   115     PEP_OUT_OF_MEMORY                               = -2,
   116     PEP_UNKNOWN_ERROR                               = -1,
   117     
   118     PEP_VERSION_MISMATCH                            = -7,
   119 } PEP_STATUS;
   120 
   121 
   122 // messageToSend() - a message needs to be delivered by application
   123 //
   124 //  parameters:
   125 //      msg (in)        message struct with message to send
   126 //
   127 //  return value:
   128 //      PEP_STATUS_OK or any other value on error
   129 //
   130 //  caveat:
   131 //      the ownership of msg goes to the callee
   132 
   133 struct _message;
   134 typedef PEP_STATUS (*messageToSend_t)(struct _message *msg);
   135 
   136 
   137 struct Sync_event;
   138 typedef struct Sync_event *SYNC_EVENT;
   139 
   140 // inject_sync_event - inject sync protocol message
   141 //
   142 //  parameters:
   143 //      ev (in)             event to inject
   144 //      management (in)     application defined; usually a locked queue
   145 //
   146 //  return value:
   147 //      0 if event could be stored successfully or nonzero otherwise
   148 
   149 typedef int (*inject_sync_event_t)(SYNC_EVENT ev, void *management);
   150 
   151 
   152 // INIT_STATUS init() - initialize pEpEngine for a thread
   153 //
   154 //  parameters:
   155 //      session (out)                       init() allocates session memory and
   156 //                                          returns a pointer as a handle
   157 //      messageToSend (in)                  callback for sending message by the
   158 //                                          application
   159 //      inject_sync_event (in)              callback for injecting a sync event
   160 //
   161 //  return value:
   162 //      PEP_STATUS_OK = 0                   if init() succeeds
   163 //      PEP_INIT_SQLITE3_WITHOUT_MUTEX      if SQLite3 was compiled with
   164 //                                          SQLITE_THREADSAFE 0
   165 //      PEP_INIT_CANNOT_LOAD_GPGME          if libgpgme.dll cannot be found
   166 //      PEP_INIT_GPGME_INIT_FAILED          if GPGME init fails
   167 //      PEP_INIT_CANNOT_OPEN_DB             if user's management db cannot be
   168 //                                          opened
   169 //      PEP_INIT_CANNOT_OPEN_SYSTEM_DB      if system's management db cannot be
   170 //                                          opened
   171 //
   172 //  caveat:
   173 //      THE CALLER MUST GUARD THIS CALL EXTERNALLY WITH A MUTEX. release()
   174 //      should be similarly guarded.
   175 //
   176 //      the pointer is valid only if the return value is PEP_STATUS_OK
   177 //      in other case a NULL pointer will be returned; a valid handle must
   178 //      be released using release() when it's no longer needed
   179 //
   180 //      the caller has to guarantee that the first call to this function
   181 //      will succeed before further calls can be done
   182 //
   183 //      messageToSend can only be null if no transport is application based
   184 //      if transport system is not used it must not be NULL
   185 
   186 DYNAMIC_API PEP_STATUS init(
   187         PEP_SESSION *session,
   188         messageToSend_t messageToSend,
   189         inject_sync_event_t inject_sync_event
   190     );
   191 
   192 
   193 // void release() - release thread session handle
   194 //
   195 //  parameters:
   196 //        session (in)    session handle to release
   197 //
   198 //    caveat:
   199 //        THE CALLER MUST GUARD THIS CALL EXTERNALLY WITH A MUTEX. init() should
   200 //        be similarly guarded.
   201 //       
   202 //        the last release() can be called only when all other release() calls
   203 //        are done
   204 
   205 DYNAMIC_API void release(PEP_SESSION session);
   206 
   207 
   208 // const stringlist_t* get_errorstack(PEP_SESSION) - get the error stack for that session, if any
   209 //
   210 //  parameters:
   211 //        session (in)    session handle
   212 //
   213 //    caveat:
   214 //        To get a useful error stack you have to compile with -DDEBUG_ERRORSTACK
   215 //        The error stack belongs to the session. Do no not change it!
   216 DYNAMIC_API const stringlist_t* get_errorstack(PEP_SESSION session);
   217 
   218 
   219 // void clear_errorstack(PEP_SESSION) - clear the error stack for that session, if any
   220 //
   221 //  parameters:
   222 //        session (in)    session handle
   223 //
   224 DYNAMIC_API void clear_errorstack(PEP_SESSION session);
   225 
   226 
   227 // config_passive_mode() - enable passive mode
   228 //
   229 //  parameters:
   230 //      session (in)    session handle
   231 //      enable (in)     flag if enabled or disabled
   232 
   233 DYNAMIC_API void config_passive_mode(PEP_SESSION session, bool enable);
   234 
   235 
   236 // config_unencrypted_subject() - disable subject encryption
   237 //
   238 //  parameters:
   239 //      session (in)    session handle
   240 //      enable (in)     flag if enabled or disabled
   241 
   242 DYNAMIC_API void config_unencrypted_subject(PEP_SESSION session, bool enable);
   243 
   244 
   245 // config_use_only_own_private_keys() - enable passive mode
   246 //
   247 //  parameters:
   248 //      session (in)    session handle
   249 //      enable (in)     flag if enabled or disabled
   250 
   251 DYNAMIC_API void config_use_only_own_private_keys(PEP_SESSION session, bool enable);
   252 
   253 
   254 // config_keep_sync_msg() - do not remove sync messages (for debugging purposes)
   255 //
   256 //      session (in)    session handle
   257 //      enable (in)     flag if enabled or disabled
   258 
   259 DYNAMIC_API void config_keep_sync_msg(PEP_SESSION session, bool enable);
   260 
   261 
   262 // config_service_log() - log more for service purposes
   263 //
   264 //      session (in)    session handle
   265 //      enable (in)     flag if enabled or disabled
   266 
   267 DYNAMIC_API void config_service_log(PEP_SESSION session, bool enable);
   268 
   269 
   270 // decrypt_and_verify() - decrypt and/or verify a message
   271 //
   272 //    parameters:
   273 //        session (in)    session handle
   274 //        ctext (in)      cipher text to decrypt and/or verify
   275 //        csize (in)      size of cipher text
   276 //        dsigtext (in)   if extant, *detached* signature text for this
   277 //                        message (or NULL if not)
   278 //        dsize (in)      size of *detached* signature text for this
   279 //                        message (0, if no detached sig exists)
   280 //        ptext (out)     pointer to internal buffer with plain text
   281 //        psize (out)     size of plain text
   282 //        keylist (out)   list of key ids which where used to encrypt
   283 //
   284 //    return value:
   285 //        PEP_UNENCRYPTED               message was unencrypted and not signed
   286 //        PEP_VERIFIED                  message was unencrypted, signature matches
   287 //        PEP_DECRYPTED                 message is decrypted now, no signature
   288 //        PEP_DECRYPTED_AND_VERIFIED    message is decrypted now and verified
   289 //        PEP_DECRYPT_WRONG_FORMAT      message has wrong format to handle
   290 //        PEP_DECRYPT_NO_KEY            key not available to decrypt and/or verify
   291 //        PEP_DECRYPT_SIGNATURE_DOES_NOT_MATCH    wrong signature
   292 //
   293 //    caveat:
   294 //        the ownerships of ptext as well as keylist are going to the caller
   295 //        the caller must use free() (or an Windoze pEp_free()) and
   296 //        free_stringlist() to free them
   297 //
   298 //      if this function failes an error message may be the first element of
   299 //      keylist and the other elements may be the keys used for encryption
   300 
   301 DYNAMIC_API PEP_STATUS decrypt_and_verify(
   302         PEP_SESSION session, const char *ctext, size_t csize,
   303         const char *dsigtext, size_t dsigsize,
   304         char **ptext, size_t *psize, stringlist_t **keylist
   305     );
   306 
   307 
   308 // verify_text() - verfy plain text with a digital signature
   309 //
   310 //  parameters:
   311 //      session (in)    session handle
   312 //      text (in)       text to verify
   313 //      size (in)       size of text
   314 //      signature (in)  signature text
   315 //      sig_size (in)   size of signature
   316 //      keylist (out)   list of key ids which where used to encrypt or NULL on
   317 //                        error
   318 //
   319 //  return value:
   320 //        PEP_VERIFIED                message was unencrypted, signature matches
   321 //        PEP_DECRYPT_NO_KEY          key not available to decrypt and/or verify
   322 //        PEP_DECRYPT_SIGNATURE_DOES_NOT_MATCH    wrong signature
   323 
   324 DYNAMIC_API PEP_STATUS verify_text(
   325         PEP_SESSION session, const char *text, size_t size,
   326         const char *signature, size_t sig_size, stringlist_t **keylist
   327     );
   328 
   329 
   330 // encrypt_and_sign() - encrypt and sign a message
   331 //
   332 //    parameters:
   333 //        session (in)    session handle
   334 //        keylist (in)    list of key ids to encrypt with as C strings
   335 //        ptext (in)      plain text to decrypt and/or verify
   336 //        psize (in)      size of plain text
   337 //        ctext (out)     pointer to internal buffer with cipher text
   338 //        csize (out)     size of cipher text
   339 //
   340 //    return value:
   341 //        PEP_STATUS_OK = 0            encryption and signing succeeded
   342 //        PEP_KEY_NOT_FOUND            at least one of the recipient keys
   343 //                                     could not be found
   344 //        PEP_KEY_HAS_AMBIG_NAME       at least one of the recipient keys has
   345 //                                     an ambiguous name
   346 //        PEP_GET_KEY_FAILED           cannot retrieve key
   347 //
   348 //    caveat:
   349 //      the ownership of ctext is going to the caller
   350 //      the caller is responsible to free() it (on Windoze use pEp_free())
   351 //      the first key in keylist is being used to sign the message
   352 //      this implies there has to be a private key for that keypair
   353 
   354 DYNAMIC_API PEP_STATUS encrypt_and_sign(
   355         PEP_SESSION session, const stringlist_t *keylist, const char *ptext,
   356         size_t psize, char **ctext, size_t *csize
   357     );
   358 
   359 
   360 // log_event() - log a user defined event defined by UTF-8 encoded strings into
   361 // management log
   362 //
   363 //    parameters:
   364 //        session (in)        session handle
   365 //        title (in)          C string with event name
   366 //        entity (in)         C string with name of entity which is logging
   367 //        description (in)    C string with long description for event or NULL if
   368 //                            omitted
   369 //        comment (in)        C string with user defined comment or NULL if
   370 //                            omitted
   371 //
   372 //    return value:
   373 //        PEP_STATUS_OK       log entry created
   374 
   375 DYNAMIC_API PEP_STATUS log_event(
   376         PEP_SESSION session,
   377         const char *title,
   378         const char *entity,
   379         const char *description,
   380         const char *comment
   381     );
   382 
   383 
   384 DYNAMIC_API PEP_STATUS log_service(PEP_SESSION session, const char *title,
   385         const char *entity, const char *description, const char *comment);
   386 
   387 #define _STR_(x) #x
   388 #define _D_STR_(x) _STR_(x)
   389 #define S_LINE _D_STR_(__LINE__)
   390 
   391 #define SERVICE_LOG(session, title, entity, desc) \
   392     log_service((session), (title), (entity), (desc), "service " __FILE__ ":" S_LINE)
   393 
   394 
   395 // trustword() - get the corresponding trustword for a 16 bit value
   396 //
   397 //    parameters:
   398 //        session (in)            session handle
   399 //        value (in)              value to find a trustword for
   400 //        lang (in)               C string with ISO 639-1 language code
   401 //        word (out)              pointer to C string with trustword UTF-8 encoded
   402 //                                NULL if language is not supported or trustword
   403 //                                wordlist is damaged or unavailable
   404 //        wsize (out)             length of trustword
   405 //
   406 //    return value:
   407 //        PEP_STATUS_OK            trustword retrieved
   408 //        PEP_TRUSTWORD_NOT_FOUND  trustword not found
   409 //
   410 //    caveat:
   411 //        the word pointer goes to the ownership of the caller
   412 //      the caller is responsible to free() it (on Windoze use pEp_free())
   413 
   414 DYNAMIC_API PEP_STATUS trustword(
   415             PEP_SESSION session, uint16_t value, const char *lang,
   416             char **word, size_t *wsize
   417         );
   418 
   419 
   420 // trustwords() - get trustwords for a string of hex values of a fingerprint
   421 //
   422 //    parameters:
   423 //        session (in)        session handle
   424 //        fingerprint (in)    C string with hex values to find trustwords for
   425 //        lang (in)           C string with ISO 639-1 language code
   426 //        words (out)         pointer to C string with trustwords UTF-8 encoded,
   427 //                            separated by a blank each
   428 //                            NULL if language is not supported or trustword
   429 //                            wordlist is damaged or unavailable
   430 //        wsize (out)         length of trustwords string
   431 //        max_words (in)      only generate a string with max_words;
   432 //                            if max_words == 0 there is no such limit
   433 //
   434 //    return value:
   435 //        PEP_STATUS_OK            trustwords retrieved
   436 //        PEP_OUT_OF_MEMORY        out of memory
   437 //        PEP_TRUSTWORD_NOT_FOUND  at least one trustword not found
   438 //
   439 //    caveat:
   440 //        the word pointer goes to the ownership of the caller
   441 //      the caller is responsible to free() it (on Windoze use pEp_free())
   442 //
   443 //  DON'T USE THIS FUNCTION FROM HIGH LEVEL LANGUAGES!
   444 //
   445 //  Better implement a simple one in the adapter yourself using trustword(), and
   446 //  return a list of trustwords.
   447 //  This function is provided for being used by C and C++ programs only.
   448 
   449 DYNAMIC_API PEP_STATUS trustwords(
   450         PEP_SESSION session, const char *fingerprint, const char *lang,
   451         char **words, size_t *wsize, int max_words
   452     );
   453 
   454 
   455 // TODO: increase versions in pEp.asn1 if rating changes
   456 
   457 typedef enum _PEP_comm_type {
   458     PEP_ct_unknown = 0,
   459 
   460     // range 0x01 to 0x09: no encryption, 0x0a to 0x0e: nothing reasonable
   461 
   462     PEP_ct_no_encryption = 0x01,                // generic
   463     PEP_ct_no_encrypted_channel = 0x02,
   464     PEP_ct_key_not_found = 0x03,
   465     PEP_ct_key_expired = 0x04,
   466     PEP_ct_key_revoked = 0x05,
   467     PEP_ct_key_b0rken = 0x06,
   468     PEP_ct_my_key_not_included = 0x09,
   469 
   470     PEP_ct_security_by_obscurity = 0x0a,
   471     PEP_ct_b0rken_crypto = 0x0b,
   472     PEP_ct_key_too_short = 0x0c,
   473 
   474     PEP_ct_compromised = 0x0e,                  // known compromised connection
   475     PEP_ct_compromized = 0x0e,                  // deprecated misspelling
   476     PEP_ct_mistrusted = 0x0f,                   // known mistrusted key
   477 
   478     // range 0x10 to 0x3f: unconfirmed encryption
   479 
   480     PEP_ct_unconfirmed_encryption = 0x10,       // generic
   481     PEP_ct_OpenPGP_weak_unconfirmed = 0x11,     // RSA 1024 is weak
   482 
   483     PEP_ct_to_be_checked = 0x20,                // generic
   484     PEP_ct_SMIME_unconfirmed = 0x21,
   485     PEP_ct_CMS_unconfirmed = 0x22,
   486 
   487     PEP_ct_strong_but_unconfirmed = 0x30,       // generic
   488     PEP_ct_OpenPGP_unconfirmed = 0x38,          // key at least 2048 bit RSA or EC
   489     PEP_ct_OTR_unconfirmed = 0x3a,
   490 
   491     // range 0x40 to 0x7f: unconfirmed encryption and anonymization
   492 
   493     PEP_ct_unconfirmed_enc_anon = 0x40,         // generic
   494     PEP_ct_pEp_unconfirmed = 0x7f,
   495 
   496     PEP_ct_confirmed = 0x80,                    // this bit decides if trust is confirmed
   497 
   498     // range 0x81 to 0x8f: reserved
   499     // range 0x90 to 0xbf: confirmed encryption
   500 
   501     PEP_ct_confirmed_encryption = 0x90,         // generic
   502     PEP_ct_OpenPGP_weak = 0x91,                 // RSA 1024 is weak (unused)
   503 
   504     PEP_ct_to_be_checked_confirmed = 0xa0,      // generic
   505     PEP_ct_SMIME = 0xa1,
   506     PEP_ct_CMS = 0xa2,
   507 
   508     PEP_ct_strong_encryption = 0xb0,            // generic
   509     PEP_ct_OpenPGP = 0xb8,                      // key at least 2048 bit RSA or EC
   510     PEP_ct_OTR = 0xba,
   511 
   512     // range 0xc0 to 0xff: confirmed encryption and anonymization
   513 
   514     PEP_ct_confirmed_enc_anon = 0xc0,           // generic
   515     PEP_ct_pEp = 0xff
   516 } PEP_comm_type;
   517 
   518 typedef enum _identity_flags {
   519     // the first octet flags are app defined settings
   520     PEP_idf_not_for_sync = 0x0001,   // don't use this identity for sync
   521     PEP_idf_list = 0x0002,           // identity of list of persons
   522     // the second octet flags are calculated
   523     PEP_idf_devicegroup = 0x0100     // identity of a device group member
   524 } identity_flags;
   525 
   526 typedef unsigned int identity_flags_t;
   527 
   528 // typedef enum _keypair_flags {
   529 // } keypair_flags;
   530 
   531 typedef unsigned int keypair_flags_t;
   532 
   533 typedef struct _pEp_identity {
   534     char *address;              // C string with address UTF-8 encoded
   535     char *fpr;                  // C string with fingerprint UTF-8 encoded
   536     char *user_id;              // C string with user ID UTF-8 encoded
   537                                 // user_id MIGHT be set to "pEp_own_userId"
   538                                 // (use PEP_OWN_USERID preprocessor define)
   539                                 // if this is own user's identity.
   540                                 // But it is not REQUIRED to be.
   541     char *username;             // C string with user name UTF-8 encoded
   542     PEP_comm_type comm_type;    // type of communication with this ID
   543     char lang[3];               // language of conversation
   544                                 // ISO 639-1 ALPHA-2, last byte is 0
   545     bool me;                    // if this is the local user herself/himself
   546     identity_flags_t flags;     // identity_flag1 | identity_flag2 | ...
   547 } pEp_identity;
   548 
   549 typedef struct _identity_list {
   550     pEp_identity *ident;
   551     struct _identity_list *next;
   552 } identity_list;
   553 
   554 
   555 // new_identity() - allocate memory and set the string and size fields
   556 //
   557 //  parameters:
   558 //      address (in)        UTF-8 string or NULL 
   559 //      fpr (in)            UTF-8 string or NULL 
   560 //      user_id (in)        UTF-8 string or NULL 
   561 //      username (in)       UTF-8 string or NULL 
   562 //
   563 //  return value:
   564 //      pEp_identity struct or NULL if out of memory
   565 //
   566 //  caveat:
   567 //      the strings are copied; the original strings are still being owned by
   568 //      the caller
   569 
   570 DYNAMIC_API pEp_identity *new_identity(
   571         const char *address, const char *fpr, const char *user_id,
   572         const char *username
   573     );
   574 
   575 
   576 // identity_dup() - allocate memory and duplicate
   577 //
   578 //  parameters:
   579 //      src (in)            identity to duplicate
   580 //
   581 //  return value:
   582 //      pEp_identity struct or NULL if out of memory
   583 //
   584 //  caveat:
   585 //      the strings are copied; the original strings are still being owned by
   586 //      the caller
   587 
   588 DYNAMIC_API pEp_identity *identity_dup(const pEp_identity *src);
   589 
   590 
   591 // free_identity() - free all memory being occupied by a pEp_identity struct
   592 //
   593 //  parameters:
   594 //      identity (in)       struct to release
   595 //
   596 //  caveat:
   597 //      not only the struct but also all string memory referenced by the
   598 //      struct is being freed; all pointers inside are invalid afterwards
   599 
   600 DYNAMIC_API void free_identity(pEp_identity *identity);
   601 
   602 
   603 // get_identity() - get identity information
   604 //
   605 //    parameters:
   606 //        session (in)        session handle
   607 //        address (in)        C string with communication address, UTF-8 encoded
   608 //        user_id (in)        unique C string to identify person that identity
   609 //                            is refering to
   610 //        identity (out)      pointer to pEp_identity structure with results or
   611 //                            NULL if failure
   612 //
   613 //    caveat:
   614 //        address and user_id are being copied; the original strings remains in
   615 //        the ownership of the caller
   616 //        the resulting pEp_identity structure goes to the ownership of the
   617 //        caller and has to be freed with free_identity() when not in use any
   618 //        more
   619 
   620 DYNAMIC_API PEP_STATUS get_identity(
   621         PEP_SESSION session,
   622         const char *address,
   623         const char *user_id,
   624         pEp_identity **identity
   625     );
   626 
   627 PEP_STATUS replace_identities_fpr(PEP_SESSION session, 
   628                                  const char* old_fpr, 
   629                                  const char* new_fpr); 
   630 
   631 
   632 // set_identity() - set identity information
   633 //
   634 //    parameters:
   635 //        session (in)        session handle
   636 //        identity (in)       pointer to pEp_identity structure
   637 //
   638 //    return value:
   639 //        PEP_STATUS_OK = 0             encryption and signing succeeded
   640 //        PEP_CANNOT_SET_PERSON         writing to table person failed
   641 //        PEP_CANNOT_SET_PGP_KEYPAIR    writing to table pgp_keypair failed
   642 //        PEP_CANNOT_SET_IDENTITY       writing to table identity failed
   643 //        PEP_COMMIT_FAILED             SQL commit failed
   644 //
   645 //    caveat:
   646 //        address, fpr, user_id and username must be given
   647 
   648 DYNAMIC_API PEP_STATUS set_identity(
   649         PEP_SESSION session, const pEp_identity *identity
   650     );
   651 
   652 // get_default own_userid() - get the user_id of the own user
   653 //
   654 //    parameters:
   655 //        session (in)        session handle
   656 //        userid  (out)       own user id (if it exists)
   657 //
   658 //    return value:
   659 //        PEP_STATUS_OK = 0             userid was found
   660 //        PEP_CANNOT_FIND_IDENTITY      no own_user found in the DB
   661 //        PEP_UNKNOWN_ERROR             results were returned, but no ID
   662 //                                      found (no reason this should ever occur)
   663 //    caveat:
   664 //        userid will be NULL if not found; otherwise, returned string
   665 //        belongs to the caller.
   666 
   667 DYNAMIC_API PEP_STATUS get_default_own_userid(
   668         PEP_SESSION session, 
   669         char** userid
   670     );
   671 
   672 // get_userid_alias_default() - get the default user_id which corresponds
   673 //                              to an alias
   674 //    parameters:
   675 //        session (in)        session handle
   676 //        alias_id (in)       the user_id which may be an alias for a default id
   677 //        default_id (out)    the default id for this alias, if the alias
   678 //                            is in the DB as an alias, else NULL
   679 //    return value:
   680 //        PEP_STATUS_OK = 0             userid was found
   681 //        PEP_CANNOT_FIND_ALIAS         this userid is not listed as an 
   682 //                                      alias in the DB
   683 //        PEP_UNKNOWN_ERROR             results were returned, but no ID
   684 //                                      found (no reason this should ever occur)
   685 //    caveat:
   686 //        default_id will be NULL if not found; otherwise, returned string
   687 //        belongs to the caller.
   688 //        also, current implementation does NOT check to see if this userid
   689 //        IS a default.
   690 
   691 DYNAMIC_API PEP_STATUS get_userid_alias_default(
   692         PEP_SESSION session, 
   693         const char* alias_id,
   694         char** default_id);
   695 
   696 // set_userid_alias() - set an alias to correspond to a default id
   697 //    parameters:
   698 //        session (in)        session handle
   699 //        default_id (in)     the default id for this alias. This must
   700 //                            correspond to the default user_id for an
   701 //                            entry in the person (user) table.
   702 //        alias_id (in)       the alias to be set for this default id
   703 //    return value:
   704 //        PEP_STATUS_OK = 0             userid was found
   705 //        PEP_CANNOT_SET_ALIAS          there was an error setting this
   706 
   707 DYNAMIC_API PEP_STATUS set_userid_alias (
   708         PEP_SESSION session, 
   709         const char* default_id,
   710         const char* alias_id);
   711 
   712 
   713 // set_device_group() - update own person's device group
   714 //
   715 //    parameters:
   716 //        session (in)        session handle
   717 //        group_name (in)     new group name
   718 //
   719 //    return value:
   720 //        PEP_STATUS_OK = 0             device group was updated
   721 //        PEP_CANNOT_SET_PERSON         update failed
   722 
   723 DYNAMIC_API PEP_STATUS set_device_group(
   724         PEP_SESSION session,
   725         const char *group_name
   726     );
   727 
   728 // get_device_group() - get own person's device group
   729 //
   730 //    parameters:
   731 //        session (in)        session handle
   732 //        group_name (in)     new group name
   733 //
   734 //    return value:
   735 //        PEP_STATUS_OK = 0             couldn't get device group
   736 //        PEP_RECORD_NOT_FOUND          update failed
   737 //
   738 //    caveat:
   739 //        the ownerships of group_name is going to the caller
   740 
   741 DYNAMIC_API PEP_STATUS get_device_group(
   742         PEP_SESSION session, 
   743         char **group_name
   744     );
   745 
   746 // set_identity_flags() - update identity flags on existing identity
   747 //
   748 //    parameters:
   749 //        session (in)        session handle
   750 //        identity (in,out)   pointer to pEp_identity structure
   751 //        flags (in)          new value for flags
   752 //
   753 //    return value:
   754 //        PEP_STATUS_OK = 0             encryption and signing succeeded
   755 //        PEP_CANNOT_SET_IDENTITY       update of identity failed
   756 //
   757 //    caveat:
   758 //        address and user_id must be given in identity
   759 
   760 DYNAMIC_API PEP_STATUS set_identity_flags(
   761         PEP_SESSION session,
   762         pEp_identity *identity,
   763         identity_flags_t flags
   764     );
   765 
   766 // unset_identity_flags() - update identity flags on existing identity
   767 //
   768 //    parameters:
   769 //        session (in)        session handle
   770 //        identity (in,out)   pointer to pEp_identity structure
   771 //        flags (in)          new value for flags
   772 //
   773 //    return value:
   774 //        PEP_STATUS_OK = 0             encryption and signing succeeded
   775 //        PEP_CANNOT_SET_IDENTITY       update of identity failed
   776 //
   777 //    caveat:
   778 //        address and user_id must be given in identity
   779 
   780 DYNAMIC_API PEP_STATUS unset_identity_flags(
   781         PEP_SESSION session,
   782         pEp_identity *identity,
   783         identity_flags_t flags
   784     );
   785 
   786 // mark_as_compromised() - mark key in trust db as compromised
   787 //
   788 //    parameters:
   789 //        session (in)        session handle
   790 //        fpr (in)            fingerprint of key to mark
   791 
   792 DYNAMIC_API PEP_STATUS mark_as_compromised(
   793         PEP_SESSION session,
   794         const char *fpr
   795     );
   796 
   797 
   798 // mark_as_compromized() - deprecated to fix misspelling. Please move to
   799 //                         mark_as_compromised();
   800 
   801 DYNAMIC_API PEP_STATUS mark_as_compromized(
   802         PEP_SESSION session,
   803         const char *fpr
   804     );
   805 
   806 
   807 // generate_keypair() - generate a new key pair and add it to the key ring
   808 //
   809 //  parameters:
   810 //      session (in)            session handle
   811 //        identity (inout)      pointer to pEp_identity structure
   812 //
   813 //    return value:
   814 //        PEP_STATUS_OK = 0       encryption and signing succeeded
   815 //        PEP_ILLEGAL_VALUE       illegal values for identity fields given
   816 //        PEP_CANNOT_CREATE_KEY   key engine is on strike
   817 //
   818 //  caveat:
   819 //      address and username fields must be set to UTF-8 strings
   820 //      the fpr field must be set to NULL
   821 //
   822 //      this function allocates a string and sets set fpr field of identity
   823 //      the caller is responsible to call free() for that string or use
   824 //      free_identity() on the struct
   825 
   826 DYNAMIC_API PEP_STATUS generate_keypair(
   827         PEP_SESSION session, pEp_identity *identity
   828     );
   829 
   830 
   831 // delete_keypair() - delete a public key or a key pair from the key ring
   832 //
   833 //  parameters:
   834 //      session (in)            session handle
   835 //      fpr (in)                C string with key id or fingerprint of the
   836 //                              public key
   837 //
   838 //  return value:
   839 //      PEP_STATUS_OK = 0       key was successfully deleted
   840 //      PEP_KEY_NOT_FOUND       key not found
   841 //      PEP_ILLEGAL_VALUE       not a valid key id or fingerprint
   842 //      PEP_KEY_HAS_AMBIG_NAME  fpr does not uniquely identify a key
   843 //      PEP_OUT_OF_MEMORY       out of memory
   844 
   845 DYNAMIC_API PEP_STATUS delete_keypair(PEP_SESSION session, const char *fpr);
   846 
   847 
   848 // import_key() - import key from data
   849 //
   850 //  parameters:
   851 //      session (in)            session handle
   852 //      key_data (in)           key data, i.e. ASCII armored OpenPGP key
   853 //      size (in)               amount of data to handle
   854 //      private_keys (out)      list of private keys that have been imported
   855 //
   856 //  return value:
   857 //      PEP_STATUS_OK = 0       key was successfully imported
   858 //      PEP_OUT_OF_MEMORY       out of memory
   859 //      PEP_ILLEGAL_VALUE       there is no key data to import
   860 //
   861 //  caveat:
   862 //      private_keys goes to the ownership of the caller
   863 //      private_keys can be left NULL, it is then ignored
   864 
   865 DYNAMIC_API PEP_STATUS import_key(
   866         PEP_SESSION session,
   867         const char *key_data,
   868         size_t size,
   869         identity_list **private_keys
   870     );
   871 
   872 
   873 // export_key() - export ascii armored key
   874 //
   875 //  parameters:
   876 //      session (in)            session handle
   877 //      fpr (in)                key id or fingerprint of key
   878 //      key_data (out)          ASCII armored OpenPGP key
   879 //      size (out)              amount of data to handle
   880 //
   881 //  return value:
   882 //      PEP_STATUS_OK = 0       key was successfully exported
   883 //      PEP_OUT_OF_MEMORY       out of memory
   884 //      PEP_KEY_NOT_FOUND       key not found
   885 //
   886 //  caveat:
   887 //      the key_data goes to the ownership of the caller
   888 //      the caller is responsible to free() it (on Windoze use pEp_free())
   889 
   890 DYNAMIC_API PEP_STATUS export_key(
   891         PEP_SESSION session, const char *fpr, char **key_data, size_t *size
   892     );
   893 
   894 
   895 // export_secret_key() - export secret key ascii armored
   896 //
   897 //  parameters:
   898 //      session (in)            session handle
   899 //      fpr (in)                fingerprint of key, at least 16 hex digits
   900 //      key_data (out)          ASCII armored OpenPGP secret key
   901 //      size (out)              amount of data to handle
   902 //
   903 //  return value:
   904 //      PEP_STATUS_OK = 0       key was successfully exported
   905 //      PEP_OUT_OF_MEMORY       out of memory
   906 //      PEP_KEY_NOT_FOUND       key not found
   907 //      PEP_CANNOT_EXPORT_KEY   cannot export secret key (i.e. it's on an HKS)
   908 //
   909 //  caveat:
   910 //      the key_data goes to the ownership of the caller
   911 //      the caller is responsible to free() it (on Windoze use pEp_free())
   912 //      beware of leaking secret key data - overwrite it in memory after use
   913 
   914 DYNAMIC_API PEP_STATUS export_secret_key(
   915         PEP_SESSION session, const char *fpr, char **key_data, size_t *size
   916     );
   917 
   918 
   919 // export_secrect_key() - deprecated misspelled function. Please replace with
   920 //                        export_secret_key
   921 
   922 DYNAMIC_API PEP_STATUS export_secrect_key(
   923         PEP_SESSION session, const char *fpr, char **key_data, size_t *size
   924     );
   925 
   926 
   927 // recv_key() - update key(s) from keyserver
   928 //
   929 //  parameters:
   930 //      session (in)            session handle
   931 //      pattern (in)            key id, user id or address to search for as
   932 //                              UTF-8 string
   933 
   934 DYNAMIC_API PEP_STATUS recv_key(PEP_SESSION session, const char *pattern);
   935 
   936 
   937 // find_keys() - find keys in keyring
   938 //
   939 //  parameters:
   940 //      session (in)            session handle
   941 //      pattern (in)            key id, user id or address to search for as
   942 //                              UTF-8 string
   943 //      keylist (out)           list of fingerprints found or NULL on error
   944 //
   945 //  caveat:
   946 //        the ownerships of keylist isgoing to the caller
   947 //        the caller must use free_stringlist() to free it
   948 
   949 
   950 DYNAMIC_API PEP_STATUS find_keys(
   951         PEP_SESSION session, const char *pattern, stringlist_t **keylist
   952     );
   953 
   954 // send_key() - send key(s) to keyserver
   955 //
   956 //  parameters:
   957 //      session (in)            session handle
   958 //      pattern (in)            key id, user id or address to search for as
   959 //                              UTF-8 string
   960 
   961 DYNAMIC_API PEP_STATUS send_key(PEP_SESSION session, const char *pattern);
   962 
   963 
   964 // pEp_free() - free memory allocated by pEp engine
   965 //
   966 //  parameters:
   967 //      p (in)                  pointer to free
   968 //
   969 //  The reason for this function is that heap management can be a pretty
   970 //  complex task with Windoze. This free() version calls the free()
   971 //  implementation of the C runtime library which was used to build pEp engine,
   972 //  so you're using the correct heap. For more information, see:
   973 //  <http://msdn.microsoft.com/en-us/library/windows/desktop/aa366711(v=vs.85).aspx>
   974 
   975 DYNAMIC_API void pEp_free(void *p);
   976 
   977 
   978 // get_trust() - get the trust level a key has for a person
   979 //
   980 //  parameters:
   981 //      session (in)            session handle
   982 //      identity (inout)        user_id and fpr to check as UTF-8 strings (in)
   983 //                              comm_type as result (out)
   984 //
   985 //  this function modifies the given identity struct; the struct remains in
   986 //  the ownership of the caller
   987 //  if the trust level cannot be determined identity->comm_type is set
   988 //  to PEP_ct_unknown
   989 
   990 DYNAMIC_API PEP_STATUS get_trust(PEP_SESSION session, pEp_identity *identity);
   991 
   992 
   993 PEP_STATUS set_trust(PEP_SESSION session, 
   994                      pEp_identity* identity);
   995                             
   996 PEP_STATUS update_trust_for_fpr(PEP_SESSION session, 
   997                                 const char* fpr, 
   998                                 PEP_comm_type comm_type);
   999 
  1000 // least_trust() - get the least known trust level for a key in the database
  1001 //
  1002 //  parameters:
  1003 //      session (in)            session handle
  1004 //      fpr (in)                fingerprint of key to check
  1005 //      comm_type (out)         least comm_type as result (out)
  1006 //
  1007 //  if the trust level cannot be determined comm_type is set to PEP_ct_unknown
  1008 
  1009 DYNAMIC_API PEP_STATUS least_trust(
  1010         PEP_SESSION session,
  1011         const char *fpr,
  1012         PEP_comm_type *comm_type
  1013     );
  1014 
  1015 
  1016 // get_key_rating() - get the rating a bare key has
  1017 //
  1018 //  parameters:
  1019 //      session (in)            session handle
  1020 //      fpr (in)                unique identifyer for key as UTF-8 string
  1021 //      comm_type (out)         key rating
  1022 //
  1023 //  if an error occurs, *comm_type is set to PEP_ct_unknown and an error
  1024 //  is returned
  1025 
  1026 DYNAMIC_API PEP_STATUS get_key_rating(
  1027         PEP_SESSION session,
  1028         const char *fpr,
  1029         PEP_comm_type *comm_type
  1030     );
  1031 
  1032 
  1033 // renew_key() - renew an expired key
  1034 //
  1035 //  parameters:
  1036 //      session (in)            session handle
  1037 //      fpr (in)                ID of key to renew as UTF-8 string
  1038 //      ts (in)                 timestamp when key should expire or NULL for
  1039 //                              default
  1040 
  1041 DYNAMIC_API PEP_STATUS renew_key(
  1042         PEP_SESSION session,
  1043         const char *fpr,
  1044         const timestamp *ts
  1045     );
  1046 
  1047 
  1048 // revoke_key() - revoke a key
  1049 //
  1050 //  parameters:
  1051 //      session (in)            session handle
  1052 //      fpr (in)                ID of key to revoke as UTF-8 string
  1053 //      reason (in)             text with reason for revoke as UTF-8 string
  1054 //                              or NULL if reason unknown
  1055 //
  1056 //  caveat:
  1057 //      reason text must not include empty lines
  1058 //      this function is meant for internal use only; better use
  1059 //      key_mistrusted() of keymanagement API
  1060 
  1061 DYNAMIC_API PEP_STATUS revoke_key(
  1062         PEP_SESSION session,
  1063         const char *fpr,
  1064         const char *reason
  1065     );
  1066 
  1067 
  1068 // key_expired() - flags if a key is already expired
  1069 //
  1070 //  parameters:
  1071 //      session (in)            session handle
  1072 //      fpr (in)                ID of key to check as UTF-8 string
  1073 //      when (in)               UTC time of when should expiry be considered
  1074 //      expired (out)           flag if key expired
  1075 
  1076 DYNAMIC_API PEP_STATUS key_expired(
  1077         PEP_SESSION session,
  1078         const char *fpr,
  1079         const time_t when,
  1080         bool *expired
  1081     );
  1082 
  1083     
  1084 // key_revoked() - flags if a key is already revoked
  1085 //
  1086 //  parameters:
  1087 //      session (in)            session handle
  1088 //      fpr (in)                ID of key to check as UTF-8 string
  1089 //      revoked (out)           flag if key revoked
  1090 
  1091 DYNAMIC_API PEP_STATUS key_revoked(
  1092         PEP_SESSION session,
  1093         const char *fpr,
  1094         bool *revoked
  1095     );
  1096 
  1097 PEP_STATUS get_key_userids(
  1098         PEP_SESSION session,
  1099         const char* fpr,
  1100         stringlist_t** keylist
  1101     );
  1102 
  1103 
  1104 // get_crashdump_log() - get the last log messages out
  1105 //
  1106 //  parameters:
  1107 //      session (in)            session handle
  1108 //      maxlines (in)           maximum number of lines (0 for default)
  1109 //      logdata (out)           logdata as string in double quoted CSV format
  1110 //                              column1 is title
  1111 //                              column2 is entity
  1112 //                              column3 is description
  1113 //                              column4 is comment
  1114 //
  1115 //  caveat:
  1116 //      the ownership of logdata goes to the caller
  1117 
  1118 DYNAMIC_API PEP_STATUS get_crashdump_log(
  1119         PEP_SESSION session,
  1120         int maxlines,
  1121         char **logdata
  1122     );
  1123 
  1124 
  1125 // get_languagelist() - get the list of languages
  1126 //
  1127 //  parameters:
  1128 //      session (in)            session handle
  1129 //      languages (out)         languages as string in double quoted CSV format
  1130 //                              column 1 is the ISO 639-1 language code
  1131 //                              column 2 is the name of the language
  1132 //
  1133 //  caveat:
  1134 //      the ownership of languages goes to the caller
  1135 
  1136 DYNAMIC_API PEP_STATUS get_languagelist(
  1137         PEP_SESSION session,
  1138         char **languages
  1139     );
  1140 
  1141 
  1142 // get_phrase() - get phrase in a dedicated language through i18n
  1143 //
  1144 //  parameters:
  1145 //      session (in)            session handle
  1146 //      lang (in)               C string with ISO 639-1 language code
  1147 //      phrase_id (in)          id of phrase in i18n
  1148 //      phrase (out)            phrase as UTF-8 string
  1149 //
  1150 //  caveat:
  1151 //      the ownership of phrase goes to the caller
  1152 
  1153 DYNAMIC_API PEP_STATUS get_phrase(
  1154         PEP_SESSION session,
  1155         const char *lang,
  1156         int phrase_id,
  1157         char **phrase
  1158     );
  1159 
  1160 
  1161 // sequence_value() - raise the value of a named sequence and retrieve it
  1162 //
  1163 //  parameters:
  1164 //      session (in)            session handle
  1165 //      name (in)               name of sequence
  1166 //      value (out)             value of sequence
  1167 //
  1168 //  returns:
  1169 //      PEP_STATUS_OK                   no error, not own sequence
  1170 //      PEP_SEQUENCE_VIOLATED           if sequence violated
  1171 //      PEP_CANNOT_INCREASE_SEQUENCE    if sequence cannot be increased
  1172 //      PEP_OWN_SEQUENCE                if own sequence
  1173 
  1174 DYNAMIC_API PEP_STATUS sequence_value(
  1175         PEP_SESSION session,
  1176         const char *name,
  1177         int32_t *value
  1178     );
  1179 
  1180 
  1181 // set_revoked() - records relation between a revoked key and its replacement
  1182 //
  1183 //  parameters:
  1184 //      session (in)            session handle
  1185 //      revoked_fpr (in)        revoked fingerprint
  1186 //      replacement_fpr (in)    replacement key fingerprint
  1187 //      revocation_date (in)    revocation date
  1188 
  1189 DYNAMIC_API PEP_STATUS set_revoked(
  1190        PEP_SESSION session,
  1191        const char *revoked_fpr,
  1192        const char *replacement_fpr,
  1193        const uint64_t revocation_date
  1194     );
  1195 
  1196 
  1197 // get_revoked() - find revoked key that may have been replaced by given key, if any
  1198 //
  1199 //  parameters:
  1200 //      session (in)            session handle
  1201 //      fpr (in)                given fingerprint
  1202 //      revoked_fpr (out)       revoked fingerprint
  1203 //      revocation_date (out)   revocation date
  1204     
  1205 DYNAMIC_API PEP_STATUS get_revoked(
  1206         PEP_SESSION session,
  1207         const char *fpr,
  1208         char **revoked_fpr,
  1209         uint64_t *revocation_date
  1210     );
  1211 
  1212 
  1213 // key_created() - get creation date of a key
  1214 //
  1215 //  parameters:
  1216 //      session (in)            session handle
  1217 //      fpr (in)                fingerprint of key
  1218 //      created (out)           date of creation
  1219 
  1220 PEP_STATUS key_created(
  1221         PEP_SESSION session,
  1222         const char *fpr,
  1223         time_t *created
  1224     );
  1225 
  1226 
  1227 // find_private_keys() - find keys in keyring
  1228 //
  1229 //  parameters:
  1230 //      session (in)            session handle
  1231 //      pattern (in)            key id, user id or address to search for as
  1232 //                              UTF-8 string
  1233 //      keylist (out)           list of fingerprints found or NULL on error
  1234 //
  1235 //  caveat:
  1236 //        the ownerships of keylist isgoing to the caller
  1237 //        the caller must use free_stringlist() to free it
  1238 PEP_STATUS find_private_keys(PEP_SESSION session, const char* pattern,
  1239                              stringlist_t **keylist);
  1240 
  1241 // get_engine_version() - returns the current version of pEpEngine (this is different
  1242 //                        from the pEp protocol version!)
  1243 //
  1244 //  parameters: none
  1245 //
  1246 //  return_value: const char* to the engine version string constant
  1247 //
  1248 DYNAMIC_API const char* get_engine_version();
  1249 
  1250 // is_pEp_user() - returns true if the USER corresponding to this identity 
  1251 //                 has been listed in the *person* table as a pEp user. 
  1252 //
  1253 //  parameters:
  1254 //      identity (in) - identity containing the user_id to check (this is
  1255 //                      the only part of the struct we require to be set)
  1256 //      is_pEp (out)  - boolean pointer - will return true or false by
  1257 //                      reference with respect to whether or not user is
  1258 //                      a known pEp user
  1259 //
  1260 //  return_value: PEP_STATUS_OK if user found in person table
  1261 //                PEP_ILLEGAL_VALUE if no user_id in input
  1262 //                PEP_CANNOT_FIND_PERSON if user_id doesn't exist
  1263 //
  1264 //  caveat: This *does not check comm_type*
  1265 //                         
  1266 DYNAMIC_API PEP_STATUS is_pEp_user(PEP_SESSION session, 
  1267                                    pEp_identity *identity, 
  1268                                    bool* is_pEp);
  1269 
  1270 
  1271 
  1272 DYNAMIC_API PEP_STATUS reset_pEptest_hack(PEP_SESSION session);
  1273 
  1274 // This is used internally when there is a temporary identity to be retrieved
  1275 // that may not yet have an FPR attached. See get_identity() for functionality,
  1276 // params and caveats.
  1277 PEP_STATUS get_identity_without_trust_check(
  1278         PEP_SESSION session,
  1279         const char *address,
  1280         const char *user_id,
  1281         pEp_identity **identity
  1282     );
  1283     
  1284 PEP_STATUS get_identities_by_address(
  1285         PEP_SESSION session,
  1286         const char *address,
  1287         identity_list** id_list
  1288     );
  1289         
  1290 PEP_STATUS replace_userid(PEP_SESSION session, const char* old_uid,
  1291                               const char* new_uid);
  1292                               
  1293 PEP_STATUS remove_fpr_as_default(PEP_SESSION session, 
  1294                                     const char* fpr);
  1295                               
  1296                                     
  1297 PEP_STATUS get_main_user_fpr(PEP_SESSION session, 
  1298                              const char* user_id,
  1299                              char** main_fpr);
  1300 
  1301 PEP_STATUS replace_main_user_fpr(PEP_SESSION session, const char* user_id,
  1302                               const char* new_fpr);
  1303     
  1304 PEP_STATUS refresh_userid_default_key(PEP_SESSION session, const char* user_id);
  1305 
  1306 // This ONLY sets the *user* flag, and creates a shell identity if necessary.
  1307 PEP_STATUS set_as_pEp_user(PEP_SESSION session, pEp_identity* user);
  1308 
  1309 // returns true (by reference) if a person with this user_id exists; 
  1310 // Also replaces aliased user_ids by defaults in identity.
  1311 PEP_STATUS exists_person(PEP_SESSION session, pEp_identity* identity, bool* exists);
  1312 
  1313 PEP_STATUS set_pgp_keypair(PEP_SESSION session, const char* fpr);
  1314 
  1315 #ifdef __cplusplus
  1316 }
  1317 #endif