Skip to main content

Signature

Struct Signature 

Source
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: u32

v=: signature version; 1, or 0 when the tag is absent from a parsed header.

§a: Algorithm

a=: signing algorithm (RFC 6376, RFC 8301, RFC 8463).

§d: String

d=: signing domain identifier (SDID), the domain claiming responsibility for the message.

§s: String

s=: 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: String

i=: agent or user identifier (AUID); empty when absent.

§l: u64

l=: body length in octets covered by the body hash; 0 means the tag is absent and the whole body is signed.

§x: u64

x=: signature expiration, in seconds since the UNIX epoch; 0 means no expiration.

§t: u64

t=: signing time, in seconds since the UNIX epoch; 0 when absent.

§r: bool

r=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: Canonicalization

Header canonicalization, the first half of the c= tag.

§cb: Canonicalization

Body canonicalization, the second half of the c= tag.

Implementations§

Source§

impl Signature

Source

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

Source

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
Source§

impl Signature

Source

pub fn identity(&self) -> &str

Returns the agent or user identifier (the i= tag), or an empty string when the tag is absent.

Trait Implementations§

Source§

impl Clone for Signature

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Signature

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Signature

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Display for Signature

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for Signature

Source§

impl HeaderWriter for Signature

Source§

fn write_header(&self, writer: &mut impl Writer)

Writes the complete header field, including the field name and the trailing CRLF, to writer.
Source§

fn to_header(&self) -> String

Returns the complete header field as a string, including the field name and the trailing CRLF. Invalid UTF-8 is replaced with U+FFFD.
Source§

impl PartialEq for Signature

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Signature

Source§

impl VerifySignature for Signature

Source§

fn signature(&self) -> &[u8] ⓘ

Returns the decoded signature data (b= tag).
Source§

fn algorithm(&self) -> Algorithm

Returns the signing algorithm (a= tag).
Source§

fn selector(&self) -> &str

Returns the selector (s= tag).
Source§

fn domain(&self) -> &str

Returns the signing domain (d= tag).
Source§

fn domain_key(&self) -> String

Returns the fully qualified name of the key record, <selector>._domainkey.<domain>., with a trailing dot.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more