2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-08-29 13:38:26 +00:00

Rename message->tsigset/querytsigset to tsig/querytsig.

This commit is contained in:
Brian Wellington 2000-05-31 23:58:35 +00:00
parent 91268e69b0
commit fe0e3c7707
3 changed files with 80 additions and 52 deletions

View File

@ -165,7 +165,7 @@ struct dns_message {
dns_name_t *cursors[DNS_SECTION_MAX]; dns_name_t *cursors[DNS_SECTION_MAX];
dns_rdataset_t *opt; dns_rdataset_t *opt;
dns_rdataset_t *sig0; dns_rdataset_t *sig0;
dns_rdataset_t *tsigset; dns_rdataset_t *tsig;
int state; int state;
unsigned int from_to_wire : 2; unsigned int from_to_wire : 2;
@ -199,7 +199,7 @@ struct dns_message {
dns_rcode_t tsigstatus; dns_rcode_t tsigstatus;
dns_rcode_t querytsigstatus; dns_rcode_t querytsigstatus;
dns_name_t *tsigname; dns_name_t *tsigname;
dns_rdataset_t *querytsigset; dns_rdataset_t *querytsig;
dns_tsigkey_t *tsigkey; dns_tsigkey_t *tsigkey;
void *tsigctx; void *tsigctx;
int sigstart; int sigstart;

View File

@ -322,7 +322,7 @@ msginitprivate(dns_message_t *m) {
m->opt = NULL; m->opt = NULL;
m->sig0 = NULL; m->sig0 = NULL;
m->sig0name = NULL; m->sig0name = NULL;
m->tsigset = NULL; m->tsig = NULL;
m->tsigname = NULL; m->tsigname = NULL;
m->state = DNS_SECTION_ANY; /* indicate nothing parsed or rendered */ m->state = DNS_SECTION_ANY; /* indicate nothing parsed or rendered */
m->opt_reserved = 0; m->opt_reserved = 0;
@ -343,7 +343,7 @@ msginittsig(dns_message_t *m) {
m->sig0status = dns_rcode_noerror; m->sig0status = dns_rcode_noerror;
m->query = NULL; m->query = NULL;
m->saved = NULL; m->saved = NULL;
m->querytsigset = NULL; m->querytsig = NULL;
} }
/* /*
@ -414,23 +414,22 @@ msgresetsigs(dns_message_t *msg, isc_boolean_t replying) {
dns_message_renderrelease(msg, msg->sig_reserved); dns_message_renderrelease(msg, msg->sig_reserved);
msg->sig_reserved = 0; msg->sig_reserved = 0;
} }
if (msg->tsigset != NULL) { if (msg->tsig != NULL) {
INSIST(dns_rdataset_isassociated(msg->tsigset)); INSIST(dns_rdataset_isassociated(msg->tsig));
INSIST(msg->namepool != NULL); INSIST(msg->namepool != NULL);
if (replying) { if (replying) {
INSIST(msg->querytsigset == NULL); INSIST(msg->querytsig == NULL);
msg->querytsigset = msg->tsigset; msg->querytsig = msg->tsig;
} else { } else {
dns_rdataset_disassociate(msg->tsigset); dns_rdataset_disassociate(msg->tsig);
isc_mempool_put(msg->rdspool, msg->tsigset); isc_mempool_put(msg->rdspool, msg->tsig);
if (msg->querytsigset != NULL) { if (msg->querytsig != NULL) {
dns_rdataset_disassociate(msg->querytsigset); dns_rdataset_disassociate(msg->querytsig);
isc_mempool_put(msg->rdspool, isc_mempool_put(msg->rdspool, msg->querytsig);
msg->querytsigset);
} }
} }
isc_mempool_put(msg->namepool, msg->tsigname); isc_mempool_put(msg->namepool, msg->tsigname);
msg->tsigset = NULL; msg->tsig = NULL;
msg->tsigname = NULL; msg->tsigname = NULL;
} }
if (msg->sig0 != NULL) { if (msg->sig0 != NULL) {
@ -1136,7 +1135,7 @@ getsection(isc_buffer_t *source, dns_message_t *msg, dns_decompress_t *dctx,
result = DNS_R_FORMERR; result = DNS_R_FORMERR;
goto cleanup; goto cleanup;
} }
if (msg->tsigset != NULL) { if (msg->tsig != NULL) {
result = DNS_R_FORMERR; result = DNS_R_FORMERR;
goto cleanup; goto cleanup;
} }
@ -1395,7 +1394,7 @@ getsection(isc_buffer_t *source, dns_message_t *msg, dns_decompress_t *dctx,
free_name = ISC_FALSE; free_name = ISC_FALSE;
} }
else if (rdtype == dns_rdatatype_tsig) { else if (rdtype == dns_rdatatype_tsig) {
msg->tsigset = rdataset; msg->tsig = rdataset;
msg->tsigname = name; msg->tsigname = name;
rdataset = NULL; rdataset = NULL;
free_rdataset = ISC_FALSE; free_rdataset = ISC_FALSE;
@ -1484,8 +1483,7 @@ dns_message_parse(dns_message_t *msg, isc_buffer_t *source,
if (r.length != 0) if (r.length != 0)
return (DNS_R_FORMERR); return (DNS_R_FORMERR);
if (msg->tsigset != NULL || msg->tsigkey != NULL || if (msg->tsig != NULL || msg->tsigkey != NULL || msg->sig0 != NULL) {
msg->sig0 != NULL) {
msg->saved = isc_mem_get(msg->mctx, sizeof(isc_region_t)); msg->saved = isc_mem_get(msg->mctx, sizeof(isc_region_t));
if (msg->saved == NULL) if (msg->saved == NULL)
return (ISC_R_NOMEMORY); return (ISC_R_NOMEMORY);
@ -1817,6 +1815,32 @@ dns_message_renderend(dns_message_t *msg) {
return (result); return (result);
} }
/*
* If we're adding a TSIG or SIG(0) to a truncated message,
* clear all rdatasets from the message except for the question
* before adding the TSIG or SIG(0).
*/
if ((msg->tsigkey != NULL || msg->sig0key != NULL) &&
(msg->flags & DNS_MESSAGEFLAG_TC) != 0)
{
isc_buffer_t *buf;
msgresetnames(msg, DNS_SECTION_ANSWER);
buf = msg->buffer;
dns_message_renderreset(msg);
msg->buffer = buf;
isc_buffer_clear(msg->buffer);
isc_buffer_add(msg->buffer, DNS_MESSAGE_HEADERLEN);
dns_compress_rollback(&msg->cctx, 0);
result = dns_message_rendersection(msg, DNS_SECTION_QUESTION,
0);
if (result != ISC_R_SUCCESS)
return (result);
}
/*
* If we're adding a TSIG record, generate and render it.
*/
if (msg->tsigkey != NULL) { if (msg->tsigkey != NULL) {
dns_message_renderrelease(msg, msg->sig_reserved); dns_message_renderrelease(msg, msg->sig_reserved);
msg->sig_reserved = 0; msg->sig_reserved = 0;
@ -1824,12 +1848,17 @@ dns_message_renderend(dns_message_t *msg) {
if (result != ISC_R_SUCCESS) if (result != ISC_R_SUCCESS)
return (result); return (result);
count = 0; count = 0;
result = dns_rdataset_towire(msg->tsigset, msg->tsigname, result = dns_rdataset_towire(msg->tsig, msg->tsigname,
&msg->cctx, msg->buffer, &count); &msg->cctx, msg->buffer, &count);
msg->counts[DNS_SECTION_ADDITIONAL] += count; msg->counts[DNS_SECTION_ADDITIONAL] += count;
if (result != ISC_R_SUCCESS) if (result != ISC_R_SUCCESS)
return (result); return (result);
} else if (msg->sig0key != NULL) { }
/*
* If we're adding a SIG(0) record, generate and render it.
*/
if (msg->sig0key != NULL) {
dns_message_renderrelease(msg, msg->sig_reserved); dns_message_renderrelease(msg, msg->sig_reserved);
msg->sig_reserved = 0; msg->sig_reserved = 0;
result = dns_dnssec_signmessage(msg, msg->sig0key); result = dns_dnssec_signmessage(msg, msg->sig0key);
@ -2179,7 +2208,7 @@ dns_message_reply(dns_message_t *msg, isc_boolean_t want_question_section) {
* This saves the query TSIG status, if the query was signed, and * This saves the query TSIG status, if the query was signed, and
* reserves space in the reply for the TSIG. * reserves space in the reply for the TSIG.
*/ */
if (msg->querytsigset != NULL) { if (msg->querytsig != NULL) {
unsigned int otherlen = 0; unsigned int otherlen = 0;
msg->querytsigstatus = msg->tsigstatus; msg->querytsigstatus = msg->tsigstatus;
msg->tsigstatus = dns_rcode_noerror; msg->tsigstatus = dns_rcode_noerror;
@ -2270,7 +2299,7 @@ dns_message_gettsig(dns_message_t *msg, dns_name_t **owner) {
REQUIRE(owner != NULL && *owner == NULL); REQUIRE(owner != NULL && *owner == NULL);
*owner = msg->tsigname; *owner = msg->tsigname;
return (msg->tsigset); return (msg->tsig);
} }
isc_result_t isc_result_t
@ -2322,7 +2351,7 @@ dns_message_setquerytsig(dns_message_t *msg, isc_buffer_t *querytsig) {
isc_result_t result; isc_result_t result;
REQUIRE(DNS_MESSAGE_VALID(msg)); REQUIRE(DNS_MESSAGE_VALID(msg));
REQUIRE(msg->querytsigset == NULL); REQUIRE(msg->querytsig == NULL);
if (querytsig == NULL) if (querytsig == NULL)
return (ISC_R_SUCCESS); return (ISC_R_SUCCESS);
@ -2353,7 +2382,7 @@ dns_message_setquerytsig(dns_message_t *msg, isc_buffer_t *querytsig) {
if (result != ISC_R_SUCCESS) if (result != ISC_R_SUCCESS)
goto cleanup; goto cleanup;
msg->querytsigset = set; msg->querytsig = set;
return (result); return (result);
@ -2378,13 +2407,13 @@ dns_message_getquerytsig(dns_message_t *msg, isc_mem_t *mctx,
REQUIRE(mctx != NULL); REQUIRE(mctx != NULL);
REQUIRE(querytsig != NULL && *querytsig == NULL); REQUIRE(querytsig != NULL && *querytsig == NULL);
if (msg->tsigset == NULL) if (msg->tsig == NULL)
return (ISC_R_SUCCESS); return (ISC_R_SUCCESS);
result = dns_rdataset_first(msg->tsigset); result = dns_rdataset_first(msg->tsig);
if (result != ISC_R_SUCCESS) if (result != ISC_R_SUCCESS)
return (result); return (result);
dns_rdataset_current(msg->tsigset, &rdata); dns_rdataset_current(msg->tsig, &rdata);
dns_rdata_toregion(&rdata, &r); dns_rdata_toregion(&rdata, &r);
result = isc_buffer_allocate(mctx, querytsig, r.length); result = isc_buffer_allocate(mctx, querytsig, r.length);
@ -2505,7 +2534,7 @@ dns_message_signer(dns_message_t *msg, dns_name_t *signer) {
REQUIRE(signer != NULL); REQUIRE(signer != NULL);
REQUIRE(msg->from_to_wire == DNS_MESSAGE_INTENTPARSE); REQUIRE(msg->from_to_wire == DNS_MESSAGE_INTENTPARSE);
if (msg->tsigset == NULL && msg->sig0 == NULL) if (msg->tsig == NULL && msg->sig0 == NULL)
return (ISC_R_NOTFOUND); return (ISC_R_NOTFOUND);
if (msg->verify_attempted == 0) if (msg->verify_attempted == 0)
@ -2543,9 +2572,9 @@ dns_message_signer(dns_message_t *msg, dns_name_t *signer) {
dns_name_t *identity; dns_name_t *identity;
dns_rdata_any_tsig_t tsig; dns_rdata_any_tsig_t tsig;
result = dns_rdataset_first(msg->tsigset); result = dns_rdataset_first(msg->tsig);
INSIST(result == ISC_R_SUCCESS); INSIST(result == ISC_R_SUCCESS);
dns_rdataset_current(msg->tsigset, &rdata); dns_rdataset_current(msg->tsig, &rdata);
result = dns_rdata_tostruct(&rdata, &tsig, NULL); result = dns_rdata_tostruct(&rdata, &tsig, NULL);
if (msg->tsigstatus != dns_rcode_noerror) if (msg->tsigstatus != dns_rcode_noerror)
@ -2575,12 +2604,12 @@ dns_message_checksig(dns_message_t *msg, dns_view_t *view) {
REQUIRE(DNS_MESSAGE_VALID(msg)); REQUIRE(DNS_MESSAGE_VALID(msg));
REQUIRE(view != NULL); REQUIRE(view != NULL);
if (msg->tsigkey == NULL && msg->tsigset == NULL && msg->sig0 == NULL) if (msg->tsigkey == NULL && msg->tsig == NULL && msg->sig0 == NULL)
return (ISC_R_SUCCESS); return (ISC_R_SUCCESS);
INSIST(msg->saved != NULL); INSIST(msg->saved != NULL);
isc_buffer_init(&msgb, msg->saved->base, msg->saved->length); isc_buffer_init(&msgb, msg->saved->base, msg->saved->length);
isc_buffer_add(&msgb, msg->saved->length); isc_buffer_add(&msgb, msg->saved->length);
if (msg->tsigkey != NULL || msg->tsigset != NULL) if (msg->tsigkey != NULL || msg->tsig != NULL)
return (dns_view_checksig(view, &msgb, msg)); return (dns_view_checksig(view, &msgb, msg));
else { else {
dns_rdata_t rdata; dns_rdata_t rdata;

View File

@ -16,7 +16,7 @@
*/ */
/* /*
* $Id: tsig.c,v 1.66 2000/05/30 23:14:54 bwelling Exp $ * $Id: tsig.c,v 1.67 2000/05/31 23:58:34 bwelling Exp $
* Principal Author: Brian Wellington * Principal Author: Brian Wellington
*/ */
@ -260,7 +260,7 @@ dns_tsig_sign(dns_message_t *msg) {
/* /*
* If this is a response, there should be a query tsig. * If this is a response, there should be a query tsig.
*/ */
if (is_response(msg) && msg->querytsigset == NULL) if (is_response(msg) && msg->querytsig == NULL)
return (DNS_R_EXPECTEDTSIG); return (DNS_R_EXPECTEDTSIG);
dynbuf = NULL; dynbuf = NULL;
@ -324,11 +324,10 @@ dns_tsig_sign(dns_message_t *msg) {
if (is_response(msg)) { if (is_response(msg)) {
dns_rdata_t querytsigrdata; dns_rdata_t querytsigrdata;
ret = dns_rdataset_first(msg->querytsigset); ret = dns_rdataset_first(msg->querytsig);
if (ret != ISC_R_SUCCESS) if (ret != ISC_R_SUCCESS)
goto cleanup_other; goto cleanup_other;
dns_rdataset_current(msg->querytsigset, dns_rdataset_current(msg->querytsig, &querytsigrdata);
&querytsigrdata);
ret = dns_rdata_tostruct(&querytsigrdata, &querytsig, ret = dns_rdata_tostruct(&querytsigrdata, &querytsig,
NULL); NULL);
if (ret != ISC_R_SUCCESS) if (ret != ISC_R_SUCCESS)
@ -525,7 +524,7 @@ dns_tsig_sign(dns_message_t *msg) {
goto cleanup_dynbuf; goto cleanup_dynbuf;
dns_rdataset_init(dataset); dns_rdataset_init(dataset);
dns_rdatalist_tordataset(datalist, dataset); dns_rdatalist_tordataset(datalist, dataset);
msg->tsigset = dataset; msg->tsig = dataset;
msg->tsigname = owner; msg->tsigname = owner;
return (ISC_R_SUCCESS); return (ISC_R_SUCCESS);
@ -575,7 +574,7 @@ dns_tsig_verify(isc_buffer_t *source, dns_message_t *msg,
/* /*
* There should be a TSIG record... * There should be a TSIG record...
*/ */
if (msg->tsigset == NULL) if (msg->tsig == NULL)
return (DNS_R_EXPECTEDTSIG); return (DNS_R_EXPECTEDTSIG);
/* /*
@ -583,7 +582,7 @@ dns_tsig_verify(isc_buffer_t *source, dns_message_t *msg,
* shouldn't be one on the response. * shouldn't be one on the response.
*/ */
if (is_response(msg) && if (is_response(msg) &&
(tsigkey == NULL || msg->querytsigset == NULL)) (tsigkey == NULL || msg->querytsig == NULL))
return (DNS_R_UNEXPECTEDTSIG); return (DNS_R_UNEXPECTEDTSIG);
mctx = msg->mctx; mctx = msg->mctx;
@ -594,18 +593,18 @@ dns_tsig_verify(isc_buffer_t *source, dns_message_t *msg,
*/ */
keyname = msg->tsigname; keyname = msg->tsigname;
ret = dns_rdataset_first(msg->tsigset); ret = dns_rdataset_first(msg->tsig);
if (ret != ISC_R_SUCCESS) if (ret != ISC_R_SUCCESS)
return (ret); return (ret);
dns_rdataset_current(msg->tsigset, &rdata); dns_rdataset_current(msg->tsig, &rdata);
ret = dns_rdata_tostruct(&rdata, &tsig, NULL); ret = dns_rdata_tostruct(&rdata, &tsig, NULL);
if (ret != ISC_R_SUCCESS) if (ret != ISC_R_SUCCESS)
return (ret); return (ret);
if (is_response(msg)) { if (is_response(msg)) {
ret = dns_rdataset_first(msg->querytsigset); ret = dns_rdataset_first(msg->querytsig);
if (ret != ISC_R_SUCCESS) if (ret != ISC_R_SUCCESS)
return (ret); return (ret);
dns_rdataset_current(msg->querytsigset, &rdata); dns_rdataset_current(msg->querytsig, &rdata);
ret = dns_rdata_tostruct(&rdata, &querytsig, NULL); ret = dns_rdata_tostruct(&rdata, &querytsig, NULL);
if (ret != ISC_R_SUCCESS) if (ret != ISC_R_SUCCESS)
return (ret); return (ret);
@ -742,7 +741,7 @@ dns_tsig_verify(isc_buffer_t *source, dns_message_t *msg,
isc_buffer_init(&databuf, data, sizeof(data)); isc_buffer_init(&databuf, data, sizeof(data));
isc_buffer_putuint16(&databuf, tsig.common.rdclass); isc_buffer_putuint16(&databuf, tsig.common.rdclass);
isc_buffer_putuint32(&databuf, msg->tsigset->ttl); isc_buffer_putuint32(&databuf, msg->tsig->ttl);
isc_buffer_usedregion(&databuf, &r); isc_buffer_usedregion(&databuf, &r);
ret = dst_key_verify(DST_SIGMODE_UPDATE, key, &ctx, &r, ret = dst_key_verify(DST_SIGMODE_UPDATE, key, &ctx, &r,
&sig_r); &sig_r);
@ -839,27 +838,27 @@ dns_tsig_verify_tcp(isc_buffer_t *source, dns_message_t *msg) {
REQUIRE(dns_message_gettsigkey(msg) != NULL); REQUIRE(dns_message_gettsigkey(msg) != NULL);
REQUIRE(msg->tcp_continuation == 1); REQUIRE(msg->tcp_continuation == 1);
REQUIRE(is_response(msg)); REQUIRE(is_response(msg));
REQUIRE(msg->querytsigset != NULL); REQUIRE(msg->querytsig != NULL);
mctx = msg->mctx; mctx = msg->mctx;
tsigkey = dns_message_gettsigkey(msg); tsigkey = dns_message_gettsigkey(msg);
if (msg->tsigset != NULL) { if (msg->tsig != NULL) {
has_tsig = ISC_TRUE; has_tsig = ISC_TRUE;
keyname = msg->tsigname; keyname = msg->tsigname;
ret = dns_rdataset_first(msg->tsigset); ret = dns_rdataset_first(msg->tsig);
if (ret != ISC_R_SUCCESS) if (ret != ISC_R_SUCCESS)
return (ret); return (ret);
dns_rdataset_current(msg->tsigset, &rdata); dns_rdataset_current(msg->tsig, &rdata);
ret = dns_rdata_tostruct(&rdata, &tsig, NULL); ret = dns_rdata_tostruct(&rdata, &tsig, NULL);
if (ret != ISC_R_SUCCESS) if (ret != ISC_R_SUCCESS)
return (ret); return (ret);
ret = dns_rdataset_first(msg->querytsigset); ret = dns_rdataset_first(msg->querytsig);
if (ret != ISC_R_SUCCESS) if (ret != ISC_R_SUCCESS)
return (ret); return (ret);
dns_rdataset_current(msg->querytsigset, &rdata); dns_rdataset_current(msg->querytsig, &rdata);
ret = dns_rdata_tostruct(&rdata, &querytsig, NULL); ret = dns_rdata_tostruct(&rdata, &querytsig, NULL);
if (ret != ISC_R_SUCCESS) if (ret != ISC_R_SUCCESS)
return (ret); return (ret);