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