mirror of
https://github.com/chatmail/core.git
synced 2026-05-13 20:06:30 +03:00
It compiles
This commit is contained in:
@@ -19,6 +19,8 @@ pub enum QrObject {
|
|||||||
invitenumber: String,
|
invitenumber: String,
|
||||||
/// Authentication code.
|
/// Authentication code.
|
||||||
authcode: String,
|
authcode: String,
|
||||||
|
/// Whether the sender supports the new Securejoin v3 protocol
|
||||||
|
is_v3: bool,
|
||||||
},
|
},
|
||||||
/// Ask the user whether to join the group.
|
/// Ask the user whether to join the group.
|
||||||
AskVerifyGroup {
|
AskVerifyGroup {
|
||||||
@@ -34,6 +36,8 @@ pub enum QrObject {
|
|||||||
invitenumber: String,
|
invitenumber: String,
|
||||||
/// Authentication code.
|
/// Authentication code.
|
||||||
authcode: String,
|
authcode: String,
|
||||||
|
/// Whether the sender supports the new Securejoin v3 protocol
|
||||||
|
is_v3: bool,
|
||||||
},
|
},
|
||||||
/// Ask the user whether to join the broadcast channel.
|
/// Ask the user whether to join the broadcast channel.
|
||||||
AskJoinBroadcast {
|
AskJoinBroadcast {
|
||||||
@@ -54,6 +58,8 @@ pub enum QrObject {
|
|||||||
invitenumber: String,
|
invitenumber: String,
|
||||||
/// Authentication code.
|
/// Authentication code.
|
||||||
authcode: String,
|
authcode: String,
|
||||||
|
/// Whether the sender supports the new Securejoin v3 protocol
|
||||||
|
is_v3: bool,
|
||||||
},
|
},
|
||||||
/// Contact fingerprint is verified.
|
/// Contact fingerprint is verified.
|
||||||
///
|
///
|
||||||
@@ -229,6 +235,7 @@ impl From<Qr> for QrObject {
|
|||||||
fingerprint,
|
fingerprint,
|
||||||
invitenumber,
|
invitenumber,
|
||||||
authcode,
|
authcode,
|
||||||
|
is_v3,
|
||||||
} => {
|
} => {
|
||||||
let contact_id = contact_id.to_u32();
|
let contact_id = contact_id.to_u32();
|
||||||
let fingerprint = fingerprint.to_string();
|
let fingerprint = fingerprint.to_string();
|
||||||
@@ -237,6 +244,7 @@ impl From<Qr> for QrObject {
|
|||||||
fingerprint,
|
fingerprint,
|
||||||
invitenumber,
|
invitenumber,
|
||||||
authcode,
|
authcode,
|
||||||
|
is_v3,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Qr::AskVerifyGroup {
|
Qr::AskVerifyGroup {
|
||||||
@@ -246,6 +254,7 @@ impl From<Qr> for QrObject {
|
|||||||
fingerprint,
|
fingerprint,
|
||||||
invitenumber,
|
invitenumber,
|
||||||
authcode,
|
authcode,
|
||||||
|
is_v3,
|
||||||
} => {
|
} => {
|
||||||
let contact_id = contact_id.to_u32();
|
let contact_id = contact_id.to_u32();
|
||||||
let fingerprint = fingerprint.to_string();
|
let fingerprint = fingerprint.to_string();
|
||||||
@@ -256,6 +265,7 @@ impl From<Qr> for QrObject {
|
|||||||
fingerprint,
|
fingerprint,
|
||||||
invitenumber,
|
invitenumber,
|
||||||
authcode,
|
authcode,
|
||||||
|
is_v3,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Qr::AskJoinBroadcast {
|
Qr::AskJoinBroadcast {
|
||||||
@@ -265,6 +275,7 @@ impl From<Qr> for QrObject {
|
|||||||
fingerprint,
|
fingerprint,
|
||||||
authcode,
|
authcode,
|
||||||
invitenumber,
|
invitenumber,
|
||||||
|
is_v3,
|
||||||
} => {
|
} => {
|
||||||
let contact_id = contact_id.to_u32();
|
let contact_id = contact_id.to_u32();
|
||||||
let fingerprint = fingerprint.to_string();
|
let fingerprint = fingerprint.to_string();
|
||||||
@@ -275,6 +286,7 @@ impl From<Qr> for QrObject {
|
|||||||
fingerprint,
|
fingerprint,
|
||||||
authcode,
|
authcode,
|
||||||
invitenumber,
|
invitenumber,
|
||||||
|
is_v3,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Qr::FprOk { contact_id } => {
|
Qr::FprOk { contact_id } => {
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ pub struct Aheader {
|
|||||||
pub public_key: SignedPublicKey,
|
pub public_key: SignedPublicKey,
|
||||||
pub prefer_encrypt: EncryptPreference,
|
pub prefer_encrypt: EncryptPreference,
|
||||||
|
|
||||||
// Whether `_verified` attribute is present.
|
/// Whether `_verified` attribute is present.
|
||||||
//
|
//
|
||||||
// `_verified` attribute is an extension to `Autocrypt-Gossip`
|
// `_verified` attribute is an extension to `Autocrypt-Gossip`
|
||||||
// header that is used to tell that the sender
|
// header that is used to tell that the sender
|
||||||
|
|||||||
@@ -1915,8 +1915,7 @@ fn render_outer_message(
|
|||||||
let mut buffer = Vec::new();
|
let mut buffer = Vec::new();
|
||||||
let cursor = Cursor::new(&mut buffer);
|
let cursor = Cursor::new(&mut buffer);
|
||||||
outer_message.clone().write_part(cursor).ok();
|
outer_message.clone().write_part(cursor).ok();
|
||||||
let message = String::from_utf8_lossy(&buffer).to_string();
|
String::from_utf8_lossy(&buffer).to_string()
|
||||||
message
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Takes the encrypted part, wraps it in a MimePart,
|
/// Takes the encrypted part, wraps it in a MimePart,
|
||||||
@@ -2279,15 +2278,14 @@ pub(crate) async fn render_symm_encrypted_securejoin_message(
|
|||||||
|
|
||||||
let from_addr = context.get_primary_self_addr().await?;
|
let from_addr = context.get_primary_self_addr().await?;
|
||||||
let from = new_address_with_name("", from_addr.to_string());
|
let from = new_address_with_name("", from_addr.to_string());
|
||||||
|
|
||||||
let mut to: Vec<Address<'static>> = Vec::new();
|
|
||||||
to.push(hidden_recipients());
|
|
||||||
|
|
||||||
headers.push(("From", from.into()));
|
headers.push(("From", from.into()));
|
||||||
|
|
||||||
|
let to: Vec<Address<'static>> = vec![hidden_recipients()];
|
||||||
headers.push((
|
headers.push((
|
||||||
"To",
|
"To",
|
||||||
mail_builder::headers::address::Address::new_list(to.clone()).into(),
|
mail_builder::headers::address::Address::new_list(to.clone()).into(),
|
||||||
));
|
));
|
||||||
|
|
||||||
headers.push((
|
headers.push((
|
||||||
"Subject",
|
"Subject",
|
||||||
mail_builder::headers::text::Text::new("Secure-Join".to_string()).into(),
|
mail_builder::headers::text::Text::new("Secure-Join".to_string()).into(),
|
||||||
|
|||||||
14
src/qr.rs
14
src/qr.rs
@@ -61,6 +61,9 @@ pub enum Qr {
|
|||||||
|
|
||||||
/// Authentication code.
|
/// Authentication code.
|
||||||
authcode: String,
|
authcode: String,
|
||||||
|
|
||||||
|
/// Whether the sender supports the new Securejoin v3 protocol
|
||||||
|
is_v3: bool,
|
||||||
},
|
},
|
||||||
|
|
||||||
/// Ask the user whether to join the group.
|
/// Ask the user whether to join the group.
|
||||||
@@ -82,6 +85,9 @@ pub enum Qr {
|
|||||||
|
|
||||||
/// Authentication code.
|
/// Authentication code.
|
||||||
authcode: String,
|
authcode: String,
|
||||||
|
|
||||||
|
/// Whether the sender supports the new Securejoin v3 protocol
|
||||||
|
is_v3: bool,
|
||||||
},
|
},
|
||||||
|
|
||||||
/// Ask whether to join the broadcast channel.
|
/// Ask whether to join the broadcast channel.
|
||||||
@@ -106,6 +112,9 @@ pub enum Qr {
|
|||||||
invitenumber: String,
|
invitenumber: String,
|
||||||
/// Authentication code.
|
/// Authentication code.
|
||||||
authcode: String,
|
authcode: String,
|
||||||
|
|
||||||
|
/// Whether the sender supports the new Securejoin v3 protocol
|
||||||
|
is_v3: bool,
|
||||||
},
|
},
|
||||||
|
|
||||||
/// Contact fingerprint is verified.
|
/// Contact fingerprint is verified.
|
||||||
@@ -501,6 +510,8 @@ async fn decode_openpgp(context: &Context, qr: &str) -> Result<Qr> {
|
|||||||
let grpname = decode_name(¶m, "g")?;
|
let grpname = decode_name(¶m, "g")?;
|
||||||
let broadcast_name = decode_name(¶m, "b")?;
|
let broadcast_name = decode_name(¶m, "b")?;
|
||||||
|
|
||||||
|
let is_v3 = param.get("v") == Some(&"3");
|
||||||
|
|
||||||
if let (Some(addr), Some(invitenumber), Some(authcode)) = (&addr, invitenumber, authcode) {
|
if let (Some(addr), Some(invitenumber), Some(authcode)) = (&addr, invitenumber, authcode) {
|
||||||
let addr = ContactAddress::new(addr)?;
|
let addr = ContactAddress::new(addr)?;
|
||||||
let (contact_id, _) = Contact::add_or_lookup_ex(
|
let (contact_id, _) = Contact::add_or_lookup_ex(
|
||||||
@@ -546,6 +557,7 @@ async fn decode_openpgp(context: &Context, qr: &str) -> Result<Qr> {
|
|||||||
fingerprint,
|
fingerprint,
|
||||||
invitenumber,
|
invitenumber,
|
||||||
authcode,
|
authcode,
|
||||||
|
is_v3,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
} else if let (Some(grpid), Some(name)) = (grpid, broadcast_name) {
|
} else if let (Some(grpid), Some(name)) = (grpid, broadcast_name) {
|
||||||
@@ -581,6 +593,7 @@ async fn decode_openpgp(context: &Context, qr: &str) -> Result<Qr> {
|
|||||||
fingerprint,
|
fingerprint,
|
||||||
invitenumber,
|
invitenumber,
|
||||||
authcode,
|
authcode,
|
||||||
|
is_v3,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
} else if context.is_self_addr(&addr).await? {
|
} else if context.is_self_addr(&addr).await? {
|
||||||
@@ -605,6 +618,7 @@ async fn decode_openpgp(context: &Context, qr: &str) -> Result<Qr> {
|
|||||||
fingerprint,
|
fingerprint,
|
||||||
invitenumber,
|
invitenumber,
|
||||||
authcode,
|
authcode,
|
||||||
|
is_v3,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
} else if let Some(addr) = addr {
|
} else if let Some(addr) = addr {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
//! Bob's side of SecureJoin handling, the joiner-side.
|
//! Bob's side of SecureJoin handling, the joiner-side.
|
||||||
|
|
||||||
use anyhow::{Context as _, Result, bail};
|
use anyhow::{Context as _, Result};
|
||||||
|
|
||||||
use super::HandshakeMessage;
|
use super::HandshakeMessage;
|
||||||
use super::qrinvite::QrInvite;
|
use super::qrinvite::QrInvite;
|
||||||
@@ -363,27 +363,25 @@ pub(crate) async fn send_handshake_message(
|
|||||||
msg.id = MsgId::new(u32::try_from(raw_id)?);
|
msg.id = MsgId::new(u32::try_from(raw_id)?);
|
||||||
*/
|
*/
|
||||||
|
|
||||||
let row_ids = create_send_msg_jobs(context, msg)
|
|
||||||
.await
|
|
||||||
.context("Failed to create send jobs")?;
|
|
||||||
|
|
||||||
let rfc724_mid = create_outgoing_rfc724_mid();
|
let rfc724_mid = create_outgoing_rfc724_mid();
|
||||||
let contact = Contact::get_by_id(context, invite.contact_id()).await?;
|
let contact = Contact::get_by_id(context, invite.contact_id()).await?;
|
||||||
let recipient = contact.get_addr();
|
let recipient = contact.get_addr();
|
||||||
|
let attach_self_pubkey = false;
|
||||||
let rendered_message = mimefactory::render_symm_encrypted_securejoin_message(
|
let rendered_message = mimefactory::render_symm_encrypted_securejoin_message(
|
||||||
context,
|
context,
|
||||||
recipient,
|
step.securejoin_header(invite),
|
||||||
rfc724_mid,
|
&rfc724_mid,
|
||||||
|
attach_self_pubkey,
|
||||||
invite.authcode(),
|
invite.authcode(),
|
||||||
)
|
)
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
|
// TODO code duplication
|
||||||
context
|
context
|
||||||
.sql
|
.sql
|
||||||
.execute(
|
.execute(
|
||||||
"INSERT INTO smtp (rfc724_mid, recipients, mime, msg_id)
|
"INSERT INTO smtp (rfc724_mid, recipients, mime, msg_id)
|
||||||
VALUES (?1, ?2, ?3, ?4)",
|
VALUES (?1, ?2, ?3, ?4)",
|
||||||
(
|
(
|
||||||
&rfc724_mid,
|
&rfc724_mid,
|
||||||
&recipient,
|
&recipient,
|
||||||
|
|||||||
@@ -83,7 +83,7 @@ impl QrInvite {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn is_v3(&self) -> bool {
|
pub fn is_v3(&self) -> bool {
|
||||||
match self {
|
match *self {
|
||||||
QrInvite::Contact { is_v3, .. } => is_v3,
|
QrInvite::Contact { is_v3, .. } => is_v3,
|
||||||
QrInvite::Group { is_v3, .. } => is_v3,
|
QrInvite::Group { is_v3, .. } => is_v3,
|
||||||
QrInvite::Broadcast { is_v3, .. } => is_v3,
|
QrInvite::Broadcast { is_v3, .. } => is_v3,
|
||||||
@@ -101,11 +101,13 @@ impl TryFrom<Qr> for QrInvite {
|
|||||||
fingerprint,
|
fingerprint,
|
||||||
invitenumber,
|
invitenumber,
|
||||||
authcode,
|
authcode,
|
||||||
|
is_v3,
|
||||||
} => Ok(QrInvite::Contact {
|
} => Ok(QrInvite::Contact {
|
||||||
contact_id,
|
contact_id,
|
||||||
fingerprint,
|
fingerprint,
|
||||||
invitenumber,
|
invitenumber,
|
||||||
authcode,
|
authcode,
|
||||||
|
is_v3,
|
||||||
}),
|
}),
|
||||||
Qr::AskVerifyGroup {
|
Qr::AskVerifyGroup {
|
||||||
grpname,
|
grpname,
|
||||||
@@ -114,6 +116,7 @@ impl TryFrom<Qr> for QrInvite {
|
|||||||
fingerprint,
|
fingerprint,
|
||||||
invitenumber,
|
invitenumber,
|
||||||
authcode,
|
authcode,
|
||||||
|
is_v3,
|
||||||
} => Ok(QrInvite::Group {
|
} => Ok(QrInvite::Group {
|
||||||
contact_id,
|
contact_id,
|
||||||
fingerprint,
|
fingerprint,
|
||||||
@@ -121,6 +124,7 @@ impl TryFrom<Qr> for QrInvite {
|
|||||||
grpid,
|
grpid,
|
||||||
invitenumber,
|
invitenumber,
|
||||||
authcode,
|
authcode,
|
||||||
|
is_v3,
|
||||||
}),
|
}),
|
||||||
Qr::AskJoinBroadcast {
|
Qr::AskJoinBroadcast {
|
||||||
name,
|
name,
|
||||||
@@ -129,6 +133,7 @@ impl TryFrom<Qr> for QrInvite {
|
|||||||
fingerprint,
|
fingerprint,
|
||||||
authcode,
|
authcode,
|
||||||
invitenumber,
|
invitenumber,
|
||||||
|
is_v3,
|
||||||
} => Ok(QrInvite::Broadcast {
|
} => Ok(QrInvite::Broadcast {
|
||||||
name,
|
name,
|
||||||
grpid,
|
grpid,
|
||||||
@@ -136,6 +141,7 @@ impl TryFrom<Qr> for QrInvite {
|
|||||||
fingerprint,
|
fingerprint,
|
||||||
authcode,
|
authcode,
|
||||||
invitenumber,
|
invitenumber,
|
||||||
|
is_v3,
|
||||||
}),
|
}),
|
||||||
_ => bail!("Unsupported QR type"),
|
_ => bail!("Unsupported QR type"),
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user