src/pEpEngine.h
author Krista 'DarthMama' Bennett <krista@pep.foundation>
Fri, 17 May 2019 17:05:47 +0200
branchENGINE-559
changeset 3727 d926613299bf
parent 3712 2af31507d5d8
child 3728 3e8c536a1634
permissions -rw-r--r--
ENGINE-559: modified DDL version to 12, added pep_version column to identity (and put in the upgrade code)
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@3674
    20
#define PEP_VERSION "2.1" // 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@934
   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@464
   252
vb@467
   253
DYNAMIC_API void config_passive_mode(PEP_SESSION session, bool enable);
vb@467
   254
vb@467
   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@3727
   633
    float latest_pEp_version;   // Used to determine highest seenencryption format.
krista@3727
   634
                                // default is 2.0 for pEp users                            
krista@2461
   635
    bool me;                    // if this is the local user herself/himself
vb@944
   636
    identity_flags_t flags;     // identity_flag1 | identity_flag2 | ...
vb@0
   637
} pEp_identity;
vb@0
   638
Edouard@730
   639
typedef struct _identity_list {
Edouard@730
   640
    pEp_identity *ident;
Edouard@730
   641
    struct _identity_list *next;
Edouard@730
   642
} identity_list;
Edouard@730
   643
vb@0
   644
vb@0
   645
// new_identity() - allocate memory and set the string and size fields
vb@0
   646
//
vb@0
   647
//  parameters:
vb@0
   648
//      address (in)        UTF-8 string or NULL 
vb@0
   649
//      fpr (in)            UTF-8 string or NULL 
vb@0
   650
//      user_id (in)        UTF-8 string or NULL 
vb@0
   651
//      username (in)       UTF-8 string or NULL 
vb@0
   652
//
vb@0
   653
//  return value:
vb@932
   654
//      pEp_identity struct or NULL if out of memory
vb@0
   655
//
vb@0
   656
//  caveat:
vb@0
   657
//      the strings are copied; the original strings are still being owned by
vb@0
   658
//      the caller
vb@0
   659
vb@0
   660
DYNAMIC_API pEp_identity *new_identity(
vb@0
   661
        const char *address, const char *fpr, const char *user_id,
vb@0
   662
        const char *username
vb@0
   663
    );
vb@0
   664
vb@0
   665
vb@932
   666
// identity_dup() - allocate memory and duplicate
vb@37
   667
//
vb@37
   668
//  parameters:
vb@37
   669
//      src (in)            identity to duplicate
vb@37
   670
//
vb@37
   671
//  return value:
vb@932
   672
//      pEp_identity struct or NULL if out of memory
vb@37
   673
//
vb@37
   674
//  caveat:
vb@37
   675
//      the strings are copied; the original strings are still being owned by
vb@37
   676
//      the caller
vb@37
   677
vb@37
   678
DYNAMIC_API pEp_identity *identity_dup(const pEp_identity *src);
vb@37
   679
vb@37
   680
vb@0
   681
// free_identity() - free all memory being occupied by a pEp_identity struct
vb@0
   682
//
vb@0
   683
//  parameters:
vb@0
   684
//      identity (in)       struct to release
vb@0
   685
//
vb@0
   686
//  caveat:
vb@0
   687
//      not only the struct but also all string memory referenced by the
vb@0
   688
//      struct is being freed; all pointers inside are invalid afterwards
vb@0
   689
vb@0
   690
DYNAMIC_API void free_identity(pEp_identity *identity);
vb@0
   691
vb@0
   692
vb@0
   693
// get_identity() - get identity information
vb@0
   694
//
roker@529
   695
//    parameters:
roker@529
   696
//        session (in)        session handle
roker@529
   697
//        address (in)        C string with communication address, UTF-8 encoded
Edouard@562
   698
//        user_id (in)        unique C string to identify person that identity
Edouard@562
   699
//                            is refering to
roker@529
   700
//        identity (out)      pointer to pEp_identity structure with results or
roker@529
   701
//                            NULL if failure
vb@0
   702
//
roker@529
   703
//    caveat:
vb@951
   704
//        address and user_id are being copied; the original strings remains in
vb@951
   705
//        the ownership of the caller
roker@529
   706
//        the resulting pEp_identity structure goes to the ownership of the
roker@529
   707
//        caller and has to be freed with free_identity() when not in use any
roker@529
   708
//        more
vb@0
   709
vb@0
   710
DYNAMIC_API PEP_STATUS get_identity(
Edouard@559
   711
        PEP_SESSION session,
Edouard@559
   712
        const char *address,
Edouard@559
   713
        const char *user_id,
vb@0
   714
        pEp_identity **identity
vb@0
   715
    );
vb@0
   716
krista@1799
   717
PEP_STATUS replace_identities_fpr(PEP_SESSION session, 
krista@1799
   718
                                 const char* old_fpr, 
krista@1799
   719
                                 const char* new_fpr); 
krista@1797
   720
krista@1797
   721
vb@0
   722
// set_identity() - set identity information
vb@0
   723
//
roker@529
   724
//    parameters:
roker@529
   725
//        session (in)        session handle
roker@529
   726
//        identity (in)       pointer to pEp_identity structure
vb@0
   727
//
roker@529
   728
//    return value:
roker@529
   729
//        PEP_STATUS_OK = 0             encryption and signing succeeded
roker@529
   730
