src/pEpEngine.h
author Volker Birk <vb@pep-project.org>
Sun, 21 Feb 2016 22:37:59 +0100
changeset 458 72b4da3d4e2d
parent 451 495e53a4b441
child 462 4e73adab046a
permissions -rw-r--r--
adding some i18n support
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"
vb@201
    13
#include "timestamp.h"
vb@0
    14
vb@94
    15
#define PEP_VERSION "1.0"
vb@94
    16
vb@0
    17
// pEp Engine API
vb@0
    18
vb@0
    19
//  caveat:
vb@0
    20
//      Unicode data has to be normalized to NFC before calling
vb@0
    21
//      UTF-8 strings are UTF-8 encoded C strings (zero terminated)
vb@0
    22
vb@0
    23
vb@46
    24
struct _pEpSession;
vb@46
    25
typedef struct _pEpSession * PEP_SESSION;
vb@0
    26
vb@0
    27
typedef enum {
vb@0
    28
	PEP_STATUS_OK									= 0,
vb@0
    29
vb@0
    30
	PEP_INIT_CANNOT_LOAD_GPGME						= 0x0110,
vb@0
    31
	PEP_INIT_GPGME_INIT_FAILED						= 0x0111,
Edouard@175
    32
	PEP_INIT_NO_GPG_HOME							= 0x0112,
Edouard@175
    33
	PEP_INIT_NETPGP_INIT_FAILED						= 0x0113,
vb@0
    34
vb@0
    35
	PEP_INIT_SQLITE3_WITHOUT_MUTEX					= 0x0120,
vb@0
    36
	PEP_INIT_CANNOT_OPEN_DB							= 0x0121,
vb@0
    37
	PEP_INIT_CANNOT_OPEN_SYSTEM_DB					= 0x0122,
vb@0
    38
	
vb@0
    39
	PEP_KEY_NOT_FOUND						        = 0x0201,
vb@0
    40
	PEP_KEY_HAS_AMBIG_NAME					        = 0x0202,
vb@0
    41
	PEP_GET_KEY_FAILED						        = 0x0203,
vb@0
    42
	
vb@0
    43
	PEP_CANNOT_FIND_IDENTITY						= 0x0301,
vb@0
    44
	PEP_CANNOT_SET_PERSON							= 0x0381,
vb@0
    45
	PEP_CANNOT_SET_PGP_KEYPAIR						= 0x0382,
vb@0
    46
	PEP_CANNOT_SET_IDENTITY							= 0x0383,
vb@370
    47
    PEP_CANNOT_SET_TRUST                            = 0x0384,
vb@0
    48
	
vb@0
    49
	PEP_UNENCRYPTED									= 0x0400,
vb@0
    50
	PEP_VERIFIED									= 0x0401,
vb@0
    51
	PEP_DECRYPTED									= 0x0402,
vb@0
    52
	PEP_DECRYPTED_AND_VERIFIED						= 0x0403,
vb@0
    53
	PEP_DECRYPT_WRONG_FORMAT						= 0x0404,
vb@0
    54
	PEP_DECRYPT_NO_KEY								= 0x0405,
vb@0
    55
	PEP_DECRYPT_SIGNATURE_DOES_NOT_MATCH			= 0x0406,
vb@0
    56
    PEP_VERIFY_NO_KEY                               = 0x0407,
vb@0
    57
    PEP_VERIFIED_AND_TRUSTED                        = 0x0408,
vb@0
    58
	PEP_CANNOT_DECRYPT_UNKNOWN						= 0x04ff,
vb@0
    59
vb@251
    60
	PEP_TRUSTWORD_NOT_FOUND							= 0x0501,
vb@0
    61
vb@0
    62
    PEP_CANNOT_CREATE_KEY                           = 0x0601,
vb@0
    63
    PEP_CANNOT_SEND_KEY                             = 0x0602,
vb@0
    64
vb@458
    65
    PEP_PHRASE_NOT_FOUND                            = 0x0701,
vb@458
    66
vb@0
    67
	PEP_COMMIT_FAILED								= 0xff01,
vb@0
    68
vb@44
    69
    PEP_CANNOT_CREATE_TEMP_FILE                     = -5,
vb@0
    70
    PEP_ILLEGAL_VALUE                               = -4,
vb@0
    71
    PEP_BUFFER_TOO_SMALL                            = -3,
vb@0
    72
	PEP_OUT_OF_MEMORY								= -2,
vb@0
    73
	PEP_UNKNOWN_ERROR								= -1
vb@0
    74
} PEP_STATUS;
vb@0
    75
vb@0
    76
vb@0
    77
// INIT_STATUS init() - initialize pEpEngine for a thread
vb@0
    78
//
vb@0
    79
//  parameters:
vb@0
    80
//		session (out)	init() allocates session memory and returns a pointer
vb@0
    81
//		                as a handle
vb@0
    82
//
vb@0
    83
//  return value:
vb@0
    84
//		PEP_STATUS_OK = 0					if init() succeeds
vb@0
    85
