aboutsummaryrefslogtreecommitdiff
path: root/plugin/dnssec/cache.go
blob: ea95b73b437046269a6d80514dd7a13378ab6775 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
package dnssec

import (
	"hash/fnv"

	"github.com/miekg/dns"
)

// hash serializes the RRset and return a signature cache key.
func hash(rrs []dns.RR) uint32 {
	h := fnv.New32()
	buf := make([]byte, 256)
	for _, r := range rrs {
		off, err := dns.PackRR(r, buf, 0, nil, false)
		if err == nil {
			h.Write(buf[:off])
		}
	}

	i := h.Sum32()
	return i
}