//        PEP_CANNOT_SET_PERSON         writing to table person failed
roker@529
   731
//        PEP_CANNOT_SET_PGP_KEYPAIR    writing to table pgp_keypair failed
roker@529
   732
//        PEP_CANNOT_SET_IDENTITY       writing to table identity failed
roker@529
   733
//        PEP_COMMIT_FAILED             SQL commit failed
vb@0
   734
//
roker@529
   735
//    caveat:
vb@932
   736
//        address, fpr, user_id and username must be given
vb@0
   737
vb@0
   738
DYNAMIC_API PEP_STATUS set_identity(
vb@0
   739
        PEP_SESSION session, const pEp_identity *identity
vb@0
   740
    );
vb@0
   741
krista@2461
   742
// get_default own_userid() - get the user_id of the own user
krista@2461
   743
//
krista@2461
   744
//    parameters:
krista@2461
   745
//        session (in)        session handle
krista@2461
   746
//        userid  (out)       own user id (if it exists)
krista@2461
   747
//
krista@2461
   748
//    return value:
krista@2461
   749
//        PEP_STATUS_OK = 0             userid was found
krista@2461
   750
//        PEP_CANNOT_FIND_IDENTITY      no own_user found in the DB
krista@2461
   751
//        PEP_UNKNOWN_ERROR             results were returned, but no ID
krista@2461
   752
//                                      found (no reason this should ever occur)
krista@2461
   753
//    caveat:
krista@2461
   754
//        userid will be NULL if not found; otherwise, returned string
krista@2461
   755
//        belongs to the caller.
krista@2461
   756
krista@2461
   757
DYNAMIC_API PEP_STATUS get_default_own_userid(
krista@2461
   758
        PEP_SESSION session, 
krista@2461
   759
        char** userid
krista@2461
   760
    );
krista@2461
   761
krista@2461
   762
// get_userid_alias_default() - get the default user_id which corresponds
krista@2461
   763
//                              to an alias
krista@2461
   764
//    parameters:
krista@2461
   765
//        session (in)        session handle
krista@2461
   766
//        alias_id (in)       the user_id which may be an alias for a default id
krista@2461
   767
//        default_id (out)    the default id for this alias, if the alias
krista@2461
   768
//                            is in the DB as an alias, else NULL
krista@2461
   769
//    return value:
krista@2461
   770
//        PEP_STATUS_OK = 0             userid was found
krista@2461
   771
//        PEP_CANNOT_FIND_ALIAS         this userid is not listed as an 
krista@2461
   772
//                                      alias in the DB
krista@2461
   773
//        PEP_UNKNOWN_ERROR             results were returned, but no ID
krista@2461
   774
//                                      found (no reason this should ever occur)
krista@2461
   775
//    caveat:
krista@2461
   776
//        default_id will be NULL if not found; otherwise, returned string
krista@2461
   777
//        belongs to the caller.
krista@2461
   778
//        also, current implementation does NOT check to see if this userid
krista@2461
   779
//        IS a default.
krista@2461
   780
krista@2461
   781
DYNAMIC_API PEP_STATUS get_userid_alias_default(
krista@2461
   782
        PEP_SESSION session, 
krista@2461
   783
        const char* alias_id,
krista@2461
   784
        char** default_id);
krista@2461
   785
krista@2461
   786
// set_userid_alias() - set an alias to correspond to a default id
krista@2461
   787
//    parameters:
krista@2461
   788
//        session (in)        session handle
krista@2461
   789
//        default_id (in)     the default id for this alias. This must
krista@2461
   790
//                            correspond to the default user_id for an
krista@2461
   791
//                            entry in the person (user) table.
krista@2461
   792
//        alias_id (in)       the alias to be set for this default id
krista@2461
   793
//    return value:
krista@2461
   794
//        PEP_STATUS_OK = 0             userid was found
krista@2461
   795
//        PEP_CANNOT_SET_ALIAS          there was an error setting this
krista@2461
   796
krista@2461
   797
DYNAMIC_API PEP_STATUS set_userid_alias (
krista@2461
   798
        PEP_SESSION session, 
krista@2461
   799
        const char* default_id,
krista@2461
   800
        const char* alias_id);
krista@2461
   801
vb@932
   802
// set_identity_flags() - update identity flags on existing identity
vb@932
   803
//
vb@932
   804
//    parameters:
vb@932
   805
//        session (in)        session handle
vb@934
   806
//        identity (in,out)   pointer to pEp_identity structure
vb@934
   807
//        flags (in)          new value for flags
vb@932
   808
//
vb@932
   809
//    return value:
vb@932
   810
//        PEP_STATUS_OK = 0             encryption and signing succeeded
vb@932
   811
//        PEP_CANNOT_SET_IDENTITY       update of identity failed
vb@932
   812
//
vb@932
   813
//    caveat:
vb@934
   814
//        address and user_id must be given in identity
vb@932
   815
vb@932
   816
DYNAMIC_API PEP_STATUS set_identity_flags(
vb@934
   817
        PEP_SESSION session,
vb@934
   818
        pEp_identity *identity,
vb@1425
   819
        identity_flags_t flags
vb@932
   820
    );
vb@932
   821
edouard@1406
   822
// unset_identity_flags() - update identity flags on existing identity
edouard@1406
   823
//
edouard@1406
   824
