dkim

package
v1.15.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 17, 2025 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrBodyHashMismatch   = errors.New("body hash mismatch")
	ErrVerificationFailed = errors.New("verification failed")
)

These two errors are returned when the verification fails, but the header is considered valid.

Functions

func WithLookupTXTFunc

func WithLookupTXTFunc(ctx context.Context, lookupTXT lookupTXTFunc) context.Context

func WithMaxHeaders

func WithMaxHeaders(ctx context.Context, maxHeaders int) context.Context

func WithTraceFunc

func WithTraceFunc(ctx context.Context, trace TraceFunc) context.Context

Types

type EvaluationState

type EvaluationState string

Evaluation states, as per https://datatracker.ietf.org/doc/html/rfc6376#section-3.9.

const (
	SUCCESS  EvaluationState = "SUCCESS"
	PERMFAIL EvaluationState = "PERMFAIL"
	TEMPFAIL EvaluationState = "TEMPFAIL"
)

type OneResult

type OneResult struct {
	// The raw signature header.
	SignatureHeader string

	// Domain and selector from the signature header.
	Domain   string
	Selector string

	// Base64-encoded signature. May be missing if it is not present in the
	// header.
	B string

	// The result of the evaluation.
	State EvaluationState
	Error error
}

type Signer

type Signer struct {
	// Domain to sign for.
	Domain string

	// Selector to use.
	Selector string

	// Signer containing the private key.
	// This can be an *rsa.PrivateKey or a ed25519.PrivateKey.
	Signer crypto.Signer
}

func (*Signer) Sign

func (s *Signer) Sign(ctx context.Context, message string) (string, error)

Sign the given message. Returns the *value* of the DKIM-Signature header to be added to the message. It will usually be multi-line, but without indenting.

type TraceFunc

type TraceFunc func(f string, a ...interface{})

type VerifyResult

type VerifyResult struct {
	// How many signatures were found.
	Found uint

	// How many signatures were verified successfully.
	Valid uint

	// The details for each signature that was found.
	Results []*OneResult
}

func VerifyMessage

func VerifyMessage(ctx context.Context, message string) (*VerifyResult, error)

func (*VerifyResult) AuthenticationResults

func (r *VerifyResult) AuthenticationResults() string

Returns the DKIM-specific contents for an Authentication-Results header. It is just the contents, the header needs to still be constructed. Note that the output will need to be indented by the caller. https://datatracker.ietf.org/doc/html/rfc8601#section-2.7.1

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL