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