diff --git a/benches/benchmark_decrypting.rs b/benches/benchmark_decrypting.rs index 47162e52a..d36f3b2c4 100644 --- a/benches/benchmark_decrypting.rs +++ b/benches/benchmark_decrypting.rs @@ -1,7 +1,7 @@ -use std::path::PathBuf; -use std::{hint::black_box, io::Write}; +use std::hint::black_box; use criterion::{Criterion, criterion_group, criterion_main}; +use deltachat::benchmark_internals::create_dummy_keypair; use deltachat::benchmark_internals::save_broadcast_shared_secret; use deltachat::{ Events, @@ -11,10 +11,7 @@ use deltachat::{ chat::ChatId, config::Config, context::Context, - imex::{ImexMode, imex}, - key, - pgp::{KeyPair, create_dummy_keypair, decrypt, encrypt_for_broadcast, pk_encrypt}, - receive_imf, + pgp::{KeyPair, decrypt, encrypt_for_broadcast, pk_encrypt}, stock_str::StockStrings, tools::create_broadcast_shared_secret_pub, }; diff --git a/src/benchmark_internals.rs b/src/benchmark_internals.rs index 423e0882e..5b088a9aa 100644 --- a/src/benchmark_internals.rs +++ b/src/benchmark_internals.rs @@ -1,6 +1,8 @@ //! Re-exports of internal functions needed for benchmarks. +#![allow(missing_docs)] // Not necessary to put a doc comment on the pub functions here use anyhow::Result; +use deltachat_contact_tools::EmailAddress; use std::collections::BTreeMap; use crate::chat::ChatId; @@ -32,3 +34,7 @@ pub async fn save_broadcast_shared_secret( ) -> Result<()> { crate::chat::save_broadcast_shared_secret(context, chat_id, secret).await } + +pub fn create_dummy_keypair(addr: &str) -> Result { + pgp::create_keypair(EmailAddress::new(addr)?) +} diff --git a/src/e2ee.rs b/src/e2ee.rs index deae246be..4fbc4b013 100644 --- a/src/e2ee.rs +++ b/src/e2ee.rs @@ -56,8 +56,8 @@ impl EncryptHelper { println!( "\nEncrypting pk:\n{}\n", - str::from_utf8(&raw_message).unwrap() - ); + String::from_utf8_lossy(&raw_message) + ); // TODO let ctext = pgp::pk_encrypt(raw_message, keyring, Some(sign_key), compress).await?; @@ -80,8 +80,8 @@ impl EncryptHelper { println!( "\nEncrypting symm:\n{}\n", - str::from_utf8(&raw_message).unwrap() - ); + String::from_utf8_lossy(&raw_message) + ); // TODO let ctext = pgp::encrypt_for_broadcast(raw_message, passphrase, sign_key, compress).await?; diff --git a/src/pgp.rs b/src/pgp.rs index 8b73f530e..1b3031a54 100644 --- a/src/pgp.rs +++ b/src/pgp.rs @@ -26,7 +26,7 @@ use crate::key::{DcKey, Fingerprint}; #[cfg(test)] pub(crate) const HEADER_AUTOCRYPT: &str = "autocrypt-prefer-encrypt"; -pub const HEADER_SETUPCODE: &str = "passphrase-begin"; +pub(crate) const HEADER_SETUPCODE: &str = "passphrase-begin"; /// Preferred symmetric encryption algorithm. const SYMMETRIC_KEY_ALGORITHM: SymmetricKeyAlgorithm = SymmetricKeyAlgorithm::AES128; @@ -149,11 +149,6 @@ pub(crate) fn create_keypair(addr: EmailAddress) -> Result { Ok(key_pair) } -#[cfg(feature = "internals")] -pub fn create_dummy_keypair(addr: &str) -> Result { - create_keypair(EmailAddress::new(addr)?) -} - /// Selects a subkey of the public key to use for encryption. /// /// Returns `None` if the public key cannot be used for encryption. diff --git a/src/qr.rs b/src/qr.rs index d6b3378f1..86e9610db 100644 --- a/src/qr.rs +++ b/src/qr.rs @@ -86,16 +86,25 @@ pub enum Qr { /// Ask whether to join the broadcast channel. AskJoinBroadcast { - // TODO document + /// The user-visible name of this broadcast channel broadcast_name: String, - // TODO not sure wheter it makes sense to call this grpid just because it's called like this in the db + /// A string of random characters, + /// uniquely identifying this broadcast channel in the database. + /// Called `grpid` for historic reasons: + /// The id of multi-user chats is always called `grpid` in the database + /// because groups were once the only multi-user chats. grpid: String, + /// The contact id of the inviter contact_id: ContactId, + /// The PGP fingerprint of the inviter fingerprint: Fingerprint, + /// The AUTH code from the secure-join protocol, + /// which is both used to encrypt the first message to the inviter + /// and to prove to the inviter that we saw the QR code. authcode: String, },