mirror of
https://github.com/chatmail/core.git
synced 2026-05-03 05:16:28 +03:00
feat: Store symmetric key non-redundantly in the database
This commit is contained in:
@@ -1143,7 +1143,7 @@ impl MimeFactory {
|
||||
Loaded::Mdn { .. } => true,
|
||||
};
|
||||
|
||||
let symmetric_key = match &self.loaded {
|
||||
let symmetric_key: Option<String> = match &self.loaded {
|
||||
Loaded::Message { chat, .. } if chat.typ == Chattype::OutBroadcast => {
|
||||
// If there is no symmetric key yet
|
||||
// (because this is an old broadcast channel,
|
||||
@@ -1152,7 +1152,13 @@ impl MimeFactory {
|
||||
// Symmetric encryption exists since 2025-08;
|
||||
// some time after that, we can think about requiring everyone
|
||||
// to switch to symmetrically-encrypted broadcast lists.
|
||||
chat.param.get(Param::SymmetricKey)
|
||||
context
|
||||
.sql
|
||||
.query_get_value(
|
||||
"SELECT secret FROM broadcasts_shared_secrets WHERE chat_id=?",
|
||||
(chat.id,),
|
||||
)
|
||||
.await?
|
||||
}
|
||||
_ => None,
|
||||
};
|
||||
@@ -1160,7 +1166,7 @@ impl MimeFactory {
|
||||
let encrypted = if let Some(symmetric_key) = symmetric_key {
|
||||
info!(context, "Symmetrically encrypting for broadcast channel.");
|
||||
encrypt_helper
|
||||
.encrypt_for_broadcast(context, symmetric_key, message, compress)
|
||||
.encrypt_for_broadcast(context, &symmetric_key, message, compress)
|
||||
.await?
|
||||
} else {
|
||||
// Asymmetric encryption
|
||||
|
||||
Reference in New Issue
Block a user