pub struct Signature {Show 17 fields
pub v: u32,
pub a: Algorithm,
pub d: String,
pub s: String,
pub b: Vec<u8>,
pub bh: Vec<u8>,
pub h: Vec<String>,
pub z: Vec<String>,
pub i: String,
pub l: u64,
pub x: u64,
pub t: u64,
pub r: bool,
pub atps: Option<String>,
pub atpsh: Option<HashAlgorithm>,
pub ch: Canonicalization,
pub cb: Canonicalization,
}Expand description
A DKIM1 signature: the tag list of a DKIM-Signature header (RFC 6376,
Section 3.5).
Obtained by parsing a header value with Signature::parse, from a
verified message through DkimOutput::signature, or as the result of
signing with DkimSigner. It is written back as a header through
HeaderWriter or Signature::write.
Each field is named after its tag.
Fields§
§v: u32v=: signature version; 1, or 0 when the tag is absent from a
parsed header.
a: Algorithma=: signing algorithm (RFC 6376, RFC 8301, RFC 8463).
d: Stringd=: signing domain identifier (SDID), the domain claiming
responsibility for the message.
s: Strings=: selector; the key record is looked up at
<s>._domainkey.<d>.
b: Vec<u8>b=: signature data, base64 decoded.
bh: Vec<u8>bh=: hash of the canonicalized body, base64 decoded.
h: Vec<String>h=: names of the signed header fields, in signing order.
z: Vec<String>z=: copied header fields, as name:value strings with quoted
printable decoded (diagnostic only).
i: Stringi=: agent or user identifier (AUID); empty when absent.
l: u64l=: body length in octets covered by the body hash; 0 means the
tag is absent and the whole body is signed.
x: u64x=: signature expiration, in seconds since the UNIX epoch; 0
means no expiration.
t: u64t=: signing time, in seconds since the UNIX epoch; 0 when absent.
r: boolr=y: the signer requests failure reports (RFC 6651, Section 3.1).
atps: Option<String>atps=: the domain authorizing this third-party signature (RFC 6541,
Section 4.1).
atpsh: Option<HashAlgorithm>atpsh=: hash algorithm applied to d= when building the ATPS query
name; None means atpsh=none, where d= is used verbatim
(RFC 6541, Section 4.1).
ch: CanonicalizationHeader canonicalization, the first half of the c= tag.
cb: CanonicalizationBody canonicalization, the second half of the c= tag.
Implementations§
Source§impl Signature
impl Signature
Sourcepub fn write(&self, writer: &mut impl Writer, as_header: bool)
pub fn write(&self, writer: &mut impl Writer, as_header: bool)
Writes the signature as a DKIM-Signature header.
With as_header set, writes DKIM-Signature: <tags>;\r\n, folded
with \r\n\t, ready to prepend to a message; this is what
HeaderWriter::write_header does. With as_header unset, writes the
form hashed during signing: no trailing CRLF and, under relaxed header
canonicalization, a lowercase dkim-signature: name folded with
single spaces. Tags with default values (i=, t=, x=, l=,
r=, atps=) are omitted.
Source§impl Signature
impl Signature
Sourcepub fn parse(header: &[u8]) -> Result<Self>
pub fn parse(header: &[u8]) -> Result<Self>
Parses the value of a DKIM-Signature header (RFC 6376, Section 3.5).
header is the raw header value, after the colon. Unknown tags are
ignored. When c= is absent, simple/simple is assumed. An atpsh=
value other than sha1, sha256 or none clears the ATPS domain so
that no ATPS check can succeed.
§Errors
DkimError::UnsupportedVersionwhenv=is present and not1.DkimError::UnsupportedAlgorithmfor an unknowna=value.DkimError::UnsupportedCanonicalizationfor an unknownc=value.Error::Base64whenb=orbh=is not valid base64.Error::Parsewheni=is not valid quoted printable.Error::MissingParameterswhen any ofd=,s=,b=,bh=orh=is missing or empty.
Trait Implementations§
impl Eq for Signature
Source§impl HeaderWriter for Signature
impl HeaderWriter for Signature
Source§fn write_header(&self, writer: &mut impl Writer)
fn write_header(&self, writer: &mut impl Writer)
writer.impl StructuralPartialEq for Signature
Source§impl VerifySignature for Signature
impl VerifySignature for Signature
Source§fn domain_key(&self) -> String
fn domain_key(&self) -> String
<selector>._domainkey.<domain>., with a trailing dot.Auto Trait Implementations§
impl Freeze for Signature
impl RefUnwindSafe for Signature
impl Send for Signature
impl Sync for Signature
impl Unpin for Signature
impl UnsafeUnpin for Signature
impl UnwindSafe for Signature
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more