securejoin: do not check the signatures existance twice

Mimeparser.was_encrypted() checks if the message is an Autocrypt encrypted
message. It already means the message has a valid signature.

This commit documents a few functions to make it clear that signatures
stored in Mimeparser must be valid and must always come from encrypted
messages.

Also one unwrap() is eliminated in encrypted_and_signed(). It is possible
to further simplify encrypted_and_signed() by skipping the was_encrypted()
check, because the function only returns true if there is a matching
signature, but it is helpful for debugging to distinguish between
non-Autocrypt messages and messages whose fingerprint does not match.
This commit is contained in:
Alexander Krotov
2020-07-13 05:08:42 +03:00
committed by holger krekel
parent 64ab86a1a6
commit 6902250d6b
3 changed files with 29 additions and 16 deletions

View File

@@ -115,6 +115,12 @@ impl EncryptHelper {
}
}
/// Tries to decrypt a message, but only if it is structured as an
/// Autocrypt message, i.e. encrypted and signed with a valid
/// signature.
///
/// Returns decrypted body and a set of valid signature fingerprints
/// if successful.
pub async fn try_decrypt(
context: &Context,
mail: &ParsedMail<'_>,