//		PEP_INIT_SQLITE3_WITHOUT_MUTEX		if SQLite3 was compiled with
vb@0
    86
//		                                    SQLITE_THREADSAFE 0
vb@0
    87
//		PEP_INIT_CANNOT_LOAD_GPGME			if libgpgme.dll cannot be found
vb@0
    88
//		PEP_INIT_GPGME_INIT_FAILED			if GPGME init fails
vb@0
    89
//		PEP_INIT_CANNOT_OPEN_DB				if user's management db cannot be
vb@0
    90
//		                                    opened
vb@0
    91
//		PEP_INIT_CANNOT_OPEN_SYSTEM_DB		if system's management db cannot be
vb@0
    92
//		                                    opened
vb@0
    93
//
vb@0
    94
//  caveat:
vb@0
    95
//      the pointer is valid only if the return value is PEP_STATUS_OK
vb@0
    96
//      in other case a NULL pointer will be returned; a valid handle must
vb@0
    97
//      be released using release() when it's no longer needed
vb@62
    98
//
vb@62
    99
//      the caller has to guarantee that the first call to this function
vb@62
   100
//      will succeed before further calls can be done
vb@0
   101
vb@0
   102
DYNAMIC_API PEP_STATUS init(PEP_SESSION *session);
vb@0
   103
vb@0
   104
vb@0
   105
// void release() - release thread session handle
vb@0
   106
//
vb@0
   107
//  parameters:
vb@0
   108
//		session (in)	session handle to release
vb@62
   109
//
vb@62
   110
//	caveat:
vb@62
   111
//	    the last release() can be called only when all other release() calls
vb@62
   112
//	    are done
vb@0
   113
vb@0
   114
DYNAMIC_API void release(PEP_SESSION session);
vb@0
   115
vb@0
   116
vb@0
   117
// decrypt_and_verify() - decrypt and/or verify a message
vb@0
   118
//
vb@0
   119
//	parameters:
vb@0
   120
//		session (in)	session handle
vb@0
   121
//		ctext (in)		cipher text to decrypt and/or verify
vb@0
   122
//		csize (in)		size of cipher text
vb@0
   123
//		ptext (out)		pointer to internal buffer with plain text
vb@0
   124
//		psize (out)		size of plain text
vb@15
   125
//		keylist (out)	list of key ids which where used to encrypt
vb@0
   126
//
vb@0
   127
//	return value:
vb@0
   128
//		PEP_UNENCRYPTED				message was unencrypted and not signed
vb@0
   129
//		PEP_VERIFIED				message was unencrypted, signature matches
vb@0
   130
//		PEP_DECRYPTED				message is decrypted now, no signature
vb@0
   131
//		PEP_DECRYPTED_AND_VERIFIED	message is decrypted now and verified
vb@0
   132
//		PEP_DECRYPT_WRONG_FORMAT	message has wrong format to handle
vb@0
   133
//		PEP_DECRYPT_NO_KEY			key not available to decrypt and/or verify
vb@0
   134
//		PEP_DECRYPT_SIGNATURE_DOES_NOT_MATCH	wrong signature
vb@0
   135
//
vb@0
   136
//	caveat:
vb@0
   137
//	    the ownerships of ptext as well as keylist are going to the caller
vb@0
   138
//	    the caller must use free() (or an Windoze pEp_free()) and
vb@0
   139
//	    free_stringlist() to free them
vb@15
   140
//
vb@15
   141
//      if this function failes an error message may be the first element of
vb@15
   142
//      keylist and the other elements may be the keys used for encryption
vb@0
   143
vb@0
   144
DYNAMIC_API PEP_STATUS decrypt_and_verify(
vb@0
   145
        PEP_SESSION session, const char *ctext, size_t csize,
vb@0
   146
        char **ptext, size_t *psize, stringlist_t **keylist
vb@0
   147
    );
vb@0
   148
vb@0
   149
vb@0
   150
// verify_text() - verfy plain text with a digital signature
vb@0
   151
//
vb@0
   152
//  parameters:
vb@0
   153
//      session (in)    session handle
vb@0
   154
//      text (in)       text to verify
vb@0
   155
//      size (in)       size of text
vb@0
   156
//      signature (in)  signature text
vb@0
   157
//      sig_size (in)   size of signature
vb@6
   158
//		keylist (out)	list of key ids which where used to encrypt or NULL on
vb@0
   159
//		                error
vb@0
   160
//
vb@0
   161
//  return value:
vb@0
   162
//		PEP_VERIFIED				message was unencrypted, signature matches
vb@0
   163
//		PEP_DECRYPT_NO_KEY			key not available to decrypt and/or verify
vb@0
   164
//		PEP_DECRYPT_SIGNATURE_DOES_NOT_MATCH	wrong signature
vb@0
   165
vb@0
   166
DYNAMIC_API PEP_STATUS verify_text(
vb@0
   167
        PEP_SESSION session, const char *text, size_t size,
vb@0
   168
        const char *signature, size_t sig_size, stringlist_t **keylist
vb@0
   169
    );
