| 
									
										
										
										
											2016-04-26 17:57:11 +01:00
										 |  |  | package dnssec
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | import "github.com/miekg/dns"
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-09-01 15:10:45 +08:00
										 |  |  | // newRRSIG returns a new RRSIG, with all fields filled out, except the signed data.
 | 
					
						
							| 
									
										
										
										
											2016-09-23 09:14:12 +01:00
										 |  |  | func (k *DNSKEY) newRRSIG(signerName string, ttl, incep, expir uint32) *dns.RRSIG {
 | 
					
						
							| 
									
										
										
										
											2016-04-26 17:57:11 +01:00
										 |  |  | 	sig := new(dns.RRSIG)
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	sig.Hdr.Rrtype = dns.TypeRRSIG
 | 
					
						
							|  |  |  | 	sig.Algorithm = k.K.Algorithm
 | 
					
						
							| 
									
										
										
										
											2017-10-20 09:22:02 +01:00
										 |  |  | 	sig.KeyTag = k.tag
 | 
					
						
							| 
									
										
										
										
											2016-04-26 17:57:11 +01:00
										 |  |  | 	sig.SignerName = signerName
 | 
					
						
							|  |  |  | 	sig.Hdr.Ttl = ttl
 | 
					
						
							| 
									
										
										
										
											2016-09-23 09:14:12 +01:00
										 |  |  | 	sig.OrigTtl = origTTL
 | 
					
						
							| 
									
										
										
										
											2016-04-26 17:57:11 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	sig.Inception = incep
 | 
					
						
							|  |  |  | 	sig.Expiration = expir
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	return sig
 | 
					
						
							|  |  |  | }
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | type rrset struct {
 | 
					
						
							|  |  |  | 	qname string
 | 
					
						
							|  |  |  | 	qtype uint16
 | 
					
						
							|  |  |  | }
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | // rrSets returns rrs as a map of RRsets. It skips RRSIG and OPT records as those don't need to be signed.
 | 
					
						
							|  |  |  | func rrSets(rrs []dns.RR) map[rrset][]dns.RR {
 | 
					
						
							|  |  |  | 	m := make(map[rrset][]dns.RR)
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	for _, r := range rrs {
 | 
					
						
							|  |  |  | 		if r.Header().Rrtype == dns.TypeRRSIG || r.Header().Rrtype == dns.TypeOPT {
 | 
					
						
							|  |  |  | 			continue
 | 
					
						
							|  |  |  | 		}
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		if s, ok := m[rrset{r.Header().Name, r.Header().Rrtype}]; ok {
 | 
					
						
							|  |  |  | 			s = append(s, r)
 | 
					
						
							|  |  |  | 			m[rrset{r.Header().Name, r.Header().Rrtype}] = s
 | 
					
						
							|  |  |  | 			continue
 | 
					
						
							|  |  |  | 		}
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		s := make([]dns.RR, 1, 3)
 | 
					
						
							|  |  |  | 		s[0] = r
 | 
					
						
							|  |  |  | 		m[rrset{r.Header().Name, r.Header().Rrtype}] = s
 | 
					
						
							|  |  |  | 	}
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	if len(m) > 0 {
 | 
					
						
							|  |  |  | 		return m
 | 
					
						
							|  |  |  | 	}
 | 
					
						
							|  |  |  | 	return nil
 | 
					
						
							|  |  |  | }
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-09-23 09:14:12 +01:00
										 |  |  | const origTTL = 3600
 |