//    parameters:
edouard@1406
   825
//        session (in)        session handle
edouard@1406
   826
//        identity (in,out)   pointer to pEp_identity structure
edouard@1406
   827
//        flags (in)          new value for flags
edouard@1406
   828
//
edouard@1406
   829
//    return value:
edouard@1406
   830
//        PEP_STATUS_OK = 0             encryption and signing succeeded
edouard@1406
   831
//        PEP_CANNOT_SET_IDENTITY       update of identity failed
edouard@1406
   832
//
edouard@1406
   833
//    caveat:
edouard@1406
   834
//        address and user_id must be given in identity
edouard@1406
   835
edouard@1406
   836
DYNAMIC_API PEP_STATUS unset_identity_flags(
edouard@1406
   837
        PEP_SESSION session,
edouard@1406
   838
        pEp_identity *identity,
vb@1425
   839
        identity_flags_t flags
edouard@1406
   840
    );
vb@932
   841
krista@2593
   842
// mark_as_compromised() - mark key in trust db as compromised
vb@357
   843
//
roker@529
   844
//    parameters:
roker@529
   845
//        session (in)        session handle
roker@529
   846
//        fpr (in)            fingerprint of key to mark
vb@357
   847
krista@2593
   848
DYNAMIC_API PEP_STATUS mark_as_compromised(
krista@2593
   849
        PEP_SESSION session,
krista@2593
   850
        const char *fpr
krista@2593
   851
    );
krista@2593
   852
krista@2593
   853
krista@2593
   854
// mark_as_compromized() - deprecated to fix misspelling. Please move to
krista@2593
   855
//                         mark_as_compromised();
krista@2593
   856
vb@357
   857
DYNAMIC_API PEP_STATUS mark_as_compromized(
vb@357
   858
        PEP_SESSION session,
vb@357
   859
        const char *fpr
vb@357
   860
    );
vb@357
   861
vb@357
   862
vb@0
   863
// generate_keypair() - generate a new key pair and add it to the key ring
vb@0
   864
//
vb@0
   865
//  parameters:
vb@0
   866
//      session (in)            session handle
roker@529
   867
//        identity (inout)      pointer to pEp_identity structure
vb@0
   868
//
roker@529
   869
//    return value:
roker@529
   870
//        PEP_STATUS_OK = 0       encryption and signing succeeded
roker@529
   871
//        PEP_ILLEGAL_VALUE       illegal values for identity fields given
roker@529
   872
//        PEP_CANNOT_CREATE_KEY   key engine is on strike
vb@0
   873
//
vb@0
   874
//  caveat:
vb@0
   875
//      address and username fields must be set to UTF-8 strings
vb@0
   876
//      the fpr field must be set to NULL
vb@0
   877
//
vb@0
   878
//      this function allocates a string and sets set fpr field of identity
vb@0
   879
//      the caller is responsible to call free() for that string or use
vb@0
   880
//      free_identity() on the struct
vb@0
   881
vb@0
   882
DYNAMIC_API PEP_STATUS generate_keypair(
vb@0
   883
        PEP_SESSION session, pEp_identity *identity
vb@0
   884
    );
vb@0
   885
vb@0
   886
vb@0
   887
// delete_keypair() - delete a public key or a key pair from the key ring
vb@0
   888
//
vb@0
   889
//  parameters:
vb@0
   890
//      session (in)            session handle
vb@0
   891
//      fpr (in)                C string with key id or fingerprint of the
vb@0
   892
//                              public key
vb@0
   893
//
vb@0
   894
//  return value:
vb@0
   895
//      PEP_STATUS_OK = 0       key was successfully deleted
vb@0
   896
//      PEP_KEY_NOT_FOUND       key not found
vb@0
   897
//      PEP_ILLEGAL_VALUE       not a valid key id or fingerprint
vb@0
   898
//      PEP_KEY_HAS_AMBIG_NAME  fpr does not uniquely identify a key
vb@0
   899
//      PEP_OUT_OF_MEMORY       out of memory
vb@0
   900
vb@0
   901
DYNAMIC_API PEP_STATUS delete_keypair(PEP_SESSION session, const char *fpr);
vb@0
   902
vb@0
   903
vb@0
   904
// import_key() - import key from data
vb@0
   905
//
vb@0
   906
//  parameters:
vb@0
   907
//      session (in)            session handle
vb@0
   908
//      key_data (in)           key data, i.e. ASCII armored OpenPGP key
vb@0
   909
//      size (in)               amount of data to handle
Edouard@772
   910
//      private_keys (out)      list of private keys that have been imported
vb@0
   911
//
vb@0
   912
//  return value:
vb@0
   913
//      PEP_STATUS_OK = 0       key was successfully imported
vb@0
   914
//      PEP_OUT_OF_MEMORY       out of memory
vb@0
   915
//      PEP_ILLEGAL_VALUE       there is no key data to import
Edouard@772
   916
//
Edouard@772
   917
//  caveat:
Edouard@772
   918
//      private_keys goes to the ownership of the caller
Edouard@772
   919
//      private_keys can be left NULL, it is then ignored
vb@0
   920
Edouard@728
   921
DYNAMIC_API PEP_STATUS import_key(
Edouard@728
   922
        PEP_SESSION session,
Edouard@728
   923
        const char *key_data,
Edouard@728
   924
        size_t size,
Edouard@728
   925
        identity_list **private_keys
Edouard@728
   926
    );
