*/
/*
- * $Id: dnssec.c,v 1.56.2.1 2001/01/09 22:43:35 bwelling Exp $
+ * $Id: dnssec.c,v 1.56.2.2 2001/01/16 22:38:42 gson Exp $
*/
RETERR(dst_context_create(key, mctx, &ctx));
+ /*
+ * Digest the fields of the SIG - we can cheat and use
+ * dns_rdata_fromstruct. Since siglen is 0, the digested data
+ * is identical to dns format.
+ */
+ RETERR(dns_rdata_fromstruct(NULL, dns_rdataclass_any,
+ dns_rdatatype_sig, &sig, &databuf));
+ isc_buffer_usedregion(&databuf, &r);
+ RETERR(dst_context_adddata(ctx, &r));
+
+ /*
+ * If this is a response, digest the query.
+ */
if (is_response(msg))
RETERR(dst_context_adddata(ctx, msg->query));
isc_region_consume(&r, DNS_MESSAGE_HEADERLEN);
RETERR(dst_context_adddata(ctx, &r));
- /*
- * Digest the fields of the SIG - we can cheat and use
- * dns_rdata_fromstruct. Since siglen is 0, the digested data
- * is identical to dns format.
- */
- RETERR(dns_rdata_fromstruct(NULL, dns_rdataclass_any,
- dns_rdatatype_sig, &sig, &databuf));
- isc_buffer_usedregion(&databuf, &r);
- RETERR(dst_context_adddata(ctx, &r));
-
RETERR(dst_key_sigsize(key, &sigsize));
sig.siglen = sigsize;
sig.signature = (unsigned char *) isc_mem_get(mctx, sig.siglen);
RETERR(dst_context_create(key, mctx, &ctx));
+ /*
+ * Digest the SIG(0) record, except for the signature.
+ */
+ dns_rdata_toregion(&rdata, &r);
+ r.length -= sig.siglen;
+ RETERR(dst_context_adddata(ctx, &r));
+
/*
* If this is a response, digest the query.
*/
r.length = msg->sigstart - DNS_MESSAGE_HEADERLEN;
RETERR(dst_context_adddata(ctx, &r));
- /*
- * Digest the SIG(0) record . Find the start of the record, skip
- * the name and 10 bytes for class, type, ttl, length to get to
- * the start of the rdata.
- */
- dns_rdata_toregion(&rdata, &r);
- r.length -= sig.siglen;
- RETERR(dst_context_adddata(ctx, &r));
-
sig_r.base = sig.signature;
sig_r.length = sig.siglen;
result = dst_context_verify(ctx, &sig_r);