|
|
|
@ -88,46 +88,6 @@ static char * keylist_to_string(const stringlist_t *keylist)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @internal
|
|
|
|
|
*
|
|
|
|
|
* <!-- rating_to_string() -->
|
|
|
|
|
*
|
|
|
|
|
* @brief TODO
|
|
|
|
|
*
|
|
|
|
|
* @param[in] rating PEP_rating
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
static const char * rating_to_string(PEP_rating rating)
|
|
|
|
|
{
|
|
|
|
|
switch (rating) {
|
|
|
|
|
case PEP_rating_cannot_decrypt:
|
|
|
|
|
return "cannot_decrypt";
|
|
|
|
|
case PEP_rating_have_no_key:
|
|
|
|
|
return "have_no_key";
|
|
|
|
|
case PEP_rating_unencrypted:
|
|
|
|
|
return "unencrypted";
|
|
|
|
|
case PEP_rating_unreliable:
|
|
|
|
|
return "unreliable";
|
|
|
|
|
case PEP_rating_reliable:
|
|
|
|
|
return "reliable";
|
|
|
|
|
case PEP_rating_trusted:
|
|
|
|
|
return "trusted";
|
|
|
|
|
case PEP_rating_trusted_and_anonymized:
|
|
|
|
|
return "trusted_and_anonymized";
|
|
|
|
|
case PEP_rating_fully_anonymous:
|
|
|
|
|
return "fully_anonymous";
|
|
|
|
|
case PEP_rating_mistrust:
|
|
|
|
|
return "mistrust";
|
|
|
|
|
case PEP_rating_b0rken:
|
|
|
|
|
return "b0rken";
|
|
|
|
|
case PEP_rating_under_attack:
|
|
|
|
|
return "under_attack";
|
|
|
|
|
default:
|
|
|
|
|
return "undefined";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @internal
|
|
|
|
|
*
|
|
|
|
@ -246,120 +206,6 @@ void replace_opt_field(message *msg,
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @internal
|
|
|
|
|
*
|
|
|
|
|
* <!-- sync_message_attached() -->
|
|
|
|
|
*
|
|
|
|
|
* @brief TODO
|
|
|
|
|
*
|
|
|
|
|
* @param[in] *msg message
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
static bool sync_message_attached(message *msg)
|
|
|
|
|
{
|
|
|
|
|
if (!(msg && msg->attachments))
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
for (bloblist_t *a = msg->attachments; a && a->value ; a = a->next) {
|
|
|
|
|
if (a->mime_type && strcasecmp(a->mime_type, "application/pEp.sync") == 0)
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @internal
|
|
|
|
|
*
|
|
|
|
|
* <!-- set_receiverRating() -->
|
|
|
|
|
*
|
|
|
|
|
* @brief TODO
|
|
|
|
|
*
|
|
|
|
|
* @param[in] session PEP_SESSION
|
|
|
|
|
* @param[in] *msg message
|
|
|
|
|
* @param[in] rating PEP_rating
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
PEP_STATUS set_receiverRating(PEP_SESSION session, message *msg, PEP_rating rating)
|
|
|
|
|
{
|
|
|
|
|
if (!(session && msg && rating))
|
|
|
|
|
return PEP_ILLEGAL_VALUE;
|
|
|
|
|
|
|
|
|
|
if (!(msg->recv_by && msg->recv_by->fpr && msg->recv_by->fpr[0]))
|
|
|
|
|
return PEP_SYNC_NO_CHANNEL;
|
|
|
|
|
|
|
|
|
|
// don't add a second sync message
|
|
|
|
|
if (sync_message_attached(msg))
|
|
|
|
|
return PEP_STATUS_OK;
|
|
|
|
|
|
|
|
|
|
Sync_t *res = new_Sync_message(Sync_PR_keysync, KeySync_PR_receiverRating);
|
|
|
|
|
if (!res)
|
|
|
|
|
return PEP_OUT_OF_MEMORY;
|
|
|
|
|
|
|
|
|
|
res->choice.keysync.choice.receiverRating.rating = (Rating_t) rating;
|
|
|
|
|
|
|
|
|
|
char *payload;
|
|
|
|
|
size_t size;
|
|
|
|
|
PEP_STATUS status = encode_Sync_message(res, &payload, &size);
|
|
|
|
|
free_Sync_message(res);
|
|
|
|
|
if (status)
|
|
|
|
|
return status;
|
|
|
|
|
|
|
|
|
|
return base_decorate_message(session, msg, BASE_SYNC, payload, size, msg->recv_by->fpr);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @internal
|
|
|
|
|
*
|
|
|
|
|
* <!-- get_receiverRating() -->
|
|
|
|
|
*
|
|
|
|
|
* @brief TODO
|
|
|
|
|
*
|
|
|
|
|
* @param[in] session PEP_SESSION
|
|
|
|
|
* @param[in] *msg message
|
|
|
|
|
* @param[in] *rating PEP_rating
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
PEP_STATUS get_receiverRating(PEP_SESSION session, message *msg, PEP_rating *rating)
|
|
|
|
|
{
|
|
|
|
|
if (!(session && msg && rating))
|
|
|
|
|
return PEP_ILLEGAL_VALUE;
|
|
|
|
|
|
|
|
|
|
*rating = PEP_rating_undefined;
|
|
|
|
|
|
|
|
|
|
size_t size;
|
|
|
|
|
const char *payload;
|
|
|
|
|
char *fpr;
|
|
|
|
|
PEP_STATUS status = base_extract_message(session, msg, BASE_SYNC, &size, &payload, &fpr);
|
|
|
|
|
if (status)
|
|
|
|
|
return status;
|
|
|
|
|
if (!fpr)
|
|
|
|
|
return PEP_SYNC_NO_CHANNEL;
|
|
|
|
|
|
|
|
|
|
bool own_key;
|
|
|
|
|
status = is_own_key(session, fpr, &own_key);
|
|
|
|
|
free(fpr);
|
|
|
|
|
if (status)
|
|
|
|
|
return status;
|
|
|
|
|
if (!own_key)
|
|
|
|
|
return PEP_SYNC_NO_CHANNEL;
|
|
|
|
|
|
|
|
|
|
Sync_t *res;
|
|
|
|
|
status = decode_Sync_message(payload, size, &res);
|
|
|
|
|
if (status)
|
|
|
|
|
return status;
|
|
|
|
|
|
|
|
|
|
if (!(res->present == Sync_PR_keysync && res->choice.keysync.present == KeySync_PR_receiverRating)) {
|
|
|
|
|
free_Sync_message(res);
|
|
|
|
|
return PEP_SYNC_NO_CHANNEL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
*rating = res->choice.keysync.choice.receiverRating.rating;
|
|
|
|
|
replace_opt_field(msg, "X-EncStatus", rating_to_string(*rating), true);
|
|
|
|
|
return PEP_STATUS_OK;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void decorate_message(
|
|
|
|
|
PEP_SESSION session,
|
|
|
|
|
message *msg,
|
|
|
|
@ -1581,52 +1427,6 @@ static bool _has_PGP_MIME_format(message* msg) {
|
|
|
|
|
}
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @internal
|
|
|
|
|
*
|
|
|
|
|
* <!-- _rating() -->
|
|
|
|
|
*
|
|
|
|
|
* @brief TODO
|
|
|
|
|
*
|
|
|
|
|
* @param[in] ct PEP_comm_type
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
static inline PEP_rating _rating(PEP_comm_type ct)
|
|
|
|
|
{
|
|
|
|
|
if (ct == PEP_ct_unknown)
|
|
|
|
|
return PEP_rating_undefined;
|
|
|
|
|
|
|
|
|
|
else if (ct == PEP_ct_key_not_found)
|
|
|
|
|
return PEP_rating_have_no_key;
|
|
|
|
|
|
|
|
|
|
else if (ct == PEP_ct_compromised)
|
|
|
|
|
return PEP_rating_under_attack;
|
|
|
|
|
|
|
|
|
|
else if (ct == PEP_ct_mistrusted)
|
|
|
|
|
return PEP_rating_mistrust;
|
|
|
|
|
|
|
|
|
|
if (ct == PEP_ct_no_encryption || ct == PEP_ct_no_encrypted_channel ||
|
|
|
|
|
ct == PEP_ct_my_key_not_included)
|
|
|
|
|
return PEP_rating_unencrypted;
|
|
|
|
|
|
|
|
|
|
if (ct >= PEP_ct_confirmed_enc_anon)
|
|
|
|
|
return PEP_rating_trusted_and_anonymized;
|
|
|
|
|
|
|
|
|
|
else if (ct >= PEP_ct_strong_encryption)
|
|
|
|
|
return PEP_rating_trusted;
|
|
|
|
|
|
|
|
|
|
else if (ct >= PEP_ct_strong_but_unconfirmed && ct < PEP_ct_confirmed)
|
|
|
|
|
return PEP_rating_reliable;
|
|
|
|
|
|
|
|
|
|
else
|
|
|
|
|
return PEP_rating_unreliable;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
DYNAMIC_API PEP_rating rating_from_comm_type(PEP_comm_type ct)
|
|
|
|
|
{
|
|
|
|
|
return _rating(ct);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @internal
|
|
|
|
|
*
|
|
|
|
@ -1719,45 +1519,6 @@ static char * without_double_ending(const char *filename)
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @internal
|
|
|
|
|
*
|
|
|
|
|
* <!-- decrypt_rating() -->
|
|
|
|
|
*
|
|
|
|
|
* @brief TODO
|
|
|
|
|
*
|
|
|
|
|
* @param[in] status PEP_STATUS
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
static PEP_rating decrypt_rating(PEP_STATUS status)
|
|
|
|
|
{
|
|
|
|
|
switch (status) {
|
|
|
|
|
case PEP_UNENCRYPTED:
|
|
|
|
|
case PEP_VERIFIED:
|
|
|
|
|
case PEP_VERIFY_NO_KEY:
|
|
|
|
|
case PEP_VERIFIED_AND_TRUSTED:
|
|
|
|
|
return PEP_rating_unencrypted;
|
|
|
|
|
|
|
|
|
|
case PEP_DECRYPTED:
|
|
|
|
|
case PEP_VERIFY_SIGNER_KEY_REVOKED:
|
|
|
|
|
case PEP_DECRYPT_SIGNATURE_DOES_NOT_MATCH:
|
|
|
|
|
return PEP_rating_unreliable;
|
|
|
|
|
|
|
|
|
|
case PEP_DECRYPTED_AND_VERIFIED:
|
|
|
|
|
return PEP_rating_reliable;
|
|
|
|
|
|
|
|
|
|
case PEP_DECRYPT_NO_KEY:
|
|
|
|
|
return PEP_rating_have_no_key;
|
|
|
|
|
|
|
|
|
|
case PEP_DECRYPT_WRONG_FORMAT:
|
|
|
|
|
case PEP_CANNOT_DECRYPT_UNKNOWN:
|
|
|
|
|
return PEP_rating_cannot_decrypt;
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
return PEP_rating_undefined;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @internal
|
|
|
|
|
*
|
|
|
|
@ -1799,7 +1560,7 @@ static PEP_rating key_rating(PEP_SESSION session, const char *fpr)
|
|
|
|
|
} else {
|
|
|
|
|
resulting_comm_type = least_comm_type;
|
|
|
|
|
}
|
|
|
|
|
return _rating(resulting_comm_type);
|
|
|
|
|
return rating_from_comm_type(resulting_comm_type);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@ -1912,57 +1673,6 @@ static PEP_comm_type _get_comm_type(
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @internal
|
|
|
|
|
*
|
|
|
|
|
* <!-- _get_comm_type_preview() -->
|
|
|
|
|
*
|
|
|
|
|
* @brief TODO
|
|
|
|
|
*
|
|
|
|
|
* @param[in] session PEP_SESSION
|
|
|
|
|
* @param[in] max_comm_type PEP_comm_type
|
|
|
|
|
* @param[in] *ident pEp_identity
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
static PEP_comm_type _get_comm_type_preview(
|
|
|
|
|
PEP_SESSION session,
|
|
|
|
|
PEP_comm_type max_comm_type,
|
|
|
|
|
pEp_identity *ident
|
|
|
|
|
)
|
|
|
|
|
{
|
|
|
|
|
assert(session);
|
|
|
|
|
assert(ident);
|
|
|
|
|
|
|
|
|
|
PEP_STATUS status = PEP_STATUS_OK;
|
|
|
|
|
|
|
|
|
|
if (max_comm_type == PEP_ct_compromised)
|
|
|
|
|
return PEP_ct_compromised;
|
|
|
|
|
|
|
|
|
|
if (max_comm_type == PEP_ct_mistrusted)
|
|
|
|
|
return PEP_ct_mistrusted;
|
|
|
|
|
|
|
|
|
|
PEP_comm_type comm_type = PEP_ct_unknown;
|
|
|
|
|
if (ident && !EMPTYSTR(ident->address) && !EMPTYSTR(ident->user_id)) {
|
|
|
|
|
pEp_identity *ident2;
|
|
|
|
|
status = get_identity(session, ident->address, ident->user_id, &ident2);
|
|
|
|
|
comm_type = ident2 ? ident2->comm_type : PEP_ct_unknown;
|
|
|
|
|
free_identity(ident2);
|
|
|
|
|
|
|
|
|
|
if (status == PEP_STATUS_OK) {
|
|
|
|
|
if (comm_type == PEP_ct_compromised)
|
|
|
|
|
comm_type = PEP_ct_compromised;
|
|
|
|
|
else if (comm_type == PEP_ct_mistrusted)
|
|
|
|
|
comm_type = PEP_ct_mistrusted;
|
|
|
|
|
else
|
|
|
|
|
comm_type = _MIN(max_comm_type, comm_type);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
comm_type = PEP_ct_unknown;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return comm_type;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// static void free_bl_entry(bloblist_t *bl)
|
|
|
|
|
// {
|
|
|
|
|
// if (bl) {
|
|
|
|
@ -2727,7 +2437,7 @@ DYNAMIC_API PEP_STATUS encrypt_message(
|
|
|
|
|
|
|
|
|
|
if (enc_format == PEP_enc_none || !dest_keys_found ||
|
|
|
|
|
stringlist_length(keys) == 0 ||
|
|
|
|
|
_rating(max_comm_type) < PEP_rating_reliable)
|
|
|
|
|
rating_from_comm_type(max_comm_type) < PEP_rating_reliable)
|
|
|
|
|
{
|
|
|
|
|
free_stringlist(keys);
|
|
|
|
|
if ((has_pEp_user || !session->passive_mode) &&
|
|
|
|
@ -2754,9 +2464,13 @@ DYNAMIC_API PEP_STATUS encrypt_message(
|
|
|
|
|
else {
|
|
|
|
|
// hide subject
|
|
|
|
|
if (enc_format != PEP_enc_inline && enc_format != PEP_enc_inline_EA) {
|
|
|
|
|
status = replace_subject(_src);
|
|
|
|
|
if (status == PEP_OUT_OF_MEMORY)
|
|
|
|
|
goto enomem;
|
|
|
|
|
// do not replace subject if message format 1.x and unencrypted
|
|
|
|
|
// subject is enabled
|
|
|
|
|
if (!(wrap_type == PEP_message_unwrapped && session->unencrypted_subject)) {
|
|
|
|
|
status = replace_subject(_src);
|
|
|
|
|
if (status == PEP_OUT_OF_MEMORY)
|
|
|
|
|
goto enomem;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (!(flags & PEP_encrypt_flag_force_no_attached_key))
|
|
|
|
|
added_key_to_real_src = true;
|
|
|
|
@ -3478,7 +3192,7 @@ static PEP_STATUS amend_rating_according_to_sender_and_recipients(
|
|
|
|
|
}
|
|
|
|
|
if (_sender->comm_type != PEP_ct_unknown) {
|
|
|
|
|
*rating = keylist_rating(session, recipients,
|
|
|
|
|
fpr, _rating(_sender->comm_type));
|
|
|
|
|
fpr, rating_from_comm_type(_sender->comm_type));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
free_identity(_sender);
|
|
|
|
@ -4273,119 +3987,6 @@ static PEP_STATUS reconcile_src_and_inner_messages(message* src,
|
|
|
|
|
// FIXME - are there any flags or anything else we need to be sure are carried?
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @internal
|
|
|
|
|
*
|
|
|
|
|
* <!-- is_trusted_own_priv_fpr() -->
|
|
|
|
|
*
|
|
|
|
|
* @brief TODO
|
|
|
|
|
*
|
|
|
|
|
* @param[in] session PEP_SESSION
|
|
|
|
|
* @param[in] *own_id constchar
|
|
|
|
|
* @param[in] *fpr constchar
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
static bool is_trusted_own_priv_fpr(PEP_SESSION session,
|
|
|
|
|
const char* own_id,
|
|
|
|
|
const char* fpr
|
|
|
|
|
)
|
|
|
|
|
{
|
|
|
|
|
bool retval = false;
|
|
|
|
|
if (!EMPTYSTR(fpr)) {
|
|
|
|
|
pEp_identity* test_identity = new_identity(NULL, fpr, own_id, NULL);
|
|
|
|
|
if (test_identity) {
|
|
|
|
|
PEP_STATUS status = get_trust(session, test_identity);
|
|
|
|
|
if (status == PEP_STATUS_OK) {
|
|
|
|
|
if (test_identity->comm_type & PEP_ct_confirmed) {
|
|
|
|
|
bool has_priv = false;
|
|
|
|
|
status = contains_priv_key(session, fpr, &has_priv);
|
|
|
|
|
if (status == PEP_STATUS_OK && has_priv)
|
|
|
|
|
retval = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
free(test_identity);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return retval;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @internal
|
|
|
|
|
*
|
|
|
|
|
* <!-- reject_fpr() -->
|
|
|
|
|
*
|
|
|
|
|
* @brief TODO
|
|
|
|
|
*
|
|
|
|
|
* @param[in] session PEP_SESSION
|
|
|
|
|
* @param[in] *fpr constchar
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
static bool reject_fpr(PEP_SESSION session, const char* fpr) {
|
|
|
|
|
bool reject = true;
|
|
|
|
|
|
|
|
|
|
PEP_STATUS status = key_revoked(session, fpr, &reject);
|
|
|
|
|
|
|
|
|
|
if (!reject) {
|
|
|
|
|
status = key_expired(session, fpr, time(NULL), &reject);
|
|
|
|
|
if (reject) {
|
|
|
|
|
timestamp *ts = new_timestamp(time(NULL) + KEY_EXPIRE_DELTA);
|
|
|
|
|
status = renew_key(session, fpr, ts);
|
|
|
|
|
free_timestamp(ts);
|
|
|
|
|
if (status == PEP_STATUS_OK)
|
|
|
|
|
reject = false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return reject;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @internal
|
|
|
|
|
*
|
|
|
|
|
* <!-- seek_good_trusted_private_fpr() -->
|
|
|
|
|
*
|
|
|
|
|
* @brief TODO
|
|
|
|
|
*
|
|
|
|
|
* @param[in] session PEP_SESSION
|
|
|
|
|
* @param[in] *own_id char
|
|
|
|
|
* @param[in] *keylist stringlist_t
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
static char* seek_good_trusted_private_fpr(PEP_SESSION session, char* own_id,
|
|
|
|
|
stringlist_t* keylist) {
|
|
|
|
|
if (!own_id || !keylist)
|
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
|
|
stringlist_t* kl_curr = keylist;
|
|
|
|
|
while (kl_curr) {
|
|
|
|
|
char* fpr = kl_curr->value;
|
|
|
|
|
|
|
|
|
|
if (is_trusted_own_priv_fpr(session, own_id, fpr)) {
|
|
|
|
|
if (!reject_fpr(session, fpr))
|
|
|
|
|
return strdup(fpr);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
kl_curr = kl_curr->next;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
char* target_own_fpr = NULL;
|
|
|
|
|
|
|
|
|
|
// Last shot...
|
|
|
|
|
PEP_STATUS status = get_user_default_key(session, own_id,
|
|
|
|
|
&target_own_fpr);
|
|
|
|
|
|
|
|
|
|
if (status == PEP_STATUS_OK && !EMPTYSTR(target_own_fpr)) {
|
|
|
|
|
if (is_trusted_own_priv_fpr(session, own_id, target_own_fpr)) {
|
|
|
|
|
if (!reject_fpr(session, target_own_fpr))
|
|
|
|
|
return target_own_fpr;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// TODO: We can also go through all of the other available fprs for the
|
|
|
|
|
// own identity, but then I submit this function requires a little refactoring
|
|
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @internal
|
|
|
|
|
*
|
|
|
|
@ -5417,7 +5018,7 @@ static PEP_STATUS _decrypt_message(
|
|
|
|
|
if (extra) {
|
|
|
|
|
stringlist_t* curr_key = NULL;
|
|
|
|
|
for (curr_key = extra; curr_key && curr_key->value; curr_key = curr_key->next) {
|
|
|
|
|
stringlist_t* found = stringlist_search(_keylist, curr_key->value);
|
|
|
|
|
const stringlist_t* found = stringlist_search(_keylist, curr_key->value);
|
|
|
|
|
if (!found) {
|
|
|
|
|
key_missing = true;
|
|
|
|
|
break;
|
|
|
|
@ -5558,6 +5159,12 @@ DYNAMIC_API PEP_STATUS decrypt_message(
|
|
|
|
|
rating, flags, NULL,
|
|
|
|
|
&imported_key_fprs, &changed_key_bitvec);
|
|
|
|
|
|
|
|
|
|
if (src->dir == PEP_dir_incoming) {
|
|
|
|
|
PEP_rating rating2;
|
|
|
|
|
PEP_STATUS status2 = incoming_message_rating(session, src, *dst, *keylist, NULL, status, rating);
|
|
|
|
|
assert(status2 != PEP_ILLEGAL_VALUE);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
message *msg = *dst ? *dst : src;
|
|
|
|
|
|
|
|
|
|
if (session->inject_sync_event && msg && msg->from &&
|
|
|
|
@ -5646,180 +5253,6 @@ DYNAMIC_API PEP_STATUS own_message_private_key_details(
|
|
|
|
|
return status;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Note: if comm_type_determine is false, it generally means that
|
|
|
|
|
// we were unable to get key information for anyone in the list,
|
|
|
|
|
// likely because a key is missing.
|
|
|
|
|
// Cannot propagate PASSPHRASE errors.
|
|
|
|
|
/**
|
|
|
|
|
* @internal
|
|
|
|
|
*
|
|
|
|
|
* <!-- _max_comm_type_from_identity_list() -->
|
|
|
|
|
*
|
|
|
|
|
* @brief TODO
|
|
|
|
|
*
|
|
|
|
|
* @param[in] *identities identity_list
|
|
|
|
|
* @param[in] session PEP_SESSION
|
|
|
|
|
* @param[in] *max_comm_type PEP_comm_type
|
|
|
|
|
* @param[in] *comm_type_determined bool
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
static void _max_comm_type_from_identity_list(
|
|
|
|
|
identity_list *identities,
|
|
|
|
|
PEP_SESSION session,
|
|
|
|
|
PEP_comm_type *max_comm_type,
|
|
|
|
|
bool *comm_type_determined
|
|
|
|
|
)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
identity_list * il;
|
|
|
|
|
for (il = identities; il != NULL; il = il->next)
|
|
|
|
|
{
|
|
|
|
|
if (il->ident)
|
|
|
|
|
{
|
|
|
|
|
PEP_STATUS status = PEP_STATUS_OK;
|
|
|
|
|
*max_comm_type = _get_comm_type(session, *max_comm_type,
|
|
|
|
|
il->ident);
|
|
|
|
|
*comm_type_determined = true;
|
|
|
|
|
|
|
|
|
|
bool is_blacklisted = false;
|
|
|
|
|
if (il->ident->fpr && IS_PGP_CT(il->ident->comm_type)) {
|
|
|
|
|
status = blacklist_is_listed(session, il->ident->fpr, &is_blacklisted);
|
|
|
|
|
if (is_blacklisted) {
|
|
|
|
|
bool user_default, ident_default, address_default;
|
|
|
|
|
status = get_valid_pubkey(session, il->ident,
|
|
|
|
|
&ident_default, &user_default,
|
|
|
|
|
&address_default,
|
|
|
|
|
true);
|
|
|
|
|
|
|
|
|
|
if (status != PEP_STATUS_OK || il->ident->fpr == NULL) {
|
|
|
|
|
il->ident->comm_type = PEP_ct_key_not_found;
|
|
|
|
|
if (*max_comm_type > PEP_ct_no_encryption)
|
|
|
|
|
*max_comm_type = PEP_ct_no_encryption;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// check for the return statuses which might not a representative
|
|
|
|
|
// value in the comm_type
|
|
|
|
|
if (status == PEP_ILLEGAL_VALUE || status == PEP_CANNOT_SET_PERSON ||
|
|
|
|
|
status == PEP_CANNOT_FIND_IDENTITY) {
|
|
|
|
|
// PEP_CANNOT_FIND_IDENTITY only comes back when we've really
|
|
|
|
|
// got nothing from update_identity after applying the whole
|
|
|
|
|
// heuristic
|
|
|
|
|
*max_comm_type = PEP_ct_no_encryption;
|
|
|
|
|
*comm_type_determined = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @internal
|
|
|
|
|
*
|
|
|
|
|
* <!-- _max_comm_type_from_identity_list_preview() -->
|
|
|
|
|
*
|
|
|
|
|
* @brief TODO
|
|
|
|
|
*
|
|
|
|
|
* @param[in] *identities identity_list
|
|
|
|
|
* @param[in] session PEP_SESSION
|
|
|
|
|
* @param[in] *max_comm_type PEP_comm_type
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
static void _max_comm_type_from_identity_list_preview(
|
|
|
|
|
identity_list *identities,
|
|
|
|
|
PEP_SESSION session,
|
|
|
|
|
PEP_comm_type *max_comm_type
|
|
|
|
|
)
|
|
|
|
|
{
|
|
|
|
|
identity_list * il;
|
|
|
|
|
for (il = identities; il != NULL; il = il->next)
|
|
|
|
|
{
|
|
|
|
|
if (il->ident)
|
|
|
|
|
{
|
|
|
|
|
*max_comm_type = _get_comm_type_preview(session, *max_comm_type,
|
|
|
|
|
il->ident);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
DYNAMIC_API PEP_STATUS outgoing_message_rating(
|
|
|
|
|
PEP_SESSION session,
|
|
|
|
|
message *msg,
|
|
|
|
|
PEP_rating *rating
|
|
|
|
|
)
|
|
|
|
|
{
|
|
|
|
|
PEP_comm_type max_comm_type = PEP_ct_pEp;
|
|
|
|
|
|
|
|
|
|
bool comm_type_determined = false;
|
|
|
|
|
|
|
|
|
|
assert(session);
|
|
|
|
|
assert(msg);
|
|
|
|
|
assert(msg->dir == PEP_dir_outgoing);
|
|
|
|
|
assert(rating);
|
|
|
|
|
|
|
|
|
|
if (!(session && msg && rating))
|
|
|
|
|
return PEP_ILLEGAL_VALUE;
|
|
|
|
|
|
|
|
|
|
if (msg->dir != PEP_dir_outgoing)
|
|
|
|
|
return PEP_ILLEGAL_VALUE;
|
|
|
|
|
|
|
|
|
|
*rating = PEP_rating_undefined;
|
|
|
|
|
|
|
|
|
|
_max_comm_type_from_identity_list(msg->to, session,
|
|
|
|
|
&max_comm_type, &comm_type_determined);
|
|
|
|
|
|
|
|
|
|
_max_comm_type_from_identity_list(msg->cc, session,
|
|
|
|
|
&max_comm_type, &comm_type_determined);
|
|
|
|
|
|
|
|
|
|
_max_comm_type_from_identity_list(msg->bcc, session,
|
|
|
|
|
&max_comm_type, &comm_type_determined);
|
|
|
|
|
|
|
|
|
|
if (comm_type_determined == false) {
|
|
|
|
|
// likely means there was a massive screwup with no sender or recipient
|
|
|
|
|
// keys
|
|
|
|
|
*rating = PEP_rating_undefined;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
*rating = _MAX(_rating(max_comm_type), PEP_rating_unencrypted);
|
|
|
|
|
|
|
|
|
|
return PEP_STATUS_OK;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
DYNAMIC_API PEP_STATUS outgoing_message_rating_preview(
|
|
|
|
|
PEP_SESSION session,
|
|
|
|
|
message *msg,
|
|
|
|
|
PEP_rating *rating
|
|
|
|
|
)
|
|
|
|
|
{
|
|
|
|
|
PEP_comm_type max_comm_type = PEP_ct_pEp;
|
|
|
|
|
|
|
|
|
|
assert(session);
|
|
|
|
|
assert(msg);
|
|
|
|
|
assert(msg->dir == PEP_dir_outgoing);
|
|
|
|
|
assert(rating);
|
|
|
|
|
|
|
|
|
|
if (!(session && msg && rating))
|
|
|
|
|
return PEP_ILLEGAL_VALUE;
|
|
|
|
|
|
|
|
|
|
if (msg->dir != PEP_dir_outgoing)
|
|
|
|
|
return PEP_ILLEGAL_VALUE;
|
|
|
|
|
|
|
|
|
|
*rating = PEP_rating_undefined;
|
|
|
|
|
|
|
|
|
|
_max_comm_type_from_identity_list_preview(msg->to, session,
|
|
|
|
|
&max_comm_type);
|
|
|
|
|
|
|
|
|
|
_max_comm_type_from_identity_list_preview(msg->cc, session,
|
|
|
|
|
&max_comm_type);
|
|
|
|
|
|
|
|
|
|
_max_comm_type_from_identity_list_preview(msg->bcc, session,
|
|
|
|
|
&max_comm_type);
|
|
|
|
|
|
|
|
|
|
*rating = _MAX(_rating(max_comm_type), PEP_rating_unencrypted);
|
|
|
|
|
|
|
|
|
|
return PEP_STATUS_OK;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// CAN return PASSPHRASE errors on own keys because
|
|
|
|
|
// of myself. Will not, however, return PASSPHRASE
|
|
|
|
|
// errors if the incoming ident isn't marked as an own
|
|
|
|
@ -5870,7 +5303,7 @@ DYNAMIC_API PEP_STATUS identity_rating(
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (status == PEP_STATUS_OK)
|
|
|
|
|
*rating = _rating(ident->comm_type);
|
|
|
|
|
*rating = rating_from_comm_type(ident->comm_type);
|
|
|
|
|
|
|
|
|
|
return status;
|
|
|
|
|
}
|
|
|
|
@ -6556,7 +5989,7 @@ DYNAMIC_API PEP_STATUS get_key_rating_for_user(
|
|
|
|
|
goto the_end;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
*rating = _rating(ident->comm_type);
|
|
|
|
|
*rating = rating_from_comm_type(ident->comm_type);
|
|
|
|
|
|
|
|
|
|
the_end:
|
|
|
|
|
free_identity(ident);
|
|
|
|
|