Browse Source

signal() and init()

async_key_management
vb 7 years ago
parent
commit
35368d2549
12 changed files with 658 additions and 494 deletions
  1. +30
    -28
      src/cryptotech.c
  2. +2
    -2
      src/cryptotech.h
  3. +3
    -0
      src/etpan_mime.c
  4. +70
    -15
      src/message_api.c
  5. +33
    -11
      src/mime.c
  6. +151
    -125
      src/pEpEngine.c
  7. +7
    -0
      src/pEpEngine.h
  8. +5
    -6
      src/pEp_internal.h
  9. +342
    -295
      src/pgp_gpg.c
  10. +2
    -2
      src/pgp_gpg.h
  11. +1
    -0
      src/pgp_gpg_internal.h
  12. +12
    -10
      src/transport.c

+ 30
- 28
src/cryptotech.c View File

@ -10,45 +10,47 @@
#include <memory.h>
#include <assert.h>
PEP_STATUS init_cryptotech(PEP_SESSION session)
PEP_STATUS init_cryptotech(PEP_SESSION session, bool in_first)
{
pEpSession *_session = (pEpSession *) session;
PEP_cryptotech_t *cryptotech = _session->cryptotech;
static PEP_cryptotech_t cryptotech[PEP_crypt__count];
PEP_STATUS _status;
assert(PEP_crypt__count == 2);
memset(cryptotech, 0, sizeof(PEP_cryptotech_t) * PEP_crypt__count);
cryptotech[PEP_crypt_none].id = PEP_crypt_none;
cryptotech[PEP_crypt_none].unconfirmed_comm_type = PEP_ct_no_encryption;
cryptotech[PEP_crypt_none].confirmed_comm_type = PEP_ct_no_encryption;
if (in_first) {
memset(cryptotech, 0, sizeof(PEP_cryptotech_t) * PEP_crypt__count);
cryptotech[PEP_crypt_none].id = PEP_crypt_none;
cryptotech[PEP_crypt_none].unconfirmed_comm_type = PEP_ct_no_encryption;
cryptotech[PEP_crypt_none].confirmed_comm_type = PEP_ct_no_encryption;
cryptotech[PEP_crypt_OpenPGP].id = PEP_crypt_OpenPGP;
cryptotech[PEP_crypt_OpenPGP].unconfirmed_comm_type = PEP_ct_OpenPGP_unconfirmed;
cryptotech[PEP_crypt_OpenPGP].confirmed_comm_type = PEP_ct_OpenPGP;
cryptotech[PEP_crypt_OpenPGP].decrypt_and_verify = pgp_decrypt_and_verify;
cryptotech[PEP_crypt_OpenPGP].encrypt_and_sign = pgp_encrypt_and_sign;
cryptotech[PEP_crypt_OpenPGP].verify_text = pgp_verify_text;
cryptotech[PEP_crypt_OpenPGP].delete_keypair = pgp_delete_keypair;
cryptotech[PEP_crypt_OpenPGP].export_key = pgp_export_key;
cryptotech[PEP_crypt_OpenPGP].find_keys = pgp_find_keys;
cryptotech[PEP_crypt_OpenPGP].generate_keypair = pgp_generate_keypair;
cryptotech[PEP_crypt_OpenPGP].get_key_rating = pgp_get_key_rating;
cryptotech[PEP_crypt_OpenPGP].import_key = pgp_import_key;
cryptotech[PEP_crypt_OpenPGP].recv_key = pgp_recv_key;
cryptotech[PEP_crypt_OpenPGP].send_key = pgp_send_key;
}
session->cryptotech = cryptotech;
_status = pgp_init(_session);
_status = pgp_init(session, in_first);
assert(_status == PEP_STATUS_OK);
if (_status != PEP_STATUS_OK) {
free(_session);
if (_status != PEP_STATUS_OK)
return _status;
}
cryptotech[PEP_crypt_OpenPGP].id = PEP_crypt_OpenPGP;
cryptotech[PEP_crypt_OpenPGP].unconfirmed_comm_type = PEP_ct_OpenPGP_unconfirmed;
cryptotech[PEP_crypt_OpenPGP].confirmed_comm_type = PEP_ct_OpenPGP;
cryptotech[PEP_crypt_OpenPGP].decrypt_and_verify = pgp_decrypt_and_verify;
cryptotech[PEP_crypt_OpenPGP].encrypt_and_sign = pgp_encrypt_and_sign;
cryptotech[PEP_crypt_OpenPGP].verify_text = pgp_verify_text;
cryptotech[PEP_crypt_OpenPGP].delete_keypair = pgp_delete_keypair;
cryptotech[PEP_crypt_OpenPGP].export_key = pgp_export_key;
cryptotech[PEP_crypt_OpenPGP].find_keys = pgp_find_keys;
cryptotech[PEP_crypt_OpenPGP].generate_keypair = pgp_generate_keypair;
cryptotech[PEP_crypt_OpenPGP].get_key_rating = pgp_get_key_rating;
cryptotech[PEP_crypt_OpenPGP].import_key = pgp_import_key;
cryptotech[PEP_crypt_OpenPGP].recv_key = pgp_recv_key;
cryptotech[PEP_crypt_OpenPGP].send_key = pgp_send_key;
return PEP_STATUS_OK;
}
void release_cryptotech(PEP_SESSION session)
void release_cryptotech(PEP_SESSION session, bool out_last)
{
pgp_release(session);
pgp_release(session, out_last);
}