vb@0
   927
vb@0
   928
vb@0
   929
// export_key() - export ascii armored key
vb@0
   930
//
vb@0
   931
//  parameters:
vb@0
   932
//      session (in)            session handle
vb@0
   933
//      fpr (in)                key id or fingerprint of key
vb@0
   934
//      key_data (out)          ASCII armored OpenPGP key
roker@529
   935
//      size (out)              amount of data to handle
vb@0
   936
//
vb@0
   937
//  return value:
vb@0
   938
//      PEP_STATUS_OK = 0       key was successfully exported
vb@0
   939
//      PEP_OUT_OF_MEMORY       out of memory
vb@0
   940
//      PEP_KEY_NOT_FOUND       key not found
vb@0
   941
//
vb@0
   942
//  caveat:
vb@0
   943
//      the key_data goes to the ownership of the caller
vb@0
   944
//      the caller is responsible to free() it (on Windoze use pEp_free())
vb@0
   945
vb@0
   946
DYNAMIC_API PEP_STATUS export_key(
vb@0
   947
        PEP_SESSION session, const char *fpr, char **key_data, size_t *size
vb@0
   948
    );
vb@0
   949
vb@0
   950
vb@1103
   951
// export_secret_key() - export secret key ascii armored
vb@1103
   952
//
vb@1103
   953
//  parameters:
vb@1103
   954
//      session (in)            session handle
vb@1103
   955
//      fpr (in)                fingerprint of key, at least 16 hex digits
vb@1103
   956
//      key_data (out)          ASCII armored OpenPGP secret key
vb@1103
   957
//      size (out)              amount of data to handle
vb@1103
   958
//
vb@1103
   959
//  return value:
vb@1103
   960
//      PEP_STATUS_OK = 0       key was successfully exported
vb@1103
   961
//      PEP_OUT_OF_MEMORY       out of memory
vb@1103
   962
//      PEP_KEY_NOT_FOUND       key not found
vb@1103
   963
//      PEP_CANNOT_EXPORT_KEY   cannot export secret key (i.e. it's on an HKS)
vb@1103
   964
//
vb@1103
   965
//  caveat:
vb@1103
   966
//      the key_data goes to the ownership of the caller
vb@1103
   967
//      the caller is responsible to free() it (on Windoze use pEp_free())
vb@1103
   968
//      beware of leaking secret key data - overwrite it in memory after use
vb@1103
   969
krista@2593
   970
DYNAMIC_API PEP_STATUS export_secret_key(
krista@2593
   971
        PEP_SESSION session, const char *fpr, char **key_data, size_t *size
krista@2593
   972
    );
krista@2593
   973
krista@2593
   974
krista@2593
   975
// export_secrect_key() - deprecated misspelled function. Please replace with
krista@2593
   976
//                        export_secret_key
krista@2593
   977
vb@1103
   978
DYNAMIC_API PEP_STATUS export_secrect_key(
vb@1103
   979
        PEP_SESSION session, const char *fpr, char **key_data, size_t *size
vb@1103
   980
    );
vb@1103
   981
vb@1103
   982
vb@0
   983
// recv_key() - update key(s) from keyserver
vb@0
   984
//
vb@0
   985
//  parameters:
vb@0
   986
//      session (in)            session handle
vb@0
   987
//      pattern (in)            key id, user id or address to search for as
vb@0
   988
//                              UTF-8 string
vb@0
   989
vb@0
   990
DYNAMIC_API PEP_STATUS recv_key(PEP_SESSION session, const char *pattern);
vb@0
   991
vb@0
   992
vb@0
   993
// find_keys() - find keys in keyring
vb@0
   994
//
vb@0
   995
//  parameters:
vb@0
   996
//      session (in)            session handle
vb@0
   997
//      pattern (in)            key id, user id or address to search for as
vb@0
   998
//                              UTF-8 string
vb@0
   999
//      keylist (out)           list of fingerprints found or NULL on error
vb@0
  1000
//
vb@0
  1001
//  caveat:
roker@529
  1002
//        the ownerships of keylist isgoing to the caller
roker@529
  1003
//        the caller must use free_stringlist() to free it
vb@0
  1004
vb@0
  1005
vb@0
  1006
DYNAMIC_API PEP_STATUS find_keys(
vb@0
  1007
        PEP_SESSION session, const char *pattern, stringlist_t **keylist
vb@0
  1008
    );
vb@0
  1009
vb@0
  1010
// send_key() - send key(s) to keyserver
vb@0
  1011
//
vb@0
  1012
//  parameters:
vb@0
  1013
//      session (in)            session handle
vb@0
  1014
//      pattern (in)            key id, user id or address to search for as
vb@0
  1015
//                              UTF-8 string
vb@0
  1016
vb@0
  1017
DYNAMIC_API PEP_STATUS send_key(PEP_SESSION session, const char *pattern);
vb@0
  1018
vb@0
  1019
vb@0
  1020
// pEp_free() - free memory allocated by pEp engine
vb@0
  1021
//
vb@0
  1022
//  parameters:
vb@0
  1023
//      p (in)                  pointer to free
vb@0
  1024
//
vb@0
  1025
//  The reason for this function is that heap management can be a pretty
vb@0
  1026
//  complex task with Windoze. This free() version calls the free()
vb@0
  1027
