Files
kumomta/crates/dkim
Wez Furlong 334a19963c deps: base64 -> data_encoding
dependabot wanted to upgrade to base64 0.21, but I resent that
the API for the common case of base64 encoding got more difficult
in the move from 0.13.

So, I'm switching us to data_encoding's implementation instead.

Note that the overall rust ecosystem on which we depend here,
transitively depends on 3 different versions of the base64 crate, so
even though we've removed direct deps on base64 from kumomta, the lock
file still references base64 0.10, 0.13 and 0.21, so that kinda sucks.
2024-02-06 13:56:41 -07:00
..
2024-02-06 13:56:41 -07:00
2023-06-15 09:10:39 -07:00
2023-06-15 09:10:39 -07:00
2024-02-06 13:56:41 -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