vb@0
   170
vb@0
   171
vb@0
   172
// encrypt_and_sign() - encrypt and sign a message
vb@0
   173
//
vb@0
   174
//	parameters:
vb@0
   175
//		session (in)	session handle
vb@6
   176
//		keylist (in)	list of key ids to encrypt with as C strings
vb@0
   177
//		ptext (in)		plain text to decrypt and/or verify
vb@0
   178
//		psize (in)		size of plain text
vb@0
   179
//		ctext (out)		pointer to internal buffer with cipher text
vb@0
   180
//		csize (out)		size of cipher text
vb@0
   181
//
vb@0
   182
//	return value:
vb@0
   183
//		PEP_STATUS_OK = 0				encryption and signing succeeded
vb@0
   184
//		PEP_KEY_NOT_FOUND	            at least one of the receipient keys
vb@0
   185
//		                                could not be found
vb@0
   186
//		PEP_KEY_HAS_AMBIG_NAME          at least one of the receipient keys has
vb@0
   187
//		                                an ambiguous name
vb@0
   188
//		PEP_GET_KEY_FAILED		        cannot retrieve key
vb@0
   189
//
vb@0
   190
//	caveat:
vb@0
   191
//	    the ownership of ctext is going to the caller
vb@0
   192
//      the caller is responsible to free() it (on Windoze use pEp_free())
vb@20
   193
//      the first key in keylist is being used to sign the message
vb@20
   194
//      this implies there has to be a private key for that keypair
vb@0
   195
vb@0
   196
DYNAMIC_API PEP_STATUS encrypt_and_sign(
vb@0
   197
        PEP_SESSION session, const stringlist_t *keylist, const char *ptext,
vb@0
   198
        size_t psize, char **ctext, size_t *csize
vb@0
   199
    );
vb@0
   200
vb@0
   201
vb@0
   202
// log_event() - log a user defined event defined by UTF-8 encoded strings into
vb@0
   203
// management log
vb@0
   204
//
vb@0
   205
//	parameters:
vb@0
   206
//		session (in)		session handle
vb@0
   207
//		title (in)			C string with event name
vb@0
   208
//		entity (in)			C string with name of entity which is logging
vb@0
   209
//		description (in)	C string with long description for event or NULL if
vb@0
   210
//		                    omitted
vb@0
   211
//		comment (in)		C string with user defined comment or NULL if
vb@0
   212
//		                    omitted
vb@0
   213
//
vb@0
   214
//	return value:
vb@0
   215
//	    PEP_STATUS_OK       log entry created
vb@0
   216
vb@0
   217
DYNAMIC_API PEP_STATUS log_event(
vb@450
   218
        PEP_SESSION session,
vb@451
   219
        const char *title,
vb@451
   220
        const char *entity,
vb@451
   221
        const char *description,
vb@451
   222
        const char *comment
vb@0
   223
    );
vb@0
   224
vb@0
   225
vb@233
   226
// trustword() - get the corresponding trustword for a 16 bit value
vb@0
   227
//
vb@0
   228
//	parameters:
vb@0
   229
//		session (in)		    session handle
vb@233
   230
//		value (in)			    value to find a trustword for
vb@367
   231
//		lang (in)			    C string with ISO 639-1 language code
vb@233
   232
//		word (out)			    pointer to C string with trustword UTF-8 encoded
vb@233
   233
//							    NULL if language is not supported or trustword
vb@0
   234
//							    wordlist is damaged or unavailable
vb@233
   235
//		wsize (out)			    length of trustword
vb@0
   236
//
vb@0
   237
//	return value:
vb@233
   238
//	    PEP_STATUS_OK           trustword retrieved
vb@251
   239
//	    PEP_TRUSTWORD_NOT_FOUND  trustword not found
vb@0
   240
//
vb@0
   241
//	caveat:
vb@0
   242
//		the word pointer goes to the ownership of the caller
vb@0
   243
//      the caller is responsible to free() it (on Windoze use pEp_free())
vb@0
   244
vb@233
   245
DYNAMIC_API PEP_STATUS trustword(
vb@0
   246
            PEP_SESSION session, uint16_t value, const char *lang,
vb@0
   247
            char **word, size_t *wsize
vb@0
   248
        );
vb@0
   249
vb@0
   250
vb@233
   251
// trustwords() - get trustwords for a string of hex values of a fingerprint
vb@0
   252
//
vb@0
   253
//	parameters:
vb@0
   254
//		session (in)		session handle
vb@233
   255
//		fingerprint (in)	C string with hex values to find trustwords for
vb@367
   256
//		lang (in)			C string with ISO 639-1 language code
vb@233
   257
//		words (out)			pointer to C string with trustwords UTF-8 encoded,
vb@0
   258
//		                    separated by a blank each
vb@233
   259
//							NULL if language is not supported or trustword
vb@0
   260
//							wordlist is damaged or unavailable
vb@233
   261
