mirror of
https://github.com/chatmail/core.git
synced 2026-04-26 18:06:35 +03:00
Some more small things I found while self-rewiewing
This commit is contained in:
@@ -10,7 +10,7 @@ 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,
|
||||
/// If successful and the message was encrypted,
|
||||
/// returns the decrypted and decompressed message.
|
||||
pub fn try_decrypt<'a>(
|
||||
mail: &'a ParsedMail<'a>,
|
||||
|
||||
@@ -9,16 +9,15 @@ use crate::context::Context;
|
||||
use crate::key;
|
||||
use crate::key::DcKey;
|
||||
use crate::mimeparser::MimeMessage;
|
||||
pub use crate::pgp;
|
||||
|
||||
use self::pgp::KeyPair;
|
||||
use crate::pgp;
|
||||
use crate::pgp::KeyPair;
|
||||
|
||||
pub fn key_from_asc(data: &str) -> Result<key::SignedSecretKey> {
|
||||
key::SignedSecretKey::from_asc(data)
|
||||
}
|
||||
|
||||
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> {
|
||||
|
||||
@@ -1921,6 +1921,9 @@ fn should_encrypt_with_auth_token(msg: &Message) -> bool {
|
||||
|
||||
fn should_encrypt_with_broadcast_secret(msg: &Message, chat: &Chat) -> bool {
|
||||
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
|
||||
// The member-added message in a broadcast must be asymmetrically encrypted,
|
||||
// because the newly-added member doesn't know the broadcast shared secret yet:
|
||||
|
||||
10
src/pgp.rs
10
src/pgp.rs
@@ -232,11 +232,11 @@ pub fn pk_calc_signature(
|
||||
Ok(sig.to_armored_string(ArmorOptions::default())?)
|
||||
}
|
||||
|
||||
/// Decrypts the message with keys from the private key keyring.
|
||||
///
|
||||
/// Receiver private keys are passed in `private_keys_for_decryption`,
|
||||
/// shared secrets used for symmetric encryption
|
||||
/// are passed in `shared_secrets`.
|
||||
/// Decrypts the message:
|
||||
/// - with keys from the private key keyring (passed in `private_keys_for_decryption`)
|
||||
/// if the message was asymmetrically encrypted,
|
||||
/// - with a shared secret/password (passed in `shared_secrets`),
|
||||
/// if the message was symmetrically encrypted.
|
||||
///
|
||||
/// Returns the decrypted and decompressed message.
|
||||
pub fn decrypt(
|
||||
|
||||
Reference in New Issue
Block a user