Browse Source

...

generate_api
Volker Birk 4 years ago
parent
commit
5eed70d884
13 changed files with 207 additions and 258 deletions
  1. +2
    -2
      src/cryptotech.c
  2. +43
    -77
      src/keymanagement.c
  3. +2
    -2
      src/keymanagement.h
  4. +81
    -81
      src/message_api.c
  5. +19
    -19
      src/mime.c
  6. +26
    -26
      src/pEpEngine.c
  7. +4
    -4
      src/pEpEngine.h
  8. +4
    -4
      src/pEp_internal.h
  9. +5
    -5
      src/pgp_gpg.c
  10. +19
    -37
      src/sync.c
  11. +0
    -1
      src/sync.h
  12. +1
    -0
      src/sync_impl.h
  13. +1
    -0
      sync/gen_statemachine.ysl2

+ 2
- 2
src/cryptotech.c View File

@ -62,11 +62,11 @@ PEP_STATUS init_cryptotech(PEP_SESSION session, bool in_first)
status = pgp_init(session, in_first);
if (status != PEP_STATUS_OK)
goto pep_error;
goto pEp_error;
return PEP_STATUS_OK;
pep_error:
pEp_error:
pgp_release(session, in_first);
return status;
}


+ 43
- 77
src/keymanagement.c View File