//		wsize (out)			length of trustwords string
vb@0
   262
//		max_words (in)		only generate a string with max_words;
vb@0
   263
//							if max_words == 0 there is no such limit
vb@0
   264
//
vb@0
   265
//	return value:
vb@233
   266
//	    PEP_STATUS_OK           trustwords retrieved
vb@0
   267
//      PEP_OUT_OF_MEMORY       out of memory
vb@251
   268
//	    PEP_TRUSTWORD_NOT_FOUND at least one trustword not found
vb@0
   269
//
vb@0
   270
//	caveat:
vb@0
   271
//		the word pointer goes to the ownership of the caller
vb@0
   272
//      the caller is responsible to free() it (on Windoze use pEp_free())
vb@0
   273
//
vb@0
   274
//  DON'T USE THIS FUNCTION FROM HIGH LEVEL LANGUAGES!
vb@0
   275
//
vb@233
   276
//  Better implement a simple one in the adapter yourself using trustword(), and
vb@233
   277
//  return a list of trustwords.
vb@0
   278
//  This function is provided for being used by C and C++ programs only.
vb@0
   279
vb@233
   280
DYNAMIC_API PEP_STATUS trustwords(
vb@0
   281
        PEP_SESSION session, const char *fingerprint, const char *lang,
vb@0
   282
        char **words, size_t *wsize, int max_words
vb@0
   283
    );
vb@0
   284
vb@0
   285
vb@0
   286
typedef enum _PEP_comm_type {
vb@9
   287
    PEP_ct_unknown = 0,
vb@0
   288
vb@9
   289
    // range 0x01 to 0x09: no encryption, 0x0a to 0x0e: nothing reasonable
vb@0
   290
vb@9
   291
    PEP_ct_no_encryption = 0x01,                // generic
vb@9
   292
    PEP_ct_no_encrypted_channel = 0x02,
vb@9
   293
    PEP_ct_key_not_found = 0x03,
vb@9
   294
    PEP_ct_key_expired = 0x04,
vb@9
   295
    PEP_ct_key_revoked = 0x05,
vb@9
   296
    PEP_ct_key_b0rken = 0x06,
vb@9
   297
    PEP_ct_my_key_not_included = 0x09,
vb@9
   298
vb@9
   299
    PEP_ct_security_by_obscurity = 0x0a,
vb@9
   300
    PEP_ct_b0rken_crypto = 0x0b,
Edouard@442
   301
    PEP_ct_key_too_short = 0x0c,
vb@9
   302
Edouard@442
   303
    PEP_ct_compromized = 0x0e,                  // known compromized connection
Edouard@442
   304
    PEP_ct_mistrusted = 0x0f,                   // known mistrusted key
vb@0
   305
vb@9
   306
    // range 0x10 to 0x3f: unconfirmed encryption
vb@0
   307
vb@0
   308
    PEP_ct_unconfirmed_encryption = 0x10,       // generic
vb@122
   309
    PEP_ct_OpenPGP_weak_unconfirmed = 0x11,	    // RSA 1024 is weak
vb@190
   310
vb@190
   311
    PEP_ct_to_be_checked = 0x20,                // generic
vb@190
   312
    PEP_ct_SMIME_unconfirmed = 0x21,
vb@190
   313
    PEP_ct_CMS_unconfirmed = 0x22,
vb@190
   314
vb@190
   315
    PEP_ct_strong_but_unconfirmed = 0x30,       // generic
vb@122
   316
    PEP_ct_OpenPGP_unconfirmed = 0x38,          // key at least 2048 bit RSA or EC
vb@122
   317
    PEP_ct_OTR_unconfirmed = 0x3a,
vb@0
   318
vb@9
   319
    // range 0x40 to 0x7f: unconfirmed encryption and anonymization
vb@0
   320
vb@0
   321
    PEP_ct_unconfirmed_enc_anon = 0x40,         // generic
vb@9
   322
    PEP_ct_PEP_unconfirmed = 0x7f,
vb@0
   323
vb@9
   324
    PEP_ct_confirmed = 0x80,                    // this bit decides if trust is confirmed
vb@9
   325
vb@9
   326
    // range 0x81 to 0x8f: reserved
vb@9
   327
    // range 0x90 to 0xbf: confirmed encryption
vb@0
   328
vb@0
   329
    PEP_ct_confirmed_encryption = 0x90,         // generic
vb@122
   330
	PEP_ct_OpenPGP_weak = 0x91,                 // RSA 1024 is weak
vb@190
   331
vb@190
   332
    PEP_ct_to_be_checked_confirmed = 0xa0,      //generic
vb@190
   333
    PEP_ct_SMIME = 0xa1,
vb@190
   334
    PEP_ct_CMS = 0xa2,
vb@190
   335
vb@190
   336
    PEP_ct_strong_encryption = 0xb0,            // generic
vb@122
   337
	PEP_ct_OpenPGP = 0xb8,                      // key at least 2048 bit RSA or EC
vb@122
   338
	PEP_ct_OTR = 0xba,
vb@0
   339
vb@0
   340
    // range 0xc0 to 0xff: confirmed encryption and anonymization
vb@0
   341
vb@0
   342
    PEP_ct_confirmed_enc_anon = 0xc0,           // generic
vb@0
   343
	PEP_ct_pEp = 0xff
vb@0
   344
} PEP_comm_type;
vb@0
   345
