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