@ -134,11 +134,11 @@ static PEP_STATUS validate_fpr(PEP_SESSION session,
ident->comm_type = ct;
}
bool pep_user = false;
bool pEp_user = false;
is_pep_user(session, ident, &pep_user);
is_pEp_user(session, ident, &pEp_user);
if (pep_user) {
if (pEp_user) {
switch (ct) {
case PEP_ct_OpenPGP:
case PEP_ct_OpenPGP_unconfirmed:
@ -369,7 +369,7 @@ static void transfer_ident_lang_and_flags(pEp_identity* new_ident,
new_ident->me = new_ident->me || stored_ident->me;
}
static void adjust_pep_trust_status(PEP_SESSION session, pEp_identity* identity) {
static void adjust_pEp_trust_status(PEP_SESSION session, pEp_identity* identity) {
assert(session);
assert(identity);
@ -377,11 +377,11 @@ static void adjust_pep_trust_status(PEP_SESSION session, pEp_identity* identity)
(identity->comm_type | PEP_ct_confirmed) == PEP_ct_pEp)
return;
bool pep_user;
bool pEp_user;
is_pep_user(session, identity, &pep_user);
is_pEp_user(session, identity, &pEp_user);
if (pep_user) {
if (pEp_user) {
PEP_comm_type confirmation_status = identity->comm_type & PEP_ct_confirmed;
identity->comm_type = PEP_ct_pEp_unconfirmed | confirmation_status;
}
@ -456,7 +456,7 @@ static PEP_STATUS prepare_updated_identity(PEP_SESSION session,
return_id->user_id = strdup(stored_ident->user_id);
}
adjust_pep_trust_status(session, return_id);
adjust_pEp_trust_status(session, return_id);
// Call set_identity() to store
if ((is_identity_default || is_user_default) &&
@ -615,7 +615,7 @@ DYNAMIC_API PEP_STATUS update_identity(
// * call set_identity() to store
if (status == PEP_STATUS_OK) {
// FIXME: Do we set if we had to copy in the address?
adjust_pep_trust_status(session, identity);
adjust_pEp_trust_status(session, identity);
status = set_identity(session, identity);
}
// * Return: created identity
@ -709,7 +709,7 @@ DYNAMIC_API PEP_STATUS update_identity(
status = get_key_rating(session, identity->fpr, &identity->comm_type);
// * call set_identity() to store
adjust_pep_trust_status(session, identity);
adjust_pEp_trust_status(session, identity);
status = set_identity(session, identity);
}
}
@ -776,7 +776,7 @@ DYNAMIC_API PEP_STATUS update_identity(
status = get_key_rating(session, identity->fpr, &identity->comm_type);
// * call set_identity() to store
adjust_pep_trust_status(session, identity);
adjust_pEp_trust_status(session, identity);
status = set_identity(session, identity);
}
@ -789,12 +789,12 @@ DYNAMIC_API PEP_STATUS update_identity(
if (session->examine_identity)
session->examine_identity(identity, session->examine_management);
goto pep_free;
goto pEp_free;
enomem:
status = PEP_OUT_OF_MEMORY;
pep_free:
pEp_free:
free(default_own_id);
free_identity(stored_ident);
return status;
@ -908,13 +908,13 @@ PEP_STATUS _myself(PEP_SESSION session, pEp_identity * identity, bool do_keygen,
status = set_userid_alias(session, default_own_id, identity->user_id);
// Do we want this to be fatal? For now, we'll do it...
if (status != PEP_STATUS_OK)
goto pep_free;
goto pEp_free;
free(identity->user_id);
identity->user_id = strdup(default_own_id);
if (identity->user_id == NULL) {
status = PEP_OUT_OF_MEMORY;
goto pep_free;
goto pEp_free;
}
}
@ -941,7 +941,7 @@ PEP_STATUS _myself(PEP_SESSION session, pEp_identity * identity, bool do_keygen,
assert(status != PEP_OUT_OF_MEMORY);
if (status == PEP_OUT_OF_MEMORY) {
status = PEP_OUT_OF_MEMORY;
goto pep_free;
goto pEp_free;
}
// Set usernames - priority is input username > stored name > address
@ -954,7 +954,7 @@ PEP_STATUS _myself(PEP_SESSION session, pEp_identity * identity, bool do_keygen,
identity->username = strdup(uname);
if (identity->username == NULL) {
status = PEP_OUT_OF_MEMORY;
goto pep_free;
goto pEp_free;
}
}
@ -970,14 +970,14 @@ PEP_STATUS _myself(PEP_SESSION session, pEp_identity * identity, bool do_keygen,
// Fall back / retrieve
status = validate_fpr(session, stored_identity, false);
if (status == PEP_OUT_OF_MEMORY)
goto pep_free;
goto pEp_free;
if (status == PEP_STATUS_OK) {
if (stored_identity->comm_type >= PEP_ct_strong_but_unconfirmed) {
identity->fpr = strdup(stored_identity->fpr);
assert(identity->fpr);
if (!identity->fpr) {
status = PEP_OUT_OF_MEMORY;
goto pep_free;
goto pEp_free;
}
valid_key_found = true;
}
@ -985,13 +985,13 @@ PEP_STATUS _myself(PEP_SESSION session, pEp_identity * identity, bool do_keygen,
bool revoked = false;
status = key_revoked(session, stored_identity->fpr, &revoked);
if (status)
goto pep_free;
goto pEp_free;
if (revoked) {
revoked_fpr = strdup(stored_identity->fpr);
assert(revoked_fpr);
if (!revoked_fpr) {
status = PEP_OUT_OF_MEMORY;
goto pep_free;
goto pEp_free;
}
}
}
@ -1037,41 +1037,15 @@ PEP_STATUS _myself(PEP_SESSION session, pEp_identity * identity, bool do_keygen,
status = set_identity(session, identity);
if (status == PEP_STATUS_OK)
status = set_as_pep_user(session, identity);
status = set_as_pEp_user(session, identity);
pep_free:
pEp_free:
free(default_own_id);
free(revoked_fpr);
free_identity(stored_identity);
return status;
}
// DYNAMIC_API PEP_STATUS initialise_own_identities(PEP_SESSION session,
// identity_list* my_idents) {
// PEP_STATUS status = PEP_STATUS_OK;
// if (!session)
// return PEP_ILLEGAL_VALUE;
//
// if (!my_idents)
// return PEP_STATUS_OK;
//
// identity_list* ident_curr = my_idents;
// while (ident_curr) {
// pEp_identity* ident = ident_curr->ident;
// if (!ident || !ident->address) {
// status = PEP_ILLEGAL_VALUE;
// goto pep_error;
// }
//
// status = _myself(session, ident, false, false);
//
// ident_curr = ident_curr->next;
// }
//
// pep_error:
// return status;
// }
DYNAMIC_API PEP_STATUS myself(PEP_SESSION session, pEp_identity * identity)
{
return _myself(session, identity, true, false);
@ -1094,26 +1068,19 @@ DYNAMIC_API PEP_STATUS register_examine_function(
}
DYNAMIC_API PEP_STATUS do_keymanagement(
PEP_SESSION session,
retrieve_next_identity_t retrieve_next_identity,
messageToSend_t messageToSend,
void *management
)
{
PEP_SESSION session;
pEp_identity *identity;
PEP_STATUS status;
assert(retrieve_next_identity);
assert(management);
if (!retrieve_next_identity || !management)
assert(session && retrieve_next_identity);
if (!(session && retrieve_next_identity))
return PEP_ILLEGAL_VALUE;
status = init(&session, messageToSend);
assert(status == PEP_STATUS_OK);
if (status != PEP_STATUS_OK)
return status;
log_event(session, "keymanagement thread started", "pEp engine", NULL, NULL);
while ((identity = retrieve_next_identity(management)))
@ -1138,7 +1105,6 @@ DYNAMIC_API PEP_STATUS do_keymanagement(
log_event(session, "keymanagement thread shutdown", "pEp engine", NULL, NULL);
release(session);
return PEP_STATUS_OK;
}
@ -1212,7 +1178,7 @@ DYNAMIC_API PEP_STATUS undo_last_mistrust(PEP_SESSION session) {
// THIS SHOULDN'T BE NECESSARY - PREVIOUS VALUE WAS IN THE DB
// if (status == PEP_STATUS_OK) {
// if ((cached_ident->comm_type | PEP_ct_confirmed) == PEP_ct_pEp)
// status = set_as_pep_user(session, cached_ident);
// status = set_as_pEp_user(session, cached_ident);
// }
free_identity(session->cached_mistrusted);
}
@ -1248,18 +1214,18 @@ DYNAMIC_API PEP_STATUS key_reset_trust(
status = get_trust(session, input_copy);
if (status != PEP_STATUS_OK)
goto pep_free;
goto pEp_free;
PEP_comm_type new_trust = PEP_ct_unknown;
status = get_key_rating(session, ident->fpr, &new_trust);
if (status != PEP_STATUS_OK)
goto pep_free;
goto pEp_free;
bool pep_user = false;
bool pEp_user = false;
status = is_pep_user(session, ident, &pep_user);
status = is_pEp_user(session, ident, &pEp_user);
if (pep_user && new_trust >= PEP_ct_unconfirmed_encryption)
if (pEp_user && new_trust >= PEP_ct_unconfirmed_encryption)
input_copy->comm_type = PEP_ct_pEp_unconfirmed;
else
input_copy->comm_type = new_trust;
@ -1267,20 +1233,20 @@ DYNAMIC_API PEP_STATUS key_reset_trust(
status = set_trust(session, input_copy);
if (status != PEP_STATUS_OK)
goto pep_free;
goto pEp_free;
bool mistrusted_key = false;
status = is_mistrusted_key(session, ident->fpr, &mistrusted_key);
if (status != PEP_STATUS_OK)
goto pep_free;
goto pEp_free;
if (mistrusted_key)
status = delete_mistrusted_key(session, ident->fpr);
if (status != PEP_STATUS_OK)
goto pep_free;
goto pEp_free;
tmp_ident = new_identity(ident->address, NULL, ident->user_id, NULL);
@ -1293,7 +1259,7 @@ DYNAMIC_API PEP_STATUS key_reset_trust(
status = update_identity(session, tmp_ident);
if (status != PEP_STATUS_OK)
goto pep_free;
goto pEp_free;
// remove as default if necessary
if (!EMPTYSTR(tmp_ident->fpr) && strcmp(tmp_ident->fpr, ident->fpr) == 0) {
@ -1302,7 +1268,7 @@ DYNAMIC_API PEP_STATUS key_reset_trust(
tmp_ident->comm_type = PEP_ct_unknown;
status = set_identity(session, tmp_ident);
if (status != PEP_STATUS_OK)
goto pep_free;
goto pEp_free;
}
char* user_default = NULL;
@ -1312,10 +1278,10 @@ DYNAMIC_API PEP_STATUS key_reset_trust(
if (strcmp(user_default, ident->fpr) == 0)
status = refresh_userid_default_key(session, ident->user_id);
if (status != PEP_STATUS_OK)
goto pep_free;
goto pEp_free;
}
pep_free:
pEp_free:
free_identity(tmp_ident);
free_identity(input_copy);
return status;
@ -1367,11 +1333,11 @@ DYNAMIC_API PEP_STATUS trust_personal_key(
// first of all, does this key even have a private component.
status = contains_priv_key(session, ident->fpr, &has_private);
if (status != PEP_STATUS_OK && status != PEP_KEY_NOT_FOUND)
goto pep_free;
goto pEp_free;
if (has_private) {
status = set_own_key(session, ident_copy, ident->fpr);
goto pep_free;
goto pEp_free;
}
}
@ -1424,7 +1390,7 @@ DYNAMIC_API PEP_STATUS trust_personal_key(
status = set_identity(session, ident_copy); // replace identity default
if (status == PEP_STATUS_OK) {
if ((ident_copy->comm_type | PEP_ct_confirmed) == PEP_ct_pEp)
status = set_as_pep_user(session, ident_copy);
status = set_as_pEp_user(session, ident_copy);
}
}
}
@ -1463,7 +1429,7 @@ DYNAMIC_API PEP_STATUS trust_personal_key(
}
}
pep_free:
pEp_free:
free(ident_default_fpr);
free(cached_fpr);
free_identity(tmp_id);


+ 2
- 2
src/keymanagement.h View File

@ -164,6 +164,7 @@ DYNAMIC_API PEP_STATUS register_examine_function(
// do_keymanagement() - function to be run on an extra thread
//
// parameters:
// session (in) session to use
// retrieve_next_identity (in) pointer to retrieve_next_identity()
// callback which returns at least a valid
// address field in the identity struct
@ -177,8 +178,6 @@ DYNAMIC_API PEP_STATUS register_examine_function(
// value on failure
//
// caveat:
// this function is creating and releasing a new session
//
// to ensure proper working of this library, a thread has to be started
// with this function immediately after initialization
//
@ -188,6 +187,7 @@ DYNAMIC_API PEP_STATUS register_examine_function(
// if transport system is not used it must not be NULL
DYNAMIC_API PEP_STATUS do_keymanagement(
PEP_SESSION session,
retrieve_next_identity_t retrieve_next_identity,
messageToSend_t messageToSend,
void *management


+ 81
- 81
src/message_api.c View File

@ -34,9 +34,9 @@ static bool is_wrapper(message* src)
bool retval = false;
if (src) {
unsigned char pepstr[] = PEP_SUBJ_STRING;
unsigned char pEpstr[] = PEP_SUBJ_STRING;
if (is_a_pEpmessage(src) || (src->shortmsg == NULL || strcmp(src->shortmsg, "pEp") == 0 ||
_unsigned_signed_strcmp(pepstr, src->shortmsg, PEP_SUBJ_BYTELEN) == 0) ||
_unsigned_signed_strcmp(pEpstr, src->shortmsg, PEP_SUBJ_BYTELEN) == 0) ||
(strcmp(src->shortmsg, "p=p") == 0)) {
char* plaintext = src->longmsg;
if (plaintext) {
@ -353,11 +353,11 @@ static char * combine_short_and_long(const char *shortmsg, const char *longmsg)
{
assert(shortmsg);
unsigned char pepstr[] = PEP_SUBJ_STRING;
assert(strcmp(shortmsg, "pEp") != 0 && _unsigned_signed_strcmp(pepstr, shortmsg, PEP_SUBJ_BYTELEN) != 0);
unsigned char pEpstr[] = PEP_SUBJ_STRING;
assert(strcmp(shortmsg, "pEp") != 0 && _unsigned_signed_strcmp(pEpstr, shortmsg, PEP_SUBJ_BYTELEN) != 0);
if (!shortmsg || strcmp(shortmsg, "pEp") == 0 ||
_unsigned_signed_strcmp(pepstr, shortmsg, PEP_SUBJ_BYTELEN) == 0) {
_unsigned_signed_strcmp(pEpstr, shortmsg, PEP_SUBJ_BYTELEN) == 0) {
if (!longmsg) {
return NULL;
}
@ -389,7 +389,7 @@ static char * combine_short_and_long(const char *shortmsg, const char *longmsg)
}
static PEP_STATUS replace_subject(message* msg) {
unsigned char pepstr[] = PEP_SUBJ_STRING;
unsigned char pEpstr[] = PEP_SUBJ_STRING;
if (msg->shortmsg && *(msg->shortmsg) != '\0') {
char* longmsg = combine_short_and_long(msg->shortmsg, msg->longmsg);
if (!longmsg)
@ -403,7 +403,7 @@ static PEP_STATUS replace_subject(message* msg) {
#ifdef WIN32
msg->shortmsg = strdup("pEp");
#else
msg->shortmsg = strdup((char*)pepstr);
msg->shortmsg = strdup((char*)pEpstr);
#endif
if (!msg->shortmsg)
@ -807,7 +807,7 @@ static message* extract_minimal_envelope(const message* src,
if (!envelope)
return NULL;
envelope->shortmsg = _pep_subj_copy();
envelope->shortmsg = _pEp_subj_copy();
if (!envelope->shortmsg)
goto enomem;
@ -1028,7 +1028,7 @@ static PEP_STATUS encrypt_PGP_MIME(
status = _mime_encode_message_internal(_src, true, &mimetext, mime_encode);
assert(status == PEP_STATUS_OK);
if (status != PEP_STATUS_OK)
goto pep_error;
goto pEp_error;
if (free_ptext){
free(ptext);
@ -1038,7 +1038,7 @@ static PEP_STATUS encrypt_PGP_MIME(
_src = NULL;
assert(mimetext);
if (mimetext == NULL)
goto pep_error;
goto pEp_error;
if (flags & PEP_encrypt_flag_force_unsigned)
status = encrypt_only(session, keys, mimetext, strlen(mimetext),
@ -1048,7 +1048,7 @@ static PEP_STATUS encrypt_PGP_MIME(
&ctext, &csize);
free(mimetext);
if (ctext == NULL)
goto pep_error;
goto pEp_error;
dst->longmsg = strdup("this message was encrypted with p≡p "
"https://pEp-project.org");
@ -1076,7 +1076,7 @@ static PEP_STATUS encrypt_PGP_MIME(
enomem:
status = PEP_OUT_OF_MEMORY;
pep_error:
pEp_error:
if (free_ptext)
free(ptext);
free(_src);
@ -1597,7 +1597,7 @@ DYNAMIC_API PEP_STATUS encrypt_message(
status = myself(session, src->from);
if (status != PEP_STATUS_OK)
goto pep_error;
goto pEp_error;
keys = new_stringlist(src->from->fpr);
if (keys == NULL)
@ -1644,7 +1644,7 @@ DYNAMIC_API PEP_STATUS encrypt_message(
if (_status != PEP_STATUS_OK) {
// DB error
status = PEP_UNENCRYPTED;
goto pep_error;
goto pEp_error;
}
if (is_blacklisted) {
bool user_default, ident_default, address_default;
@ -1665,7 +1665,7 @@ DYNAMIC_API PEP_STATUS encrypt_message(
_status = myself(session, _il->ident);
if (_status != PEP_STATUS_OK) {
status = PEP_UNENCRYPTED;
goto pep_error;
goto pEp_error;
}
if (_il->ident->fpr && _il->ident->fpr[0]) {
@ -1696,7 +1696,7 @@ DYNAMIC_API PEP_STATUS encrypt_message(
if (_status != PEP_STATUS_OK) {
// DB error
status = PEP_UNENCRYPTED;
goto pep_error;
goto pEp_error;
}
if (is_blacklisted) {
bool user_default, ident_default, address_default;
@ -1717,7 +1717,7 @@ DYNAMIC_API PEP_STATUS encrypt_message(
_status = myself(session, _il->ident);
if (_status != PEP_STATUS_OK) {
status = PEP_UNENCRYPTED;
goto pep_error;
goto pEp_error;
}
if (_il->ident->fpr && _il->ident->fpr[0]) {
@ -1747,7 +1747,7 @@ DYNAMIC_API PEP_STATUS encrypt_message(
if (_status != PEP_STATUS_OK) {
// DB error
status = PEP_UNENCRYPTED;
goto pep_error;
goto pEp_error;
}
if (is_blacklisted) {
bool user_default, ident_default, address_default;
@ -1769,7 +1769,7 @@ DYNAMIC_API PEP_STATUS encrypt_message(
if (_status != PEP_STATUS_OK)
{
status = PEP_UNENCRYPTED;
goto pep_error;
goto pEp_error;
}
if (_il->ident->fpr && _il->ident->fpr[0]) {
@ -1804,7 +1804,7 @@ DYNAMIC_API PEP_STATUS encrypt_message(
if ((!force_v_1) && ((max_comm_type | PEP_ct_confirmed) == PEP_ct_pEp)) {
_src = wrap_message_as_attachment(NULL, src, false);
if (!_src)
goto pep_error;
goto pEp_error;
}
else {
// hide subject
@ -1836,14 +1836,14 @@ DYNAMIC_API PEP_STATUS encrypt_message(
default:
assert(0);
status = PEP_ILLEGAL_VALUE;
goto pep_error;
goto pEp_error;
}
if (status == PEP_OUT_OF_MEMORY)
goto enomem;
if (status != PEP_STATUS_OK)
goto pep_error;
goto pEp_error;
}
free_stringlist(keys);
@ -1879,7 +1879,7 @@ DYNAMIC_API PEP_STATUS encrypt_message(
enomem:
status = PEP_OUT_OF_MEMORY;
pep_error:
pEp_error:
free_stringlist(keys);
free_message(msg);
if (_src && _src != src)
@ -1942,7 +1942,7 @@ DYNAMIC_API PEP_STATUS encrypt_message_and_add_priv_key(
status = get_userid_alias_default(session, src->from->user_id, &default_id);
if (status != PEP_STATUS_OK || !default_id || strcmp(default_id, own_id) != 0) {
status = PEP_ILLEGAL_VALUE;
goto pep_free;
goto pEp_free;
}
}
}
@ -1954,7 +1954,7 @@ DYNAMIC_API PEP_STATUS encrypt_message_and_add_priv_key(
status = myself(session, own_identity);
if (status != PEP_STATUS_OK)
goto pep_free;
goto pEp_free;
// Ok, now we know the address is an own address. All good. Then...
own_private_fpr = own_identity->fpr;
@ -1965,12 +1965,12 @@ DYNAMIC_API PEP_STATUS encrypt_message_and_add_priv_key(
if (status != PEP_STATUS_OK) {
if (status == PEP_CANNOT_FIND_IDENTITY)
status = PEP_ILLEGAL_VALUE;
goto pep_free;
goto pEp_free;
}
if ((own_identity->comm_type & PEP_ct_confirmed) != PEP_ct_confirmed) {
status = PEP_ILLEGAL_VALUE;
goto pep_free;
goto pEp_free;
}
// Ok, so all the things are now allowed.
@ -1981,18 +1981,18 @@ DYNAMIC_API PEP_STATUS encrypt_message_and_add_priv_key(
&priv_key_size);
if (status != PEP_STATUS_OK)
goto pep_free;
goto pEp_free;
if (!priv_key_data) {
status = PEP_CANNOT_EXPORT_KEY;
goto pep_free;
goto pEp_free;
}
// Ok, fine... let's encrypt yon blob
keys = new_stringlist(own_private_fpr);
if (!keys) {
status = PEP_OUT_OF_MEMORY;
goto pep_free;
goto pEp_free;
}
stringlist_add(keys, to_fpr);
@ -2009,7 +2009,7 @@ DYNAMIC_API PEP_STATUS encrypt_message_and_add_priv_key(
if (!encrypted_key_text) {
status = PEP_UNKNOWN_ERROR;
goto pep_free;
goto pEp_free;
}
// We will have to delete this before returning, as we allocated it.
@ -2042,7 +2042,7 @@ DYNAMIC_API PEP_STATUS encrypt_message_and_add_priv_key(
if (!created_bl) {
status = PEP_OUT_OF_MEMORY;
goto pep_free;
goto pEp_free;
}
// Ok, it's in there. Let's do this.
@ -2059,7 +2059,7 @@ DYNAMIC_API PEP_STATUS encrypt_message_and_add_priv_key(
src->attachments = NULL;
}
pep_free:
pEp_free:
free(own_id);
free(default_id);
free(own_private_fpr);
@ -2112,7 +2112,7 @@ DYNAMIC_API PEP_STATUS encrypt_message_for_self(
if (target_id->address) {
status = myself(session, target_id);
if (status != PEP_STATUS_OK)
goto pep_error;
goto pEp_error;
}
else if (!target_id->fpr)
return PEP_ILLEGAL_VALUE;
@ -2122,7 +2122,7 @@ DYNAMIC_API PEP_STATUS encrypt_message_for_self(
// PEP_STATUS _status = update_identity(session, target_id);
// if (_status != PEP_STATUS_OK) {
// status = _status;
// goto pep_error;
// goto pEp_error;
// }
char* target_fpr = target_id->fpr;
@ -2145,7 +2145,7 @@ DYNAMIC_API PEP_STATUS encrypt_message_for_self(
_src = wrap_message_as_attachment(NULL, src, false);
if (!_src)
goto pep_error;
goto pEp_error;
msg = clone_to_empty_message(_src);
if (msg == NULL)
@ -2162,17 +2162,17 @@ DYNAMIC_API PEP_STATUS encrypt_message_for_self(
default:
assert(0);
status = PEP_ILLEGAL_VALUE;
goto pep_error;
goto pEp_error;
}
if (status == PEP_OUT_OF_MEMORY)
goto enomem;
if (status != PEP_STATUS_OK)
goto pep_error;
goto pEp_error;
if (msg && msg->shortmsg == NULL) {
msg->shortmsg = _pep_subj_copy();
msg->shortmsg = _pEp_subj_copy();
assert(msg->shortmsg);
if (msg->shortmsg == NULL)
goto enomem;
@ -2198,7 +2198,7 @@ DYNAMIC_API PEP_STATUS encrypt_message_for_self(
enomem:
status = PEP_OUT_OF_MEMORY;
pep_error:
pEp_error:
free_stringlist(keys);
free_message(msg);
if (src != _src)
@ -2482,7 +2482,7 @@ static PEP_STATUS unencapsulate_hidden_fields(message* src, message* msg,
char** msg_wrap_info) {
if (!src)
return PEP_ILLEGAL_VALUE;
unsigned char pepstr[] = PEP_SUBJ_STRING;
unsigned char pEpstr[] = PEP_SUBJ_STRING;
PEP_STATUS status = PEP_STATUS_OK;
bool change_source_in_place = (msg ? false : true);
@ -2505,7 +2505,7 @@ static PEP_STATUS unencapsulate_hidden_fields(message* src, message* msg,
// FIXME: This is a mess. Talk with VB about how far we go to identify
if (is_a_pEpmessage(src) || (src->shortmsg == NULL || strcmp(src->shortmsg, "pEp") == 0 ||
_unsigned_signed_strcmp(pepstr, src->shortmsg, PEP_SUBJ_BYTELEN) == 0) ||
_unsigned_signed_strcmp(pEpstr, src->shortmsg, PEP_SUBJ_BYTELEN) == 0) ||
(strcmp(src->shortmsg, "p=p") == 0))
{
char * shortmsg = NULL;
@ -2526,7 +2526,7 @@ static PEP_STATUS unencapsulate_hidden_fields(message* src, message* msg,
if (!(*msg_wrap_info || change_source_in_place)) {
if (!shortmsg ||
(src->shortmsg != NULL && strcmp(src->shortmsg, "pEp") != 0 &&
_unsigned_signed_strcmp(pepstr, src->shortmsg, PEP_SUBJ_BYTELEN) != 0 &&
_unsigned_signed_strcmp(pEpstr, src->shortmsg, PEP_SUBJ_BYTELEN) != 0 &&
strcmp(src->shortmsg, "p=p") != 0)) {
if (shortmsg != NULL)
@ -2809,7 +2809,7 @@ static PEP_STATUS import_priv_keys_from_decrypted_msg(PEP_SESSION session,
return status;
}
static PEP_STATUS update_sender_to_pep_trust(
static PEP_STATUS update_sender_to_pEp_trust(
PEP_SESSION session,
pEp_identity* sender,
stringlist_t* keylist)
@ -3049,7 +3049,7 @@ DYNAMIC_API PEP_STATUS _decrypt_message(
size_t psize;
stringlist_t *_keylist = NULL;
char* signer_fpr = NULL;
bool is_pep_msg = is_a_pEpmessage(src);
bool is_pEp_msg = is_a_pEpmessage(src);
// Grab input flags
bool reencrypt = (((*flags & PEP_decrypt_flag_untrusted_server) > 0) && *keylist && !EMPTYSTR((*keylist)->value));
@ -3073,7 +3073,7 @@ DYNAMIC_API PEP_STATUS _decrypt_message(
// encrypted or not, we set the sender as a pEp user. This has NOTHING to do
// with the key.
if (src->from && !(is_me(session, src->from))) {
if (is_pep_msg) {
if (is_pEp_msg) {
pEp_identity* tmp_from = src->from;
// Ensure there's a user id
@ -3150,7 +3150,7 @@ DYNAMIC_API PEP_STATUS _decrypt_message(
&ptext, &psize, &_keylist);
if (status > PEP_CANNOT_DECRYPT_UNKNOWN)
goto pep_error;
goto pEp_error;
decrypt_status = status;
@ -3165,7 +3165,7 @@ DYNAMIC_API PEP_STATUS _decrypt_message(
status = mime_decode_message(ptext, psize, &msg);
if (status != PEP_STATUS_OK)
goto pep_error;
goto pEp_error;
/* Ensure messages whose maintext is in the attachments
move main text into message struct longmsg et al */
@ -3187,7 +3187,7 @@ DYNAMIC_API PEP_STATUS _decrypt_message(
&imported_private_key_address,
private_il);
if (status != PEP_STATUS_OK)
goto pep_error;
goto pEp_error;
/* if decrypted, but not verified... */
if (decrypt_status == PEP_DECRYPTED) {
@ -3230,7 +3230,7 @@ DYNAMIC_API PEP_STATUS _decrypt_message(
goto enomem;
if (status != PEP_STATUS_OK)
goto pep_error;
goto pEp_error;
if (decrypt_status == PEP_DECRYPTED || decrypt_status == PEP_DECRYPTED_AND_VERIFIED) {
char* wrap_info = NULL;
@ -3260,7 +3260,7 @@ DYNAMIC_API PEP_STATUS _decrypt_message(
actual_message->size,
&inner_message);
if (status != PEP_STATUS_OK)
goto pep_error;
goto pEp_error;
if (inner_message) {
// Though this will strip any message info on the
@ -3277,7 +3277,7 @@ DYNAMIC_API PEP_STATUS _decrypt_message(
if (strcmp(wrap_info, "INNER") == 0) {
if (status != PEP_STATUS_OK) {
free_message(inner_message);
goto pep_error;
goto pEp_error;
}
// check for private key in decrypted message attachment while importing
@ -3295,7 +3295,7 @@ DYNAMIC_API PEP_STATUS _decrypt_message(
&imported_private_key_address,
private_il);
if (status != PEP_STATUS_OK)
goto pep_error;
goto pEp_error;
// THIS is our message
// Now, let's make sure we've copied in
@ -3318,7 +3318,7 @@ DYNAMIC_API PEP_STATUS _decrypt_message(
else { // should never happen
status = PEP_UNKNOWN_ERROR;
free_message(inner_message);
goto pep_error;
goto pEp_error;
}
}
inner_message->enc_format = PEP_enc_none;
@ -3343,8 +3343,8 @@ DYNAMIC_API PEP_STATUS _decrypt_message(
// Ok, so if it was signed and it's all verified, we can update
// eligible signer comm_types to PEP_ct_pEp_*
if (decrypt_status == PEP_DECRYPTED_AND_VERIFIED && is_pep_msg)
status = update_sender_to_pep_trust(session, calculated_src->from, _keylist);
if (decrypt_status == PEP_DECRYPTED_AND_VERIFIED && is_pEp_msg)
status = update_sender_to_pEp_trust(session, calculated_src->from, _keylist);
/* Ok, now we have a keylist used for decryption/verification.
now we need to update the message rating with the
@ -3353,7 +3353,7 @@ DYNAMIC_API PEP_STATUS _decrypt_message(
rating, calculated_src->from, _keylist);
if (status != PEP_STATUS_OK)
goto pep_error;
goto pEp_error;
/* We decrypted ok, hallelujah. */
msg->enc_format = PEP_enc_none;
@ -3362,7 +3362,7 @@ DYNAMIC_API PEP_STATUS _decrypt_message(
// We did not get a plaintext out of the decryption process.
// Abort and return error.
*rating = decrypt_rating(decrypt_status);
goto pep_error;
goto pEp_error;
}
/*
@ -3454,7 +3454,7 @@ DYNAMIC_API PEP_STATUS _decrypt_message(
enomem:
status = PEP_OUT_OF_MEMORY;
pep_error:
pEp_error:
free(ptext);
free(signer_fpr);
free_message(msg);
@ -4016,7 +4016,7 @@ DYNAMIC_API PEP_STATUS MIME_decrypt_message(
status = mime_decode_message(mimetext, size, &tmp_msg);
if (status != PEP_STATUS_OK)
goto pep_error;
goto pEp_error;
// MIME decode message delivers only addresses. We need more.
if (tmp_msg->from) {
@ -4026,20 +4026,20 @@ DYNAMIC_API PEP_STATUS MIME_decrypt_message(
status = myself(session, tmp_msg->from);
if (status == PEP_ILLEGAL_VALUE || status == PEP_OUT_OF_MEMORY)
goto pep_error;
goto pEp_error;
}
status = update_identity_recip_list(session, tmp_msg->to);
if (status != PEP_STATUS_OK)
goto pep_error;
goto pEp_error;
status = update_identity_recip_list(session, tmp_msg->cc);
if (status != PEP_STATUS_OK)
goto pep_error;
goto pEp_error;
status = update_identity_recip_list(session, tmp_msg->bcc);
if (status != PEP_STATUS_OK)
goto pep_error;
goto pEp_error;
PEP_STATUS decrypt_status = decrypt_message(session,
tmp_msg,
@ -4056,7 +4056,7 @@ DYNAMIC_API PEP_STATUS MIME_decrypt_message(
if (decrypt_status > PEP_CANNOT_DECRYPT_UNKNOWN || !dec_msg)
{
status = decrypt_status;
goto pep_error;
goto pEp_error;
}
if (*flags & PEP_decrypt_flag_src_modified) {
@ -4077,7 +4077,7 @@ DYNAMIC_API PEP_STATUS MIME_decrypt_message(
return decrypt_status;
}
pep_error:
pEp_error:
free_message(tmp_msg);
free_message(dec_msg);
@ -4101,7 +4101,7 @@ DYNAMIC_API PEP_STATUS MIME_encrypt_message(
status = mime_decode_message(mimetext, size, &tmp_msg);
if (status != PEP_STATUS_OK)
goto pep_error;
goto pEp_error;
// MIME decode message delivers only addresses. We need more.
if (tmp_msg->from) {
@ -4118,7 +4118,7 @@ DYNAMIC_API PEP_STATUS MIME_encrypt_message(
status = myself(session, tmp_msg->from);
if (status != PEP_STATUS_OK)
goto pep_error;
goto pEp_error;
}
// Own identities can be retrieved here where they would otherwise
@ -4126,15 +4126,15 @@ DYNAMIC_API PEP_STATUS MIME_encrypt_message(
// desired. FIXME: IS it?
status = update_identity_recip_list(session, tmp_msg->to);
if (status != PEP_STATUS_OK)
goto pep_error;
goto pEp_error;
status = update_identity_recip_list(session, tmp_msg->cc);
if (status != PEP_STATUS_OK)
goto pep_error;
goto pEp_error;
status = update_identity_recip_list(session, tmp_msg->bcc);
if (status != PEP_STATUS_OK)
goto pep_error;
goto pEp_error;
// This isn't incoming, though... so we need to reverse the direction
tmp_msg->dir = PEP_dir_outgoing;
@ -4146,17 +4146,17 @@ DYNAMIC_API PEP_STATUS MIME_encrypt_message(
flags);
if (status != PEP_STATUS_OK)
goto pep_error;
goto pEp_error;
if (!enc_msg) {
status = PEP_UNKNOWN_ERROR;
goto pep_error;
goto pEp_error;
}
status = _mime_encode_message_internal(enc_msg, false, mime_ciphertext, false);
pep_error:
pEp_error:
free_message(tmp_msg);
free_message(enc_msg);
@ -4181,7 +4181,7 @@ DYNAMIC_API PEP_STATUS MIME_encrypt_message_for_self(
status = mime_decode_message(mimetext, size, &tmp_msg);
if (status != PEP_STATUS_OK)
goto pep_error;
goto pEp_error;
// This isn't incoming, though... so we need to reverse the direction
tmp_msg->dir = PEP_dir_outgoing;
@ -4193,16 +4193,16 @@ DYNAMIC_API PEP_STATUS MIME_encrypt_message_for_self(
enc_format,
flags);
if (status != PEP_STATUS_OK)
goto pep_error;
goto pEp_error;
if (!enc_msg) {
status = PEP_UNKNOWN_ERROR;
goto pep_error;
goto pEp_error;
}
status = mime_encode_message(enc_msg, false, mime_ciphertext);
pep_error:
pEp_error:
free_message(tmp_msg);
free_message(enc_msg);
@ -4322,7 +4322,7 @@ got_rating:
if (strcasecmp(i->value->key, "X-KeyList") == 0){
status = string_to_keylist(i->value->value, &_keylist);
if (status != PEP_STATUS_OK)
goto pep_error;
goto pEp_error;
must_free_keylist = true;
goto got_keylist;
}
@ -4353,7 +4353,7 @@ got_keylist:
case PEP_STATUS_OK:
break;
default:
goto pep_error;
goto pEp_error;
}
status = amend_rating_according_to_sender_and_recipients(session, &_rating,
@ -4361,7 +4361,7 @@ got_keylist:
if (status == PEP_STATUS_OK)
*rating = _rating;
pep_error:
pEp_error:
if (must_free_keylist)
free_stringlist(_keylist);


+ 19
- 19
src/mime.c View File

@ -84,12 +84,12 @@ static PEP_STATUS render_mime(struct mailmime *mime, char **mimetext)
err_file:
status = PEP_CANNOT_CREATE_TEMP_FILE;
goto pep_error;
goto pEp_error;
enomem:
status = PEP_OUT_OF_MEMORY;
pep_error:
pEp_error:
if (buffer)
mmap_string_free(buffer);
if (buf)
@ -111,10 +111,10 @@ static PEP_STATUS mime_attachment(
*result = NULL;
// TODO: It seems the pep com server adapter sends an empty string here,
// TODO: It seems the pEp COM server adapter sends an empty string here,
// which leads to a crash later. Thus, we workaround here by treating an
// empty string as NULL. We need to check whether the bug really is here,
// or the pep com server adapter needs to be changed.
// or the pEp COM server adapter needs to be changed.
if (blob->mime_type == NULL || blob->mime_type[0] == '\0')
mime_type = "application/octet-stream";
else
@ -437,11 +437,11 @@ static PEP_STATUS build_fields(const message *msg, struct mailimf_fields **resul
struct mailimf_fields * fields = NULL;
int r;
clist * fields_list = NULL;
unsigned char pepstr[] = PEP_SUBJ_STRING; // unsigned due to UTF-8 byte fun
unsigned char pEpstr[] = PEP_SUBJ_STRING; // unsigned due to UTF-8 byte fun
#ifdef WIN32
char* altstr = "pEp";
#else
char* altstr = (char*)pepstr;
char* altstr = (char*)pEpstr;
#endif
char *subject = msg->shortmsg ? msg->shortmsg : altstr;
@ -754,7 +754,7 @@ static PEP_STATUS mime_encode_message_plain(
transport_encode);
if (status != PEP_STATUS_OK)
goto pep_error;
goto pEp_error;
}
else {
pEp_rid_list_t* resource = NULL;
@ -814,7 +814,7 @@ static PEP_STATUS mime_encode_message_plain(
status = mime_attachment(_a, &submime, transport_encode);
if (status != PEP_STATUS_OK)
goto pep_error;
goto pEp_error;
r = mailmime_smart_add_part(mime, submime);
assert(r == MAILIMF_NO_ERROR);
@ -834,7 +834,7 @@ static PEP_STATUS mime_encode_message_plain(
enomem:
status = PEP_OUT_OF_MEMORY;
pep_error:
pEp_error:
if (mime)
mailmime_free(mime);
@ -977,7 +977,7 @@ PEP_STATUS _mime_encode_message_internal(
}
if (status != PEP_STATUS_OK)
goto pep_error;
goto pEp_error;
msg_mime = mailmime_new_message_data(NULL);
assert(msg_mime);
@ -994,14 +994,14 @@ PEP_STATUS _mime_encode_message_internal(
if (!omit_fields) {
status = build_fields(msg, &fields);
if (status != PEP_STATUS_OK)
goto pep_error;
goto pEp_error;
mailmime_set_imf_fields(msg_mime, fields);
}
status = render_mime(msg_mime, &buf);
if (status != PEP_STATUS_OK)
goto pep_error;
goto pEp_error;
mailmime_free(msg_mime);
*mimetext = buf;
@ -1011,7 +1011,7 @@ PEP_STATUS _mime_encode_message_internal(
enomem:
status = PEP_OUT_OF_MEMORY;
pep_error:
pEp_error:
if (msg_mime)
mailmime_free(msg_mime);
else
@ -1209,7 +1209,7 @@ static PEP_STATUS read_fields(message *msg, clist *fieldlist)
ident = mbl_to_identity(mbl);
if (ident == NULL)
goto pep_error;
goto pEp_error;
free_identity(msg->from);
msg->from = ident;
@ -1352,7 +1352,7 @@ static PEP_STATUS read_fields(message *msg, clist *fieldlist)
enomem:
status = PEP_OUT_OF_MEMORY;
pep_error:
pEp_error:
return status;
}
@ -1705,7 +1705,7 @@ DYNAMIC_API PEP_STATUS mime_decode_message(
if (_fieldlist) {
status = read_fields(_msg, _fieldlist);
if (status != PEP_STATUS_OK)
goto pep_error;
goto pEp_error;
}
struct mailmime_content *content = _get_content(mime);
@ -1714,7 +1714,7 @@ DYNAMIC_API PEP_STATUS mime_decode_message(
status = interpret_MIME(mime->mm_data.mm_message.mm_msg_mime,
_msg);
if (status != PEP_STATUS_OK)
goto pep_error;
goto pEp_error;
}
mailmime_free(mime);
@ -1724,12 +1724,12 @@ DYNAMIC_API PEP_STATUS mime_decode_message(
err_mime:
status = PEP_ILLEGAL_VALUE;
goto pep_error;
goto pEp_error;
enomem:
status = PEP_OUT_OF_MEMORY;
pep_error:
pEp_error:
free_message(_msg);
if (mime)


+ 26
- 26
src/pEpEngine.c View File

@ -284,7 +284,7 @@ static const char *sql_update_trust =
"update trust set comm_type = ?3 "
" where user_id = ?1 and pgp_keypair_fpr = upper(replace(?2,' ',''));";
static const char *sql_update_trust_to_pep =
static const char *sql_update_trust_to_pEp =
"update trust set comm_type = comm_type + 71 "
" where (user_id = ?1 "
" and (case when (comm_type = 56) then (1) "
@ -548,7 +548,7 @@ DYNAMIC_API PEP_STATUS init(
assert(LOCAL_DB);
if (LOCAL_DB == NULL) {
status = PEP_INIT_CANNOT_OPEN_DB;
goto pep_error;
goto pEp_error;
}
#if _PEP_SQLITE_DEBUG
@ -567,7 +567,7 @@ DYNAMIC_API PEP_STATUS init(
if (int_result != SQLITE_OK) {
status = PEP_INIT_CANNOT_OPEN_DB;
goto pep_error;
goto pEp_error;
}
int_result = sqlite3_exec(
@ -592,7 +592,7 @@ DYNAMIC_API PEP_STATUS init(
assert(SYSTEM_DB);
if (SYSTEM_DB == NULL) {
status = PEP_INIT_CANNOT_OPEN_SYSTEM_DB;
goto pep_error;
goto pEp_error;
}
int_result = sqlite3_open_v2(
@ -605,7 +605,7 @@ DYNAMIC_API PEP_STATUS init(
if (int_result != SQLITE_OK) {
status = PEP_INIT_CANNOT_OPEN_SYSTEM_DB;
goto pep_error;
goto pEp_error;
}
sqlite3_busy_timeout(_session->system_db, 1000);
@ -1154,8 +1154,8 @@ DYNAMIC_API PEP_STATUS init(
(int)strlen(sql_update_trust), &_session->update_trust, NULL);
assert(int_result == SQLITE_OK);
int_result = sqlite3_prepare_v2(_session->db, sql_update_trust_to_pep,
(int)strlen(sql_update_trust_to_pep), &_session->update_trust_to_pep, NULL);
int_result = sqlite3_prepare_v2(_session->db, sql_update_trust_to_pEp,
(int)strlen(sql_update_trust_to_pEp), &_session->update_trust_to_pEp, NULL);
assert(int_result == SQLITE_OK);
int_result = sqlite3_prepare_v2(_session->db, sql_exists_trust_entry,
@ -1270,15 +1270,15 @@ DYNAMIC_API PEP_STATUS init(
status = init_cryptotech(_session, in_first);
if (status != PEP_STATUS_OK)
goto pep_error;
goto pEp_error;
status = init_transport_system(_session, in_first);
if (status != PEP_STATUS_OK)
goto pep_error;
goto pEp_error;
status = log_event(_session, "init", "pEp " PEP_ENGINE_VERSION, NULL, NULL);
if (status != PEP_STATUS_OK)
goto pep_error;
goto pEp_error;
// runtime config
@ -1313,7 +1313,7 @@ DYNAMIC_API PEP_STATUS init(
enomem:
status = PEP_OUT_OF_MEMORY;
pep_error:
pEp_error:
release(_session);
return status;
}
@ -1390,8 +1390,8 @@ DYNAMIC_API void release(PEP_SESSION session)
sqlite3_finalize(session->set_trust);
if (session->update_trust)
sqlite3_finalize(session->update_trust);
if (session->update_trust_to_pep)
sqlite3_finalize(session->update_trust_to_pep);
if (session->update_trust_to_pEp)
sqlite3_finalize(session->update_trust_to_pEp);
if (session->update_trust_for_fpr)
sqlite3_finalize(session->update_trust_for_fpr);
if (session->get_trust)
@ -2384,20 +2384,20 @@ DYNAMIC_API PEP_STATUS set_identity(
status = set_person(session, ident_copy, false);
if (status != PEP_STATUS_OK) {
sqlite3_exec(session->db, "ROLLBACK ;", NULL, NULL, NULL);
goto pep_free;
goto pEp_free;
}
status = set_identity_entry(session, ident_copy, false);
if (status != PEP_STATUS_OK) {
sqlite3_exec(session->db, "ROLLBACK ;", NULL, NULL, NULL);
goto pep_free;
goto pEp_free;
}
if (has_fpr) {
status = _set_trust_internal(session, ident_copy, false);
if (status != PEP_STATUS_OK) {
sqlite3_exec(session->db, "ROLLBACK ;", NULL, NULL, NULL);
goto pep_free;
goto pEp_free;
}
}
@ -2407,7 +2407,7 @@ DYNAMIC_API PEP_STATUS set_identity(