diff --git a/benches/benchmark_decrypting.rs b/benches/benchmark_decrypting.rs
index 47162e52a..f46cf7a7e 100644
--- a/benches/benchmark_decrypting.rs
+++ b/benches/benchmark_decrypting.rs
@@ -71,7 +71,7 @@ fn criterion_benchmark(c: &mut Criterion) {
});
b.iter(|| {
- let mut msg =
+ let (mut msg, _) =
decrypt(encrypted.clone().into_bytes(), &[], black_box(&secrets)).unwrap();
let decrypted = msg.as_data_vec().unwrap();
@@ -101,7 +101,7 @@ fn criterion_benchmark(c: &mut Criterion) {
});
b.iter(|| {
- let mut msg = decrypt(
+ let (mut msg, _) = decrypt(
encrypted.clone().into_bytes(),
&[key_pair.secret.clone()],
black_box(&secrets),
diff --git a/src/chat.rs b/src/chat.rs
index 682c0e6a8..933dcee1b 100644
--- a/src/chat.rs
+++ b/src/chat.rs
@@ -2941,10 +2941,13 @@ async fn prepare_send_msg(
SystemMessage::MemberRemovedFromGroup | SystemMessage::SecurejoinMessage
)
}
- CantSendReason::MissingKey => msg
- .param
- .get_bool(Param::ForcePlaintext)
- .unwrap_or_default(),
+ CantSendReason::MissingKey => {
+ msg.param
+ .get_bool(Param::ForcePlaintext)
+ .unwrap_or_default()
+ // V2 securejoin messages are symmetrically encrypted, no need for the public key:
+ || msg.securejoin_step() == Some("vb-request-v2")
+ }
_ => false,
};
if let Some(reason) = chat.why_cant_send_ex(context, &skip_fn).await? {
@@ -3878,11 +3881,13 @@ pub(crate) async fn save_broadcast_shared_secret(
chat_id: ChatId,
secret: &str,
) -> Result<()> {
+ info!(context, "Saving broadcast secret for chat {chat_id}");
+ info!(context, "dbg the new secret for chat {chat_id} is {secret}");
context
.sql
.execute(
"INSERT INTO broadcasts_shared_secrets (chat_id, secret) VALUES (?, ?)
- ON CONFLICT(chat_id) DO UPDATE SET secret=excluded.chat_id",
+ ON CONFLICT(chat_id) DO UPDATE SET secret=excluded.secret",
(chat_id, secret),
)
.await?;
diff --git a/src/chat/chat_tests.rs b/src/chat/chat_tests.rs
index f6681e573..0f1b07cd4 100644
--- a/src/chat/chat_tests.rs
+++ b/src/chat/chat_tests.rs
@@ -7,7 +7,7 @@ use crate::imex::{ImexMode, has_backup, imex};
use crate::message::{MessengerMessage, delete_msgs};
use crate::mimeparser::{self, MimeMessage};
use crate::receive_imf::receive_imf;
-use crate::securejoin::get_securejoin_qr;
+use crate::securejoin::{get_securejoin_qr, join_securejoin};
use crate::test_utils::{
AVATAR_64x64_BYTES, AVATAR_64x64_DEDUPLICATED, E2EE_INFO_MSGS, TestContext, TestContextManager,
TimeShiftFalsePositiveNote, sync,
@@ -3094,8 +3094,12 @@ async fn test_leave_broadcast_multidevice() -> Result<()> {
tcm.section("Alice creates broadcast channel with Bob.");
let alice_chat_id = create_broadcast(alice, "foo".to_string()).await?;
let qr = get_securejoin_qr(alice, Some(alice_chat_id)).await.unwrap();
- tcm.exec_securejoin_qr(bob0, alice, &qr).await;
- sync(bob0, bob1).await;
+ join_securejoin(bob0, &qr).await.unwrap();
+ let request = bob0.pop_sent_msg().await;
+ alice.recv_msg(&request).await;
+ let answer = alice.pop_sent_msg().await;
+ bob0.recv_msg(&answer).await;
+ bob1.recv_msg(&answer).await;
tcm.section("Alice sends first message to broadcast.");
let sent_msg = alice.send_text(alice_chat_id, "Hello!").await;
diff --git a/src/decrypt.rs b/src/decrypt.rs
index 3da5217d8..48f8cd4a2 100644
--- a/src/decrypt.rs
+++ b/src/decrypt.rs
@@ -10,18 +10,22 @@ use crate::pgp;
/// Tries to decrypt a message, but only if it is structured as an Autocrypt message.
///
-/// If successful and the message is encrypted, returns decrypted body.
+/// If successful and the message is encrypted, returns a tuple of:
+///
+/// - The decrypted and decompressed message
+/// - If the message was symmetrically encrypted:
+/// The index in `shared_secrets` of the secret used to decrypt the message.
pub fn try_decrypt<'a>(
mail: &'a ParsedMail<'a>,
private_keyring: &'a [SignedSecretKey],
- symmetric_secrets: &[String],
-) -> Result