Add support for PKCS8v1 ED25519 keys

This commit is contained in:
mdecimus 2023-07-28 10:18:27 +02:00
parent 9ff09c98ba
commit 66170bc177
2 changed files with 39 additions and 10 deletions

View file

@ -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)?;
(

View file

@ -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