*/
/*
- * $Id: tsig.c,v 1.148 2011/03/21 19:54:03 each Exp $
+ * $Id: tsig.c,v 1.149 2011/08/25 06:20:07 marka Exp $
*/
/*! \file */
#include <config.h>
isc_result_t ret;
unsigned char badtimedata[BADTIMELEN];
unsigned int sigsize = 0;
+ isc_boolean_t response = is_response(msg);
REQUIRE(msg != NULL);
REQUIRE(VALID_TSIG_KEY(dns_message_gettsigkey(msg)));
/*
* If this is a response, there should be a query tsig.
*/
- if (is_response(msg) && msg->querytsig == NULL)
+ if (response && msg->querytsig == NULL)
return (DNS_R_EXPECTEDTSIG);
dynbuf = NULL;
isc_buffer_init(&databuf, data, sizeof(data));
- if (is_response(msg))
+ if (response)
tsig.error = msg->querytsigstatus;
else
tsig.error = dns_rcode_noerror;
/*
* If this is a response, digest the query signature.
*/
- if (is_response(msg)) {
+ if (response) {
dns_rdata_t querytsigrdata = DNS_RDATA_INIT;
ret = dns_rdataset_first(msg->querytsig);
digestbits = dst_key_getbits(key->key);
if (digestbits != 0) {
unsigned int bytes = (digestbits + 1) / 8;
- if (is_response(msg) && bytes < querytsig.siglen)
+ if (response && bytes < querytsig.siglen)
bytes = querytsig.siglen;
if (bytes > isc_buffer_usedlength(&sigbuf))
bytes = isc_buffer_usedlength(&sigbuf);
isc_uint16_t addcount, id;
unsigned int siglen;
unsigned int alg;
+ isc_boolean_t response;
REQUIRE(source != NULL);
REQUIRE(DNS_MESSAGE_VALID(msg));
tsigkey = dns_message_gettsigkey(msg);
+ response = is_response(msg);
REQUIRE(tsigkey == NULL || VALID_TSIG_KEY(tsigkey));
* If this is a response and there's no key or query TSIG, there
* shouldn't be one on the response.
*/
- if (is_response(msg) &&
- (tsigkey == NULL || msg->querytsig == NULL))
+ if (response && (tsigkey == NULL || msg->querytsig == NULL))
return (DNS_R_UNEXPECTEDTSIG);
mctx = msg->mctx;
if (ret != ISC_R_SUCCESS)
return (ret);
dns_rdata_reset(&rdata);
- if (is_response(msg)) {
+ if (response) {
ret = dns_rdataset_first(msg->querytsig);
if (ret != ISC_R_SUCCESS)
return (ret);
/*
* Do the key name and algorithm match that of the query?
*/
- if (is_response(msg) &&
+ if (response &&
(!dns_name_equal(keyname, &tsigkey->name) ||
!dns_name_equal(&tsig.algorithm, &querytsig.algorithm))) {
msg->tsigstatus = dns_tsigerror_badkey;
if (ret != ISC_R_SUCCESS)
return (ret);
- if (is_response(msg)) {
+ if (response) {
isc_buffer_init(&databuf, data, sizeof(data));
isc_buffer_putuint16(&databuf, querytsig.siglen);
isc_buffer_usedregion(&databuf, &r);