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