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