diff --git a/crates/smtp/src/config/auth.rs b/crates/smtp/src/config/auth.rs index 8ff6b2c6..2c976e3b 100644 --- a/crates/smtp/src/config/auth.rs +++ b/crates/smtp/src/config/auth.rs @@ -235,17 +235,20 @@ impl ConfigAuth for Config { })?; } - let key = Ed25519Key::from_seed_and_public_key(&private_key, &public_key) + let key = Ed25519Key::from_pkcs8_maybe_unchecked_der(&private_key) + .or_else(|_| { + Ed25519Key::from_seed_and_public_key(&private_key, &public_key) + }) .map_err(|err| { - format!("Failed to build ED25519 key for signature {id:?}: {err}") - })?; - let key_clone = - Ed25519Key::from_seed_and_public_key(&private_key, &public_key) - .map_err(|err| { - format!( - "Failed to build ED25519 key for signature {id:?}: {err}" - ) - })?; + format!("Failed to build ED25519 key for signature {id:?}: {err}") + })?; + let key_clone = Ed25519Key::from_pkcs8_maybe_unchecked_der(&private_key) + .or_else(|_| { + Ed25519Key::from_seed_and_public_key(&private_key, &public_key) + }) + .map_err(|err| { + format!("Failed to build ED25519 key for signature {id:?}: {err}") + })?; let (signer, sealer) = parse_signature(self, id, key_clone, key)?; ( diff --git a/tests/resources/test_config.toml b/tests/resources/test_config.toml index e61095ea..f6b9a1ed 100644 --- a/tests/resources/test_config.toml +++ b/tests/resources/test_config.toml @@ -198,3 +198,29 @@ allow-plain-text = true [imap.rate-limit] requests = "90000/1s" concurrent = 9000 + +[signature."ed25519"] +public-key = "-----BEGIN PUBLIC KEY----- +MCowBQYDK2VwAyEAUA3S0BdVG7LeA1agv7ZtqLkQMn+/AoYx1VPyGmLWEIM= +-----END PUBLIC KEY-----" +private-key = "-----BEGIN PRIVATE KEY----- +MC4CAQAwBQYDK2VwBCIEIPdRszAzLvx4JaSIE4dQdZtN9y2XW+55K+YkCJI6lcn8 +-----END PRIVATE KEY-----" +domain = "example.org" +selector = "stalwart_ed" +headers = ["From", "To", "Date", "Subject", "Message-ID"] +algorithm = "ed25519-sha256" +canonicalization = "simple/simple" +set-body-length = true +report = true + +[signature."ed25519-2"] +public-key = "11qYAYKxCrfVS/7TyWQHOg7hcvPapiMlrwIaaPcHURo=" +private-key = "nWGxne/9WmC6hEr0kuwsxERJxWl7MmkZcDusAxyuf2A=" +domain = "example.org" +selector = "stalwart_ed2" +headers = ["From", "To", "Date", "Subject", "Message-ID"] +algorithm = "ed25519-sha256" +canonicalization = "simple/simple" +set-body-length = true +report = true