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