Some more small things I found while self-rewiewing

This commit is contained in:
Hocuri
2025-09-15 17:34:41 +02:00
parent 43d65cb012
commit 380f6e2786
4 changed files with 12 additions and 10 deletions

View File

@@ -10,7 +10,7 @@ use crate::pgp;
/// Tries to decrypt a message, but only if it is structured as an Autocrypt message. /// Tries to decrypt a message, but only if it is structured as an Autocrypt message.
/// ///
/// If successful and the message is encrypted, /// If successful and the message was encrypted,
/// returns the decrypted and decompressed message. /// returns the decrypted and decompressed message.
pub fn try_decrypt<'a>( pub fn try_decrypt<'a>(
mail: &'a ParsedMail<'a>, mail: &'a ParsedMail<'a>,

View File

@@ -9,16 +9,15 @@ use crate::context::Context;
use crate::key; use crate::key;
use crate::key::DcKey; use crate::key::DcKey;
use crate::mimeparser::MimeMessage; use crate::mimeparser::MimeMessage;
pub use crate::pgp; use crate::pgp;
use crate::pgp::KeyPair;
use self::pgp::KeyPair;
pub fn key_from_asc(data: &str) -> Result<key::SignedSecretKey> { pub fn key_from_asc(data: &str) -> Result<key::SignedSecretKey> {
key::SignedSecretKey::from_asc(data) key::SignedSecretKey::from_asc(data)
} }
pub async fn store_self_keypair(context: &Context, keypair: &KeyPair) -> Result<()> { pub async fn store_self_keypair(context: &Context, keypair: &KeyPair) -> Result<()> {
crate::key::store_self_keypair(context, keypair).await key::store_self_keypair(context, keypair).await
} }
pub async fn parse_and_get_text(context: &Context, imf_raw: &[u8]) -> Result<String> { pub async fn parse_and_get_text(context: &Context, imf_raw: &[u8]) -> Result<String> {

View File

@@ -1921,6 +1921,9 @@ fn should_encrypt_with_auth_token(msg: &Message) -> bool {
fn should_encrypt_with_broadcast_secret(msg: &Message, chat: &Chat) -> bool { fn should_encrypt_with_broadcast_secret(msg: &Message, chat: &Chat) -> bool {
chat.typ == Chattype::OutBroadcast chat.typ == Chattype::OutBroadcast
// The only `SystemMessage::SecurejoinMessage` that is ever sent into a broadcast,
// which is `vb-request-with-auth`,
// should be encrypted with the AUTH token rather than the broadcast secret.
&& msg.param.get_cmd() != SystemMessage::SecurejoinMessage && msg.param.get_cmd() != SystemMessage::SecurejoinMessage
// The member-added message in a broadcast must be asymmetrically encrypted, // The member-added message in a broadcast must be asymmetrically encrypted,
// because the newly-added member doesn't know the broadcast shared secret yet: // because the newly-added member doesn't know the broadcast shared secret yet:

View File

@@ -232,11 +232,11 @@ pub fn pk_calc_signature(
Ok(sig.to_armored_string(ArmorOptions::default())?) Ok(sig.to_armored_string(ArmorOptions::default())?)
} }
/// Decrypts the message with keys from the private key keyring. /// Decrypts the message:
/// /// - with keys from the private key keyring (passed in `private_keys_for_decryption`)
/// Receiver private keys are passed in `private_keys_for_decryption`, /// if the message was asymmetrically encrypted,
/// shared secrets used for symmetric encryption /// - with a shared secret/password (passed in `shared_secrets`),
/// are passed in `shared_secrets`. /// if the message was symmetrically encrypted.
/// ///
/// Returns the decrypted and decompressed message. /// Returns the decrypted and decompressed message.
pub fn decrypt( pub fn decrypt(