diff --git a/deltachat-ffi/deltachat.h b/deltachat-ffi/deltachat.h index ee50d1644..ffd22d9af 100644 --- a/deltachat-ffi/deltachat.h +++ b/deltachat-ffi/deltachat.h @@ -440,14 +440,6 @@ char* dc_get_blobdir (const dc_context_t* context); * also show all mails of confirmed contacts, * DC_SHOW_EMAILS_ALL (2)= * also show mails of unconfirmed contacts (default). - * - `key_gen_type` = DC_KEY_GEN_DEFAULT (0)= - * generate recommended key type (default), - * DC_KEY_GEN_RSA2048 (1)= - * generate RSA 2048 keypair - * DC_KEY_GEN_ED25519 (2)= - * generate Curve25519 keypair - * DC_KEY_GEN_RSA4096 (3)= - * generate RSA 4096 keypair * - `delete_device_after` = 0=do not delete messages from device automatically (default), * >=1=seconds, after which messages are deleted automatically from the device. * Messages in the "saved messages" chat (see dc_chat_is_self_talk()) are skipped. @@ -6546,15 +6538,6 @@ void dc_event_unref(dc_event_t* event); #define DC_MEDIA_QUALITY_WORSE 1 -/* - * Values for dc_get|set_config("key_gen_type") - */ -#define DC_KEY_GEN_DEFAULT 0 -#define DC_KEY_GEN_RSA2048 1 -#define DC_KEY_GEN_ED25519 2 -#define DC_KEY_GEN_RSA4096 3 - - /** * @defgroup DC_PROVIDER_STATUS DC_PROVIDER_STATUS * diff --git a/python/tests/test_1_online.py b/python/tests/test_1_online.py index 1a3ce113f..985417ad1 100644 --- a/python/tests/test_1_online.py +++ b/python/tests/test_1_online.py @@ -31,37 +31,6 @@ def test_basic_imap_api(acfactory, tmp_path): imap2.shutdown() -@pytest.mark.ignored() -def test_configure_generate_key(acfactory, lp): - # A slow test which will generate new keys. - acfactory.remove_preconfigured_keys() - ac1 = acfactory.new_online_configuring_account(key_gen_type=str(dc.const.DC_KEY_GEN_RSA2048)) - ac2 = acfactory.new_online_configuring_account(key_gen_type=str(dc.const.DC_KEY_GEN_ED25519)) - acfactory.bring_accounts_online() - chat = acfactory.get_accepted_chat(ac1, ac2) - - lp.sec("ac1: send unencrypted message to ac2") - chat.send_text("message1") - lp.sec("ac2: waiting for message from ac1") - msg_in = ac2._evtracker.wait_next_incoming_message() - assert msg_in.text == "message1" - assert not msg_in.is_encrypted() - - lp.sec("ac2: send encrypted message to ac1") - msg_in.chat.send_text("message2") - lp.sec("ac1: waiting for message from ac2") - msg2_in = ac1._evtracker.wait_next_incoming_message() - assert msg2_in.text == "message2" - assert msg2_in.is_encrypted() - - lp.sec("ac1: send encrypted message to ac2") - msg2_in.chat.send_text("message3") - lp.sec("ac2: waiting for message from ac1") - msg3_in = ac2._evtracker.wait_next_incoming_message() - assert msg3_in.text == "message3" - assert msg3_in.is_encrypted() - - def test_configure_canceled(acfactory): ac1 = acfactory.new_online_configuring_account() ac1.stop_ongoing() diff --git a/src/config.rs b/src/config.rs index f1db35916..795110014 100644 --- a/src/config.rs +++ b/src/config.rs @@ -193,10 +193,6 @@ pub enum Config { #[strum(props(default = "1"))] FetchedExistingMsgs, - /// Type of the OpenPGP key to generate. - #[strum(props(default = "0"))] - KeyGenType, - /// Timer in seconds after which the message is deleted from the /// server. /// diff --git a/src/constants.rs b/src/constants.rs index 898b8c5ec..e26f17b5a 100644 --- a/src/constants.rs +++ b/src/constants.rs @@ -58,25 +58,6 @@ pub enum MediaQuality { Worse = 1, } -/// Type of the key to generate. -#[derive( - Debug, Default, Display, Clone, Copy, PartialEq, Eq, FromPrimitive, ToPrimitive, FromSql, ToSql, -)] -#[repr(u8)] -pub enum KeyGenType { - #[default] - Default = 0, - - /// 2048-bit RSA. - Rsa2048 = 1, - - /// [Ed25519](https://ed25519.cr.yp.to/) signature and X25519 encryption. - Ed25519 = 2, - - /// 4096-bit RSA. - Rsa4096 = 3, -} - /// Video chat URL type. #[derive( Debug, Default, Display, Clone, Copy, PartialEq, Eq, FromPrimitive, ToPrimitive, FromSql, ToSql, @@ -255,16 +236,6 @@ mod tests { assert_eq!(Chattype::Broadcast, Chattype::from_i32(160).unwrap()); } - #[test] - fn test_keygentype_values() { - // values may be written to disk and must not change - assert_eq!(KeyGenType::Default, KeyGenType::default()); - assert_eq!(KeyGenType::Default, KeyGenType::from_i32(0).unwrap()); - assert_eq!(KeyGenType::Rsa2048, KeyGenType::from_i32(1).unwrap()); - assert_eq!(KeyGenType::Ed25519, KeyGenType::from_i32(2).unwrap()); - assert_eq!(KeyGenType::Rsa4096, KeyGenType::from_i32(3).unwrap()); - } - #[test] fn test_showemails_values() { // values may be written to disk and must not change diff --git a/src/context.rs b/src/context.rs index 154eb999d..de6689907 100644 --- a/src/context.rs +++ b/src/context.rs @@ -938,10 +938,6 @@ impl Context { res.insert("configured_trash_folder", configured_trash_folder); res.insert("mdns_enabled", mdns_enabled.to_string()); res.insert("e2ee_enabled", e2ee_enabled.to_string()); - res.insert( - "key_gen_type", - self.get_config_int(Config::KeyGenType).await?.to_string(), - ); res.insert("bcc_self", bcc_self.to_string()); res.insert("sync_msgs", sync_msgs.to_string()); res.insert("disable_idle", disable_idle.to_string()); diff --git a/src/key.rs b/src/key.rs index 0582f5d28..95a1fef8e 100644 --- a/src/key.rs +++ b/src/key.rs @@ -7,7 +7,6 @@ use std::io::Cursor; use anyhow::{bail, ensure, Context as _, Result}; use base64::Engine as _; use deltachat_contact_tools::EmailAddress; -use num_traits::FromPrimitive; use pgp::composed::Deserializable; pub use pgp::composed::{SignedPublicKey, SignedSecretKey}; use pgp::ser::Serialize; @@ -15,8 +14,6 @@ use pgp::types::{PublicKeyTrait, SecretKeyTrait}; use rand::thread_rng; use tokio::runtime::Handle; -use crate::config::Config; -use crate::constants::KeyGenType; use crate::context::Context; use crate::log::LogExt; use crate::pgp::KeyPair; @@ -282,11 +279,9 @@ async fn generate_keypair(context: &Context) -> Result { Some(key_pair) => Ok(key_pair), None => { let start = tools::Time::now(); - let keytype = KeyGenType::from_i32(context.get_config_int(Config::KeyGenType).await?) - .unwrap_or_default(); - info!(context, "Generating keypair with type {}", keytype); + info!(context, "Generating keypair."); let keypair = Handle::current() - .spawn_blocking(move || crate::pgp::create_keypair(addr, keytype)) + .spawn_blocking(move || crate::pgp::create_keypair(addr)) .await??; store_self_keypair(context, &keypair).await?; @@ -466,6 +461,7 @@ mod tests { use once_cell::sync::Lazy; use super::*; + use crate::config::Config; use crate::test_utils::{alice_keypair, TestContext}; static KEYPAIR: Lazy = Lazy::new(alice_keypair); diff --git a/src/pgp.rs b/src/pgp.rs index 48db25bc6..2973bab27 100644 --- a/src/pgp.rs +++ b/src/pgp.rs @@ -18,7 +18,6 @@ use pgp::types::{CompressionAlgorithm, PublicKeyTrait, SignatureBytes, StringToK use rand::{thread_rng, CryptoRng, Rng}; use tokio::runtime::Handle; -use crate::constants::KeyGenType; use crate::key::{DcKey, Fingerprint}; #[cfg(test)] @@ -181,15 +180,9 @@ impl KeyPair { /// /// Both secret and public key consist of signing primary key and encryption subkey /// as [described in the Autocrypt standard](https://autocrypt.org/level1.html#openpgp-based-key-data). -pub(crate) fn create_keypair(addr: EmailAddress, keygen_type: KeyGenType) -> Result { - let (signing_key_type, encryption_key_type) = match keygen_type { - KeyGenType::Rsa2048 => (PgpKeyType::Rsa(2048), PgpKeyType::Rsa(2048)), - KeyGenType::Rsa4096 => (PgpKeyType::Rsa(4096), PgpKeyType::Rsa(4096)), - KeyGenType::Ed25519 | KeyGenType::Default => ( - PgpKeyType::EdDSALegacy, - PgpKeyType::ECDH(ECCCurve::Curve25519), - ), - }; +pub(crate) fn create_keypair(addr: EmailAddress) -> Result { + let signing_key_type = PgpKeyType::EdDSALegacy; + let encryption_key_type = PgpKeyType::ECDH(ECCCurve::Curve25519); let user_id = format!("<{addr}>"); let key_params = SecretKeyParamsBuilder::default() @@ -478,16 +471,8 @@ mod tests { #[test] fn test_create_keypair() { - let keypair0 = create_keypair( - EmailAddress::new("foo@bar.de").unwrap(), - KeyGenType::Default, - ) - .unwrap(); - let keypair1 = create_keypair( - EmailAddress::new("two@zwo.de").unwrap(), - KeyGenType::Default, - ) - .unwrap(); + let keypair0 = create_keypair(EmailAddress::new("foo@bar.de").unwrap()).unwrap(); + let keypair1 = create_keypair(EmailAddress::new("two@zwo.de").unwrap()).unwrap(); assert_ne!(keypair0.public, keypair1.public); }