stalwartlabs / mail-auth

DKIM, ARC, SPF and DMARC library for Rust
https://docs.rs/mail-auth/
Apache License 2.0
82 stars 13 forks source link

Implement signing and verification using *ring* #10

Closed djc closed 1 year ago

djc commented 1 year ago

Took some time to figure out the remaining issues, but this seems to be in pretty good shape now!

Also fixed the test that broke on main after 25abc977799d76dd3af4d2b71c4c95748c1e285e.

mdecimus commented 1 year ago

Merged, thank you very much for the contribution! I was thinking that ring should be the default crypto backend since trust-dns is already using it. I'll do some tests and make that change shortly.

mdecimus commented 1 year ago

@djc I found something weird, the ARC validation is failing with CryptoError("ring::error::Unspecified") on a message that can be successfully verified with rust-crypto. This message is available under resources/arc/002.txt and here is the output of the test:

$ cargo test arc_verify
    Finished test [unoptimized + debuginfo] target(s) in 0.08s
     Running unittests src/lib.rs (target/debug/deps/mail_auth-6af072c951a7fde6)

running 3 tests
test dmarc::verify::test::dmarc_verify_report_address ... ok
test dmarc::verify::test::dmarc_verify ... ok
test arc::verify::test::arc_verify ... FAILED

failures:

---- arc::verify::test::arc_verify stdout ----
file /home/vagrant/code/mail-auth/resources/arc/002.txt
thread 'arc::verify::test::arc_verify' panicked at 'assertion failed: `(left == right)`
  left: `Fail(CryptoError("ring::error::Unspecified"))`,
 right: `Pass`', src/arc/verify.rs:211:13
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

failures:
    arc::verify::test::arc_verify

test result: FAILED. 2 passed; 1 failed; 0 ignored; 0 measured; 29 filtered out; finished in 0.01s

error: test failed, to rerun pass `--lib`
djc commented 1 year ago

Ah, but you added this after the PR was merged, right? I'll have a look at it tomorrow.

mdecimus commented 1 year ago

That's correct, I added the 002.txt test to help you track the problem. The error is triggered when the Ed25519 seal is verified. Thanks.