Commit 4137b84e authored by Giovanni Bajo's avatar Giovanni Bajo Committed by Simon Kelley

Postpone RRSIG processing after all DNSKEY/DS have been parsed.

parent e6c2a670
...@@ -382,17 +382,33 @@ int dnssec_validate(struct dns_header *header, size_t pktlen) ...@@ -382,17 +382,33 @@ int dnssec_validate(struct dns_header *header, size_t pktlen)
printf("DNSKEY found\n"); printf("DNSKEY found\n");
dnssec_parsekey(header, pktlen, owner, ttl, rdlen, p); dnssec_parsekey(header, pktlen, owner, ttl, rdlen, p);
} }
else if (qtype == T_RRSIG) p += rdlen;
}
/* After we have parsed DNSKEY/DS records, start looking for RRSIGs.
We want to do this in a separate step because we want the cache
to be already populated with DNSKEYs before parsing signatures. */
p = reply;
for (i = 0; i < ntohs(header->ancount); i++)
{
if (!extract_name(header, pktlen, &p, owner, 1, 10))
return 0;
GETSHORT(qtype, p);
GETSHORT(qclass, p);
GETLONG(ttl, p);
GETSHORT(rdlen, p);
if (qtype == T_RRSIG)
{ {
printf("RRSIG found\n"); printf("RRSIG found\n");
/* TODO: missing logic. We should only validate RRSIGs for which we /* TODO: missing logic. We should only validate RRSIGs for which we
have a valid DNSKEY that is referenced by a DS record upstream. have a valid DNSKEY that is referenced by a DS record upstream.
There is a memory vs CPU conflict here; should we validate everything There is a memory vs CPU conflict here; should we validate everything
to save memory and thus waste CPU, or better first acquire all information to save memory and thus waste CPU, or better first acquire all information
(wasting memory) and then doing the minimum CPU computations required? */ (wasting memory) and then doing the minimum CPU computations required? */
dnssec_parserrsig(header, pktlen, reply, ntohs(header->ancount), owner, qclass, rdlen, p); dnssec_parserrsig(header, pktlen, reply, ntohs(header->ancount), owner, qclass, rdlen, p);
} }
p += rdlen; p += rdlen;
} }
return 1; return 1;
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment