mirror of
https://github.com/chatmail/core.git
synced 2026-05-08 09:26:29 +03:00
remove encrypted attr from mimeparser.
This commit is contained in:
@@ -1389,7 +1389,7 @@ fn check_verified_properties(
|
|||||||
) -> Result<()> {
|
) -> Result<()> {
|
||||||
let contact = Contact::load_from_db(context, from_id)?;
|
let contact = Contact::load_from_db(context, from_id)?;
|
||||||
|
|
||||||
ensure!(mimeparser.encrypted, "This message is not encrypted.");
|
ensure!(mimeparser.was_encrypted(), "This message is not encrypted.");
|
||||||
|
|
||||||
// ensure, the contact is verified
|
// ensure, the contact is verified
|
||||||
// and the message is signed with a verified key of the sender.
|
// and the message is signed with a verified key of the sender.
|
||||||
|
|||||||
@@ -30,7 +30,6 @@ pub struct MimeParser<'a> {
|
|||||||
pub parts: Vec<Part>,
|
pub parts: Vec<Part>,
|
||||||
pub header: HashMap<String, String>,
|
pub header: HashMap<String, String>,
|
||||||
pub decrypting_failed: bool,
|
pub decrypting_failed: bool,
|
||||||
pub encrypted: bool,
|
|
||||||
pub signatures: HashSet<String>,
|
pub signatures: HashSet<String>,
|
||||||
pub gossipped_addr: HashSet<String>,
|
pub gossipped_addr: HashSet<String>,
|
||||||
pub is_forwarded: bool,
|
pub is_forwarded: bool,
|
||||||
@@ -73,7 +72,8 @@ impl<'a> MimeParser<'a> {
|
|||||||
parts: Vec::new(),
|
parts: Vec::new(),
|
||||||
header: Default::default(),
|
header: Default::default(),
|
||||||
decrypting_failed: false,
|
decrypting_failed: false,
|
||||||
encrypted: false,
|
|
||||||
|
// only non-empty if it was a valid autocrypt message
|
||||||
signatures: Default::default(),
|
signatures: Default::default(),
|
||||||
gossipped_addr: Default::default(),
|
gossipped_addr: Default::default(),
|
||||||
is_forwarded: false,
|
is_forwarded: false,
|
||||||
@@ -100,7 +100,6 @@ impl<'a> MimeParser<'a> {
|
|||||||
let mail = match e2ee::try_decrypt(parser.context, &mail, message_time) {
|
let mail = match e2ee::try_decrypt(parser.context, &mail, message_time) {
|
||||||
Ok((raw, signatures)) => {
|
Ok((raw, signatures)) => {
|
||||||
// Valid autocrypt message, encrypted
|
// Valid autocrypt message, encrypted
|
||||||
parser.encrypted = raw.is_some();
|
|
||||||
parser.signatures = signatures;
|
parser.signatures = signatures;
|
||||||
|
|
||||||
if let Some(raw) = raw {
|
if let Some(raw) = raw {
|
||||||
@@ -330,6 +329,10 @@ impl<'a> MimeParser<'a> {
|
|||||||
self.parts.iter_mut().rev().find(|part| !part.is_meta)
|
self.parts.iter_mut().rev().find(|part| !part.is_meta)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn was_encrypted(&self) -> bool {
|
||||||
|
!self.signatures.is_empty()
|
||||||
|
}
|
||||||
|
|
||||||
pub(crate) fn has_chat_version(&self) -> bool {
|
pub(crate) fn has_chat_version(&self) -> bool {
|
||||||
self.header.contains_key("chat-version")
|
self.header.contains_key("chat-version")
|
||||||
}
|
}
|
||||||
@@ -450,6 +453,9 @@ impl<'a> MimeParser<'a> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
(mime::MULTIPART, "encrypted") => {
|
(mime::MULTIPART, "encrypted") => {
|
||||||
|
// we currently do not try to decrypt non-autocrypt messages
|
||||||
|
// at all. If we see an encrypted part, we set
|
||||||
|
// decrypting_failed.
|
||||||
let msg_body = self.context.stock_str(StockMessage::CantDecryptMsgBody);
|
let msg_body = self.context.stock_str(StockMessage::CantDecryptMsgBody);
|
||||||
let txt = format!("[{}]", msg_body);
|
let txt = format!("[{}]", msg_body);
|
||||||
|
|
||||||
@@ -636,15 +642,8 @@ impl<'a> MimeParser<'a> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn do_add_single_part(&mut self, mut part: Part) {
|
fn do_add_single_part(&mut self, mut part: Part) {
|
||||||
if self.encrypted {
|
if self.was_encrypted() {
|
||||||
if !self.signatures.is_empty() {
|
part.param.set_int(Param::GuaranteeE2ee, 1);
|
||||||
part.param.set_int(Param::GuaranteeE2ee, 1);
|
|
||||||
} else {
|
|
||||||
// XXX if the message was encrypted but not signed
|
|
||||||
// it's not neccessarily an error we need to signal.
|
|
||||||
// we could just treat it as if it was not encrypted.
|
|
||||||
part.param.set_int(Param::ErroneousE2ee, 0x2);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
self.parts.push(part);
|
self.parts.push(part);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -422,7 +422,7 @@ pub(crate) fn handle_securejoin_handshake(
|
|||||||
could_not_establish_secure_connection(
|
could_not_establish_secure_connection(
|
||||||
context,
|
context,
|
||||||
contact_chat_id,
|
contact_chat_id,
|
||||||
if mimeparser.encrypted {
|
if mimeparser.was_encrypted() {
|
||||||
"No valid signature."
|
"No valid signature."
|
||||||
} else {
|
} else {
|
||||||
"Not encrypted."
|
"Not encrypted."
|
||||||
@@ -717,7 +717,7 @@ fn mark_peer_as_verified(context: &Context, fingerprint: impl AsRef<str>) -> Res
|
|||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
|
|
||||||
fn encrypted_and_signed(mimeparser: &MimeParser, expected_fingerprint: impl AsRef<str>) -> bool {
|
fn encrypted_and_signed(mimeparser: &MimeParser, expected_fingerprint: impl AsRef<str>) -> bool {
|
||||||
if !mimeparser.encrypted {
|
if !mimeparser.was_encrypted() {
|
||||||
warn!(mimeparser.context, "Message not encrypted.",);
|
warn!(mimeparser.context, "Message not encrypted.",);
|
||||||
false
|
false
|
||||||
} else if mimeparser.signatures.is_empty() {
|
} else if mimeparser.signatures.is_empty() {
|
||||||
|
|||||||
Reference in New Issue
Block a user