email-auth
A Rust library implementing email authentication protocols: SPF, DKIM, DMARC, ARC, and BIMI.
Installation
[]
= "0.1.2"
Requires Rust edition 2024 (Rust 1.85+) and Tokio.
Quick Start
use ;
use Disposition;
// Implement DnsResolver for your DNS backend (see below)
let auth = new;
let result = auth.authenticate.await?;
match result.dmarc.disposition
DNS Resolver
The library is DNS-backend agnostic. Implement the DnsResolver trait:
use ;
use ;
DNS caching is the caller's responsibility — implement it at the resolver layer.
Individual Protocols
Each protocol can be used independently:
SPF
use ;
let result = check_host.await;
match result
DKIM
use ;
let verifier = new;
let results = verifier.verify_message.await;
// headers: &[(&str, &str)] — (name, value) pairs
// body: &[u8]
for result in &results
DMARC
use DmarcEvaluator;
let evaluator = new;
let result = evaluator.evaluate.await;
ARC
use ;
// Validate incoming ARC chain
let validator = new;
let chain_result = validator.validate.await;
// Seal outgoing message (as intermediary)
let sealer = new;
let new_headers = sealer.seal.await?;
BIMI
use BimiVerifier;
let verifier = new;
let result = verifier.discover.await;
RFC Compliance
| Protocol | RFC | Status |
|---|---|---|
| SPF | RFC 7208 | Full — including void lookup limits, include/redirect semantics, macro expansion |
| DKIM | RFC 6376 | Full — RSA-SHA256, Ed25519, relaxed/simple canonicalization, key revocation |
| DMARC | RFC 7489 | Full — alignment, pct sampling, subdomain/np= policy, reporting URIs |
| ARC | RFC 8617 | Full — chain validation, oldest-pass algorithm, sealing |
| BIMI | draft-bimi | Record discovery, SVG Tiny PS validation, VMC certificate chain |
Security Considerations
- SPF: DNS lookup limit (10) and void lookup limit (2) enforced per RFC 7208 §4.6.4
- DKIM: Minimum RSA key size 1024-bit;
t=sstrict mode enforced; clock skew configurable - DMARC:
p=rejectoutside pct sample correctly downgrades to quarantine (not none) - SVG: 32KB size limit, XXE prevention via
<!ENTITY>detection, script/event handler rejection - ARC: Forward-confirmed PTR validation; chain integrity verified before oldest-pass selection
License
Dual-licensed: MIT OR Apache-2.0