Skip to content

Commit

Permalink
v0.3.1
Browse files Browse the repository at this point in the history
  • Loading branch information
mdecimus committed Apr 14, 2023
1 parent eb20e41 commit e589e5d
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 106 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
mail-auth 0.3.1
================================
- Fix: Avoid panicking on invalid RSA key input (#17)

mail-auth 0.3.0
================================
- ``ring`` backend support.
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "mail-auth"
description = "DKIM, ARC, SPF and DMARC library for Rust"
version = "0.3.0"
version = "0.3.1"
edition = "2021"
authors = [ "Stalwart Labs <[email protected]>"]
license = "Apache-2.0 OR MIT"
Expand Down
9 changes: 2 additions & 7 deletions src/arc/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,19 +79,14 @@ pub struct Set<'x> {
pub(crate) results: Header<'x, &'x Results>,
}

#[derive(Debug, PartialEq, Eq, Clone)]
#[derive(Debug, PartialEq, Eq, Clone, Default)]
pub(crate) enum ChainValidation {
#[default]
None,
Fail,
Pass,
}

impl Default for ChainValidation {
fn default() -> Self {
ChainValidation::None
}
}

impl VerifySignature for Signature {
fn signature(&self) -> &[u8] {
&self.b
Expand Down
3 changes: 2 additions & 1 deletion src/common/crypto/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,9 +144,10 @@ impl AsRef<[u8]> for HashOutput {
}
}

#[derive(Debug, Clone, Copy, PartialEq, Eq)]
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
pub enum Algorithm {
RsaSha1,
#[default]
RsaSha256,
Ed25519Sha256,
}
Expand Down
15 changes: 2 additions & 13 deletions src/dkim/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,9 @@ pub mod parse;
pub mod sign;
pub mod verify;

#[derive(Debug, Clone, Copy, PartialEq, Eq)]
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
pub enum Canonicalization {
#[default]
Relaxed,
Simple,
}
Expand Down Expand Up @@ -63,18 +64,6 @@ pub struct Signature {
pub(crate) cb: Canonicalization,
}

impl Default for Algorithm {
fn default() -> Self {
Algorithm::RsaSha256
}
}

impl Default for Canonicalization {
fn default() -> Self {
Canonicalization::Relaxed
}
}

#[derive(Debug, PartialEq, Eq, Clone)]
pub struct DomainKeyReport {
pub(crate) ra: String,
Expand Down
108 changes: 24 additions & 84 deletions src/report/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,27 +32,30 @@ pub struct ReportMetadata {
error: Vec<String>,
}

#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize, Default)]
pub enum Alignment {
Relaxed,
Strict,
#[default]
Unspecified,
}

#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize, Default)]
pub enum Disposition {
None,
Quarantine,
Reject,
#[default]
Unspecified,
}

#[derive(Debug, Hash, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
#[derive(Debug, Hash, Clone, Copy, PartialEq, Eq, Serialize, Deserialize, Default)]
pub enum ActionDisposition {
None,
Pass,
Quarantine,
Reject,
#[default]
Unspecified,
}

Expand All @@ -70,20 +73,22 @@ pub struct PolicyPublished {

impl Eq for PolicyPublished {}

#[derive(Debug, Clone, Copy, Hash, PartialEq, Eq, Serialize, Deserialize)]
#[derive(Debug, Clone, Copy, Hash, PartialEq, Eq, Serialize, Deserialize, Default)]
pub enum DmarcResult {
Pass,
Fail,
#[default]
Unspecified,
}

#[derive(Debug, Clone, Copy, Hash, PartialEq, Eq, Serialize, Deserialize)]
#[derive(Debug, Clone, Copy, Hash, PartialEq, Eq, Serialize, Deserialize, Default)]
pub enum PolicyOverride {
Forwarded,
SampledOut,
TrustedForwarder,
MailingList,
LocalPolicy,
#[default]
Other,
}

Expand Down Expand Up @@ -121,8 +126,9 @@ pub struct Identifier {
header_from: String,
}

#[derive(Debug, Clone, Copy, Hash, PartialEq, Eq, Serialize, Deserialize)]
#[derive(Debug, Clone, Copy, Hash, PartialEq, Eq, Serialize, Deserialize, Default)]
pub enum DkimResult {
#[default]
None,
Pass,
Fail,
Expand All @@ -140,15 +146,17 @@ pub struct DKIMAuthResult {
human_result: Option<String>,
}

#[derive(Debug, Clone, Copy, Hash, PartialEq, Eq, Serialize, Deserialize)]
#[derive(Debug, Clone, Copy, Hash, PartialEq, Eq, Serialize, Deserialize, Default)]
pub enum SPFDomainScope {
Helo,
MailFrom,
#[default]
Unspecified,
}

#[derive(Debug, Clone, Copy, Hash, PartialEq, Eq, Serialize, Deserialize)]
#[derive(Debug, Clone, Copy, Hash, PartialEq, Eq, Serialize, Deserialize, Default)]
pub enum SpfResult {
#[default]
None,
Neutral,
Pass,
Expand Down Expand Up @@ -191,54 +199,6 @@ pub struct Report {

impl Eq for Report {}

impl Default for Alignment {
fn default() -> Self {
Alignment::Unspecified
}
}

impl Default for Disposition {
fn default() -> Self {
Disposition::Unspecified
}
}

impl Default for ActionDisposition {
fn default() -> Self {
ActionDisposition::None
}
}

impl Default for DmarcResult {
fn default() -> Self {
DmarcResult::Unspecified
}
}

impl Default for PolicyOverride {
fn default() -> Self {
PolicyOverride::Other
}
}

impl Default for DkimResult {
fn default() -> Self {
DkimResult::None
}
}

impl Default for SpfResult {
fn default() -> Self {
SpfResult::None
}
}

impl Default for SPFDomainScope {
fn default() -> Self {
SPFDomainScope::Unspecified
}
}

#[derive(Debug, Clone, PartialEq, Eq)]
pub enum Error {
MailParseError,
Expand Down Expand Up @@ -287,70 +247,50 @@ pub struct Feedback<'x> {
headers: Option<Cow<'x, [u8]>>,
}

#[derive(Debug, Clone, PartialEq, Eq, Copy, Serialize, Deserialize)]
#[derive(Debug, Clone, PartialEq, Eq, Copy, Serialize, Deserialize, Default)]
pub enum AuthFailureType {
Adsp,
BodyHash,
Revoked,
Signature,
Spf,
Dmarc,
#[default]
Unspecified,
}

#[derive(Debug, Clone, PartialEq, Eq, Copy, Serialize, Deserialize)]
#[derive(Debug, Clone, PartialEq, Eq, Copy, Serialize, Deserialize, Default)]
pub enum IdentityAlignment {
None,
Spf,
Dkim,
DkimSpf,
#[default]
Unspecified,
}

#[derive(Debug, Clone, PartialEq, Eq, Copy, Serialize, Deserialize)]
#[derive(Debug, Clone, PartialEq, Eq, Copy, Serialize, Deserialize, Default)]
pub enum DeliveryResult {
Delivered,
Spam,
Policy,
Reject,
Other,
#[default]
Unspecified,
}

#[derive(Debug, Clone, PartialEq, Eq, Copy, Serialize, Deserialize)]
#[derive(Debug, Clone, PartialEq, Eq, Copy, Serialize, Deserialize, Default)]
pub enum FeedbackType {
Abuse,
AuthFailure,
Fraud,
NotSpam,
#[default]
Other,
Virus,
}

impl Default for AuthFailureType {
fn default() -> Self {
AuthFailureType::Unspecified
}
}

impl Default for IdentityAlignment {
fn default() -> Self {
IdentityAlignment::Unspecified
}
}

impl Default for DeliveryResult {
fn default() -> Self {
DeliveryResult::Unspecified
}
}

impl Default for FeedbackType {
fn default() -> Self {
FeedbackType::Other
}
}

impl From<&crate::DkimResult> for AuthFailureType {
fn from(value: &crate::DkimResult) -> Self {
match value {
Expand Down

0 comments on commit e589e5d

Please sign in to comment.