Files
kumomta/crates/dkim
Wez Furlong d331df5965 dkim: add separate key cache to signer machinery
The signer cache maps the signer parameters to a pre-made
signing context.

It is essentially a map of (domain, key) -> signer.

Assuming that the (domain,key) tuple is unique, then this is
a good, effective use of that cache.

However, if multiple domains can share the same key then we
can end up re-parsing the same key data for each of them,
which is moderately expensive and a waste of CPU.

This commit introduces an additional cache for the key source to
the resultant compiled key.

This allows sharing of the same compiled key across signing
parameters that otherwise vary, and should help to shave off
some latency.
2025-02-06 16:47:15 -07:00
..
2024-04-10 13:26:49 -07:00
2024-04-10 13:26:49 -07:00
2023-06-15 09:10:39 -07:00
2023-06-15 09:10:39 -07:00
2023-06-15 09:10:39 -07:00
2023-06-15 09:10:39 -07:00
2023-08-25 08:55:30 -07:00

kumo-dkim

DKIM (RFC6376) implementation

Features

Verifying email signatures

Example:

let res: DKIMResult = kumo_dkim::verify_email(&from_domain, &parsed_email).await?;

if let Some(err) = &res.error() {
  error!(logger, "dkim verify fail: {}", err);
}

println!("dkim={}", res.with_detail());

Signing an email

Example:

let private_key =
    rsa::RsaPrivateKey::read_pkcs1_pem_file(Path::new("./test/keys/2022.private"))?;

let signer = SignerBuilder::new()
    .with_signed_headers(["From", "Subject"])?
    .with_private_key(private_key)
    .with_selector("2020")
    .with_signing_domain("example.com")
    .build()?;
let signature = signer.sign(&email)?;

println!("{}", signature); // DKIM-Signature: ...

See the SignerBuilder object documentation for more information.

Generate a test DKIM key

Using OpenDKIM:

opendkim-genkey \
    --testmode \
    --domain=example.com \
    --selector=2022 \
    --nosubdomains