vb@0
   346
typedef struct _pEp_identity {
vb@0
   347
	size_t struct_size;			// size of whole struct
vb@0
   348
	char *address;		        // C string with address UTF-8 encoded
vb@0
   349
	size_t address_size;		// size of address
vb@0
   350
	char *fpr;			        // C string with fingerprint UTF-8 encoded
vb@0
   351
	size_t fpr_size;			// size of fingerprint
vb@0
   352
	char *user_id;		        // C string with user ID UTF-8 encoded
vb@0
   353
	size_t user_id_size;		// size of user ID
vb@0
   354
	char *username;		        // C string with user name UTF-8 encoded
vb@0
   355
	size_t username_size;		// size of user name
vb@0
   356
	PEP_comm_type comm_type;	// type of communication with this ID
vb@0
   357
    char lang[3];				// language of conversation
vb@0
   358
                                // ISO 639-1 ALPHA-2, last byte is 0
vb@0
   359
    bool me;                    // if this is the local user herself/himself
vb@0
   360
} pEp_identity;
vb@0
   361
vb@0
   362
vb@0
   363
// new_identity() - allocate memory and set the string and size fields
vb@0
   364
//
vb@0
   365
//  parameters:
vb@0
   366
//      address (in)        UTF-8 string or NULL 
vb@0
   367
//      fpr (in)            UTF-8 string or NULL 
vb@0
   368
//      user_id (in)        UTF-8 string or NULL 
vb@0
   369
//      username (in)       UTF-8 string or NULL 
vb@0
   370
//
vb@0
   371
//  return value:
vb@0
   372
//      pEp_identity struct with correct size values or NULL if out of memory
vb@0
   373
//
vb@0
   374
//  caveat:
vb@0
   375
//      the strings are copied; the original strings are still being owned by
vb@0
   376
//      the caller
vb@0
   377
vb@0
   378
DYNAMIC_API pEp_identity *new_identity(
vb@0
   379
        const char *address, const char *fpr, const char *user_id,
vb@0
   380
        const char *username
vb@0
   381
    );
vb@0
   382
vb@0
   383
vb@37
   384
// identity_dup() - allocate memory and set the string and size fields
vb@37
   385
//
vb@37
   386
//  parameters:
vb@37
   387
//      src (in)            identity to duplicate
vb@37
   388
//
vb@37
   389
//  return value:
vb@37
   390
//      pEp_identity struct with correct size values or NULL if out of memory
vb@37
   391
//
vb@37
   392
//  caveat:
vb@37
   393
//      the strings are copied; the original strings are still being owned by
vb@37
   394
//      the caller
vb@37
   395
vb@37
   396
DYNAMIC_API pEp_identity *identity_dup(const pEp_identity *src);
vb@37
   397
vb@37
   398
vb@0
   399
// free_identity() - free all memory being occupied by a pEp_identity struct
vb@0
   400
//
vb@0
   401
//  parameters:
vb@0
   402
//      identity (in)       struct to release
vb@0
   403
//
vb@0
   404
//  caveat:
vb@0
   405
//      not only the struct but also all string memory referenced by the
vb@0
   406
//      struct is being freed; all pointers inside are invalid afterwards
vb@0
   407
vb@0
   408
DYNAMIC_API void free_identity(pEp_identity *identity);
vb@0
   409
vb@0
   410
vb@0
   411
// get_identity() - get identity information
vb@0
   412
//
vb@0
   413
//	parameters:
vb@0
   414
//		session (in)		session handle
vb@0
   415
//		address (in)		C string with communication address, UTF-8 encoded
vb@0
   416
//		identity (out)		pointer to pEp_identity structure with results or
vb@0
   417
//		                    NULL if failure
vb@0
   418
//
vb@0
   419
//	caveat:
vb@0
   420
//	    the address string is being copied; the original string remains in the
vb@0
   421
//	    ownership of the caller
vb@0
   422
//		the resulting pEp_identity structure goes to the ownership of the
vb@0
   423
//		caller and has to be freed with free_identity() when not in use any
vb@0
   424
//		more
vb@0
   425
vb@0
   426
DYNAMIC_API PEP_STATUS get_identity(
vb@0
   427
        PEP_SESSION session, const char *address,
vb@0
   428
        pEp_identity **identity
vb@0
   429
    );
vb@0
   430
vb@0
   431
vb@0
   432
// set_identity() - set identity information
vb@0
   433
//
vb@0
   434
//	parameters:
vb@0
   435
//		session (in)		session handle
vb@0
   436
//		identity (in)		pointer to pEp_identity structure
vb@0
   437
