mirror of
https://github.com/chatmail/core.git
synced 2026-04-17 21:46:35 +03:00
refactor: Rename to symm_encrypt_message()
This commit is contained in:
@@ -38,7 +38,7 @@ use deltachat::{
|
||||
internals_for_benchmarks::key_from_asc,
|
||||
internals_for_benchmarks::parse_and_get_text,
|
||||
internals_for_benchmarks::store_self_keypair,
|
||||
pgp::{KeyPair, decrypt, encrypt_symmetrically, pk_encrypt},
|
||||
pgp::{KeyPair, decrypt, pk_encrypt, symm_encrypt_message},
|
||||
stock_str::StockStrings,
|
||||
};
|
||||
use rand::{Rng, thread_rng};
|
||||
@@ -83,7 +83,7 @@ fn criterion_benchmark(c: &mut Criterion) {
|
||||
let secrets = generate_secrets();
|
||||
let encrypted = tokio::runtime::Runtime::new().unwrap().block_on(async {
|
||||
let secret = secrets[NUM_SECRETS / 2].clone();
|
||||
let encrypted = encrypt_symmetrically(
|
||||
let encrypted = symm_encrypt_message(
|
||||
plain.clone(),
|
||||
black_box(&secret),
|
||||
create_dummy_keypair("alice@example.org").unwrap().secret,
|
||||
|
||||
@@ -76,7 +76,7 @@ impl EncryptHelper {
|
||||
mail_to_encrypt.clone().write_part(cursor).ok();
|
||||
|
||||
let ctext =
|
||||
pgp::encrypt_symmetrically(raw_message, shared_secret, sign_key, compress).await?;
|
||||
pgp::symm_encrypt_message(raw_message, shared_secret, sign_key, compress).await?;
|
||||
|
||||
Ok(ctext)
|
||||
}
|
||||
|
||||
@@ -98,7 +98,7 @@ pub async fn render_setup_file(context: &Context, passphrase: &str) -> Result<St
|
||||
true => Some(("Autocrypt-Prefer-Encrypt", "mutual")),
|
||||
};
|
||||
let private_key_asc = private_key.to_asc(ac_headers);
|
||||
let encr = pgp::symm_encrypt(passphrase, private_key_asc.into_bytes())
|
||||
let encr = pgp::symm_encrypt_setup_file(passphrase, private_key_asc.into_bytes())
|
||||
.await?
|
||||
.replace('\n', "\r\n");
|
||||
|
||||
|
||||
13
src/pgp.rs
13
src/pgp.rs
@@ -362,8 +362,8 @@ pub fn pk_validate(
|
||||
Ok(ret)
|
||||
}
|
||||
|
||||
/// Symmetric encryption.
|
||||
pub async fn symm_encrypt(passphrase: &str, plain: Vec<u8>) -> Result<String> {
|
||||
/// Symmetric encryption for the autocrypt setup file.
|
||||
pub async fn symm_encrypt_setup_file(passphrase: &str, plain: Vec<u8>) -> Result<String> {
|
||||
let passphrase = Password::from(passphrase.to_string());
|
||||
|
||||
tokio::task::spawn_blocking(move || {
|
||||
@@ -380,11 +380,10 @@ pub async fn symm_encrypt(passphrase: &str, plain: Vec<u8>) -> Result<String> {
|
||||
.await?
|
||||
}
|
||||
|
||||
/// Symmetrically encrypt the message to be sent into a broadcast channel,
|
||||
/// or for version 2 of the Securejoin protocol.
|
||||
/// Symmetrically encrypt the message.
|
||||
/// This is used for broadcast channels and for version 2 of the Securejoin protocol.
|
||||
/// `shared secret` is the secret that will be used for symmetric encryption.
|
||||
// TODO this name is veeery similar to `symm_encrypt()`
|
||||
pub async fn encrypt_symmetrically(
|
||||
pub async fn symm_encrypt_message(
|
||||
plain: Vec<u8>,
|
||||
shared_secret: &str,
|
||||
private_key_for_signing: SignedSecretKey,
|
||||
@@ -654,7 +653,7 @@ mod tests {
|
||||
|
||||
let plain = Vec::from(b"this is the secret message");
|
||||
let shared_secret = "shared secret";
|
||||
let ctext = encrypt_symmetrically(
|
||||
let ctext = symm_encrypt_message(
|
||||
plain.clone(),
|
||||
shared_secret,
|
||||
load_self_secret_key(alice).await?,
|
||||
|
||||
Reference in New Issue
Block a user