//  implementation of the C runtime library which was used to build pEp engine,
vb@0
  1028
//  so you're using the correct heap. For more information, see:
vb@0
  1029
//  <http://msdn.microsoft.com/en-us/library/windows/desktop/aa366711(v=vs.85).aspx>
vb@0
  1030
vb@0
  1031
DYNAMIC_API void pEp_free(void *p);
vb@0
  1032
vb@8
  1033
vb@8
  1034
// get_trust() - get the trust level a key has for a person
vb@8
  1035
//
vb@8
  1036
//  parameters:
vb@8
  1037
//      session (in)            session handle
vb@8
  1038
//      identity (inout)        user_id and fpr to check as UTF-8 strings (in)
krista@2461
  1039
//                              comm_type as result (out)
vb@8
  1040
//
vb@14
  1041
//  this function modifies the given identity struct; the struct remains in
vb@251
  1042
//  the ownership of the caller
vb@14
  1043
//  if the trust level cannot be determined identity->comm_type is set
vb@14
  1044
//  to PEP_ct_unknown
vb@8
  1045
vb@8
  1046
DYNAMIC_API PEP_STATUS get_trust(PEP_SESSION session, pEp_identity *identity);
vb@8
  1047
krista@2129
  1048
krista@1797
  1049
PEP_STATUS set_trust(PEP_SESSION session, 
krista@2480
  1050
                     pEp_identity* identity);
krista@1805
  1051
                            
krista@1805
  1052
PEP_STATUS update_trust_for_fpr(PEP_SESSION session, 
krista@1805
  1053
                                const char* fpr, 
krista@1805
  1054
                                PEP_comm_type comm_type);
vb@8
  1055
vb@251
  1056
// least_trust() - get the least known trust level for a key in the database
vb@251
  1057
//
vb@251
  1058
//  parameters:
vb@251
  1059
//      session (in)            session handle
vb@251
  1060
//      fpr (in)                fingerprint of key to check
vb@251
  1061
//      comm_type (out)         least comm_type as result (out)
vb@251
  1062
//
vb@251
  1063
//  if the trust level cannot be determined comm_type is set to PEP_ct_unknown
vb@251
  1064
vb@251
  1065
DYNAMIC_API PEP_STATUS least_trust(
vb@251
  1066
        PEP_SESSION session,
vb@251
  1067
        const char *fpr,
vb@251
  1068
        PEP_comm_type *comm_type
vb@251
  1069
    );
vb@251
  1070
vb@251
  1071
vb@9
  1072
// get_key_rating() - get the rating a bare key has
vb@9
  1073
//
vb@9
  1074
//  parameters:
vb@9
  1075
//      session (in)            session handle
vb@9
  1076
//      fpr (in)                unique identifyer for key as UTF-8 string
vb@9
  1077
//      comm_type (out)         key rating
vb@10
  1078
//
vb@14
  1079
//  if an error occurs, *comm_type is set to PEP_ct_unknown and an error
vb@10
  1080
//  is returned
vb@9
  1081
vb@9
  1082
DYNAMIC_API PEP_STATUS get_key_rating(
vb@14
  1083
        PEP_SESSION session,
vb@14
  1084
        const char *fpr,
vb@14
  1085
        PEP_comm_type *comm_type
vb@9
  1086
    );
vb@9
  1087
vb@9
  1088
vb@198
  1089
// renew_key() - renew an expired key
vb@196
  1090
//
vb@196
  1091
//  parameters:
vb@196
  1092
//      session (in)            session handle
vb@214
  1093
//      fpr (in)                ID of key to renew as UTF-8 string
vb@201
  1094
//      ts (in)                 timestamp when key should expire or NULL for
vb@201
  1095
//                              default
vb@196
  1096
vb@201
  1097
DYNAMIC_API PEP_STATUS renew_key(
vb@201
  1098
        PEP_SESSION session,
vb@201
  1099
        const char *fpr,
vb@201
  1100
        const timestamp *ts
vb@201
  1101
    );
vb@196
  1102
vb@196
  1103
vb@224
  1104
// revoke_key() - revoke a key
vb@197
  1105
//
vb@197
  1106
//  parameters:
vb@197
  1107
//      session (in)            session handle
vb@214
  1108
//      fpr (in)                ID of key to revoke as UTF-8 string
vb@211
  1109
//      reason (in)             text with reason for revoke as UTF-8 string
vb@211
  1110
//                              or NULL if reason unknown
vb@211
  1111
//
vb@211
  1112
//  caveat:
vb@211
  1113
//      reason text must not include empty lines
vb@224
  1114
//      this function is meant for internal use only; better use
krista@1213
  1115
//      key_mistrusted() of keymanagement API
vb@197
  1116
vb@211
  1117
DYNAMIC_API PEP_STATUS revoke_key(
vb@211
  1118
        PEP_SESSION session,
vb@211
  1119
        const char *fpr,
vb@211
  1120
        const char *reason
vb@211
  1121
    );
vb@197
  1122
vb@197
  1123
vb@214
  1124
// key_expired() - flags if a key is already expired
vb@214
  1125
//
vb@214
  1126
//  parameters:
vb@214
  1127
//      session (in)            session handle
vb@214
  1128
//      fpr (in)                ID of key to check as UTF-8 string
Edouard@701
  1129