//
vb@0
   438
//	return value:
vb@0
   439
//		PEP_STATUS_OK = 0			    encryption and signing succeeded
vb@0
   440
//		PEP_CANNOT_SET_PERSON		    writing to table person failed
vb@0
   441
//		PEP_CANNOT_SET_PGP_KEYPAIR	    writing to table pgp_keypair failed
vb@0
   442
//		PEP_CANNOT_SET_IDENTITY		    writing to table identity failed
vb@0
   443
//		PEP_COMMIT_FAILED			    SQL commit failed
vb@0
   444
//
vb@0
   445
//	caveat:
vb@0
   446
//		in the identity structure you need to set the const char * fields to
vb@0
   447
//		UTF-8 C strings
vb@0
   448
//		the size fields are ignored
vb@0
   449
vb@0
   450
DYNAMIC_API PEP_STATUS set_identity(
vb@0
   451
        PEP_SESSION session, const pEp_identity *identity
vb@0
   452
    );
vb@0
   453
vb@0
   454
vb@357
   455
// mark_as_compromized() - mark key in trust db as compromized
vb@357
   456
//
vb@357
   457
//	parameters:
vb@357
   458
//		session (in)		session handle
vb@357
   459
//		fpr (in)            fingerprint of key to mark
vb@357
   460
vb@357
   461
DYNAMIC_API PEP_STATUS mark_as_compromized(
vb@357
   462
        PEP_SESSION session,
vb@357
   463
        const char *fpr
vb@357
   464
    );
vb@357
   465
vb@357
   466
vb@0
   467
// generate_keypair() - generate a new key pair and add it to the key ring
vb@0
   468
//
vb@0
   469
//  parameters:
vb@0
   470
//      session (in)            session handle
vb@0
   471
//		identity (inout)	    pointer to pEp_identity structure
vb@0
   472
//
vb@0
   473
//	return value:
vb@0
   474
//		PEP_STATUS_OK = 0	    encryption and signing succeeded
vb@0
   475
//		PEP_ILLEGAL_VALUE       illegal values for identity fields given
vb@0
   476
//		PEP_CANNOT_CREATE_KEY   key engine is on strike
vb@0
   477
//
vb@0
   478
//  caveat:
vb@0
   479
//      address and username fields must be set to UTF-8 strings
vb@0
   480
//      the fpr field must be set to NULL
vb@0
   481
//
vb@0
   482
//      this function allocates a string and sets set fpr field of identity
vb@0
   483
//      the caller is responsible to call free() for that string or use
vb@0
   484
//      free_identity() on the struct
vb@0
   485
vb@0
   486
DYNAMIC_API PEP_STATUS generate_keypair(
vb@0
   487
        PEP_SESSION session, pEp_identity *identity
vb@0
   488
    );
vb@0
   489
vb@0
   490
vb@0
   491
// delete_keypair() - delete a public key or a key pair from the key ring
vb@0
   492
//
vb@0
   493
//  parameters:
vb@0
   494
//      session (in)            session handle
vb@0
   495
//      fpr (in)                C string with key id or fingerprint of the
vb@0
   496
//                              public key
vb@0
   497
//
vb@0
   498
//  return value:
vb@0
   499
//      PEP_STATUS_OK = 0       key was successfully deleted
vb@0
   500
//      PEP_KEY_NOT_FOUND       key not found
vb@0
   501
//      PEP_ILLEGAL_VALUE       not a valid key id or fingerprint
vb@0
   502
//      PEP_KEY_HAS_AMBIG_NAME  fpr does not uniquely identify a key
vb@0
   503
//      PEP_OUT_OF_MEMORY       out of memory
vb@0
   504
vb@0
   505
DYNAMIC_API PEP_STATUS delete_keypair(PEP_SESSION session, const char *fpr);
vb@0
   506
vb@0
   507
vb@0
   508
// import_key() - import key from data
vb@0
   509
//
vb@0
   510
//  parameters:
vb@0
   511
//      session (in)            session handle
vb@0
   512
//      key_data (in)           key data, i.e. ASCII armored OpenPGP key
vb@0
   513
//      size (in)               amount of data to handle
vb@0
   514
//
vb@0
   515
//  return value:
vb@0
   516
//      PEP_STATUS_OK = 0       key was successfully imported
vb@0
   517
//      PEP_OUT_OF_MEMORY       out of memory
vb@0
   518
//      PEP_ILLEGAL_VALUE       there is no key data to import
vb@0
   519
vb@0
   520
DYNAMIC_API PEP_STATUS import_key(PEP_SESSION session, const char *key_data, size_t size);
vb@0
   521
vb@0
   522
vb@0
   523
// export_key() - export ascii armored key
vb@0
   524
//
vb@0
   525
//  parameters:
vb@0
   526
//      session (in)            session handle
vb@0
   527
//      fpr (in)                key id or fingerprint of key
vb@0
   528
//      key_data (out)          ASCII armored OpenPGP key
vb@0
   529
