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