added ENGINE-781

doxygen-key-id
commit aac1844f16

@ -54,6 +54,7 @@ clean:
$(MAKE) -C db clean
$(MAKE) -C asn.1 clean
$(MAKE) -C sync clean
$(MAKE) -C build-android clean
tags:
$(MAKE) -C asn.1 tags

@ -0,0 +1,13 @@
# Copyright 2020, pEp Foundation
# This file is part of pEpEngine - Android Build
# This file may be used under the terms of the GNU General Public License version 3
# see LICENSE.txt
include ../Makefile.conf
all:
echo "Placeholder command, this is meant to be cleaned by JNIAdapter Android build"
.PHONY: clean
clean:
rm -rf include/

@ -60,10 +60,6 @@
<Link>
<SubSystem>Windows</SubSystem>
</Link>
<PreBuildEvent>
<Command>cd "$(ProjectDir)..\.." &amp;&amp; "$(ProjectDir)..\generate_code.cmd"</Command>
<Message>Generating Code for pEp Sync</Message>
</PreBuildEvent>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
@ -81,10 +77,6 @@
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
<PreBuildEvent>
<Command>cd "$(ProjectDir)..\.." &amp;&amp; "$(ProjectDir)..\generate_code.cmd"</Command>
<Message>Generating Code for pEp Sync</Message>
</PreBuildEvent>
</ItemDefinitionGroup>
<ItemGroup>
<Text Include="ReadMe.txt" />
@ -227,4 +219,8 @@
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets" />
<Target Name="BeforeRebuild">
<Message Text="Generating Code for pEp Sync" />
<Exec Command="CD &quot;$(ProjectDir)..\..&quot; &amp;&amp; &quot;$(ProjectDir)..\generate_code.cmd&quot;" />
</Target>
</Project>

@ -28,7 +28,7 @@ endif
ifeq ($(BUILD_ON),Darwin)
ifeq ($(BUILD_FOR),Darwin)
CFLAGS+= -DSQLITE_THREADSAFE=1
LDLIBS+= -lz -liconv
LDLIBS+= -lz -liconv -mmacosx-version-min=10.10
else
$(error I do not know how to make for $(BUILD_FOR) on $(BUILD_ON))
endif

@ -551,6 +551,12 @@ timestamp * etpantime_to_timestamp(const struct mailimf_date_time *et)
result->tm_mon = et->dt_month - 1;
result->tm_year = et->dt_year - 1900;
result->tm_gmtoff = 36L * (long) et->dt_zone;
// Normalize to UTC and then forget the offset.
time_t t = timegm_with_gmtoff(result);
gmtime_r(&t, result);
result->tm_gmtoff = 0;
return result;
}