+ 2
- 2
src/cryptotech.h View File

@ -73,5 +73,5 @@ typedef struct _PEP_cryptotech_t {
typedef uint64_t cryptotech_mask;
PEP_STATUS init_cryptotech(PEP_SESSION session);
void release_cryptotech(PEP_SESSION session);
PEP_STATUS init_cryptotech(PEP_SESSION session, bool in_first);
void release_cryptotech(PEP_SESSION session, bool out_last);

+ 3
- 0
src/etpan_mime.c View File

@ -3,6 +3,9 @@
#include <unistd.h>
#include "etpan_mime.h"
#ifndef mailmime_param_new_with_data
#include <libetpan/mailprivacy_tools.h>
#endif
#define MAX_MESSAGE_ID 512


+ 70
- 15
src/message_api.c View File

@ -1,16 +1,31 @@
#include "message_api.h"
#include "keymanagement.h"
#include "mime.h"
#include <libetpan/mailmime.h>
#ifndef mailmime_param_new_with_data
#include <libetpan/mailprivacy_tools.h>
#endif
#include <assert.h>
#include <string.h>
#include <stdlib.h>
#define NOT_IMPLEMENTED assert(0);
static char * combine_short_and_long(const message * src)
{
char * ptext;
assert(src);
assert(src->shortmsg && src->longmsg && strcmp(src->shortmsg, "pEp") != 0);
ptext = calloc(1, strlen(src->shortmsg) + strlen(src->longmsg)
+ 12);
if (ptext == NULL)
return NULL;
strcpy(ptext, "subject: ");
strcat(ptext, src->shortmsg);
strcat(ptext, "\n\n");
strcat(ptext, src->longmsg);
return ptext;
}
DYNAMIC_API PEP_STATUS encrypt_message(
PEP_SESSION session,
@ -101,27 +116,64 @@ DYNAMIC_API PEP_STATUS encrypt_message(
switch (format) {
case PEP_enc_MIME_multipart: {
message *interim;
// status = mime_encode_parts(src, &interim);
// assert(status == PEP_STATUS_OK);
// if (status != PEP_STATUS_OK)
// break;
char *resulttext;
bool free_ptext = false;
msg->enc_format = PEP_enc_MIME_multipart;
if (src->shortmsg && src->longmsg && strcmp(src->shortmsg, "pEp") != 0) {
ptext = combine_short_and_long(src);
if (ptext == NULL) {
free_message(msg);
free_stringlist(keys);
return PEP_OUT_OF_MEMORY;
}
free_ptext = true;
}
else if (src->longmsg) {
ptext = src->longmsg;
}
else {
ptext = NULL;
}
// TO EXTEND: we only support HTML yet
assert(src->format == PEP_format_plain
|| src->format == PEP_format_html);
status = mime_encode_text(ptext, src->longmsg_formatted,
src->attachments, &resulttext);
assert(status == PEP_STATUS_OK);
if (free_ptext)
free(ptext);
assert(resulttext);
if (resulttext == NULL) {
free_message(msg);
free_stringlist(keys);
return status;
}
status = encrypt_and_sign(session, keys, resulttext, strlen(resulttext),
&ctext, &csize);
free(resulttext);
free_stringlist(keys);
if (ctext) {
msg->longmsg = strdup(ctext);
msg->shortmsg = strdup("pEp");
if (!(msg->longmsg && msg->shortmsg)) {
free_message(msg);
return PEP_OUT_OF_MEMORY;
}
}
}
case PEP_enc_pieces:
if (src->shortmsg && src->longmsg && strcmp(src->shortmsg, "pEp") != 0) {
ptext = calloc(1, strlen(src->shortmsg) + strlen(src->longmsg)
+ 12);
ptext = combine_short_and_long(src);
if (ptext == NULL) {
free_message(msg);
free_stringlist(keys);
return PEP_OUT_OF_MEMORY;
}
strcpy(ptext, "subject: ");
strcat(ptext, src->shortmsg);
strcat(ptext, "\n\n");
strcat(ptext, src->longmsg);
status = encrypt_and_sign(session, keys, ptext, strlen(ptext),
&ctext, &csize);
free(ptext);
@ -129,12 +181,14 @@ DYNAMIC_API PEP_STATUS encrypt_message(
msg->longmsg = strdup(ctext);
msg->shortmsg = strdup("pEp");
if (!(msg->longmsg && msg->shortmsg)) {
free_stringlist(keys);
free_message(msg);
return PEP_OUT_OF_MEMORY;
}
}
else {
free_message(msg);
free_stringlist(keys);
msg = NULL;
}
}
@ -156,6 +210,7 @@ DYNAMIC_API PEP_STATUS encrypt_message(
msg->shortmsg = strdup("pEp");
if (!(msg->longmsg && msg->shortmsg)) {
free_message(msg);
free_stringlist(keys);
return PEP_OUT_OF_MEMORY;
}
}


+ 33
- 11
src/mime.c View File

@ -1,6 +1,6 @@
#include "mime.h"
#include <libetpan/libetpan.h>
#include <libetpan/mailmime.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
@ -179,8 +179,14 @@ DYNAMIC_API PEP_STATUS mime_encode_text(
errno = 0;
rewind(file);
assert(errno == 0);
clearerr(file);
switch (errno) {
case ENOMEM:
goto enomem;
default:
goto err_file;
}
buf = calloc(1, size + 1);
assert(buf);
@ -190,15 +196,23 @@ DYNAMIC_API PEP_STATUS mime_encode_text(
char *_buf = buf;
size_t rest = size;
for (size_t bytes_read = 0; rest > 0; rest -= bytes_read, _buf += rest) {
assert(feof(file) == 0);
if (feof(file))
goto err_file;
clearerr(file);
bytes_read = rest * fread(_buf, rest, 1, file);
if (ferror(file))
assert(ferror(file) == 0 || ferror(file) == EINTR);
if (ferror(file) != 0 && ferror(file) != EINTR)
goto err_file;
assert(!feof(file));
if (feof(file))
goto err_file;
}
fclose(file);
do {
r = fclose(file);
} while (r == -1 && errno == EINTR);
assert(r == 0);
mailmime_free(mime);
*resulttext = buf;
return PEP_STATUS_OK;
@ -218,10 +232,18 @@ release:
free(buf);
free(template);
if (file)
fclose(file);
else if (fd != -1)
close(fd);
if (file) {
do {
r = fclose(file);
} while (r == -1 && errno == EINTR);
assert(r == 0);
}
else if (fd != -1) {
do {
r = close(fd);
} while (r == -1 && errno == EINTR);
assert(r == 0);
}
if (mime)
mailmime_free(mime);


+ 151
- 125
src/pEpEngine.c View File

@ -2,21 +2,32 @@
#include "cryptotech.h"
#include "transport.h"
int init_count = -1;
DYNAMIC_API PEP_STATUS init(PEP_SESSION *session)
{
int int_result;
const char *sql_log;
const char *sql_safeword;
const char *sql_get_identity;
const char *sql_set_person;
const char *sql_set_pgp_keypair;
const char *sql_set_identity;
const char *sql_set_trust;
const char *sql_get_trust;
assert(sqlite3_threadsafe());
if (!sqlite3_threadsafe())
return PEP_INIT_SQLITE3_WITHOUT_MUTEX;
static const char *sql_log;
static const char *sql_safeword;
static const char *sql_get_identity;
static const char *sql_set_person;
static const char *sql_set_pgp_keypair;
static const char *sql_set_identity;
static const char *sql_set_trust;
static const char *sql_get_trust;
bool in_first = false;
assert(sqlite3_threadsafe());
if (!sqlite3_threadsafe())
return PEP_INIT_SQLITE3_WITHOUT_MUTEX;
// a little race condition - but still a race condition
// removed by calling caveat (see documentation)
++init_count;
if (init_count == 0) {
in_first = true;
}
assert(session);
*session = NULL;
@ -25,16 +36,11 @@ DYNAMIC_API PEP_STATUS init(PEP_SESSION *session)
assert(_session);
if (_session == NULL)
return PEP_OUT_OF_MEMORY;
_session->version = PEP_ENGINE_VERSION;
init_cryptotech(_session);
init_transport_system(_session);
assert(LOCAL_DB);
if (LOCAL_DB == NULL) {
release_transport_system(_session);
release_cryptotech(_session);
free(_session);
return PEP_INIT_CANNOT_OPEN_DB;
}
@ -51,8 +57,6 @@ DYNAMIC_API PEP_STATUS init(PEP_SESSION *session)
if (int_result != SQLITE_OK) {
sqlite3_close_v2(_session->db);
release_transport_system(_session);
release_cryptotech(_session);
free(_session);
return PEP_INIT_CANNOT_OPEN_DB;
}
@ -62,8 +66,6 @@ DYNAMIC_API PEP_STATUS init(PEP_SESSION *session)
assert(SYSTEM_DB);
if (SYSTEM_DB == NULL) {
sqlite3_close_v2(_session->db);
release_transport_system(_session);
release_cryptotech(_session);
free(_session);
return PEP_INIT_CANNOT_OPEN_SYSTEM_DB;
}
@ -79,138 +81,148 @@ DYNAMIC_API PEP_STATUS init(PEP_SESSION *session)
if (int_result != SQLITE_OK) {
sqlite3_close_v2(_session->system_db);
sqlite3_close_v2(_session->db);
release_transport_system(_session);
release_cryptotech(_session);
free(_session);
return PEP_INIT_CANNOT_OPEN_SYSTEM_DB;
}
sqlite3_busy_timeout(_session->system_db, 1000);
int_result = sqlite3_exec(
_session->db,
"create table if not exists version_info ("
" id integer primary key,"
" timestamp integer default (datetime('now')) ,"
" version text,"
" comment text"
");"
"create table if not exists log ("
" timestamp integer default (datetime('now')) ,"
" title text not null,"
" entity text not null,"
" description text,"
" comment text"
");"
"create index if not exists log_timestamp on log ("
" timestamp"
");"
"create table if not exists pgp_keypair ("
" fpr text primary key,"
" public_id text unique,"
" private_id text,"
" created integer,"
" expires integer,"
" comment text"
");"
"create index if not exists pgp_keypair_expires on pgp_keypair ("
" expires"
");"
"create table if not exists person ("
" id text primary key,"
" username text not null,"
" main_key_id text"
" references pgp_keypair (fpr)"
" on delete set null,"
" lang text,"
" comment text"
");"
"create table if not exists identity ("
" address text primary key,"
" user_id text"
" references person (id)"
" on delete cascade,"
" main_key_id text"
" references pgp_keypair (fpr)"
" on delete set null,"
" comment text"
");"
"create table if not exists trust ("
" user_id text not null"
" references person (id)"
" on delete cascade,"
" pgp_keypair_fpr text not null"
" references pgp_keypair (fpr)"
" on delete cascade,"
" comm_type integer not null,"
" comment text"
");"
"create unique index if not exists trust_index on trust ("
" user_id,"
" pgp_keypair_fpr"
");",
NULL,
NULL,
NULL
);
assert(int_result == SQLITE_OK);
if (in_first) {
int_result = sqlite3_exec(
_session->db,
"create table if not exists version_info ("
" id integer primary key,"
" timestamp integer default (datetime('now')) ,"
" version text,"
" comment text"
");"
"create table if not exists log ("
" timestamp integer default (datetime('now')) ,"
" title text not null,"
" entity text not null,"
" description text,"
" comment text"
");"
"create index if not exists log_timestamp on log ("
" timestamp"
");"
"create table if not exists pgp_keypair ("
" fpr text primary key,"
" public_id text unique,"
" private_id text,"
" created integer,"
" expires integer,"
" comment text"
");"
"create index if not exists pgp_keypair_expires on pgp_keypair ("
" expires"
");"
"create table if not exists person ("
" id text primary key,"
" username text not null,"
" main_key_id text"
" references pgp_keypair (fpr)"
" on delete set null,"
" lang text,"
" comment text"
");"
"create table if not exists identity ("
" address text primary key,"
" user_id text"
" references person (id)"
" on delete cascade,"
" main_key_id text"
" references pgp_keypair (fpr)"
" on delete set null,"
" comment text"
");"
"create table if not exists trust ("
" user_id text not null"
" references person (id)"
" on delete cascade,"
" pgp_keypair_fpr text not null"
" references pgp_keypair (fpr)"
" on delete cascade,"
" comm_type integer not null,"
" comment text"
");"
"create unique index if not exists trust_index on trust ("
" user_id,"
" pgp_keypair_fpr"
");",
NULL,
NULL,
NULL
);
assert(int_result == SQLITE_OK);
int_result = sqlite3_exec(
_session->db,
"insert or replace into version_info (id, version) values (1, '1.0');",
NULL,
NULL,
NULL
);
assert(int_result == SQLITE_OK);
sql_log = "insert into log (title, entity, description, comment)"
"values (?1, ?2, ?3, ?4);";
sql_get_identity = "select fpr, identity.user_id, username, comm_type, lang"
" from identity"
" join person on id = identity.user_id"
" join pgp_keypair on fpr = identity.main_key_id"
" join trust on id = trust.user_id"
" and pgp_keypair_fpr = identity.main_key_id"
" where address = ?1 ;";
sql_safeword = "select id, word from wordlist where lang = lower(?1) "
"and id = ?2 ;";
sql_set_person = "insert or replace into person (id, username, lang) "
"values (?1, ?2, ?3) ;";
sql_set_pgp_keypair = "insert or replace into pgp_keypair (fpr) "
"values (?1) ;";
sql_set_identity = "insert or replace into identity (address, main_key_id, "
"user_id) values (?1, ?2, ?3) ;";
sql_set_trust = "insert or replace into trust (user_id, pgp_keypair_fpr, comm_type) "
"values (?1, ?2, ?3) ;";
int_result = sqlite3_exec(
_session->db,
"insert or replace into version_info (id, version) values (1, '1.0');",
NULL,
NULL,
NULL
);
assert(int_result == SQLITE_OK);
sql_get_trust = "select user_id, comm_type from trust where user_id = ?1 "
"and pgp_keypair_fpr = ?2 ;";
}
sql_log = "insert into log (title, entity, description, comment)"
"values (?1, ?2, ?3, ?4);";
int_result = sqlite3_prepare_v2(_session->db, sql_log, strlen(sql_log),
&_session->log, NULL);
assert(int_result == SQLITE_OK);
sql_safeword = "select id, word from wordlist where lang = lower(?1)"
"and id = ?2 ;";
int_result = sqlite3_prepare_v2(_session->system_db, sql_safeword,
strlen(sql_safeword), &_session->safeword, NULL);
assert(int_result == SQLITE_OK);
sql_get_identity = "select fpr, identity.user_id, username, comm_type, lang"
" from identity"
" join person on id = identity.user_id"
" join pgp_keypair on fpr = identity.main_key_id"
" join trust on id = trust.user_id"
" and pgp_keypair_fpr = identity.main_key_id"
" where address = ?1 ;";
int_result = sqlite3_prepare_v2(_session->db, sql_get_identity,
strlen(sql_get_identity), &_session->get_identity, NULL);
assert(int_result == SQLITE_OK);
sql_set_person = "insert or replace into person (id, username, lang)"
"values (?1, ?2, ?3) ;";
sql_set_pgp_keypair = "insert or replace into pgp_keypair (fpr)"
"values (?1) ;";
sql_set_identity = "insert or replace into identity (address, main_key_id,"
"user_id) values (?1, ?2, ?3) ;";
sql_set_trust = "insert or replace into trust (user_id, pgp_keypair_fpr, comm_type)"
"values (?1, ?2, ?3) ;";
sql_get_trust = "select user_id, comm_type from trust where user_id = ?1 and pgp_keypair_fpr = ?2 ;";
int_result = sqlite3_prepare_v2(_session->db, sql_set_person,
strlen(sql_set_person), &_session->set_person, NULL);
assert(int_result == SQLITE_OK);
int_result = sqlite3_prepare_v2(_session->db, sql_set_pgp_keypair,
strlen(sql_set_pgp_keypair), &_session->set_pgp_keypair, NULL);
assert(int_result == SQLITE_OK);
int_result = sqlite3_prepare_v2(_session->db, sql_set_identity,
strlen(sql_set_identity), &_session->set_identity, NULL);
assert(int_result == SQLITE_OK);
int_result = sqlite3_prepare_v2(_session->db, sql_set_trust,
strlen(sql_set_trust), &_session->set_trust, NULL);
assert(int_result == SQLITE_OK);
int_result = sqlite3_prepare_v2(_session->db, sql_get_trust,
strlen(sql_get_trust), &_session->get_trust, NULL);
assert(int_result == SQLITE_OK);
@ -225,14 +237,27 @@ DYNAMIC_API PEP_STATUS init(PEP_SESSION *session)
} while (int_result == SQLITE_BUSY);
sqlite3_reset(_session->log);
init_cryptotech(_session, in_first);
init_transport_system(_session, in_first);
*session = (void *) _session;
return PEP_STATUS_OK;
}
DYNAMIC_API void release(PEP_SESSION session)
{
bool out_last = false;
assert(init_count >= 0);
assert(session);
// a small race condition but still a race condition
// removed by calling caveat (see documentation)
if (init_count == 0)
out_last = true;
--init_count;
if (session) {
if (session->db) {
sqlite3_finalize(session->safeword);
@ -247,10 +272,11 @@ DYNAMIC_API void release(PEP_SESSION session)
sqlite3_close_v2(session->db);
sqlite3_close_v2(session->system_db);
}
release_transport_system(session);
release_cryptotech(session);
}
release_transport_system(session, out_last);
release_cryptotech(session, out_last);
free(session);
}


+ 7
- 0
src/pEpEngine.h View File

@ -95,6 +95,9 @@ typedef enum {
// the pointer is valid only if the return value is PEP_STATUS_OK
// in other case a NULL pointer will be returned; a valid handle must
// be released using release() when it's no longer needed
//
// the caller has to guarantee that the first call to this function
// will succeed before further calls can be done
DYNAMIC_API PEP_STATUS init(PEP_SESSION *session);
@ -103,6 +106,10 @@ DYNAMIC_API PEP_STATUS init(PEP_SESSION *session);
//
// parameters:
// session (in) session handle to release
//
// caveat:
// the last release() can be called only when all other release() calls
// are done
DYNAMIC_API void release(PEP_SESSION session);


+ 5
- 6
src/pEp_internal.h View File

@ -62,15 +62,14 @@
typedef struct _pEpSession {
const char *version;
#ifndef NO_GPG
void *gpgme;
struct gpg_s gpg;
struct gpg_s *gpg;
gpgme_ctx_t ctx;
#endif
PEP_cryptotech_t cryptotech[PEP_crypt__count];
PEP_transport_t transports[PEP_trans__count];
PEP_cryptotech_t *cryptotech;
PEP_transport_t *transports;
sqlite3 *db;
sqlite3 *system_db;
@ -85,6 +84,6 @@ typedef struct _pEpSession {
sqlite3_stmt *get_trust;
} pEpSession;
PEP_STATUS init_transport_system(PEP_SESSION session);
void release_transport_system(PEP_SESSION session);
PEP_STATUS init_transport_system(PEP_SESSION session, bool in_first);
void release_transport_system(PEP_SESSION session, bool out_last);

+ 342
- 295
src/pgp_gpg.c
File diff suppressed because it is too large
View File


+ 2
- 2
src/pgp_gpg.h View File

@ -2,8 +2,8 @@
#include "pEpEngine.h"
PEP_STATUS pgp_init(PEP_SESSION session);
void pgp_release(PEP_SESSION session);
PEP_STATUS pgp_init(PEP_SESSION session, bool in_first);
void pgp_release(PEP_SESSION session, bool out_last);
PEP_STATUS pgp_decrypt_and_verify(
PEP_SESSION session, const char *ctext, size_t csize,


+ 1
- 0
src/pgp_gpg_internal.h View File

@ -68,6 +68,7 @@ typedef void(*gpgme_key_ref_t)(gpgme_key_t KEY);
typedef void(*gpgme_key_unref_t)(gpgme_key_t KEY);
struct gpg_s {
const char * version;
gpgme_check_version_t gpgme_check;
gpgme_set_locale_t gpgme_set_locale;
gpgme_new_t gpgme_new;


+ 12
- 10
src/transport.c View File

@ -4,24 +4,26 @@
#include <memory.h>
#include <assert.h>
PEP_STATUS init_transport_system(PEP_SESSION session)
PEP_STATUS init_transport_system(PEP_SESSION session, bool in_first)
{
static PEP_transport_t transports[PEP_trans__count];
assert(session);
session->transports = transports;
pEpSession *_session = (pEpSession *) session;
PEP_transport_t* transports = _session->transports;
if (in_first) {
assert(PEP_trans__count == 1);
memset(transports, 0, sizeof(PEP_transport_t) * PEP_trans__count);
assert(PEP_trans__count == 1);
memset(transports, 0, sizeof(PEP_transport_t) * PEP_trans__count);
transports[PEP_trans_auto].id = PEP_trans_auto;
transports[PEP_trans_auto].sendto = auto_sendto;
transports[PEP_trans_auto].readnext = auto_readnext;
transports[PEP_trans_auto].id = PEP_trans_auto;
transports[PEP_trans_auto].sendto = auto_sendto;
transports[PEP_trans_auto].readnext = auto_readnext;
}
return PEP_STATUS_OK;
}
void release_transport_system(PEP_SESSION session)
void release_transport_system(PEP_SESSION session, bool out_last)
{
assert(session);
// nothing yet


Loading…
Cancel
Save