src/pEpEngine.c
changeset 28 7fc9fc3e680c
parent 26 843e629627bf
child 31 132481aa7ed0
     1.1 --- a/src/pEpEngine.c	Mon Sep 01 19:30:30 2014 +0200
     1.2 +++ b/src/pEpEngine.c	Mon Sep 01 20:56:05 2014 +0200
     1.3 @@ -1,13 +1,9 @@
     1.4  #include "pEp_internal.h"
     1.5 -#ifndef NO_GPG
     1.6 -#include "pgp_gpg.h"
     1.7 -#else
     1.8 -#include "pgp_netpgp.h"
     1.9 -#endif
    1.10 +#include "cryptotech.h"
    1.11 +#include "transport.h"
    1.12  
    1.13  DYNAMIC_API PEP_STATUS init(PEP_SESSION *session)
    1.14  {
    1.15 -    PEP_STATUS status_result;
    1.16  	int int_result;
    1.17  	const char *sql_log;
    1.18  	const char *sql_safeword;
    1.19 @@ -32,16 +28,12 @@
    1.20  	
    1.21  	_session->version = PEP_ENGINE_VERSION;
    1.22  
    1.23 -    status_result = pgp_init(_session);
    1.24 -    assert(status_result == PEP_STATUS_OK);
    1.25 -    if (status_result != PEP_STATUS_OK) {
    1.26 -        free(_session);
    1.27 -        return status_result;
    1.28 -    }
    1.29 +    init_cryptotech(_session);
    1.30 +    init_transport_system(_session->transports);
    1.31  
    1.32      assert(LOCAL_DB);
    1.33      if (LOCAL_DB == NULL) {
    1.34 -        pgp_release(session);
    1.35 +        release_cryptotech(_session);
    1.36          free(_session);
    1.37          return PEP_INIT_CANNOT_OPEN_DB;
    1.38      }
    1.39 @@ -58,7 +50,7 @@
    1.40  
    1.41  	if (int_result != SQLITE_OK) {
    1.42  		sqlite3_close_v2(_session->db);
    1.43 -        pgp_release(session);
    1.44 +        release_cryptotech(_session);
    1.45          free(_session);
    1.46  		return PEP_INIT_CANNOT_OPEN_DB;
    1.47  	}
    1.48 @@ -68,7 +60,7 @@
    1.49      assert(SYSTEM_DB);
    1.50      if (SYSTEM_DB == NULL) {
    1.51  		sqlite3_close_v2(_session->db);
    1.52 -        pgp_release(session);
    1.53 +        release_cryptotech(_session);
    1.54          free(_session);
    1.55  		return PEP_INIT_CANNOT_OPEN_SYSTEM_DB;
    1.56      }
    1.57 @@ -84,7 +76,7 @@
    1.58  	if (int_result != SQLITE_OK) {
    1.59  		sqlite3_close_v2(_session->system_db);
    1.60  		sqlite3_close_v2(_session->db);
    1.61 -        pgp_release(session);
    1.62 +        release_cryptotech(_session);
    1.63          free(_session);
    1.64  		return PEP_INIT_CANNOT_OPEN_SYSTEM_DB;
    1.65  	}
    1.66 @@ -252,7 +244,9 @@
    1.67  			sqlite3_close_v2(_session->db);
    1.68  			sqlite3_close_v2(_session->system_db);
    1.69  		}
    1.70 -        pgp_release(session);
    1.71 +
    1.72 +        release_cryptotech(_session);
    1.73 +        release_transport_system(_session);
    1.74      }
    1.75  	free(_session);
    1.76  }
    1.77 @@ -280,7 +274,6 @@
    1.78  
    1.79      if (stringlist->next != NULL)
    1.80          return stringlist_add(stringlist->next, value);
    1.81 -
    1.82      if (stringlist->value == NULL) {
    1.83          stringlist->value = strdup(value);
    1.84          assert(stringlist->value);
    1.85 @@ -731,7 +724,8 @@
    1.86      char **ptext, size_t *psize, stringlist_t **keylist
    1.87      )
    1.88  {
    1.89 -    return pgp_decrypt_and_verify(session, ctext, csize, ptext, psize, keylist);
    1.90 +    pEpSession *_session = (pEpSession *) session;
    1.91 +    return _session->cryptotech[PEP_crypt_OpenPGP].decrypt_and_verify(session, ctext, csize, ptext, psize, keylist);
    1.92  }
    1.93  
    1.94  DYNAMIC_API PEP_STATUS encrypt_and_sign(
    1.95 @@ -739,7 +733,8 @@
    1.96      size_t psize, char **ctext, size_t *csize
    1.97      )
    1.98  {
    1.99 -    return pgp_encrypt_and_sign(session, keylist, ptext, psize, ctext, csize);
   1.100 +    pEpSession *_session = (pEpSession *) session;
   1.101 +    return _session->cryptotech[PEP_crypt_OpenPGP].encrypt_and_sign(session, keylist, ptext, psize, ctext, csize);
   1.102  }
   1.103  
   1.104  DYNAMIC_API PEP_STATUS verify_text(
   1.105 @@ -747,33 +742,38 @@
   1.106      const char *signature, size_t sig_size, stringlist_t **keylist
   1.107      )
   1.108  {
   1.109 -    return pgp_verify_text(session, text, size, signature, sig_size, keylist);
   1.110 +    pEpSession *_session = (pEpSession *) session;
   1.111 +    return _session->cryptotech[PEP_crypt_OpenPGP].verify_text(session, text, size, signature, sig_size, keylist);
   1.112  }
   1.113  
   1.114  DYNAMIC_API PEP_STATUS delete_keypair(PEP_SESSION session, const char *fpr)
   1.115  {
   1.116 -    return pgp_delete_keypair(session, fpr);
   1.117 +    pEpSession *_session = (pEpSession *) session;
   1.118 +    return _session->cryptotech[PEP_crypt_OpenPGP].delete_keypair(session, fpr);
   1.119  }
   1.120  
   1.121  DYNAMIC_API PEP_STATUS export_key(
   1.122      PEP_SESSION session, const char *fpr, char **key_data, size_t *size
   1.123      )
   1.124  {
   1.125 -    return pgp_export_key(session, fpr, key_data, size);
   1.126 +    pEpSession *_session = (pEpSession *) session;
   1.127 +    return _session->cryptotech[PEP_crypt_OpenPGP].export_key(session, fpr, key_data, size);
   1.128  }
   1.129  
   1.130  DYNAMIC_API PEP_STATUS find_keys(
   1.131      PEP_SESSION session, const char *pattern, stringlist_t **keylist
   1.132      )
   1.133  {
   1.134 -    return pgp_find_keys(session, pattern, keylist);
   1.135 +    pEpSession *_session = (pEpSession *) session;
   1.136 +    return _session->cryptotech[PEP_crypt_OpenPGP].find_keys(session, pattern, keylist);
   1.137  }
   1.138  
   1.139  DYNAMIC_API PEP_STATUS generate_keypair(
   1.140      PEP_SESSION session, pEp_identity *identity
   1.141      )
   1.142  {
   1.143 -    return pgp_generate_keypair(session, identity);
   1.144 +    pEpSession *_session = (pEpSession *) session;
   1.145 +    return _session->cryptotech[PEP_crypt_OpenPGP].generate_keypair(session, identity);
   1.146  }
   1.147  
   1.148  DYNAMIC_API PEP_STATUS get_key_rating(
   1.149 @@ -782,20 +782,24 @@
   1.150      PEP_comm_type *comm_type
   1.151      )
   1.152  {
   1.153 -    return pgp_get_key_rating(session, fpr, comm_type);
   1.154 +    pEpSession *_session = (pEpSession *) session;
   1.155 +    return _session->cryptotech[PEP_crypt_OpenPGP].get_key_rating(session, fpr, comm_type);
   1.156  }
   1.157  
   1.158  DYNAMIC_API PEP_STATUS import_key(PEP_SESSION session, const char *key_data, size_t size)
   1.159  {
   1.160 -    return pgp_import_key(session, key_data, size);
   1.161 +    pEpSession *_session = (pEpSession *) session;
   1.162 +    return _session->cryptotech[PEP_crypt_OpenPGP].import_key(session, key_data, size);
   1.163  }
   1.164  
   1.165  DYNAMIC_API PEP_STATUS recv_key(PEP_SESSION session, const char *pattern)
   1.166  {
   1.167 -    return pgp_recv_key(session, pattern);
   1.168 +    pEpSession *_session = (pEpSession *) session;
   1.169 +    return _session->cryptotech[PEP_crypt_OpenPGP].recv_key(session, pattern);
   1.170  }
   1.171  
   1.172  DYNAMIC_API PEP_STATUS send_key(PEP_SESSION session, const char *pattern)
   1.173  {
   1.174 -    return pgp_send_key(session, pattern);
   1.175 +    pEpSession *_session = (pEpSession *) session;
   1.176 +    return _session->cryptotech[PEP_crypt_OpenPGP].send_key(session, pattern);
   1.177  }