//      size (out)               amount of data to handle
vb@0
   530
//
vb@0
   531
//  return value:
vb@0
   532
//      PEP_STATUS_OK = 0       key was successfully exported
vb@0
   533
//      PEP_OUT_OF_MEMORY       out of memory
vb@0
   534
//      PEP_KEY_NOT_FOUND       key not found
vb@0
   535
//
vb@0
   536
//  caveat:
vb@0
   537
//      the key_data goes to the ownership of the caller
vb@0
   538
//      the caller is responsible to free() it (on Windoze use pEp_free())
vb@0
   539
vb@0
   540
DYNAMIC_API PEP_STATUS export_key(
vb@0
   541
        PEP_SESSION session, const char *fpr, char **key_data, size_t *size
vb@0
   542
    );
vb@0
   543
vb@0
   544
vb@0
   545
// recv_key() - update key(s) from keyserver
vb@0
   546
//
vb@0
   547
//  parameters:
vb@0
   548
//      session (in)            session handle
vb@0
   549
//      pattern (in)            key id, user id or address to search for as
vb@0
   550
//                              UTF-8 string
vb@0
   551
vb@0
   552
DYNAMIC_API PEP_STATUS recv_key(PEP_SESSION session, const char *pattern);
vb@0
   553
vb@0
   554
vb@0
   555
// find_keys() - find keys in keyring
vb@0
   556
//
vb@0
   557
//  parameters:
vb@0
   558
//      session (in)            session handle
vb@0
   559
//      pattern (in)            key id, user id or address to search for as
vb@0
   560
//                              UTF-8 string
vb@0
   561
//      keylist (out)           list of fingerprints found or NULL on error
vb@0
   562
//
vb@0
   563
//  caveat:
vb@0
   564
//	    the ownerships of keylist isgoing to the caller
vb@0
   565
//	    the caller must use free_stringlist() to free it
vb@0
   566
vb@0
   567
vb@0
   568
DYNAMIC_API PEP_STATUS find_keys(
vb@0
   569
        PEP_SESSION session, const char *pattern, stringlist_t **keylist
vb@0
   570
    );
vb@0
   571
vb@0
   572
vb@0
   573
// send_key() - send key(s) to keyserver
vb@0
   574
//
vb@0
   575
//  parameters:
vb@0
   576
//      session (in)            session handle
vb@0
   577
//      pattern (in)            key id, user id or address to search for as
vb@0
   578
//                              UTF-8 string
vb@0
   579
vb@0
   580
DYNAMIC_API PEP_STATUS send_key(PEP_SESSION session, const char *pattern);
vb@0
   581
vb@0
   582
vb@0
   583
// pEp_free() - free memory allocated by pEp engine
vb@0
   584
//
vb@0
   585
//  parameters:
vb@0
   586
//      p (in)                  pointer to free
vb@0
   587
//
vb@0
   588
//  The reason for this function is that heap management can be a pretty
vb@0
   589
//  complex task with Windoze. This free() version calls the free()
vb@0
   590
//  implementation of the C runtime library which was used to build pEp engine,
vb@0
   591
//  so you're using the correct heap. For more information, see:
vb@0
   592
//  <http://msdn.microsoft.com/en-us/library/windows/desktop/aa366711(v=vs.85).aspx>
vb@0
   593
vb@0
   594
DYNAMIC_API void pEp_free(void *p);
vb@0
   595
vb@8
   596
vb@8
   597
// get_trust() - get the trust level a key has for a person
vb@8
   598
//
vb@8
   599
//  parameters:
vb@8
   600
//      session (in)            session handle
vb@8
   601
//      identity (inout)        user_id and fpr to check as UTF-8 strings (in)
vb@8
   602
//                              user_id and comm_type as result (out)
vb@8
   603
//
vb@14
   604
//  this function modifies the given identity struct; the struct remains in
vb@251
   605
//  the ownership of the caller
vb@14
   606
//  if the trust level cannot be determined identity->comm_type is set
vb@14
   607
//  to PEP_ct_unknown
vb@8
   608
vb@8
   609
DYNAMIC_API PEP_STATUS get_trust(PEP_SESSION session, pEp_identity *identity);
vb@8
   610
vb@8
   611
vb@251
   612
// least_trust() - get the least known trust level for a key in the database
vb@251
   613
//
vb@251
   614
//  parameters:
vb@251
   615
//      session (in)            session handle
vb@251
   616
//      fpr (in)                fingerprint of key to check
vb@251
   617
//      comm_type (out)         least comm_type as result (out)
vb@251
   618
//
vb@251
   619
//  if the trust level cannot be determined comm_type is set to PEP_ct_unknown
vb@251
   620
vb@251
   621
DYNAMIC_API PEP_STATUS least_trust(
vb@251
   622
        PEP_SESSION session,
vb@251
   623
        const char *fpr,
vb@251
   624
        PEP_comm_type *comm_type
vb@251
   625
    );
vb@251
   626
vb@251
   627
vb@9
   628
