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