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