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