@ -626,6 +626,9 @@ PEP_STATUS receive_key_reset(PEP_SESSION session,
status = replace_main_user_fpr_if_equal(session, curr_ident->user_id,
new_fpr, old_fpr);
if (status != PEP_STATUS_OK)
return status;
// This only sets as the default, does NOT TRUST IN ANY WAY
PEP_comm_type new_key_rating = PEP_ct_unknown;
@ -771,8 +774,10 @@ PEP_STATUS create_standalone_key_reset_message(PEP_SESSION session,
if (!reset_msg)
return PEP_ILLEGAL_VALUE;
if (!reset_msg->attachments)
return PEP_UNKNOWN_ERROR;
if (!reset_msg->attachments) {
status = PEP_UNKNOWN_ERROR;
goto pEp_free;
}
message* output_msg = NULL;
@ -782,6 +787,8 @@ PEP_STATUS create_standalone_key_reset_message(PEP_SESSION session,
if (status == PEP_STATUS_OK)
*dst = output_msg;
else if (output_msg) // shouldn't happen, but...
free_message(output_msg);
pEp_free:
@ -968,6 +975,67 @@ static PEP_STATUS _dup_grouped_only(identity_list* idents, identity_list** filte
return PEP_STATUS_OK;
}
static PEP_STATUS _check_own_reset_passphrase_readiness(PEP_SESSION session,
const char* key) {
// Check generation setup
// Because of the above, we can support a signing passphrase
// that differs from the generation passphrase. We'll
// just check to make sure everything is in order for
// later use, however
if (session->new_key_pass_enable) {
if (EMPTYSTR(session->generation_passphrase))
return PEP_PASSPHRASE_FOR_NEW_KEYS_REQUIRED;
}
stringlist_t* test_key = NULL;
// Be sure we HAVE this key
PEP_STATUS status = find_keys(session, key, &test_key);
bool exists_key = test_key != NULL;
free_stringlist(test_key);
if (!exists_key || status == PEP_KEY_NOT_FOUND) {
remove_fpr_as_default(session, key);
return PEP_KEY_NOT_FOUND;
}
if (status != PEP_STATUS_OK)
return status;
ensure_passphrase_t ensure_key_cb = session->ensure_passphrase;
// Check to see that this key has its passphrase set as the configured
// passphrase, IF it has one. If not, bail early.
status = probe_encrypt(session, key);
if (PASS_ERROR(status)) {
if (ensure_key_cb)
status = ensure_key_cb(session, key);
}
if (status != PEP_STATUS_OK)
return status;
if (EMPTYSTR(session->curr_passphrase) && !EMPTYSTR(session->generation_passphrase)) {
// We'll need it as the current passphrase to sign
// messages with the generated keys
config_passphrase(session, session->generation_passphrase);
}
return PEP_STATUS_OK;
}
// This is for ONE specific key, but possibly many identities
// We could have ONE return for PEP_PASSPHRASE_FOR_NEW_KEYS_REQUIRED
// and another for PEP_PASSPHRASE_REQUIRED/PEP_WRONG_PASSPHRASE
// State would advance though, it just might need to be called
// twice with correct passwords, and more without.
// (In other words, with multiple passwords, this is not the end of all things)
//
// N.B. This function presumes that ALL idents in this group have the
// key in question as their main key. That's what this function
// was created for.
// FIXME:
// I am not sure this is safe with already-revoked keys.
//
static PEP_STATUS _key_reset_device_group_for_shared_key(PEP_SESSION session,
identity_list* key_idents,
const char* old_key,
@ -978,19 +1046,33 @@ static PEP_STATUS _key_reset_device_group_for_shared_key(PEP_SESSION session,
if (!session || !key_idents || EMPTYSTR(old_key))
return PEP_ILLEGAL_VALUE;
messageToSend_t send_cb = session->messageToSend;
if (!send_cb)
return PEP_SYNC_NO_MESSAGE_SEND_CALLBACK;
PEP_STATUS status = PEP_STATUS_OK;
message* enc_msg = NULL;
message* outmsg = NULL;
stringlist_t* test_key = NULL;
// Make sure the signing password is set correctly and that
// we are also ready for keygen
status = _check_own_reset_passphrase_readiness(session, old_key);
if (status != PEP_STATUS_OK)
return status;
char* cached_passphrase = EMPTYSTR(session->curr_passphrase) ? NULL : strdup(session->curr_passphrase);
// if we only want grouped identities, we do this:
if (grouped_only) {
identity_list* new_list = NULL;
status = _dup_grouped_only(key_idents, &new_list);
if (status != PEP_STATUS_OK)
return status;
goto pEp_error;
key_idents = new_list; // local var change, won't impact caller
}
@ -1005,47 +1087,70 @@ static PEP_STATUS _key_reset_device_group_for_shared_key(PEP_SESSION session,
ident->fpr = NULL;
status = _generate_keypair(session, ident, true);
if (status != PEP_STATUS_OK)
return status;
goto pEp_error;
}
// Ok, everyone's got a new keypair. Hoorah!
// generate, sign, and push messages into queue
message* outmsg = NULL;
//
// Because we have to export the NEW secret keys,
// we have to switch in the passgen key
// as the configured key. We'll switch it back
// afterward (no revocation, decrypt, or signing
// with the old key happens in here)
config_passphrase(session, session->generation_passphrase);
status = _generate_own_commandlist_msg(session,
key_idents,
old_key,
&outmsg);
config_passphrase(session, cached_passphrase);
// Key-based errors here shouldn't happen.
if (status != PEP_STATUS_OK)
goto pEp_error;
// Following will only be true if some idents were grouped,
// and will only include grouped idents!
// and will only include grouped idents!
// Will be signed with old signing key.
// (Again, see the FIXME - we need to figure oout what
// happens if it got revoked externally)
if (outmsg) {
message* enc_msg = NULL;
// encrypt this baby and get out
// extra keys???
status = encrypt_message(session, outmsg, NULL, &enc_msg, PEP_enc_auto, PEP_encrypt_flag_key_reset_only);
if (status != PEP_STATUS_OK) {
goto pEp_free;
}
if (status != PEP_STATUS_OK)
goto pEp_error;
_add_auto_consume(enc_msg);
// insert into queue
status = send_cb(enc_msg);
if (status != PEP_STATUS_OK) {
free(enc_msg);
goto pEp_free;
}
if (status != PEP_STATUS_OK)
goto pEp_error;
}
// Ok, we've signed everything we need to with the old key,
// Revoke that baby.
status = revoke_key(session, old_key, NULL);
// again, we should not have key-related issues here,
// as we ensured the correct password earlier
if (status != PEP_STATUS_OK)
goto pEp_free;
goto pEp_error;
// Ok, NOW - the current password needs to be swapped out
// because we're going to sign with keys using it.
//
// All new keys have the same passphrase, if any
//
config_passphrase(session, session->generation_passphrase);
for (curr_ident = key_idents; curr_ident && curr_ident->ident; curr_ident = curr_ident->next) {
if (curr_ident->ident->flags & PEP_idf_devicegroup) {
pEp_identity* ident = curr_ident->ident;
@ -1055,10 +1160,10 @@ static PEP_STATUS _key_reset_device_group_for_shared_key(PEP_SESSION session,
char* new_key = ident->fpr;
ident->fpr = NULL;
status = set_own_key(session, ident, new_key);
if (status != PEP_STATUS_OK) {
if (status != PEP_STATUS_OK)
// scream loudly and cry, then hang head in shame
return status;
}
goto pEp_error;
free(ident->fpr);
// release ownership to the struct again
@ -1070,7 +1175,7 @@ static PEP_STATUS _key_reset_device_group_for_shared_key(PEP_SESSION session,
status = set_revoked(session, old_key, new_key, time(NULL));
if (status != PEP_STATUS_OK)
goto pEp_free;
goto pEp_error;
// Whether new_key is NULL or not, if this key is equal to the current user default, we
// replace it.
@ -1080,12 +1185,12 @@ static PEP_STATUS _key_reset_device_group_for_shared_key(PEP_SESSION session,
old_key);
if (status != PEP_STATUS_OK)
goto pEp_free;
goto pEp_error;
pEp_identity* tmp_ident = identity_dup(ident);
if (!tmp_ident) {
status = PEP_OUT_OF_MEMORY;
goto pEp_free;
goto pEp_error;
}
free(tmp_ident->fpr);
@ -1094,24 +1199,36 @@ static PEP_STATUS _key_reset_device_group_for_shared_key(PEP_SESSION session,
tmp_ident->fpr = strdup(old_key); // freed in free_identity
if (status == PEP_STATUS_OK)
status = send_key_reset_to_recents(session, tmp_ident, old_key, ident->fpr);
if (status != PEP_STATUS_OK)
goto pEp_error;
free_identity(tmp_ident);
}
}
config_passphrase(session, cached_passphrase);
if (status == PEP_STATUS_OK)
// cascade that mistrust for anyone using this key
status = mark_as_compromised(session, old_key);
status = mark_as_compromised(session, old_key);
if (status == PEP_STATUS_OK)
status = remove_fpr_as_default(session, old_key);
if (status == PEP_STATUS_OK)
status = add_mistrusted_key(session, old_key);
pEp_free:
return status;
pEp_error:
// Just in case
config_passphrase(session, cached_passphrase);
free_stringlist(test_key);
free_message(outmsg);
free_message(enc_msg);
free(cached_passphrase);
return status;
}
DYNAMIC_API PEP_STATUS key_reset_own_grouped_keys(PEP_SESSION session) {
assert(session);
@ -1129,7 +1246,7 @@ DYNAMIC_API PEP_STATUS key_reset_own_grouped_keys(PEP_SESSION session) {
status = get_all_keys_for_user(session, user_id, &keys);
// TODO: free
if (status == PEP_STATUS_OK) {
if (status == PEP_STATUS_OK) {
stringlist_t* curr_key;
for (curr_key = keys; curr_key && curr_key->value; curr_key = curr_key->next) {
@ -1146,6 +1263,16 @@ DYNAMIC_API PEP_STATUS key_reset_own_grouped_keys(PEP_SESSION session) {
else
goto pEp_free;
// This is in a switch because our return statuses COULD get more
// complicated
switch (status) {
case PEP_STATUS_OK:
case PEP_KEY_NOT_FOUND: // call removed it as a default
break;
default:
goto pEp_free;
}
free_identity_list(key_idents);
}
}
@ -1157,8 +1284,6 @@ pEp_free:
return status;
}
// Notes to integrate into header:
// IF there is an ident, it must have a user_id.
PEP_STATUS key_reset(
PEP_SESSION session,
const char* key_id,
@ -1178,6 +1303,8 @@ PEP_STATUS key_reset(
identity_list* key_idents = NULL;
stringlist_t* keys = NULL;
char* cached_passphrase = EMPTYSTR(session->curr_passphrase) ? NULL : strdup(session->curr_passphrase);
if (!EMPTYSTR(key_id)) {
fpr_copy = strdup(key_id);
if (!fpr_copy)
@ -1277,7 +1404,7 @@ PEP_STATUS key_reset(
// case of own identities with private keys.
if (is_own_private) {
// This is now the "is_own" base case - we don't do this
// per-identity, because all identities using this key will
// need new ones. That said, this is really only a problem
@ -1299,6 +1426,14 @@ PEP_STATUS key_reset(
if (is_grouped)
status = _key_reset_device_group_for_shared_key(session, key_idents, fpr_copy, false);
else if (status == PEP_STATUS_OK) {
// KB: FIXME_NOW - revoked?
// Make sure we can even progress - if there are passphrase issues,
// bounce back to the caller now, because our attempts to make it work failed,
// even possibly with callback.
status = _check_own_reset_passphrase_readiness(session, fpr_copy);
if (status != PEP_STATUS_OK)
return status;
// now have ident list, or should
identity_list* curr_ident;
@ -1309,10 +1444,14 @@ PEP_STATUS key_reset(
// Do the full reset on this identity
// Base case for is_own_private starts here
// Note that we reset this key for ANY own ident that has it. And if
// tmp_ident did NOT have this key, it won't matter. We will reset the
// tmp_ident did NOT have this key, it won't matter. We will reset this
// key for all idents for this user.
status = revoke_key(session, fpr_copy, NULL);
// Should never happen, we checked this, but STILL.
if (PASS_ERROR(status))
goto pEp_free;
// If we have a full identity, we have some cleanup and generation tasks here
if (!EMPTYSTR(this_ident->address)) {
// generate new key
@ -1357,10 +1496,14 @@ PEP_STATUS key_reset(
// for all active communication partners:
// active_send revocation
config_passphrase(session, session->generation_passphrase);
tmp_ident->fpr = fpr_copy;
if (status == PEP_STATUS_OK)
status = send_key_reset_to_recents(session, this_ident, fpr_copy, new_key);
config_passphrase(session, cached_passphrase);
tmp_ident->fpr = NULL;
if (PASS_ERROR(status))
goto pEp_free; // should NOT happen
}
// Whether new_key is NULL or not, if this key is equal to the current user default, we
@ -1372,8 +1515,10 @@ PEP_STATUS key_reset(
// we got an error and want to bail anyway.
goto pEp_free;
}
else
return PEP_CANNOT_FIND_IDENTITY;
else {
status = PEP_CANNOT_FIND_IDENTITY;
goto pEp_free;
}
} // end is_own_private
else {
// if it's mistrusted, make it not be so.
@ -1415,7 +1560,9 @@ pEp_free:
free(own_id);
free_identity_list(key_idents);
free_stringlist(keys);
free(new_key);
free(new_key);
config_passphrase(session, cached_passphrase);
free(cached_passphrase);
return status;
}

@ -93,6 +93,8 @@ DYNAMIC_API PEP_STATUS key_reset_user(
DYNAMIC_API PEP_STATUS key_reset_all_own_keys(PEP_SESSION session);
// FIXME: Doc
// This is simply NOT SAFE for multiple passwords on the extant
// keys. Cannot be called with multiple passwords for that purpose.
DYNAMIC_API PEP_STATUS key_reset_own_grouped_keys(PEP_SESSION session);
// key_reset() - reset the database status for a key, removing all trust information
@ -119,6 +121,7 @@ DYNAMIC_API PEP_STATUS key_reset_own_grouped_keys(PEP_SESSION session);
// if NULL and fpr is non-NULL, we'll reset the key for all
// associated identities. If both ident and fpr are NULL, see
// the fpr arg documentation.
// ***IF there is an ident, it must have a user_id.***
//
// Note: ident->fpr is always ignored
//

@ -1361,7 +1361,8 @@ DYNAMIC_API PEP_STATUS do_keymanagement(
{
PEP_SESSION session;
pEp_identity *identity;
PEP_STATUS status = init(&session, NULL, NULL);
// FIXME_NOW: ensure_decrypt callback???
PEP_STATUS status = init(&session, NULL, NULL, NULL);
assert(!status);
if (status)
return status;

@ -566,6 +566,8 @@ PEP_STATUS try_encrypt_message(
PEP_encrypt_flags_t flags
);
PEP_STATUS probe_encrypt(PEP_SESSION session, const char *fpr);
#ifdef __cplusplus
}
#endif

@ -541,9 +541,6 @@ static const char *sql_get_last_contacted =
static int user_version(void *_version, int count, char **text, char **name)
{
assert(_version);
assert(count == 1);
assert(text && text[0]);
if (!(_version && count == 1 && text && text[0]))
return -1;
@ -950,7 +947,8 @@ static PEP_STATUS upgrade_revoc_contact_to_13(PEP_SESSION session) {
DYNAMIC_API PEP_STATUS init(
PEP_SESSION *session,
messageToSend_t messageToSend,
inject_sync_event_t inject_sync_event
inject_sync_event_t inject_sync_event,
ensure_passphrase_t ensure_passphrase
)
{
PEP_STATUS status = PEP_STATUS_OK;
@ -986,7 +984,6 @@ DYNAMIC_API PEP_STATUS init(
// client session, or by using synchronization primitive to protect
// creation/deletion of first/last session from the app.
assert(session);
if (session == NULL)
return PEP_ILLEGAL_VALUE;
@ -1000,11 +997,8 @@ DYNAMIC_API PEP_STATUS init(
_session->version = PEP_ENGINE_VERSION;
_session->messageToSend = messageToSend;
_session->inject_sync_event = inject_sync_event;
#ifdef DEBUG_ERRORSTACK
_session->errorstack = new_stringlist("init()");
#endif
_session->ensure_passphrase = ensure_passphrase;
assert(LOCAL_DB);
if (LOCAL_DB == NULL) {
status = PEP_INIT_CANNOT_OPEN_DB;
@ -2131,10 +2125,7 @@ DYNAMIC_API void release(PEP_SESSION session)
bool out_last = false;
int _count = --init_count;
assert(_count >= -1);
assert(session);
if (!((_count >= -1) && session))
if ((_count < -1) || !session)
return;
// a small race condition but still a race condition
@ -2310,10 +2301,6 @@ DYNAMIC_API void release(PEP_SESSION session)
release_transport_system(session, out_last);
release_cryptotech(session, out_last);
#ifdef DEBUG_ERRORSTACK
free_stringlist(session->errorstack);
#endif
free(session);
}
}
@ -2405,11 +2392,7 @@ DYNAMIC_API PEP_STATUS log_event(
session->service_log = true;
int result;
assert(session);
assert(title);
assert(entity);
if (!(session && title && entity))
return PEP_ILLEGAL_VALUE;
@ -2439,7 +2422,6 @@ DYNAMIC_API PEP_STATUS log_service(
const char *comment
)
{
assert(session);
if (!session)
return PEP_ILLEGAL_VALUE;
@ -2456,10 +2438,6 @@ DYNAMIC_API PEP_STATUS trustword(
{
PEP_STATUS status = PEP_STATUS_OK;
assert(session);
assert(word);
assert(wsize);
if (!(session && word && wsize))
return PEP_ILLEGAL_VALUE;
@ -2469,6 +2447,7 @@ DYNAMIC_API PEP_STATUS trustword(
if (lang == NULL)
lang = "en";
// FIXME: should this not be an actual check???
assert((lang[0] >= 'A' && lang[0] <= 'Z')
|| (lang[0] >= 'a' && lang[0] <= 'z'));
assert((lang[1] >= 'A' && lang[1] <= 'Z')
@ -2501,12 +2480,6 @@ DYNAMIC_API PEP_STATUS trustwords(
{
const char *source = fingerprint;
assert(session);
assert(fingerprint);
assert(words);
assert(wsize);
assert(max_words >= 0);
if (!(session && fingerprint && words && wsize && max_words >= 0))
return PEP_ILLEGAL_VALUE;
@ -2524,6 +2497,7 @@ DYNAMIC_API PEP_STATUS trustwords(
if (!lang || !lang[0])
lang = "en";
// FIXME: Should this not be an actual check?
assert((lang[0] >= 'A' && lang[0] <= 'Z')
|| (lang[0] >= 'a' && lang[0] <= 'z'));
assert((lang[1] >= 'A' && lang[1] <= 'Z')
@ -2589,7 +2563,6 @@ pEp_identity *new_identity(
)
{
pEp_identity *result = calloc(1, sizeof(pEp_identity));
assert(result);
if (result) {
if (address) {
result->address = strdup(address);
@ -2629,23 +2602,23 @@ pEp_identity *new_identity(
pEp_identity *identity_dup(const pEp_identity *src)
{
assert(src);
pEp_identity *dup = new_identity(src->address, src->fpr, src->user_id,
src->username);
assert(dup);
if (dup == NULL)
return NULL;
dup->comm_type = src->comm_type;
dup->lang[0] = src->lang[0];
dup->lang[1] = src->lang[1];
dup->lang[2] = 0;
dup->flags = src->flags;
dup->me = src->me;
dup->major_ver = src->major_ver;
dup->minor_ver = src->minor_ver;
pEp_identity* dup = NULL;
if (src) {
dup = new_identity(src->address, src->fpr, src->user_id,
src->username);
assert(dup);
if (dup == NULL)
return NULL;
dup->comm_type = src->comm_type;
dup->lang[0] = src->lang[0];
dup->lang[1] = src->lang[1];
dup->lang[2] = 0;
dup->flags = src->flags;
dup->me = src->me;
dup->major_ver = src->major_ver;
dup->minor_ver = src->minor_ver;
}
return dup;
}
@ -2665,8 +2638,6 @@ DYNAMIC_API PEP_STATUS get_default_own_userid(
char** userid
)
{
assert(session);
assert(userid);
if (!session || !userid)
return PEP_ILLEGAL_VALUE;
@ -2709,11 +2680,6 @@ DYNAMIC_API PEP_STATUS get_userid_alias_default(
const char* alias_id,
char** default_id) {
assert(session);
assert(alias_id);
assert(alias_id[0]);
assert(default_id);
if (!(session && alias_id && alias_id[0] && default_id))
return PEP_ILLEGAL_VALUE;
@ -2754,10 +2720,6 @@ DYNAMIC_API PEP_STATUS set_userid_alias (
int result;
assert(session);
assert(default_id);
assert(alias_id);
if (!(session && default_id && alias_id &&
default_id[0] != '\0' && alias_id[0] != '\0'))
return PEP_ILLEGAL_VALUE;
@ -2793,11 +2755,6 @@ DYNAMIC_API PEP_STATUS get_identity(
PEP_STATUS status = PEP_STATUS_OK;
pEp_identity *_identity = NULL;
assert(session);
assert(address);
assert(address[0]);
assert(identity);
if (!(session && address && address[0] && identity))
return PEP_ILLEGAL_VALUE;
@ -3022,11 +2979,6 @@ PEP_STATUS get_identity_without_trust_check(
PEP_STATUS status = PEP_STATUS_OK;
pEp_identity *_identity = NULL;
assert(session);
assert(address);
assert(address[0]);
assert(identity);
if (!(session && address && address[0] && identity))
return PEP_ILLEGAL_VALUE;
@ -3091,10 +3043,6 @@ PEP_STATUS get_identities_by_address(
identity_list** id_list
)
{
assert(session);
assert(address);
assert(address[0]);
assert(id_list);
if (!(session && address && address[0] && id_list))
return PEP_ILLEGAL_VALUE;
@ -3162,11 +3110,7 @@ PEP_STATUS get_identities_by_address(
PEP_STATUS exists_identity_entry(PEP_SESSION session, pEp_identity* identity,
bool* exists) {
assert(session);
assert(identity);
assert(!EMPTYSTR(identity->user_id));
assert(!EMPTYSTR(identity->address));
if (!session || !exists || EMPTYSTR(identity->user_id) || EMPTYSTR(identity->address))
if (!session || !exists || !identity || EMPTYSTR(identity->user_id) || EMPTYSTR(identity->address))
return PEP_ILLEGAL_VALUE;
*exists = false;
@ -3197,11 +3141,7 @@ PEP_STATUS exists_identity_entry(PEP_SESSION session, pEp_identity* identity,
PEP_STATUS exists_trust_entry(PEP_SESSION session, pEp_identity* identity,
bool* exists) {
assert(session);
assert(identity);
assert(!EMPTYSTR(identity->user_id));
assert(!EMPTYSTR(identity->fpr));
if (!session || !exists || EMPTYSTR(identity->user_id) || EMPTYSTR(identity->fpr))
if (!session || !exists || !identity || EMPTYSTR(identity->user_id) || EMPTYSTR(identity->fpr))
return PEP_ILLEGAL_VALUE;
*exists = false;
@ -3272,11 +3212,6 @@ PEP_STATUS clear_trust_info(PEP_SESSION session,
static PEP_STATUS _set_or_update_trust(PEP_SESSION session,
pEp_identity* identity,
sqlite3_stmt* set_or_update) {
assert(session);
assert(identity);
assert(identity->user_id);
assert(identity->fpr);
if (!session || !identity || EMPTYSTR(identity->user_id) || EMPTYSTR(identity->fpr))
return PEP_ILLEGAL_VALUE;
@ -3305,9 +3240,6 @@ static PEP_STATUS _set_or_update_trust(PEP_SESSION session,
static PEP_STATUS _set_or_update_identity_entry(PEP_SESSION session,
pEp_identity* identity,
sqlite3_stmt* set_or_update) {
assert(session);
assert(identity);
assert(set_or_update);
if (!session || !identity || !identity->user_id || !identity->address)
return PEP_ILLEGAL_VALUE;
@ -3335,9 +3267,6 @@ static PEP_STATUS _set_or_update_identity_entry(PEP_SESSION session,
static PEP_STATUS _set_or_update_person(PEP_SESSION session,
pEp_identity* identity,
sqlite3_stmt* set_or_update) {
assert(session);
assert(identity);
assert(set_or_update);
if (!session || !identity || !identity->user_id || !identity->username)
return PEP_ILLEGAL_VALUE;
@ -3444,12 +3373,6 @@ DYNAMIC_API PEP_STATUS set_identity(
{
int result;
assert(session);
assert(identity);
assert(identity->address);
assert(identity->user_id);
assert(identity->username);
if (!(session && identity && identity->address &&
identity->user_id && identity->username))
return PEP_ILLEGAL_VALUE;
@ -3542,10 +3465,6 @@ PEP_STATUS update_pEp_user_trust_vals(PEP_SESSION session,
// This ONLY sets the user flag. Must be called outside of a transaction.
DYNAMIC_API PEP_STATUS set_as_pEp_user(PEP_SESSION session, pEp_identity* user) {
assert(session);
assert(user);
assert(!EMPTYSTR(user->user_id));
if (!session || !user || EMPTYSTR(user->user_id))
return PEP_ILLEGAL_VALUE;
@ -3579,10 +3498,10 @@ DYNAMIC_API PEP_STATUS set_as_pEp_user(PEP_SESSION session, pEp_identity* user)
// This ONLY sets the version flag. Must be called outside of a transaction.
PEP_STATUS set_pEp_version(PEP_SESSION session, pEp_identity* ident, unsigned int new_ver_major, unsigned int new_ver_minor) {
assert(session);
assert(!EMPTYSTR(ident->user_id));
assert(!EMPTYSTR(ident->address));
if (!session || !ident || EMPTYSTR(ident->user_id) || EMPTYSTR(ident->address))
return PEP_ILLEGAL_VALUE;
sqlite3_reset(session->set_pEp_version);
sqlite3_bind_double(session->set_pEp_version, 1, new_ver_major);
sqlite3_bind_double(session->set_pEp_version, 2, new_ver_minor);
@ -3607,8 +3526,9 @@ PEP_STATUS upgrade_pEp_version_by_user_id(PEP_SESSION session,
unsigned int new_ver_minor
)
{
assert(session);
assert(!EMPTYSTR(ident->user_id));
if (!session || !ident || EMPTYSTR(ident->user_id))
return PEP_ILLEGAL_VALUE;
sqlite3_reset(session->upgrade_pEp_version_by_user_id);
sqlite3_bind_int(session->upgrade_pEp_version_by_user_id, 1, new_ver_major);
@ -3627,14 +3547,7 @@ PEP_STATUS upgrade_pEp_version_by_user_id(PEP_SESSION session,
PEP_STATUS exists_person(PEP_SESSION session, pEp_identity* identity,
bool* exists) {
// const char* user_id,
// char** default_id, bool* exists) {
assert(session);
assert(exists);
assert(identity);
assert(!EMPTYSTR(identity->user_id));
if (!session || !exists || !identity || EMPTYSTR(identity->user_id))
return PEP_ILLEGAL_VALUE;
@ -3676,8 +3589,7 @@ PEP_STATUS exists_person(PEP_SESSION session, pEp_identity* identity,
}
PEP_STATUS delete_person(PEP_SESSION session, const char* user_id) {
assert(session);
assert(!EMPTYSTR(user_id));
if (!session || EMPTYSTR(user_id))
return PEP_ILLEGAL_VALUE;
@ -3698,10 +3610,6 @@ PEP_STATUS delete_person(PEP_SESSION session, const char* user_id) {
DYNAMIC_API PEP_STATUS is_pEp_user(PEP_SESSION session, pEp_identity *identity, bool* is_pEp)
{
assert(session);
assert(is_pEp);
assert(identity);
assert(!EMPTYSTR(identity->user_id));
if (!session || !is_pEp || !identity || EMPTYSTR(identity->user_id))
return PEP_ILLEGAL_VALUE;
@ -3743,9 +3651,6 @@ DYNAMIC_API PEP_STATUS is_pEp_user(PEP_SESSION session, pEp_identity *identity,
PEP_STATUS is_own_address(PEP_SESSION session, const char* address, bool* is_own_addr)
{
assert(session);
assert(is_own_addr);
assert(!EMPTYSTR(address));
if (!session || !is_own_addr || EMPTYSTR(address))
return PEP_ILLEGAL_VALUE;
@ -3803,12 +3708,7 @@ PEP_STATUS bind_own_ident_with_contact_ident(PEP_SESSION session,
// since this could be either way
PEP_STATUS has_partner_contacted_address(PEP_SESSION session, const char* partner_id,
const char* own_address, bool* was_contacted) {
assert(session);
assert(!EMPTYSTR(partner_id));
assert(!EMPTYSTR(own_address));
assert(was_contacted);
if (!session || !was_contacted || EMPTYSTR(partner_id) || EMPTYSTR(own_address))
return PEP_ILLEGAL_VALUE;
@ -3886,7 +3786,6 @@ PEP_STATUS get_own_ident_for_contact_id(PEP_SESSION session,
PEP_STATUS remove_fpr_as_default(PEP_SESSION session,
const char* fpr)
{
assert(fpr);
if (!session || !fpr)
return PEP_ILLEGAL_VALUE;
@ -3919,8 +3818,6 @@ PEP_STATUS replace_identities_fpr(PEP_SESSION session,
const char* old_fpr,
const char* new_fpr)
{
assert(old_fpr);
assert(new_fpr);
if (!old_fpr || !new_fpr)
return PEP_ILLEGAL_VALUE;
@ -3968,11 +3865,6 @@ DYNAMIC_API PEP_STATUS set_identity_flags(
{
int result;
assert(session);
assert(identity);
assert(identity->address);
assert(identity->user_id);
if (!(session && identity && identity->address && identity->user_id))
return PEP_ILLEGAL_VALUE;
@ -4001,11 +3893,6 @@ DYNAMIC_API PEP_STATUS unset_identity_flags(
{
int result;
assert(session);
assert(identity);
assert(identity->address);
assert(identity->user_id);
if (!(session && identity && identity->address && identity->user_id))
return PEP_ILLEGAL_VALUE;
@ -4033,11 +3920,6 @@ DYNAMIC_API PEP_STATUS set_ident_enc_format(
{
int result;
assert(session);
assert(identity);
assert(identity->address);
assert(identity->user_id);
if (!(session && identity && identity->address && identity->user_id))
return PEP_ILLEGAL_VALUE;
@ -4378,9 +4260,6 @@ pEp_free:
PEP_STATUS replace_userid(PEP_SESSION session, const char* old_uid,
const char* new_uid) {
assert(session);
assert(old_uid);
assert(new_uid);
if (!session || !old_uid || !new_uid)
return PEP_ILLEGAL_VALUE;
@ -4417,8 +4296,6 @@ PEP_STATUS replace_userid(PEP_SESSION session, const char* old_uid,
}
PEP_STATUS remove_key(PEP_SESSION session, const char* fpr) {
assert(session);
assert(fpr);
if (!session || EMPTYSTR(fpr))
return PEP_ILLEGAL_VALUE;
@ -4438,8 +4315,6 @@ PEP_STATUS remove_key(PEP_SESSION session, const char* fpr) {
PEP_STATUS refresh_userid_default_key(PEP_SESSION session, const char* user_id) {
assert(session);
assert(user_id);
if (!session || !user_id)
return PEP_ILLEGAL_VALUE;
@ -4459,9 +4334,6 @@ PEP_STATUS refresh_userid_default_key(PEP_SESSION session, const char* user_id)
PEP_STATUS replace_main_user_fpr(PEP_SESSION session, const char* user_id,
const char* new_fpr) {
assert(session);
assert(user_id);
assert(new_fpr);
if (!session || !user_id || !new_fpr)
return PEP_ILLEGAL_VALUE;
@ -4483,9 +4355,6 @@ PEP_STATUS replace_main_user_fpr(PEP_SESSION session, const char* user_id,
PEP_STATUS replace_main_user_fpr_if_equal(PEP_SESSION session, const char* user_id,
const char* new_fpr, const char* compare_fpr) {
assert(session);
assert(user_id);
assert(compare_fpr);
if (!session || !user_id || !compare_fpr)
return PEP_ILLEGAL_VALUE;
@ -4516,11 +4385,7 @@ PEP_STATUS get_main_user_fpr(PEP_SESSION session,
{
PEP_STATUS status = PEP_STATUS_OK;
int result;
assert(session);
assert(user_id);
assert(main_fpr);
if (!(session && user_id && user_id[0] && main_fpr))
return PEP_ILLEGAL_VALUE;
@ -4568,9 +4433,6 @@ DYNAMIC_API PEP_STATUS mark_as_compromised(
{
int result;
assert(session);
assert(fpr && fpr[0]);
if (!(session && fpr && fpr[0]))
return PEP_ILLEGAL_VALUE;
@ -4601,15 +4463,6 @@ DYNAMIC_API PEP_STATUS get_trust(PEP_SESSION session, pEp_identity *identity)
PEP_STATUS status = PEP_STATUS_OK;
int result;
// We need to be able to test that we break correctly without shutting
// asserts off everywhere.
// assert(session);
// assert(identity);
// assert(identity->user_id);
// assert(identity->user_id[0]);
// assert(identity->fpr);
// assert(identity->fpr[0]);
if (!(session && identity && identity->user_id && identity->user_id[0] &&
identity->fpr && identity->fpr[0]))
return PEP_ILLEGAL_VALUE;
@ -4648,10 +4501,6 @@ DYNAMIC_API PEP_STATUS least_trust(
PEP_STATUS status = PEP_STATUS_OK;
int result;
assert(session);
assert(fpr);
assert(comm_type);
if (!(session && fpr && comm_type))
return PEP_ILLEGAL_VALUE;
@ -4703,12 +4552,6 @@ DYNAMIC_API PEP_STATUS decrypt_and_verify(
char** filename_ptr
)
{
assert(session);
assert(ctext);
assert(csize);
assert(ptext);
assert(psize);
assert(keylist);
if (!(session && ctext && csize && ptext && psize && keylist))
return PEP_ILLEGAL_VALUE;
@ -4731,12 +4574,6 @@ DYNAMIC_API PEP_STATUS encrypt_and_sign(
size_t psize, char **ctext, size_t *csize
)
{
assert(session);
assert(keylist);
assert(ptext);
assert(psize);
assert(ctext);
assert(csize);
if (!(session && keylist && ptext && psize && ctext && csize))
return PEP_ILLEGAL_VALUE;
@ -4750,12 +4587,6 @@ PEP_STATUS encrypt_only(
size_t psize, char **ctext, size_t *csize
)
{
assert(session);
assert(keylist);
assert(ptext);
assert(psize);
assert(ctext);
assert(csize);
if (!(session && keylist && ptext && psize && ctext && csize))
return PEP_ILLEGAL_VALUE;
@ -4770,12 +4601,6 @@ PEP_STATUS sign_only(PEP_SESSION session,
const char *fpr,
char **sign,
size_t *sign_size) {
assert(session);
assert(fpr);
assert(data);
assert(data_size);
assert(sign);
assert(sign_size);
if (!(session && fpr && data && data_size && sign && sign_size))
return PEP_ILLEGAL_VALUE;
@ -4792,12 +4617,6 @@ DYNAMIC_API PEP_STATUS verify_text(
const char *signature, size_t sig_size, stringlist_t **keylist
)
{
assert(session);
assert(text);
assert(size);
assert(signature);
assert(sig_size);
assert(keylist);
if (!(session && text && size && signature && sig_size && keylist))
return PEP_ILLEGAL_VALUE;
@ -4808,8 +4627,6 @@ DYNAMIC_API PEP_STATUS verify_text(
DYNAMIC_API PEP_STATUS delete_keypair(PEP_SESSION session, const char *fpr)
{
assert(session);
assert(fpr);
if (!(session && fpr))
return PEP_ILLEGAL_VALUE;
@ -4821,10 +4638,6 @@ DYNAMIC_API PEP_STATUS export_key(
PEP_SESSION session, const char *fpr, char **key_data, size_t *size
)
{
assert(session);
assert(fpr);
assert(key_data);
assert(size);
if (!(session && fpr && key_data && size))
return PEP_ILLEGAL_VALUE;
@ -4837,11 +4650,6 @@ DYNAMIC_API PEP_STATUS export_secret_key(
PEP_SESSION session, const char *fpr, char **key_data, size_t *size
)
{
assert(session);
assert(fpr);
assert(key_data);
assert(size);
if (!(session && fpr && key_data && size))
return PEP_ILLEGAL_VALUE;
@ -4865,10 +4673,6 @@ DYNAMIC_API PEP_STATUS find_keys(
PEP_SESSION session, const char *pattern, stringlist_t **keylist
)
{
assert(session);
assert(pattern);
assert(keylist);
if (!(session && pattern && keylist))
return PEP_ILLEGAL_VALUE;
@ -4889,11 +4693,6 @@ PEP_STATUS _generate_keypair(PEP_SESSION session,
bool suppress_event
)
{
assert(session);
assert(identity);
assert(identity->address);
assert(identity->fpr == NULL || identity->fpr[0] == 0);
// assert(identity->username);
// N.B. We now allow empty usernames, so the underlying layer for
// non-sequoia crypto implementations will have to deal with this.
@ -4952,10 +4751,6 @@ DYNAMIC_API PEP_STATUS get_key_rating(
PEP_comm_type *comm_type
)
{
assert(session);
assert(fpr);
assert(comm_type);
if (!(session && fpr && comm_type))
return PEP_ILLEGAL_VALUE;
@ -4981,9 +4776,6 @@ PEP_STATUS _import_key_with_fpr_return(
uint64_t* changed_public_keys
)
{
assert(session);
assert(key_data);
if (!(session && key_data))
return PEP_ILLEGAL_VALUE;
@ -4995,10 +4787,7 @@ PEP_STATUS _import_key_with_fpr_return(
}
DYNAMIC_API PEP_STATUS recv_key(PEP_SESSION session, const char *pattern)
{
assert(session);
assert(pattern);
{
if (!(session && pattern))
return PEP_ILLEGAL_VALUE;
@ -5007,9 +4796,6 @@ DYNAMIC_API PEP_STATUS recv_key(PEP_SESSION session, const char *pattern)
DYNAMIC_API PEP_STATUS send_key(PEP_SESSION session, const char *pattern)
{
assert(