src/pEp_internal.h
author Volker Birk <vb@pep-project.org>
Mon, 16 May 2016 15:36:26 +0200
changeset 633 a2a4ad55e19e
parent 632 a213fafe3f4f
child 658 244734164566
permissions -rw-r--r--
better ASN.1
vb@450
     1
#define PEP_ENGINE_VERSION "0.6.0"
vb@24
     2
vb@233
     3
// this is 20 trustwords with 79 chars max
vb@251
     4
#define MAX_TRUSTWORDS_SPACE (20 * 80)
vb@24
     5
vb@24
     6
// XML parameters string
vb@24
     7
#define PARMS_MAX 32768
vb@24
     8
vb@24
     9
// maximum busy wait time in ms
vb@24
    10
#define BUSY_WAIT_TIME 5000
vb@24
    11
vb@24
    12
// maximum line length for reading gpg.conf
vb@24
    13
#define MAX_LINELENGTH 1024
vb@24
    14
vb@24
    15
// default keyserver
vb@450
    16
#ifndef DEFAULT_KEYSERVER
vb@24
    17
#define DEFAULT_KEYSERVER "hkp://keys.gnupg.net"
vb@450
    18
#endif
vb@450
    19
vb@450
    20
// crashdump constants
vb@450
    21
#ifndef CRASHDUMP_DEFAULT_LINES
vb@450
    22
#define CRASHDUMP_DEFAULT_LINES 100
vb@450
    23
#endif
vb@450
    24
#define CRASHDUMP_MAX_LINES 32767
vb@24
    25
vb@130
    26
#include "platform.h"
vb@130
    27
vb@24
    28
#ifdef WIN32
vb@24
    29
#define LOCAL_DB windoze_local_db()
vb@24
    30
#define SYSTEM_DB windoze_system_db()
vb@24
    31
#define LIBGPGME "libgpgme-11.dll"
vb@24
    32
#else // UNIX
vb@24
    33
#define _POSIX_C_SOURCE 200809L
vb@24
    34
#include <dlfcn.h>
vb@24
    35
#define LOCAL_DB unix_local_db()
vb@24
    36
#ifndef SYSTEM_DB
vb@24
    37
#define SYSTEM_DB "/usr/share/pEp/system.db"
vb@24
    38
#endif
vb@24
    39
#ifndef LIBGPGME
vb@24
    40
#define LIBGPGME "libgpgme-pthread.so"
vb@24
    41
#endif
vb@24
    42
#endif
vb@24
    43
vb@24
    44
#include <locale.h>
vb@24
    45
#include <stdlib.h>
vb@24
    46
#include <string.h>
vb@24
    47
#include <assert.h>
vb@24
    48
#include <stdio.h>
vb@24
    49
vb@24
    50
#include "sqlite3.h"
vb@24
    51
vb@24
    52
#define _EXPORT_PEP_ENGINE_DLL
vb@24
    53
#include "pEpEngine.h"
Edouard@168
    54
Edouard@168
    55
// If not specified, build for GPG
Edouard@168
    56
#ifndef USE_NETPGP
Edouard@168
    57
#ifndef USE_GPG
Edouard@168
    58
#define USE_GPG
Edouard@168
    59
#endif
Edouard@168
    60
#endif
Edouard@168
    61
Edouard@168
    62
#ifdef USE_GPG
vb@24
    63
#include "pgp_gpg_internal.h"
vb@229
    64
#elif defined(USE_NETPGP)
Edouard@168
    65
#include "pgp_netpgp_internal.h"
vb@24
    66
#endif
vb@24
    67
vb@292
    68
#include "keymanagement.h"
vb@28
    69
#include "cryptotech.h"
vb@28
    70
#include "transport.h"
vb@604
    71
#include "sync.h"
vb@28
    72
vb@125
    73
#define NOT_IMPLEMENTED assert(0); return PEP_UNKNOWN_ERROR;
vb@24
    74
vb@46
    75
typedef struct _pEpSession {
vb@24
    76
    const char *version;
Edouard@168
    77
#ifdef USE_GPG
vb@24
    78
    gpgme_ctx_t ctx;
vb@229
    79
#elif defined(USE_NETPGP)
Edouard@252
    80
    pEpNetPGPSession ctx;
vb@24
    81
#endif
vb@24
    82
vb@62
    83
    PEP_cryptotech_t *cryptotech;
vb@62
    84
    PEP_transport_t *transports;
vb@28
    85
vb@24
    86
    sqlite3 *db;
vb@24
    87
    sqlite3 *system_db;
vb@24
    88
vb@24
    89
    sqlite3_stmt *log;
vb@233
    90
    sqlite3_stmt *trustword;
vb@24
    91
    sqlite3_stmt *get_identity;
vb@24
    92
    sqlite3_stmt *set_person;
vb@24
    93
    sqlite3_stmt *set_pgp_keypair;
vb@24
    94
    sqlite3_stmt *set_identity;
vb@24
    95
    sqlite3_stmt *set_trust;
vb@24
    96
    sqlite3_stmt *get_trust;
vb@251
    97
    sqlite3_stmt *least_trust;
vb@357
    98
    sqlite3_stmt *mark_compromized;
Edouard@409
    99
    sqlite3_stmt *reset_trust;
vb@450
   100
    sqlite3_stmt *crashdump;
vb@458
   101
    sqlite3_stmt *languagelist;
vb@458
   102
    sqlite3_stmt *i18n_token;
fdik@494
   103
fdik@494
   104
    // blacklist
fdik@494
   105
    sqlite3_stmt *blacklist_add;
fdik@494
   106
    sqlite3_stmt *blacklist_delete;
fdik@494
   107
    sqlite3_stmt *blacklist_is_listed;
fdik@494
   108
    sqlite3_stmt *blacklist_retrieve;
Edouard@584
   109
    
Edouard@584
   110
    // Own keys
Edouard@584
   111
    sqlite3_stmt *own_key_add;
Edouard@584
   112
    sqlite3_stmt *own_key_is_listed;
Edouard@584
   113
    sqlite3_stmt *own_key_retrieve;
vb@292
   114
vb@632
   115
    // sequence value
vb@633
   116
    sqlite3_stmt *sequence_value1;
vb@633
   117
    sqlite3_stmt *sequence_value2;
vb@632
   118
vb@599
   119
    // callbacks   
vb@292
   120
    examine_identity_t examine_identity;
vb@292
   121
    void *examine_management;
vb@599
   122
    void *sync_obj;
vb@604
   123
    messageToSend_t messageToSend;
vb@604
   124
    showHandshake_t showHandshake;
vb@464
   125
vb@464
   126
    // runtime config
vb@464
   127
vb@464
   128
    bool passive_mode;
vb@464
   129
    bool unencrypted_subject;
vb@24
   130
} pEpSession;
vb@48
   131
vb@62
   132
PEP_STATUS init_transport_system(PEP_SESSION session, bool in_first);
vb@62
   133
void release_transport_system(PEP_SESSION session, bool out_last);
vb@48
   134
vb@216
   135
#ifdef NDEBUG
vb@216
   136
#define DEBUG_LOG(TITLE, ENTITY, DESC)
vb@216
   137
#else
vb@216
   138
#define DEBUG_LOG(TITLE, ENTITY, DESC) \
vb@216
   139
    log_event(session, (TITLE), (ENTITY), (DESC), "debug");
vb@216
   140
#endif
vb@216
   141