// get_key_rating() - get the rating a bare key has
vb@9
   629
//
vb@9
   630
//  parameters:
vb@9
   631
//      session (in)            session handle
vb@9
   632
//      fpr (in)                unique identifyer for key as UTF-8 string
vb@9
   633
//      comm_type (out)         key rating
vb@10
   634
//
vb@14
   635
//  if an error occurs, *comm_type is set to PEP_ct_unknown and an error
vb@10
   636
//  is returned
vb@9
   637
vb@9
   638
DYNAMIC_API PEP_STATUS get_key_rating(
vb@14
   639
        PEP_SESSION session,
vb@14
   640
        const char *fpr,
vb@14
   641
        PEP_comm_type *comm_type
vb@9
   642
    );
vb@9
   643
vb@9
   644
vb@198
   645
// renew_key() - renew an expired key
vb@196
   646
//
vb@196
   647
//  parameters:
vb@196
   648
//      session (in)            session handle
vb@214
   649
//      fpr (in)                ID of key to renew as UTF-8 string
vb@201
   650
//      ts (in)                 timestamp when key should expire or NULL for
vb@201
   651
//                              default
vb@196
   652
vb@201
   653
DYNAMIC_API PEP_STATUS renew_key(
vb@201
   654
        PEP_SESSION session,
vb@201
   655
        const char *fpr,
vb@201
   656
        const timestamp *ts
vb@201
   657
    );
vb@196
   658
vb@196
   659
vb@224
   660
// revoke_key() - revoke a key
vb@197
   661
//
vb@197
   662
//  parameters:
vb@197
   663
//      session (in)            session handle
vb@214
   664
//      fpr (in)                ID of key to revoke as UTF-8 string
vb@211
   665
//      reason (in)             text with reason for revoke as UTF-8 string
vb@211
   666
//                              or NULL if reason unknown
vb@211
   667
//
vb@211
   668
//  caveat:
vb@211
   669
//      reason text must not include empty lines
vb@224
   670
//      this function is meant for internal use only; better use
vb@224
   671
//      key_compromized() of keymanagement API
vb@197
   672
vb@211
   673
DYNAMIC_API PEP_STATUS revoke_key(
vb@211
   674
        PEP_SESSION session,
vb@211
   675
        const char *fpr,
vb@211
   676
        const char *reason
vb@211
   677
    );
vb@197
   678
vb@197
   679
vb@214
   680
// key_expired() - flags if a key is already expired
vb@214
   681
//
vb@214
   682
//  parameters:
vb@214
   683
//      session (in)            session handle
vb@214
   684
//      fpr (in)                ID of key to check as UTF-8 string
vb@214
   685
//      expired (out)           flag if key expired
vb@214
   686
vb@214
   687
DYNAMIC_API PEP_STATUS key_expired(
vb@214
   688
        PEP_SESSION session,
vb@214
   689
        const char *fpr,
vb@214
   690
        bool *expired
vb@214
   691
    );
vb@214
   692
vb@214
   693
vb@450
   694
// get_crashdump_log() - get the last log messages out
vb@450
   695
//
vb@450
   696
//  parameters:
vb@450
   697
//      session (in)            session handle
vb@450
   698
//      maxlines (in)           maximum number of lines (0 for default)
vb@458
   699
//      logdata (out)           logdata as string in double quoted CSV format
vb@450
   700
vb@450
   701
DYNAMIC_API PEP_STATUS get_crashdump_log(
vb@450
   702
        PEP_SESSION session,
vb@450
   703
        int maxlines,
vb@450
   704
        char **logdata
vb@450
   705
    );
vb@450
   706
vb@450
   707
vb@458
   708
// get_languagelist() - get the last log messages out
vb@458
   709
//
vb@458
   710
//  parameters:
vb@458
   711
//      session (in)            session handle
vb@458
   712
//      languages (out)         languages as string in double quoted CSV format
vb@458
   713
vb@458
   714
DYNAMIC_API PEP_STATUS get_languagelist(
vb@458
   715
        PEP_SESSION session,
vb@458
   716
        char **languages
vb@458
   717
    );
vb@458
   718
vb@458
   719
vb@458
   720
// get_phrase() - get phrase in a dedicated language through i18n
vb@458
   721
//
vb@458
   722
//  parameters:
vb@458
   723
//      session (in)            session handle
vb@458
   724
//		lang (in)			    C string with ISO 639-1 language code
vb@458
   725
//      phrase_id (in)          id of phrase in i18n
vb@458
   726
//      phrase (out)            phrase as UTF-8 string
vb@458
   727
vb@458
   728
DYNAMIC_API PEP_STATUS get_phrase(
vb@458
   729
        PEP_SESSION session,
vb@458
   730
        const char *lang,
vb@458
   731
        int phrase_id,
vb@458
   732
        char **phrase
vb@458
   733
    );
vb@458
   734
vb@458
   735
vb@0
   736
#ifdef __cplusplus
vb@0
   737
}
vb@0
   738
#endif