Documentation
¶
Index ¶
- Constants
- Variables
- func ComputeNSEC3Hash(name string, algorithm uint8, iterations uint16, salt []byte) ([]byte, error)
- func HasType(nsec3 *dns.NSEC3Record, rrtype uint16) bool
- func NSEC3HashToString(hash []byte) string
- func VerifyClosestEncloser(qname string, nsec3Records []*dns.NSEC3Record) (string, error)
- func VerifyDS(dnskey *dns.DNSKEYRecord, ds *dns.DSRecord, ownerName string) bool
- func VerifyNSEC3Denial(qname string, nsec3Records []*dns.NSEC3Record) (bool, error)
- func VerifyNSEC3DenialFull(qname string, nsec3Records []NSEC3RecordWithOwner) (bool, error)
- func VerifyRRSIG(rrset []dns.ResourceRecord, rrsig *dns.RRSIGRecord, dnskey *dns.DNSKEYRecord) error
- type NSEC3RecordWithOwner
- type Querier
- type ValidationResult
- type Validator
Constants ¶
const MaxNSEC3Iterations = 150
MaxNSEC3Iterations is the maximum allowed iterations per RFC 8659.
Variables ¶
var RootDSRecords = []dns.DSRecord{ { KeyTag: 20326, Algorithm: dns.AlgRSASHA256, DigestType: dns.DigestSHA256, Digest: hexDecode("E06D44B80B8F1D39A95C0B0D7C65D08458E880409BBC683457104237C7F8EC8D"), }, }
RootDSRecords contains the trust anchors for the DNS root zone. These are the well-known IANA root KSK trust anchors used to anchor the DNSSEC chain of trust.
Key tag 20326: Root KSK (2017), RSA/SHA-256 See: https://data.iana.org/root-anchors/root-anchors.xml
Functions ¶
func ComputeNSEC3Hash ¶
ComputeNSEC3Hash computes the NSEC3 hash for a domain name. Algorithm 1 is SHA-1 (the only defined algorithm per RFC 5155). The result is the raw hash bytes (not base32-encoded).
func HasType ¶
func HasType(nsec3 *dns.NSEC3Record, rrtype uint16) bool
HasType checks whether the NSEC3 type bitmap includes the given RR type.
func NSEC3HashToString ¶
NSEC3HashToString encodes raw NSEC3 hash bytes to the base32hex string representation used in NSEC3 owner names.
func VerifyClosestEncloser ¶
func VerifyClosestEncloser(qname string, nsec3Records []*dns.NSEC3Record) (string, error)
VerifyClosestEncloser finds the closest encloser for the queried name by looking for an NSEC3 record whose hash matches a parent of qname. Returns the closest encloser name if found.
func VerifyDS ¶
VerifyDS checks if a DNSKEY matches a DS record by computing the DS digest over the canonical owner name + DNSKEY RDATA and comparing it to the DS digest. The ownerName is the domain name that owns the DNSKEY (e.g., "example.com.").
func VerifyNSEC3Denial ¶
func VerifyNSEC3Denial(qname string, nsec3Records []*dns.NSEC3Record) (bool, error)
VerifyNSEC3Denial verifies that a queried name falls within an NSEC3 hash gap, proving the name does not exist (NXDOMAIN) or the type does not exist (NODATA). Returns true if the denial proof is valid.
func VerifyNSEC3DenialFull ¶
func VerifyNSEC3DenialFull(qname string, nsec3Records []NSEC3RecordWithOwner) (bool, error)
VerifyNSEC3DenialFull verifies NSEC3 denial with full owner hash information. This is the proper implementation that checks hash ranges correctly.
func VerifyRRSIG ¶
func VerifyRRSIG(rrset []dns.ResourceRecord, rrsig *dns.RRSIGRecord, dnskey *dns.DNSKEYRecord) error
VerifyRRSIG verifies an RRSIG signature over an RRset using a DNSKEY. It builds the signed data (RRSIG RDATA without signature + canonical RRset) and verifies the cryptographic signature according to the algorithm.
Types ¶
type NSEC3RecordWithOwner ¶
type NSEC3RecordWithOwner struct {
dns.NSEC3Record
OwnerHash []byte // raw hash bytes from the NSEC3 RR owner name
}
NSEC3RecordWithOwner extends NSEC3Record with the owner hash for proper range checking in denial proofs.
type Querier ¶
type Querier interface {
// QueryDNSSEC sends a DNS query with the DO (DNSSEC OK) bit set
// and returns the response.
QueryDNSSEC(name string, qtype uint16, qclass uint16) (*dns.Message, error)
}
Querier is the interface the validator uses to fetch DNSKEY and DS records needed for DNSSEC chain-of-trust validation.
type ValidationResult ¶
type ValidationResult int
ValidationResult represents the outcome of DNSSEC validation.
const ( // Secure means all signatures validated and the chain of trust is intact. Secure ValidationResult = iota // Insecure means the zone does not have DNSSEC (no RRSIG/DS records). Insecure // Bogus means signature validation failed - the response cannot be trusted. Bogus // Indeterminate means validation could not be completed (e.g., missing keys). Indeterminate )
func (ValidationResult) String ¶
func (v ValidationResult) String() string
String returns a human-readable name for the validation result.
type Validator ¶
type Validator struct {
// contains filtered or unexported fields
}
Validator performs DNSSEC signature verification and trust chain validation.
func NewValidator ¶
NewValidator creates a new DNSSEC Validator that uses the given Querier to fetch DNSKEY/DS records and the root trust anchors for chain validation.
func (*Validator) ValidateResponse ¶
func (v *Validator) ValidateResponse(response *dns.Message, qname string, qtype uint16) ValidationResult
ValidateResponse validates DNSSEC signatures in a DNS response. It checks RRSIG records in the answer section and validates the trust chain from the signer back to the root trust anchors. For NXDOMAIN/NODATA responses, it also validates NSEC3 proofs.