//      when (in)               UTC time of when should expiry be considered
vb@214
  1130
//      expired (out)           flag if key expired
vb@214
  1131
vb@214
  1132
DYNAMIC_API PEP_STATUS key_expired(
vb@214
  1133
        PEP_SESSION session,
vb@214
  1134
        const char *fpr,
Edouard@701
  1135
        const time_t when,
vb@214
  1136
        bool *expired
vb@214
  1137
    );
vb@214
  1138
Edouard@694
  1139
    
Edouard@694
  1140
// key_revoked() - flags if a key is already revoked
Edouard@694
  1141
//
Edouard@694
  1142
//  parameters:
Edouard@694
  1143
//      session (in)            session handle
Edouard@694
  1144
//      fpr (in)                ID of key to check as UTF-8 string
Edouard@694
  1145
//      revoked (out)           flag if key revoked
Edouard@694
  1146
Edouard@694
  1147
DYNAMIC_API PEP_STATUS key_revoked(
Edouard@694
  1148
        PEP_SESSION session,
Edouard@694
  1149
        const char *fpr,
Edouard@694
  1150
        bool *revoked
Edouard@694
  1151
    );
Edouard@694
  1152
krista@1797
  1153
PEP_STATUS get_key_userids(
krista@1797
  1154
        PEP_SESSION session,
krista@1797
  1155
        const char* fpr,
krista@1797
  1156
        stringlist_t** keylist
krista@1797
  1157
    );
krista@1797
  1158
vb@214
  1159
vb@450
  1160
// get_crashdump_log() - get the last log messages out
vb@450
  1161
//
vb@450
  1162
//  parameters:
vb@450
  1163
//      session (in)            session handle
vb@450
  1164
//      maxlines (in)           maximum number of lines (0 for default)
vb@458
  1165
//      logdata (out)           logdata as string in double quoted CSV format
vb@463
  1166
//                              column1 is title
vb@463
  1167
//                              column2 is entity
vb@463
  1168
//                              column3 is description
vb@463
  1169
//                              column4 is comment
vb@462
  1170
//
vb@462
  1171
//  caveat:
vb@462
  1172
//      the ownership of logdata goes to the caller
vb@450
  1173
vb@450
  1174
DYNAMIC_API PEP_STATUS get_crashdump_log(
vb@450
  1175
        PEP_SESSION session,
vb@450
  1176
        int maxlines,
vb@450
  1177
        char **logdata
vb@450
  1178
    );
vb@450
  1179
vb@450
  1180
dirk@501
  1181
// get_languagelist() - get the list of languages
vb@458
  1182
//
vb@458
  1183
//  parameters:
vb@458
  1184
//      session (in)            session handle
vb@458
  1185
//      languages (out)         languages as string in double quoted CSV format
vb@463
  1186
//                              column 1 is the ISO 639-1 language code
vb@463
  1187
//                              column 2 is the name of the language
vb@462
  1188
//
vb@462
  1189
//  caveat:
vb@462
  1190
//      the ownership of languages goes to the caller
vb@458
  1191
vb@458
  1192
DYNAMIC_API PEP_STATUS get_languagelist(
vb@458
  1193
        PEP_SESSION session,
vb@458
  1194
        char **languages
vb@458
  1195
    );
vb@458
  1196
vb@458
  1197
vb@458
  1198
// get_phrase() - get phrase in a dedicated language through i18n
vb@458
  1199
//
vb@458
  1200
//  parameters:
vb@458
  1201
//      session (in)            session handle
roker@529
  1202
//      lang (in)               C string with ISO 639-1 language code
vb@458
  1203
//      phrase_id (in)          id of phrase in i18n
vb@458
  1204
//      phrase (out)            phrase as UTF-8 string
vb@462
  1205
//
vb@462
  1206
//  caveat:
vb@462
  1207
//      the ownership of phrase goes to the caller
vb@458
  1208
vb@458
  1209
DYNAMIC_API PEP_STATUS get_phrase(
vb@458
  1210
        PEP_SESSION session,
vb@458
  1211
        const char *lang,
vb@458
  1212
        int phrase_id,
vb@458
  1213
        char **phrase
vb@458
  1214
    );
vb@458
  1215
vb@458
  1216
vb@632
  1217
// sequence_value() - raise the value of a named sequence and retrieve it
vb@632
  1218
//
vb@632
  1219
//  parameters:
vb@632
  1220
//      session (in)            session handle
vb@2848
  1221
//      name (in)               name of sequence
vb@2848
  1222
//      value (out)             value of sequence
vb@1085
  1223
//
vb@1085
  1224
//  returns:
vb@1086
  1225
//      PEP_STATUS_OK                   no error, not own sequence
vb@1086
  1226
//      PEP_SEQUENCE_VIOLATED           if sequence violated
vb@1086
  1227
//      PEP_CANNOT_INCREASE_SEQUENCE    if sequence cannot be increased
vb@1086
  1228
//      PEP_OWN_SEQUENCE                if own sequence
vb@632
  1229
vb@632
  1230
DYNAMIC_API PEP_STATUS sequence_value(
vb@632
  1231
        PEP_SESSION session,
vb@2848
  1232
        const char *name,
vb@652
  1233
        int32_t *value
vb@632
  1234
    );
vb@632
  1235
vb@1044
  1236
Edouard@694
  1237
