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