Help us shape the future of Go! Take the 2026 Go Developer Survey

sending

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2026 License: AGPL-3.0 Imports: 12 Imported by: 0

Documentation

Overview

Package sending owns the workspace Sending-domain authentication primitives (ADR 0010): per-domain DKIM keypair generation, the DNS records a user publishes, and DKIM DNS verification. It is transport-independent on purpose — no mail is sent here; the send path (internal/messaging) consumes the keys in a later slice.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DKIMRecord

func DKIMRecord(selector, domain, pubTXT string) (host, value string)

DKIMRecord returns the DNS host and value the user publishes to authenticate the domain. host is "<selector>._domainkey.<domain>".

func DMARCRecord

func DMARCRecord(domain string) (host, value string)

DMARCRecord returns the suggested _dmarc TXT. Advisory bulk-readiness signal (ADR 0012): Gmail/Yahoo require at least p=none for bulk senders, but sphericon never mandates the stricter policies, which live on the organizational domain.

func GenerateKeypair

func GenerateKeypair() (privPEM []byte, pubTXT string, err error)

GenerateKeypair mints a fresh RSA keypair for a Sending domain. It returns the PKCS#8 PEM private key (to be Tink-encrypted before storage) and the DKIM TXT record value carrying the public key ("v=DKIM1; k=rsa; p=<base64 DER>").

func NormalizeDomain

func NormalizeDomain(raw string) (string, bool)

NormalizeDomain validates raw as a registrable domain name (IDNA registration rules: label syntax, length limits, punycode) with at least one dot and not an IP address, and returns its lower-case ASCII (punycode) form, the form DNS records and stored domains use. ok is false for anything else.

func PublicKeyFromPrivatePEM

func PublicKeyFromPrivatePEM(privPEM []byte) (string, error)

PublicKeyFromPrivatePEM re-derives the DKIM TXT value from a stored private key PEM — used to check a published record against our key without persisting the public value separately.

func SPFRecord

func SPFRecord(domain string) (host, value string)

SPFRecord returns the suggested SPF TXT for the domain. Advisory only — native DKIM signing deliberately abstracts the sending IPs, so SPF does not gate (ADR 0010). host is the domain apex.

func VerifyDKIM

func VerifyDKIM(ctx context.Context, lookup TXTLookup, selector, domain, expectedPubTXT string) (bool, error)

VerifyDKIM reports whether the DKIM TXT published at "<selector>._domainkey. <domain>" carries the same public key as expectedPubTXT. It is tolerant of TXT chunking (records split into multiple strings) and whitespace differences in the p= tag. A missing record verifies false with a nil error; a resolver failure returns the error.

Types

type TXTLookup

type TXTLookup func(ctx context.Context, name string) ([]string, error)

TXTLookup resolves TXT records for a name. net.Resolver satisfies it; tests inject a stub.

Jump to

Keyboard shortcuts

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