// set_revoked() - records relation between a revoked key and its replacement
Edouard@694
  1238
//
Edouard@694
  1239
//  parameters:
Edouard@694
  1240
//      session (in)            session handle
Edouard@694
  1241
//      revoked_fpr (in)        revoked fingerprint
Edouard@694
  1242
//      replacement_fpr (in)    replacement key fingerprint
Edouard@694
  1243
//      revocation_date (in)    revocation date
Edouard@694
  1244
Edouard@693
  1245
DYNAMIC_API PEP_STATUS set_revoked(
Edouard@693
  1246
       PEP_SESSION session,
Edouard@693
  1247
       const char *revoked_fpr,
Edouard@693
  1248
       const char *replacement_fpr,
Edouard@693
  1249
       const uint64_t revocation_date
Edouard@693
  1250
    );
Edouard@693
  1251
vb@958
  1252
Edouard@694
  1253
// get_revoked() - find revoked key that may have been replaced by given key, if any
Edouard@694
  1254
//
Edouard@694
  1255
//  parameters:
Edouard@694
  1256
//      session (in)            session handle
Edouard@694
  1257
//      fpr (in)                given fingerprint
Edouard@694
  1258
//      revoked_fpr (out)       revoked fingerprint
Edouard@694
  1259
//      revocation_date (out)   revocation date
Edouard@694
  1260
    
Edouard@693
  1261
DYNAMIC_API PEP_STATUS get_revoked(
Edouard@693
  1262
        PEP_SESSION session,
Edouard@693
  1263
        const char *fpr,
Edouard@693
  1264
        char **revoked_fpr,
Edouard@693
  1265
        uint64_t *revocation_date
Edouard@693
  1266
    );
Edouard@693
  1267
vb@958
  1268
// key_created() - get creation date of a key
vb@958
  1269
//
vb@958
  1270
//  parameters:
vb@958
  1271
//      session (in)            session handle
vb@958
  1272
//      fpr (in)                fingerprint of key
vb@958
  1273
//      created (out)           date of creation
vb@958
  1274
vb@958
  1275
PEP_STATUS key_created(
vb@958
  1276
        PEP_SESSION session,
vb@958
  1277
        const char *fpr,
vb@958
  1278
        time_t *created
vb@958
  1279
    );
vb@958
  1280
vb@958
  1281
krista@1377
  1282
// find_private_keys() - find keys in keyring
krista@1357
  1283
//
krista@1357
  1284
//  parameters:
krista@1357
  1285
//      session (in)            session handle
krista@1357
  1286
//      pattern (in)            key id, user id or address to search for as
krista@1357
  1287
//                              UTF-8 string
krista@1357
  1288
//      keylist (out)           list of fingerprints found or NULL on error
krista@1357
  1289
//
krista@1357
  1290
//  caveat:
krista@1357
  1291
//        the ownerships of keylist isgoing to the caller
krista@1357
  1292
//        the caller must use free_stringlist() to free it
krista@1357
  1293
PEP_STATUS find_private_keys(PEP_SESSION session, const char* pattern,
krista@1357
  1294
                             stringlist_t **keylist);
krista@1357
  1295
krista@1011
  1296
// get_engine_version() - returns the current version of pEpEngine (this is different
krista@1011
  1297
//                        from the pEp protocol version!)
krista@1011
  1298
//
krista@1011
  1299
//  parameters: none
krista@1011
  1300
//
krista@1011
  1301
//  return_value: const char* to the engine version string constant
krista@1011
  1302
//
krista@1011
  1303
DYNAMIC_API const char* get_engine_version();
krista@1011
  1304
vb@2833
  1305
// is_pEp_user() - returns true if the USER corresponding to this identity 
krista@2490
  1306
//                 has been listed in the *person* table as a pEp user. 
krista@2490
  1307
//
krista@2490
  1308
//  parameters:
krista@2490
  1309
//      identity (in) - identity containing the user_id to check (this is
krista@2490
  1310
//                      the only part of the struct we require to be set)
vb@2834
  1311
//      is_pEp (out)  - boolean pointer - will return true or false by
krista@2490
  1312
//                      reference with respect to whether or not user is
vb@2834
  1313
//                      a known pEp user
krista@2490
  1314
//
krista@2490
  1315
//  return_value: PEP_STATUS_OK if user found in person table
krista@2490
  1316
//                PEP_ILLEGAL_VALUE if no user_id in input
krista@2490
  1317
//                PEP_CANNOT_FIND_PERSON if user_id doesn't exist
krista@2490
  1318
//
krista@2490
  1319
//  caveat: This *does not check comm_type*
krista@2490
  1320
//                         
vb@2833
  1321
DYNAMIC_API PEP_STATUS is_pEp_user(PEP_SESSION session, 
krista@2490
  1322
                                   pEp_identity *identity, 
vb@2834
  1323
                                   bool* is_pEp);
krista@2490
  1324
krista@2490
  1325
krista@1307
  1326
vb@2833
  1327
DYNAMIC_API PEP_STATUS reset_pEptest_hack(PEP_SESSION session);
vb@482
  1328
krista@2461
  1329
// This is used internally when there is a temporary identity to be retrieved
krista@2461
  1330
// that may not yet have an FPR attached. See get_identity() for functionality,
krista@2461
  1331
// params and caveats.
krista@2461
  1332
