tkey_log("process_gsstkey(): dns_tsigerror_noerror"); /* XXXSRA */
/*
- * We found a TKEY to respond with. We don't know if
- * the request is TSIG signed, but if it is not we need to make
- * sure the response is signed (RFC 2845 secton 2.2).
+ * We found a TKEY to respond with. If the request is not TSIG signed,
+ * we need to make sure the response is signed (see RFC 3645, Section
+ * 2.2).
*/
-
- if (tsigkey != NULL) {
+ if (tsigkey != NULL && msg->tsigkey == NULL && msg->sig0key == NULL) {
dns_message_settsigkey(msg, tsigkey);
}
key = dns_message_gettsigkey(msg);
REQUIRE(VALID_TSIG_KEY(key));
+ /*
+ * If this is a response, there should be a TSIG in the query with the
+ * the exception if this is a TKEY request (see RFC 3645, Section 2.2).
+ */
response = is_response(msg);
+ if (response && msg->querytsig == NULL) {
+ if (msg->tkey != 1) {
+ return (DNS_R_EXPECTEDTSIG);
+ }
+ }
mctx = msg->mctx;