PEP_STATUS get_identity_without_trust_check(
krista@2461
  1333
        PEP_SESSION session,
krista@2461
  1334
        const char *address,
krista@2461
  1335
        const char *user_id,
krista@2461
  1336
        pEp_identity **identity
krista@2461
  1337
    );
krista@2461
  1338
    
krista@2461
  1339
PEP_STATUS get_identities_by_address(
krista@2461
  1340
        PEP_SESSION session,
krista@2461
  1341
        const char *address,
krista@2461
  1342
        identity_list** id_list
krista@2461
  1343
    );
krista@2893
  1344
    
krista@2893
  1345
PEP_STATUS get_identities_by_userid(
krista@2893
  1346
        PEP_SESSION session,
krista@2893
  1347
        const char *user_id,
krista@2893
  1348
        identity_list **identities
krista@2893
  1349
    );    
krista@2461
  1350
        
krista@3349
  1351
PEP_STATUS is_own_address(PEP_SESSION session, 
krista@3349
  1352
                          const char* address, 
krista@3349
  1353
                          bool* is_own_addr);
krista@3349
  1354
krista@2461
  1355
PEP_STATUS replace_userid(PEP_SESSION session, const char* old_uid,
krista@2461
  1356
                              const char* new_uid);
krista@2461
  1357
                              
krista@2948
  1358
PEP_STATUS remove_key(PEP_SESSION session, const char* fpr);
krista@2948
  1359
                              
krista@2461
  1360
PEP_STATUS remove_fpr_as_default(PEP_SESSION session, 
krista@2461
  1361
                                    const char* fpr);
krista@2461
  1362
                              
krista@2461
  1363
                                    
krista@2461
  1364
PEP_STATUS get_main_user_fpr(PEP_SESSION session, 
krista@2461
  1365
                             const char* user_id,
krista@2461
  1366
                             char** main_fpr);
krista@2461
  1367
krista@2461
  1368
PEP_STATUS replace_main_user_fpr(PEP_SESSION session, const char* user_id,
krista@2461
  1369
                              const char* new_fpr);
krista@2461
  1370
    
krista@2817
  1371
DYNAMIC_API PEP_STATUS get_replacement_fpr(
krista@2817
  1372
        PEP_SESSION session,
krista@2817
  1373
        const char *fpr,
krista@2817
  1374
        char **revoked_fpr,
krista@2817
  1375
        uint64_t *revocation_date
krista@2817
  1376
    );
krista@2817
  1377
    
krista@2461
  1378
PEP_STATUS refresh_userid_default_key(PEP_SESSION session, const char* user_id);
krista@2461
  1379
krista@2468
  1380
// This ONLY sets the *user* flag, and creates a shell identity if necessary.
krista@2956
  1381
DYNAMIC_API PEP_STATUS set_as_pEp_user(PEP_SESSION session, pEp_identity* user);
krista@2468
  1382
krista@2480
  1383
// returns true (by reference) if a person with this user_id exists; 
krista@2480
  1384
// Also replaces aliased user_ids by defaults in identity.
krista@2480
  1385
PEP_STATUS exists_person(PEP_SESSION session, pEp_identity* identity, bool* exists);
krista@2468
  1386
krista@2477
  1387
PEP_STATUS set_pgp_keypair(PEP_SESSION session, const char* fpr);
krista@2468
  1388
krista@2995
  1389
// exposed for testing
krista@2995
  1390
PEP_STATUS set_person(PEP_SESSION session, pEp_identity* identity,
krista@2995
  1391
                      bool guard_transaction);
krista@2919
  1392
PEP_STATUS bind_own_ident_with_contact_ident(PEP_SESSION session,
krista@2919
  1393
                                             pEp_identity* own_ident, 
krista@2919
  1394
                                             pEp_identity* contact_ident);
krista@2995
  1395
krista@2817
  1396
PEP_STATUS get_last_contacted(
krista@2817
  1397
        PEP_SESSION session,
krista@2817
  1398
        identity_list** id_list
krista@2817
  1399
    );
krista@2817
  1400
krista@2817
  1401
PEP_STATUS get_own_ident_for_contact_id(PEP_SESSION session,
krista@2817
  1402
                                          const pEp_identity* contact,
krista@2817
  1403
                                          pEp_identity** own_ident);
krista@2817
  1404
krista@2817
  1405
PEP_STATUS exists_trust_entry(PEP_SESSION session, pEp_identity* identity,
krista@2817
  1406
                              bool* exists);
krista@2817
  1407
krista@2817
  1408
PEP_STATUS is_own_key(PEP_SESSION session, const char* fpr, bool* own_key);
krista@2817
  1409
krista@2893
  1410
PEP_STATUS get_identities_by_main_key_id(
krista@2893
  1411
        PEP_SESSION session,
krista@2893
  1412
        const char *fpr,
krista@2893
  1413
        identity_list **identities);
krista@3139
  1414
        
krista@3139
  1415
PEP_STATUS sign_only(PEP_SESSION session, 
krista@3139
  1416
                     const char *data, 
krista@3139
  1417
                     size_t data_size, 
krista@3139
  1418
                     const char *fpr, 
krista@3139
  1419
                     char **sign, 
krista@3139
  1420
                     size_t *sign_size);
vb@3375
  1421
vb@0
  1422
#ifdef __cplusplus
vb@0
  1423
}
vb@0
  1424
#endif