2000-02-23 23:31:33 +00:00
|
|
|
/*
|
2018-02-23 09:53:12 +01:00
|
|
|
* Copyright (C) Internet Systems Consortium, Inc. ("ISC")
|
2000-08-01 01:33:37 +00:00
|
|
|
*
|
2016-06-27 14:56:38 +10:00
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
2018-02-23 09:53:12 +01:00
|
|
|
*
|
|
|
|
* See the COPYRIGHT file distributed with this work for additional
|
|
|
|
* information regarding copyright ownership.
|
2000-02-23 23:31:33 +00:00
|
|
|
*/
|
|
|
|
|
2018-03-28 14:19:37 +02:00
|
|
|
#include <inttypes.h>
|
2018-04-17 08:29:14 -07:00
|
|
|
#include <stdbool.h>
|
2018-03-28 14:19:37 +02:00
|
|
|
|
2008-09-24 02:46:23 +00:00
|
|
|
#include <isc/base32.h>
|
2000-05-08 14:38:29 +00:00
|
|
|
#include <isc/mem.h>
|
2018-06-01 09:31:59 +02:00
|
|
|
#include <isc/md.h>
|
2000-04-12 19:07:12 +00:00
|
|
|
#include <isc/print.h>
|
2004-01-20 14:19:42 +00:00
|
|
|
#include <isc/string.h>
|
2000-02-24 22:40:55 +00:00
|
|
|
#include <isc/task.h>
|
|
|
|
#include <isc/util.h>
|
2000-02-24 21:05:28 +00:00
|
|
|
|
2017-08-16 09:29:20 +10:00
|
|
|
#include <dns/client.h>
|
2000-03-17 00:01:28 +00:00
|
|
|
#include <dns/db.h>
|
2000-04-05 22:30:57 +00:00
|
|
|
#include <dns/dnssec.h>
|
2010-05-14 04:38:52 +00:00
|
|
|
#include <dns/ds.h>
|
2000-02-24 22:40:55 +00:00
|
|
|
#include <dns/events.h>
|
2000-03-17 00:01:28 +00:00
|
|
|
#include <dns/keytable.h>
|
2010-05-14 04:38:52 +00:00
|
|
|
#include <dns/keyvalues.h>
|
2000-04-11 20:35:37 +00:00
|
|
|
#include <dns/log.h>
|
2000-04-13 18:10:07 +00:00
|
|
|
#include <dns/message.h>
|
2002-07-19 03:29:15 +00:00
|
|
|
#include <dns/ncache.h>
|
2003-09-30 06:00:40 +00:00
|
|
|
#include <dns/nsec.h>
|
2008-09-24 02:46:23 +00:00
|
|
|
#include <dns/nsec3.h>
|
2000-03-17 00:01:28 +00:00
|
|
|
#include <dns/rdata.h>
|
|
|
|
#include <dns/rdataset.h>
|
2000-05-02 03:54:17 +00:00
|
|
|
#include <dns/rdatatype.h>
|
2000-04-07 17:36:40 +00:00
|
|
|
#include <dns/resolver.h>
|
2000-05-02 03:54:17 +00:00
|
|
|
#include <dns/result.h>
|
|
|
|
#include <dns/validator.h>
|
2000-02-24 22:40:55 +00:00
|
|
|
#include <dns/view.h>
|
|
|
|
|
2005-11-03 00:51:55 +00:00
|
|
|
/*! \file
|
|
|
|
* \brief
|
2019-08-06 13:44:30 -07:00
|
|
|
* Basic processing sequences:
|
2005-11-03 00:51:55 +00:00
|
|
|
*
|
|
|
|
* \li When called with rdataset and sigrdataset:
|
2019-08-07 16:54:05 -07:00
|
|
|
* validator_start -> validate_answer -> proveunsecure
|
|
|
|
* validator_start -> validate_answer -> validate_nx (if secure wildcard)
|
2008-01-18 23:46:58 +00:00
|
|
|
*
|
2019-08-07 16:54:05 -07:00
|
|
|
* \li When called with rdataset but no sigrdataset:
|
2019-08-06 13:44:30 -07:00
|
|
|
* validator_start -> proveunsecure
|
2005-11-03 00:51:55 +00:00
|
|
|
*
|
2019-08-07 16:54:05 -07:00
|
|
|
* \li When called with no rdataset or sigrdataset:
|
|
|
|
* validator_start -> validate_nx-> proveunsecure
|
2005-11-03 00:51:55 +00:00
|
|
|
*
|
2019-08-07 16:54:05 -07:00
|
|
|
* validator_start: determine what type of validation to do.
|
|
|
|
* validate_answer: attempt to perform a positive validation.
|
|
|
|
* proveunsecure: attempt to prove the answer comes from an unsecure zone.
|
|
|
|
* validate_nx: attempt to prove a negative response.
|
2005-11-03 00:51:55 +00:00
|
|
|
*/
|
|
|
|
|
2019-08-06 13:44:30 -07:00
|
|
|
#define VALIDATOR_MAGIC ISC_MAGIC('V', 'a', 'l', '?')
|
|
|
|
#define VALID_VALIDATOR(v) ISC_MAGIC_VALID(v, VALIDATOR_MAGIC)
|
2000-02-23 23:31:33 +00:00
|
|
|
|
2019-08-06 13:44:30 -07:00
|
|
|
#define VALATTR_SHUTDOWN 0x0001 /*%< Shutting down. */
|
|
|
|
#define VALATTR_CANCELED 0x0002 /*%< Canceled. */
|
|
|
|
#define VALATTR_TRIEDVERIFY 0x0004 /*%< We have found a key and
|
2005-11-03 00:51:55 +00:00
|
|
|
* have attempted a verify. */
|
2019-08-06 13:44:30 -07:00
|
|
|
#define VALATTR_INSECURITY 0x0010 /*%< Attempting proveunsecure. */
|
2004-01-14 02:06:51 +00:00
|
|
|
|
2005-11-03 00:51:55 +00:00
|
|
|
/*!
|
|
|
|
* NSEC proofs to be looked for.
|
|
|
|
*/
|
2019-08-06 13:44:30 -07:00
|
|
|
#define VALATTR_NEEDNOQNAME 0x00000100
|
|
|
|
#define VALATTR_NEEDNOWILDCARD 0x00000200
|
|
|
|
#define VALATTR_NEEDNODATA 0x00000400
|
2004-01-14 02:06:51 +00:00
|
|
|
|
2005-11-03 00:51:55 +00:00
|
|
|
/*!
|
|
|
|
* NSEC proofs that have been found.
|
|
|
|
*/
|
2019-08-06 13:44:30 -07:00
|
|
|
#define VALATTR_FOUNDNOQNAME 0x00001000
|
|
|
|
#define VALATTR_FOUNDNOWILDCARD 0x00002000
|
|
|
|
#define VALATTR_FOUNDNODATA 0x00004000
|
|
|
|
#define VALATTR_FOUNDCLOSEST 0x00008000
|
|
|
|
#define VALATTR_FOUNDOPTOUT 0x00010000
|
|
|
|
#define VALATTR_FOUNDUNKNOWN 0x00020000
|
|
|
|
|
|
|
|
#define NEEDNODATA(val) ((val->attributes & VALATTR_NEEDNODATA) != 0)
|
|
|
|
#define NEEDNOQNAME(val) ((val->attributes & VALATTR_NEEDNOQNAME) != 0)
|
|
|
|
#define NEEDNOWILDCARD(val) ((val->attributes & VALATTR_NEEDNOWILDCARD) != 0)
|
|
|
|
#define FOUNDNODATA(val) ((val->attributes & VALATTR_FOUNDNODATA) != 0)
|
|
|
|
#define FOUNDNOQNAME(val) ((val->attributes & VALATTR_FOUNDNOQNAME) != 0)
|
2010-05-14 00:13:43 +00:00
|
|
|
#define FOUNDNOWILDCARD(val) ((val->attributes & VALATTR_FOUNDNOWILDCARD) != 0)
|
2019-08-06 13:44:30 -07:00
|
|
|
#define FOUNDCLOSEST(val) ((val->attributes & VALATTR_FOUNDCLOSEST) != 0)
|
|
|
|
#define FOUNDOPTOUT(val) ((val->attributes & VALATTR_FOUNDOPTOUT) != 0)
|
2004-01-14 02:06:51 +00:00
|
|
|
|
2019-08-06 13:44:30 -07:00
|
|
|
#define SHUTDOWN(v) (((v)->attributes & VALATTR_SHUTDOWN) != 0)
|
|
|
|
#define CANCELED(v) (((v)->attributes & VALATTR_CANCELED) != 0)
|
2000-03-17 00:01:28 +00:00
|
|
|
|
2019-08-06 13:44:30 -07:00
|
|
|
#define NEGATIVE(r) (((r)->attributes & DNS_RDATASETATTR_NEGATIVE) != 0)
|
2011-06-08 22:13:51 +00:00
|
|
|
|
2000-05-24 05:10:00 +00:00
|
|
|
static void
|
2002-06-17 04:01:37 +00:00
|
|
|
destroy(dns_validator_t *val);
|
2000-05-24 05:10:00 +00:00
|
|
|
|
2002-02-01 20:08:56 +00:00
|
|
|
static isc_result_t
|
2003-09-30 06:00:40 +00:00
|
|
|
get_dst_key(dns_validator_t *val, dns_rdata_rrsig_t *siginfo,
|
2000-05-24 05:10:00 +00:00
|
|
|
dns_rdataset_t *rdataset);
|
2000-05-26 21:45:53 +00:00
|
|
|
|
2002-02-01 20:08:56 +00:00
|
|
|
static isc_result_t
|
2019-08-07 16:54:05 -07:00
|
|
|
validate_answer(dns_validator_t *val, bool resume);
|
2000-05-24 05:10:00 +00:00
|
|
|
|
2002-06-17 04:01:37 +00:00
|
|
|
static isc_result_t
|
2004-03-10 02:19:58 +00:00
|
|
|
validatezonekey(dns_validator_t *val);
|
2002-06-17 04:01:37 +00:00
|
|
|
|
2002-02-01 20:08:56 +00:00
|
|
|
static isc_result_t
|
2019-08-07 16:54:05 -07:00
|
|
|
validate_nx(dns_validator_t *val, bool resume);
|
2000-05-24 05:10:00 +00:00
|
|
|
|
2002-02-01 20:08:56 +00:00
|
|
|
static isc_result_t
|
2019-08-06 13:44:30 -07:00
|
|
|
proveunsecure(dns_validator_t *val, bool have_ds, bool resume);
|
2000-05-24 05:10:00 +00:00
|
|
|
|
2002-02-01 20:08:56 +00:00
|
|
|
static void
|
|
|
|
validator_logv(dns_validator_t *val, isc_logcategory_t *category,
|
|
|
|
isc_logmodule_t *module, int level, const char *fmt, va_list ap)
|
2019-08-06 13:44:30 -07:00
|
|
|
ISC_FORMAT_PRINTF(5, 0);
|
2002-02-01 20:08:56 +00:00
|
|
|
|
2000-05-24 05:10:00 +00:00
|
|
|
static void
|
2012-12-19 09:55:02 +11:00
|
|
|
validator_log(void *val, int level, const char *fmt, ...)
|
2019-08-06 13:44:30 -07:00
|
|
|
ISC_FORMAT_PRINTF(3, 4);
|
2000-04-11 20:35:37 +00:00
|
|
|
|
2002-06-17 04:01:37 +00:00
|
|
|
static void
|
|
|
|
validator_logcreate(dns_validator_t *val,
|
|
|
|
dns_name_t *name, dns_rdatatype_t type,
|
|
|
|
const char *caller, const char *operation);
|
|
|
|
|
2019-08-06 13:13:38 -07:00
|
|
|
/*%
|
|
|
|
* Ensure the validator's rdatasets are marked as expired.
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
expire_rdatasets(dns_validator_t *val) {
|
|
|
|
if (dns_rdataset_isassociated(&val->frdataset)) {
|
|
|
|
dns_rdataset_expire(&val->frdataset);
|
|
|
|
}
|
|
|
|
if (dns_rdataset_isassociated(&val->fsigrdataset)) {
|
|
|
|
dns_rdataset_expire(&val->fsigrdataset);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*%
|
|
|
|
* Ensure the validator's rdatasets are disassociated.
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
disassociate_rdatasets(dns_validator_t *val) {
|
|
|
|
if (dns_rdataset_isassociated(&val->frdataset)) {
|
|
|
|
dns_rdataset_disassociate(&val->frdataset);
|
|
|
|
}
|
|
|
|
if (dns_rdataset_isassociated(&val->fsigrdataset)) {
|
|
|
|
dns_rdataset_disassociate(&val->fsigrdataset);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-11-03 00:51:55 +00:00
|
|
|
/*%
|
2019-08-06 16:36:28 -07:00
|
|
|
* Mark the rdatasets in val->event with trust level "answer",
|
|
|
|
* indicating that they did not validate, but could be cached as insecure.
|
|
|
|
*
|
|
|
|
* If we are validating a name that is marked as "must be secure", log a
|
|
|
|
* warning and return DNS_R_MUSTBESECURE instead.
|
2005-11-03 00:51:55 +00:00
|
|
|
*/
|
2019-08-06 16:36:28 -07:00
|
|
|
static inline isc_result_t
|
|
|
|
markanswer(dns_validator_t *val, const char *where, const char *mbstext) {
|
|
|
|
if (val->mustbesecure && mbstext != NULL) {
|
|
|
|
validator_log(val, ISC_LOG_WARNING,
|
|
|
|
"must be secure failure, %s", mbstext);
|
|
|
|
return (DNS_R_MUSTBESECURE);
|
|
|
|
}
|
|
|
|
|
2010-05-14 00:13:43 +00:00
|
|
|
validator_log(val, ISC_LOG_DEBUG(3), "marking as answer (%s)", where);
|
2019-08-06 13:44:30 -07:00
|
|
|
if (val->event->rdataset != NULL) {
|
2010-02-25 04:39:13 +00:00
|
|
|
dns_rdataset_settrust(val->event->rdataset, dns_trust_answer);
|
2019-08-06 13:44:30 -07:00
|
|
|
}
|
|
|
|
if (val->event->sigrdataset != NULL) {
|
2010-02-25 04:39:13 +00:00
|
|
|
dns_rdataset_settrust(val->event->sigrdataset,
|
|
|
|
dns_trust_answer);
|
2019-08-06 13:44:30 -07:00
|
|
|
}
|
2019-08-06 16:36:28 -07:00
|
|
|
|
|
|
|
return (ISC_R_SUCCESS);
|
2010-02-25 04:39:13 +00:00
|
|
|
}
|
|
|
|
|
2019-08-06 16:36:28 -07:00
|
|
|
/*%
|
|
|
|
* Mark the RRsets with trust level secure.
|
|
|
|
*/
|
2010-02-25 04:39:13 +00:00
|
|
|
static inline void
|
|
|
|
marksecure(dns_validatorevent_t *event) {
|
|
|
|
dns_rdataset_settrust(event->rdataset, dns_trust_secure);
|
2019-08-06 13:44:30 -07:00
|
|
|
if (event->sigrdataset != NULL) {
|
2010-05-14 00:13:43 +00:00
|
|
|
dns_rdataset_settrust(event->sigrdataset, dns_trust_secure);
|
2019-08-06 13:44:30 -07:00
|
|
|
}
|
2018-04-17 08:29:14 -07:00
|
|
|
event->secure = true;
|
2005-08-25 00:56:08 +00:00
|
|
|
}
|
|
|
|
|
2000-03-17 00:01:28 +00:00
|
|
|
static void
|
|
|
|
validator_done(dns_validator_t *val, isc_result_t result) {
|
|
|
|
isc_task_t *task;
|
|
|
|
|
2019-08-06 13:44:30 -07:00
|
|
|
if (val->event == NULL) {
|
2000-08-15 00:21:05 +00:00
|
|
|
return;
|
2019-08-06 13:44:30 -07:00
|
|
|
}
|
2000-03-17 00:01:28 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Caller must be holding the lock.
|
|
|
|
*/
|
|
|
|
|
2000-04-07 17:36:40 +00:00
|
|
|
val->event->result = result;
|
2000-04-17 19:22:44 +00:00
|
|
|
task = val->event->ev_sender;
|
|
|
|
val->event->ev_sender = val;
|
|
|
|
val->event->ev_type = DNS_EVENT_VALIDATORDONE;
|
|
|
|
val->event->ev_action = val->action;
|
|
|
|
val->event->ev_arg = val->arg;
|
2000-03-17 00:01:28 +00:00
|
|
|
isc_task_sendanddetach(&task, (isc_event_t **)&val->event);
|
|
|
|
}
|
|
|
|
|
2018-04-17 08:29:14 -07:00
|
|
|
static inline bool
|
2002-06-17 04:01:37 +00:00
|
|
|
exit_check(dns_validator_t *val) {
|
|
|
|
/*
|
|
|
|
* Caller must be holding the lock.
|
|
|
|
*/
|
2019-08-06 13:44:30 -07:00
|
|
|
if (!SHUTDOWN(val)) {
|
2018-04-17 08:29:14 -07:00
|
|
|
return (false);
|
2019-08-06 13:44:30 -07:00
|
|
|
}
|
2002-06-17 04:01:37 +00:00
|
|
|
|
|
|
|
INSIST(val->event == NULL);
|
|
|
|
|
2019-08-06 13:44:30 -07:00
|
|
|
if (val->fetch != NULL || val->subvalidator != NULL) {
|
2018-04-17 08:29:14 -07:00
|
|
|
return (false);
|
2019-08-06 13:44:30 -07:00
|
|
|
}
|
2002-06-17 04:01:37 +00:00
|
|
|
|
2018-04-17 08:29:14 -07:00
|
|
|
return (true);
|
2002-06-17 04:01:37 +00:00
|
|
|
}
|
|
|
|
|
2005-11-03 00:51:55 +00:00
|
|
|
/*%
|
|
|
|
* Look in the NSEC record returned from a DS query to see if there is
|
|
|
|
* a NS RRset at this name. If it is found we are at a delegation point.
|
|
|
|
*/
|
2018-04-17 08:29:14 -07:00
|
|
|
static bool
|
2002-07-19 03:29:15 +00:00
|
|
|
isdelegation(dns_name_t *name, dns_rdataset_t *rdataset,
|
|
|
|
isc_result_t dbresult)
|
|
|
|
{
|
2009-02-15 23:46:23 +00:00
|
|
|
dns_fixedname_t fixed;
|
2008-09-24 02:46:23 +00:00
|
|
|
dns_label_t hashlabel;
|
|
|
|
dns_name_t nsec3name;
|
|
|
|
dns_rdata_nsec3_t nsec3;
|
2002-07-19 03:29:15 +00:00
|
|
|
dns_rdata_t rdata = DNS_RDATA_INIT;
|
2008-09-24 02:46:23 +00:00
|
|
|
dns_rdataset_t set;
|
|
|
|
int order;
|
|
|
|
int scope;
|
2018-04-17 08:29:14 -07:00
|
|
|
bool found;
|
2008-09-24 02:46:23 +00:00
|
|
|
isc_buffer_t buffer;
|
2002-07-19 03:29:15 +00:00
|
|
|
isc_result_t result;
|
2008-09-24 02:46:23 +00:00
|
|
|
unsigned char hash[NSEC3_MAX_HASH_LENGTH];
|
|
|
|
unsigned char owner[NSEC3_MAX_HASH_LENGTH];
|
|
|
|
unsigned int length;
|
2002-07-19 03:29:15 +00:00
|
|
|
|
|
|
|
REQUIRE(dbresult == DNS_R_NXRRSET || dbresult == DNS_R_NCACHENXRRSET);
|
|
|
|
|
|
|
|
dns_rdataset_init(&set);
|
2019-08-06 13:44:30 -07:00
|
|
|
if (dbresult == DNS_R_NXRRSET) {
|
2002-07-19 03:29:15 +00:00
|
|
|
dns_rdataset_clone(rdataset, &set);
|
2019-08-06 13:44:30 -07:00
|
|
|
} else {
|
2002-07-19 03:29:15 +00:00
|
|
|
result = dns_ncache_getrdataset(rdataset, name,
|
2003-09-30 06:00:40 +00:00
|
|
|
dns_rdatatype_nsec, &set);
|
2019-08-06 13:44:30 -07:00
|
|
|
if (result == ISC_R_NOTFOUND) {
|
2008-09-24 02:46:23 +00:00
|
|
|
goto trynsec3;
|
2019-08-06 13:44:30 -07:00
|
|
|
}
|
|
|
|
if (result != ISC_R_SUCCESS) {
|
2018-04-17 08:29:14 -07:00
|
|
|
return (false);
|
2019-08-06 13:44:30 -07:00
|
|
|
}
|
2002-07-19 03:29:15 +00:00
|
|
|
}
|
|
|
|
|
2003-09-30 06:00:40 +00:00
|
|
|
INSIST(set.type == dns_rdatatype_nsec);
|
2002-07-19 03:29:15 +00:00
|
|
|
|
2018-04-17 08:29:14 -07:00
|
|
|
found = false;
|
2002-07-19 03:29:15 +00:00
|
|
|
result = dns_rdataset_first(&set);
|
|
|
|
if (result == ISC_R_SUCCESS) {
|
|
|
|
dns_rdataset_current(&set, &rdata);
|
2003-09-30 06:00:40 +00:00
|
|
|
found = dns_nsec_typepresent(&rdata, dns_rdatatype_ns);
|
2008-09-24 02:46:23 +00:00
|
|
|
dns_rdata_reset(&rdata);
|
2002-07-19 03:29:15 +00:00
|
|
|
}
|
|
|
|
dns_rdataset_disassociate(&set);
|
|
|
|
return (found);
|
2008-09-24 02:46:23 +00:00
|
|
|
|
|
|
|
trynsec3:
|
|
|
|
/*
|
|
|
|
* Iterate over the ncache entry.
|
|
|
|
*/
|
2018-04-17 08:29:14 -07:00
|
|
|
found = false;
|
2008-09-24 02:46:23 +00:00
|
|
|
dns_name_init(&nsec3name, NULL);
|
2009-02-15 23:46:23 +00:00
|
|
|
dns_fixedname_init(&fixed);
|
|
|
|
dns_name_downcase(name, dns_fixedname_name(&fixed), NULL);
|
|
|
|
name = dns_fixedname_name(&fixed);
|
2008-09-24 02:46:23 +00:00
|
|
|
for (result = dns_rdataset_first(rdataset);
|
|
|
|
result == ISC_R_SUCCESS;
|
|
|
|
result = dns_rdataset_next(rdataset))
|
|
|
|
{
|
|
|
|
dns_ncache_current(rdataset, &nsec3name, &set);
|
|
|
|
if (set.type != dns_rdatatype_nsec3) {
|
|
|
|
dns_rdataset_disassociate(&set);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
dns_name_getlabel(&nsec3name, 0, &hashlabel);
|
|
|
|
isc_region_consume(&hashlabel, 1);
|
|
|
|
isc_buffer_init(&buffer, owner, sizeof(owner));
|
2014-04-24 18:58:03 +10:00
|
|
|
result = isc_base32hexnp_decoderegion(&hashlabel, &buffer);
|
2008-09-24 02:46:23 +00:00
|
|
|
if (result != ISC_R_SUCCESS) {
|
|
|
|
dns_rdataset_disassociate(&set);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
for (result = dns_rdataset_first(&set);
|
|
|
|
result == ISC_R_SUCCESS;
|
|
|
|
result = dns_rdataset_next(&set))
|
|
|
|
{
|
|
|
|
dns_rdata_reset(&rdata);
|
|
|
|
dns_rdataset_current(&set, &rdata);
|
|
|
|
(void)dns_rdata_tostruct(&rdata, &nsec3, NULL);
|
2019-08-06 13:44:30 -07:00
|
|
|
if (nsec3.hash != 1) {
|
2008-09-24 02:46:23 +00:00
|
|
|
continue;
|
2019-08-06 13:44:30 -07:00
|
|
|
}
|
2008-09-24 02:46:23 +00:00
|
|
|
length = isc_iterated_hash(hash, nsec3.hash,
|
|
|
|
nsec3.iterations, nsec3.salt,
|
|
|
|
nsec3.salt_length,
|
|
|
|
name->ndata, name->length);
|
2019-08-06 13:44:30 -07:00
|
|
|
if (length != isc_buffer_usedlength(&buffer)) {
|
2008-09-24 02:46:23 +00:00
|
|
|
continue;
|
2019-08-06 13:44:30 -07:00
|
|
|
}
|
2008-09-24 02:46:23 +00:00
|
|
|
order = memcmp(hash, owner, length);
|
|
|
|
if (order == 0) {
|
|
|
|
found = dns_nsec3_typepresent(&rdata,
|
|
|
|
dns_rdatatype_ns);
|
|
|
|
dns_rdataset_disassociate(&set);
|
|
|
|
return (found);
|
|
|
|
}
|
2019-08-06 13:44:30 -07:00
|
|
|
if ((nsec3.flags & DNS_NSEC3FLAG_OPTOUT) == 0) {
|
2008-09-24 02:46:23 +00:00
|
|
|
continue;
|
2019-08-06 13:44:30 -07:00
|
|
|
}
|
2008-09-24 02:46:23 +00:00
|
|
|
/*
|
|
|
|
* Does this optout span cover the name?
|
|
|
|
*/
|
|
|
|
scope = memcmp(owner, nsec3.next, nsec3.next_length);
|
|
|
|
if ((scope < 0 && order > 0 &&
|
|
|
|
memcmp(hash, nsec3.next, length) < 0) ||
|
|
|
|
(scope >= 0 && (order > 0 ||
|
2019-08-06 13:44:30 -07:00
|
|
|
memcmp(hash, nsec3.next,
|
|
|
|
length) < 0)))
|
2008-09-24 02:46:23 +00:00
|
|
|
{
|
|
|
|
dns_rdataset_disassociate(&set);
|
2018-04-17 08:29:14 -07:00
|
|
|
return (true);
|
2008-09-24 02:46:23 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
dns_rdataset_disassociate(&set);
|
|
|
|
}
|
|
|
|
return (found);
|
2002-07-19 03:29:15 +00:00
|
|
|
}
|
|
|
|
|
2005-11-03 00:51:55 +00:00
|
|
|
/*%
|
2009-05-07 09:41:23 +00:00
|
|
|
* We have been asked to look for a key.
|
2019-08-16 12:28:22 -07:00
|
|
|
* If found, resume the validation process.
|
|
|
|
* If not found, fail the validation process.
|
2005-11-03 00:51:55 +00:00
|
|
|
*/
|
2000-04-07 17:36:40 +00:00
|
|
|
static void
|
2019-08-16 12:28:22 -07:00
|
|
|
fetch_callback_dnskey(isc_task_t *task, isc_event_t *event) {
|
2000-04-07 17:36:40 +00:00
|
|
|
dns_fetchevent_t *devent;
|
|
|
|
dns_validator_t *val;
|
|
|
|
dns_rdataset_t *rdataset;
|
2018-04-17 08:29:14 -07:00
|
|
|
bool want_destroy;
|
2000-04-07 17:36:40 +00:00
|
|
|
isc_result_t result;
|
2000-05-26 21:45:53 +00:00
|
|
|
isc_result_t eresult;
|
2010-11-16 01:14:51 +00:00
|
|
|
isc_result_t saved_result;
|
2012-11-14 07:41:32 +11:00
|
|
|
dns_fetch_t *fetch;
|
2000-04-07 17:36:40 +00:00
|
|
|
|
|
|
|
UNUSED(task);
|
2000-04-17 19:22:44 +00:00
|
|
|
INSIST(event->ev_type == DNS_EVENT_FETCHDONE);
|
2000-04-07 17:36:40 +00:00
|
|
|
devent = (dns_fetchevent_t *)event;
|
2000-04-17 19:22:44 +00:00
|
|
|
val = devent->ev_arg;
|
2000-05-26 21:45:53 +00:00
|
|
|
rdataset = &val->frdataset;
|
|
|
|
eresult = devent->result;
|
|
|
|
|
2005-11-02 01:46:31 +00:00
|
|
|
/* Free resources which are not of interest. */
|
2019-08-06 13:44:30 -07:00
|
|
|
if (devent->node != NULL) {
|
2005-11-02 01:46:31 +00:00
|
|
|
dns_db_detachnode(devent->db, &devent->node);
|
2019-08-06 13:44:30 -07:00
|
|
|
}
|
|
|
|
if (devent->db != NULL) {
|
2005-11-02 01:46:31 +00:00
|
|
|
dns_db_detach(&devent->db);
|
2019-08-06 13:44:30 -07:00
|
|
|
}
|
|
|
|
if (dns_rdataset_isassociated(&val->fsigrdataset)) {
|
2005-11-02 01:46:31 +00:00
|
|
|
dns_rdataset_disassociate(&val->fsigrdataset);
|
2019-08-06 13:44:30 -07:00
|
|
|
}
|
2000-05-26 21:45:53 +00:00
|
|
|
isc_event_free(&event);
|
2000-04-07 17:36:40 +00:00
|
|
|
|
2002-02-05 19:46:30 +00:00
|
|
|
INSIST(val->event != NULL);
|
2000-08-15 00:21:05 +00:00
|
|
|
|
2019-08-16 12:28:22 -07:00
|
|
|
validator_log(val, ISC_LOG_DEBUG(3), "in fetch_callback_dnskey");
|
2000-05-26 21:45:53 +00:00
|
|
|
LOCK(&val->lock);
|
2012-11-14 07:41:32 +11:00
|
|
|
fetch = val->fetch;
|
|
|
|
val->fetch = NULL;
|
2007-09-14 05:43:05 +00:00
|
|
|
if (CANCELED(val)) {
|
|
|
|
validator_done(val, ISC_R_CANCELED);
|
|
|
|
} else if (eresult == ISC_R_SUCCESS) {
|
2001-09-14 20:53:33 +00:00
|
|
|
validator_log(val, ISC_LOG_DEBUG(3),
|
2011-05-26 04:35:02 +00:00
|
|
|
"keyset with trust %s",
|
|
|
|
dns_trust_totext(rdataset->trust));
|
2000-05-26 21:45:53 +00:00
|
|
|
/*
|
|
|
|
* Only extract the dst key if the keyset is secure.
|
|
|
|
*/
|
|
|
|
if (rdataset->trust >= dns_trust_secure) {
|
|
|
|
result = get_dst_key(val, val->siginfo, rdataset);
|
2019-08-06 13:44:30 -07:00
|
|
|
if (result == ISC_R_SUCCESS) {
|
2000-05-26 21:45:53 +00:00
|
|
|
val->keyset = &val->frdataset;
|
2019-08-06 13:44:30 -07:00
|
|
|
}
|
2000-04-07 17:36:40 +00:00
|
|
|
}
|
2019-08-07 16:54:05 -07:00
|
|
|
result = validate_answer(val, true);
|
2010-11-16 01:14:51 +00:00
|
|
|
if (result == DNS_R_NOVALIDSIG &&
|
|
|
|
(val->attributes & VALATTR_TRIEDVERIFY) == 0)
|
|
|
|
{
|
|
|
|
saved_result = result;
|
|
|
|
validator_log(val, ISC_LOG_DEBUG(3),
|
|
|
|
"falling back to insecurity proof");
|
2018-04-17 08:29:14 -07:00
|
|
|
result = proveunsecure(val, false, false);
|
2019-08-06 13:44:30 -07:00
|
|
|
if (result == DNS_R_NOTINSECURE) {
|
2010-11-16 01:14:51 +00:00
|
|
|
result = saved_result;
|
2019-08-06 13:44:30 -07:00
|
|
|
}
|
2010-11-16 01:14:51 +00:00
|
|
|
}
|
2019-08-06 13:44:30 -07:00
|
|
|
if (result != DNS_R_WAIT) {
|
2000-04-07 17:36:40 +00:00
|
|
|
validator_done(val, result);
|
2019-08-06 13:44:30 -07:00
|
|
|
}
|
2000-05-19 23:04:14 +00:00
|
|
|
} else {
|
2001-09-14 20:53:33 +00:00
|
|
|
validator_log(val, ISC_LOG_DEBUG(3),
|
2019-08-16 12:28:22 -07:00
|
|
|
"fetch_callback_dnskey: got %s",
|
2002-02-01 20:18:33 +00:00
|
|
|
isc_result_totext(eresult));
|
2019-08-06 13:44:30 -07:00
|
|
|
if (eresult == ISC_R_CANCELED) {
|
2002-02-05 19:46:30 +00:00
|
|
|
validator_done(val, eresult);
|
2019-08-06 13:44:30 -07:00
|
|
|
} else {
|
2010-02-25 04:39:13 +00:00
|
|
|
validator_done(val, DNS_R_BROKENCHAIN);
|
2019-08-06 13:44:30 -07:00
|
|
|
}
|
2000-05-19 23:04:14 +00:00
|
|
|
}
|
2019-08-06 16:36:28 -07:00
|
|
|
|
2002-06-17 04:01:37 +00:00
|
|
|
want_destroy = exit_check(val);
|
2000-05-26 21:45:53 +00:00
|
|
|
UNLOCK(&val->lock);
|
2019-08-06 16:36:28 -07:00
|
|
|
|
2019-08-06 13:44:30 -07:00
|
|
|
if (fetch != NULL) {
|
2012-11-14 07:41:32 +11:00
|
|
|
dns_resolver_destroyfetch(&fetch);
|
2019-08-06 13:44:30 -07:00
|
|
|
}
|
2019-08-06 16:36:28 -07:00
|
|
|
|
2019-08-06 13:44:30 -07:00
|
|
|
if (want_destroy) {
|
2002-06-17 04:01:37 +00:00
|
|
|
destroy(val);
|
2019-08-06 13:44:30 -07:00
|
|
|
}
|
2000-04-07 21:44:47 +00:00
|
|
|
}
|
|
|
|
|
2019-08-16 12:28:22 -07:00
|
|
|
/*%
|
|
|
|
* We have been asked to look for a DS. This may be part of
|
|
|
|
* walking a trust chain, or an insecurity proof.
|
|
|
|
*/
|
2000-04-19 18:08:27 +00:00
|
|
|
static void
|
2019-08-16 12:28:22 -07:00
|
|
|
fetch_callback_ds(isc_task_t *task, isc_event_t *event) {
|
2000-04-19 18:08:27 +00:00
|
|
|
dns_fetchevent_t *devent;
|
|
|
|
dns_validator_t *val;
|
2002-06-17 04:01:37 +00:00
|
|
|
dns_rdataset_t *rdataset;
|
2019-08-07 17:26:35 -07:00
|
|
|
bool want_destroy, trustchain;
|
2000-04-19 18:08:27 +00:00
|
|
|
isc_result_t result;
|
2000-05-26 21:45:53 +00:00
|
|
|
isc_result_t eresult;
|
2012-11-14 07:41:32 +11:00
|
|
|
dns_fetch_t *fetch;
|
2000-04-19 18:08:27 +00:00
|
|
|
|
|
|
|
UNUSED(task);
|
|
|
|
INSIST(event->ev_type == DNS_EVENT_FETCHDONE);
|
|
|
|
devent = (dns_fetchevent_t *)event;
|
|
|
|
val = devent->ev_arg;
|
2000-05-26 21:45:53 +00:00
|
|
|
rdataset = &val->frdataset;
|
|
|
|
eresult = devent->result;
|
2000-04-19 18:08:27 +00:00
|
|
|
|
2019-08-07 17:26:35 -07:00
|
|
|
/*
|
2019-08-16 12:28:22 -07:00
|
|
|
* Set 'trustchain' to true if we're walking a chain of
|
|
|
|
* trust; false if we're attempting to prove insecurity.
|
2019-08-07 17:26:35 -07:00
|
|
|
*/
|
|
|
|
trustchain = ((val->attributes & VALATTR_INSECURITY) == 0);
|
|
|
|
|
2005-11-02 01:46:31 +00:00
|
|
|
/* Free resources which are not of interest. */
|
2019-08-06 13:44:30 -07:00
|
|
|
if (devent->node != NULL) {
|
2005-11-02 01:46:31 +00:00
|
|
|
dns_db_detachnode(devent->db, &devent->node);
|
2019-08-06 13:44:30 -07:00
|
|
|
}
|
|
|
|
if (devent->db != NULL) {
|
2005-11-02 01:46:31 +00:00
|
|
|
dns_db_detach(&devent->db);
|
2019-08-06 13:44:30 -07:00
|
|
|
}
|
|
|
|
if (dns_rdataset_isassociated(&val->fsigrdataset)) {
|
2005-11-02 01:46:31 +00:00
|
|
|
dns_rdataset_disassociate(&val->fsigrdataset);
|
2019-08-06 13:44:30 -07:00
|
|
|
}
|
2000-08-15 00:21:05 +00:00
|
|
|
|
2002-02-05 19:46:30 +00:00
|
|
|
INSIST(val->event != NULL);
|
2000-08-15 00:21:05 +00:00
|
|
|
|
2019-08-16 12:28:22 -07:00
|
|
|
validator_log(val, ISC_LOG_DEBUG(3), "in fetch_callback_ds");
|
2000-05-26 21:45:53 +00:00
|
|
|
LOCK(&val->lock);
|
2012-11-14 07:41:32 +11:00
|
|
|
fetch = val->fetch;
|
|
|
|
val->fetch = NULL;
|
2019-08-07 17:26:35 -07:00
|
|
|
|
2007-09-14 05:43:05 +00:00
|
|
|
if (CANCELED(val)) {
|
|
|
|
validator_done(val, ISC_R_CANCELED);
|
2019-08-07 17:26:35 -07:00
|
|
|
goto done;
|
2000-05-19 23:04:14 +00:00
|
|
|
}
|
2019-08-06 16:36:28 -07:00
|
|
|
|
2019-08-07 17:26:35 -07:00
|
|
|
switch (eresult) {
|
|
|
|
case DNS_R_NXDOMAIN:
|
|
|
|
case DNS_R_NCACHENXDOMAIN:
|
2002-06-17 04:01:37 +00:00
|
|
|
/*
|
2019-08-07 17:26:35 -07:00
|
|
|
* These results only make sense if we're attempting
|
|
|
|
* an insecurity proof, not when walking a chain of trust.
|
2002-06-17 04:01:37 +00:00
|
|
|
*/
|
2019-08-07 17:26:35 -07:00
|
|
|
if (trustchain) {
|
|
|
|
goto unexpected;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* FALLTHROUGH */
|
|
|
|
case ISC_R_SUCCESS:
|
|
|
|
if (trustchain) {
|
|
|
|
/*
|
|
|
|
* We looked for a DS record as part of
|
|
|
|
* following a key chain upwards; resume following
|
|
|
|
* the chain.
|
|
|
|
*/
|
|
|
|
validator_log(val, ISC_LOG_DEBUG(3),
|
|
|
|
"dsset with trust %s",
|
|
|
|
dns_trust_totext(rdataset->trust));
|
|
|
|
val->dsset = &val->frdataset;
|
|
|
|
result = validatezonekey(val);
|
|
|
|
if (result != DNS_R_WAIT) {
|
|
|
|
validator_done(val, result);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
/*
|
|
|
|
* There is a DS which may or may not be a zone cut.
|
|
|
|
* In either case we are still in a secure zone,
|
|
|
|
* so keep looking for the break in the chain
|
|
|
|
* of trust.
|
|
|
|
*/
|
|
|
|
result = proveunsecure(val, (eresult == ISC_R_SUCCESS),
|
|
|
|
true);
|
|
|
|
if (result != DNS_R_WAIT) {
|
|
|
|
validator_done(val, result);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case DNS_R_CNAME:
|
|
|
|
case DNS_R_NXRRSET:
|
|
|
|
case DNS_R_NCACHENXRRSET:
|
|
|
|
case DNS_R_SERVFAIL: /* RFC 1034 parent? */
|
|
|
|
if (trustchain) {
|
|
|
|
/*
|
|
|
|
* Failed to find a DS while following the
|
|
|
|
* chain of trust; now we need to prove insecurity.
|
|
|
|
*/
|
|
|
|
validator_log(val, ISC_LOG_DEBUG(3),
|
|
|
|
"falling back to insecurity proof (%s)",
|
|
|
|
dns_result_totext(eresult));
|
|
|
|
result = proveunsecure(val, false, false);
|
|
|
|
if (result != DNS_R_WAIT) {
|
|
|
|
validator_done(val, result);
|
|
|
|
}
|
|
|
|
} else if (eresult == DNS_R_SERVFAIL) {
|
|
|
|
goto unexpected;
|
|
|
|
} else if (eresult != DNS_R_CNAME &&
|
|
|
|
isdelegation(dns_fixedname_name(&devent->foundname),
|
|
|
|
&val->frdataset, eresult))
|
2019-08-06 16:36:28 -07:00
|
|
|
{
|
2019-08-07 17:26:35 -07:00
|
|
|
/*
|
|
|
|
* Failed to find a DS while trying to prove
|
|
|
|
* insecurity. If this is a zone cut, that
|
|
|
|
* means we're insecure.
|
|
|
|
*/
|
2019-08-16 12:28:22 -07:00
|
|
|
result = markanswer(val, "fetch_callback_ds",
|
2019-08-06 16:36:28 -07:00
|
|
|
"no DS and this is a delegation");
|
|
|
|
validator_done(val, result);
|
2002-07-19 03:29:15 +00:00
|
|
|
} else {
|
2019-08-07 17:26:35 -07:00
|
|
|
/*
|
|
|
|
* Not a zone cut, so we have to keep looking for
|
|
|
|
* the break point in the chain of trust.
|
|
|
|
*/
|
2018-04-17 08:29:14 -07:00
|
|
|
result = proveunsecure(val, false, true);
|
2019-08-06 13:44:30 -07:00
|
|
|
if (result != DNS_R_WAIT) {
|
2002-07-19 03:29:15 +00:00
|
|
|
validator_done(val, result);
|
2019-08-06 13:44:30 -07:00
|
|
|
}
|
2002-07-19 03:29:15 +00:00
|
|
|
}
|
2019-08-07 17:26:35 -07:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
unexpected:
|
2019-08-16 12:28:22 -07:00
|
|
|
validator_log(val, ISC_LOG_DEBUG(3),
|
|
|
|
"fetch_callback_ds: got %s",
|
2019-08-07 17:26:35 -07:00
|
|
|
isc_result_totext(eresult));
|
2019-08-06 13:44:30 -07:00
|
|
|
if (eresult == ISC_R_CANCELED) {
|
2002-06-17 04:01:37 +00:00
|
|
|
validator_done(val, eresult);
|
2019-08-06 13:44:30 -07:00
|
|
|
} else {
|
2019-08-07 17:26:35 -07:00
|
|
|
validator_done(val, DNS_R_BROKENCHAIN);
|
2019-08-06 13:44:30 -07:00
|
|
|
}
|
2002-06-17 04:01:37 +00:00
|
|
|
}
|
2019-08-07 17:26:35 -07:00
|
|
|
done:
|
2019-08-06 16:36:28 -07:00
|
|
|
|
2002-07-19 03:29:15 +00:00
|
|
|
isc_event_free(&event);
|
2002-06-17 04:01:37 +00:00
|
|
|
want_destroy = exit_check(val);
|
|
|
|
UNLOCK(&val->lock);
|
2019-08-06 16:36:28 -07:00
|
|
|
|
2019-08-06 13:44:30 -07:00
|
|
|
if (fetch != NULL) {
|
2012-11-14 07:41:32 +11:00
|
|
|
dns_resolver_destroyfetch(&fetch);
|
2019-08-06 13:44:30 -07:00
|
|
|
}
|
2019-08-06 16:36:28 -07:00
|
|
|
|
2019-08-06 13:44:30 -07:00
|
|
|
if (want_destroy) {
|
2002-06-17 04:01:37 +00:00
|
|
|
destroy(val);
|
2019-08-06 13:44:30 -07:00
|
|
|
}
|
2000-04-19 18:08:27 +00:00
|
|
|
}
|
|
|
|
|
2005-11-03 00:51:55 +00:00
|
|
|
/*%
|
|
|
|
* Callback from when a DNSKEY RRset has been validated.
|
|
|
|
*
|
|
|
|
* Resumes the stalled validation process.
|
|
|
|
*/
|
2000-04-07 21:44:47 +00:00
|
|
|
static void
|
2019-08-16 12:28:22 -07:00
|
|
|
validator_callback_dnskey(isc_task_t *task, isc_event_t *event) {
|
2000-04-07 21:44:47 +00:00
|
|
|
dns_validatorevent_t *devent;
|
|
|
|
dns_validator_t *val;
|
2018-04-17 08:29:14 -07:00
|
|
|
bool want_destroy;
|
2000-04-07 21:44:47 +00:00
|
|
|
isc_result_t result;
|
2000-05-26 21:45:53 +00:00
|
|
|
isc_result_t eresult;
|
2010-11-16 01:14:51 +00:00
|
|
|
isc_result_t saved_result;
|
2000-04-07 21:44:47 +00:00
|
|
|
|
|
|
|
UNUSED(task);
|
2000-04-17 19:22:44 +00:00
|
|
|
INSIST(event->ev_type == DNS_EVENT_VALIDATORDONE);
|
2000-08-15 00:21:05 +00:00
|
|
|
|
2000-08-15 01:22:33 +00:00
|
|
|
devent = (dns_validatorevent_t *)event;
|
|
|
|
val = devent->ev_arg;
|
|
|
|
eresult = devent->result;
|
|
|
|
|
|
|
|
isc_event_free(&event);
|
2002-06-17 04:01:37 +00:00
|
|
|
dns_validator_destroy(&val->subvalidator);
|
2000-08-15 01:22:33 +00:00
|
|
|
|
2002-02-05 19:46:30 +00:00
|
|
|
INSIST(val->event != NULL);
|
2000-08-15 00:21:05 +00:00
|
|
|
|
2019-08-16 12:28:22 -07:00
|
|
|
validator_log(val, ISC_LOG_DEBUG(3), "in validator_callback_dnskey");
|
2000-05-26 21:45:53 +00:00
|
|
|
LOCK(&val->lock);
|
2007-09-14 05:43:05 +00:00
|
|
|
if (CANCELED(val)) {
|
|
|
|
validator_done(val, ISC_R_CANCELED);
|
|
|
|
} else if (eresult == ISC_R_SUCCESS) {
|
2001-09-14 20:53:33 +00:00
|
|
|
validator_log(val, ISC_LOG_DEBUG(3),
|
2011-05-26 04:35:02 +00:00
|
|
|
"keyset with trust %s",
|
|
|
|
dns_trust_totext(val->frdataset.trust));
|
2000-05-26 21:45:53 +00:00
|
|
|
/*
|
|
|
|
* Only extract the dst key if the keyset is secure.
|
|
|
|
*/
|
2019-08-06 13:44:30 -07:00
|
|
|
if (val->frdataset.trust >= dns_trust_secure) {
|
2000-05-26 21:45:53 +00:00
|
|
|
(void) get_dst_key(val, val->siginfo, &val->frdataset);
|
2019-08-06 13:44:30 -07:00
|
|
|
}
|
2019-08-07 16:54:05 -07:00
|
|
|
result = validate_answer(val, true);
|
2010-11-16 01:14:51 +00:00
|
|
|
if (result == DNS_R_NOVALIDSIG &&
|
|
|
|
(val->attributes & VALATTR_TRIEDVERIFY) == 0)
|
|
|
|
{
|
|
|
|
saved_result = result;
|
|
|
|
validator_log(val, ISC_LOG_DEBUG(3),
|
|
|
|
"falling back to insecurity proof");
|
2018-04-17 08:29:14 -07:00
|
|
|
result = proveunsecure(val, false, false);
|
2019-08-06 13:44:30 -07:00
|
|
|
if (result == DNS_R_NOTINSECURE) {
|
2010-11-16 01:14:51 +00:00
|
|
|
result = saved_result;
|
2019-08-06 13:44:30 -07:00
|
|
|
}
|
2010-11-16 01:14:51 +00:00
|
|
|
}
|
2019-08-06 13:44:30 -07:00
|
|
|
if (result != DNS_R_WAIT) {
|
2000-04-07 21:44:47 +00:00
|
|
|
validator_done(val, result);
|
2019-08-06 13:44:30 -07:00
|
|
|
}
|
2000-05-19 23:04:14 +00:00
|
|
|
} else {
|
2010-02-25 04:39:13 +00:00
|
|
|
if (eresult != DNS_R_BROKENCHAIN) {
|
2019-08-06 13:13:38 -07:00
|
|
|
expire_rdatasets(val);
|
2010-02-25 04:39:13 +00:00
|
|
|
}
|
2001-09-14 20:53:33 +00:00
|
|
|
validator_log(val, ISC_LOG_DEBUG(3),
|
2019-08-16 12:28:22 -07:00
|
|
|
"validator_callback_dnskey: got %s",
|
2002-02-01 20:18:33 +00:00
|
|
|
isc_result_totext(eresult));
|
2010-02-25 04:39:13 +00:00
|
|
|
validator_done(val, DNS_R_BROKENCHAIN);
|
2000-05-19 23:04:14 +00:00
|
|
|
}
|
2019-08-06 16:36:28 -07:00
|
|
|
|
2002-06-17 04:01:37 +00:00
|
|
|
want_destroy = exit_check(val);
|
|
|
|
UNLOCK(&val->lock);
|
2019-08-06 13:44:30 -07:00
|
|
|
if (want_destroy) {
|
2002-06-17 04:01:37 +00:00
|
|
|
destroy(val);
|
2019-08-06 13:44:30 -07:00
|
|
|
}
|
2002-06-17 04:01:37 +00:00
|
|
|
}
|
|
|
|
|
2005-11-03 00:51:55 +00:00
|
|
|
/*%
|
|
|
|
* Callback when the DS record has been validated.
|
|
|
|
*
|
|
|
|
* Resumes validation of the zone key or the unsecure zone proof.
|
|
|
|
*/
|
2002-06-17 04:01:37 +00:00
|
|
|
static void
|
2019-08-16 12:28:22 -07:00
|
|
|
validator_callback_ds(isc_task_t *task, isc_event_t *event) {
|
2002-06-17 04:01:37 +00:00
|
|
|
dns_validatorevent_t *devent;
|
|
|
|
dns_validator_t *val;
|
2018-04-17 08:29:14 -07:00
|
|
|
bool want_destroy;
|
2002-06-17 04:01:37 +00:00
|
|
|
isc_result_t result;
|
|
|
|
isc_result_t eresult;
|
|
|
|
|
|
|
|
UNUSED(task);
|
|
|
|
INSIST(event->ev_type == DNS_EVENT_VALIDATORDONE);
|
|
|
|
|
|
|
|
devent = (dns_validatorevent_t *)event;
|
|
|
|
val = devent->ev_arg;
|
|
|
|
eresult = devent->result;
|
|
|
|
|
|
|
|
isc_event_free(&event);
|
|
|
|
dns_validator_destroy(&val->subvalidator);
|
|
|
|
|
|
|
|
INSIST(val->event != NULL);
|
2000-05-19 23:04:14 +00:00
|
|
|
|
2019-08-16 12:28:22 -07:00
|
|
|
validator_log(val, ISC_LOG_DEBUG(3), "in validator_callback_ds");
|
2002-06-17 04:01:37 +00:00
|
|
|
LOCK(&val->lock);
|
2007-09-14 05:43:05 +00:00
|
|
|
if (CANCELED(val)) {
|
|
|
|
validator_done(val, ISC_R_CANCELED);
|
|
|
|
} else if (eresult == ISC_R_SUCCESS) {
|
2018-04-17 08:29:14 -07:00
|
|
|
bool have_dsset;
|
2010-05-14 00:13:43 +00:00
|
|
|
dns_name_t *name;
|
2002-06-17 04:01:37 +00:00
|
|
|
validator_log(val, ISC_LOG_DEBUG(3),
|
2011-05-26 04:35:02 +00:00
|
|
|
"%s with trust %s",
|
2010-05-14 00:13:43 +00:00
|
|
|
val->frdataset.type == dns_rdatatype_ds ?
|
|
|
|
"dsset" : "ds non-existance",
|
2011-05-26 04:35:02 +00:00
|
|
|
dns_trust_totext(val->frdataset.trust));
|
2018-04-17 08:29:14 -07:00
|
|
|
have_dsset = (val->frdataset.type == dns_rdatatype_ds);
|
2010-05-14 00:13:43 +00:00
|
|
|
name = dns_fixedname_name(&val->fname);
|
|
|
|
if ((val->attributes & VALATTR_INSECURITY) != 0 &&
|
|
|
|
val->frdataset.covers == dns_rdatatype_ds &&
|
2011-06-08 22:13:51 +00:00
|
|
|
NEGATIVE(&val->frdataset) &&
|
2019-08-06 13:13:38 -07:00
|
|
|
isdelegation(name, &val->frdataset, DNS_R_NCACHENXRRSET))
|
|
|
|
{
|
2019-08-16 12:28:22 -07:00
|
|
|
result = markanswer(val, "validator_callback_ds",
|
2019-08-06 16:36:28 -07:00
|
|
|
"no DS and this is a delegation");
|
2010-05-14 00:13:43 +00:00
|
|
|
} else if ((val->attributes & VALATTR_INSECURITY) != 0) {
|
2018-04-17 08:29:14 -07:00
|
|
|
result = proveunsecure(val, have_dsset, true);
|
2019-08-06 13:44:30 -07:00
|
|
|
} else {
|
2004-03-10 02:19:58 +00:00
|
|
|
result = validatezonekey(val);
|
2019-08-06 13:44:30 -07:00
|
|
|
}
|
|
|
|
if (result != DNS_R_WAIT) {
|
2002-06-17 04:01:37 +00:00
|
|
|
validator_done(val, result);
|
2019-08-06 13:44:30 -07:00
|
|
|
}
|
2002-06-17 04:01:37 +00:00
|
|
|
} else {
|
2010-02-25 04:39:13 +00:00
|
|
|
if (eresult != DNS_R_BROKENCHAIN) {
|
2019-08-06 13:13:38 -07:00
|
|
|
expire_rdatasets(val);
|
2010-02-25 04:39:13 +00:00
|
|
|
}
|
2002-06-17 04:01:37 +00:00
|
|
|
validator_log(val, ISC_LOG_DEBUG(3),
|
2019-08-16 12:28:22 -07:00
|
|
|
"validator_callback_ds: got %s",
|
2002-06-17 04:01:37 +00:00
|
|
|
isc_result_totext(eresult));
|
2010-02-25 04:39:13 +00:00
|
|
|
validator_done(val, DNS_R_BROKENCHAIN);
|
2002-06-17 04:01:37 +00:00
|
|
|
}
|
2019-08-06 16:36:28 -07:00
|
|
|
|
2002-06-17 04:01:37 +00:00
|
|
|
want_destroy = exit_check(val);
|
2000-05-26 21:45:53 +00:00
|
|
|
UNLOCK(&val->lock);
|
2019-08-06 13:44:30 -07:00
|
|
|
if (want_destroy) {
|
2002-06-17 04:01:37 +00:00
|
|
|
destroy(val);
|
2019-08-06 13:44:30 -07:00
|
|
|
}
|
2000-05-26 21:45:53 +00:00
|
|
|
}
|
|
|
|
|
2011-02-21 23:37:31 +00:00
|
|
|
/*%
|
|
|
|
* Callback when the CNAME record has been validated.
|
|
|
|
*
|
|
|
|
* Resumes validation of the unsecure zone proof.
|
|
|
|
*/
|
|
|
|
static void
|
2019-08-16 12:28:22 -07:00
|
|
|
validator_callback_cname(isc_task_t *task, isc_event_t *event) {
|
2011-02-21 23:37:31 +00:00
|
|
|
dns_validatorevent_t *devent;
|
|
|
|
dns_validator_t *val;
|
2018-04-17 08:29:14 -07:00
|
|
|
bool want_destroy;
|
2011-02-21 23:37:31 +00:00
|
|
|
isc_result_t result;
|
|
|
|
isc_result_t eresult;
|
|
|
|
|
|
|
|
UNUSED(task);
|
|
|
|
INSIST(event->ev_type == DNS_EVENT_VALIDATORDONE);
|
|
|
|
|
|
|
|
devent = (dns_validatorevent_t *)event;
|
|
|
|
val = devent->ev_arg;
|
|
|
|
eresult = devent->result;
|
|
|
|
|
|
|
|
isc_event_free(&event);
|
|
|
|
dns_validator_destroy(&val->subvalidator);
|
|
|
|
|
|
|
|
INSIST(val->event != NULL);
|
|
|
|
INSIST((val->attributes & VALATTR_INSECURITY) != 0);
|
|
|
|
|
2019-08-16 12:28:22 -07:00
|
|
|
validator_log(val, ISC_LOG_DEBUG(3), "in validator_callback_cname");
|
2011-02-21 23:37:31 +00:00
|
|
|
LOCK(&val->lock);
|
|
|
|
if (CANCELED(val)) {
|
|
|
|
validator_done(val, ISC_R_CANCELED);
|
|
|
|
} else if (eresult == ISC_R_SUCCESS) {
|
2011-05-26 04:35:02 +00:00
|
|
|
validator_log(val, ISC_LOG_DEBUG(3), "cname with trust %s",
|
|
|
|
dns_trust_totext(val->frdataset.trust));
|
2018-04-17 08:29:14 -07:00
|
|
|
result = proveunsecure(val, false, true);
|
2019-08-06 13:44:30 -07:00
|
|
|
if (result != DNS_R_WAIT) {
|
2011-02-21 23:37:31 +00:00
|
|
|
validator_done(val, result);
|
2019-08-06 13:44:30 -07:00
|
|
|
}
|
2011-02-21 23:37:31 +00:00
|
|
|
} else {
|
|
|
|
if (eresult != DNS_R_BROKENCHAIN) {
|
2019-08-06 13:13:38 -07:00
|
|
|
expire_rdatasets(val);
|
2011-02-21 23:37:31 +00:00
|
|
|
}
|
|
|
|
validator_log(val, ISC_LOG_DEBUG(3),
|
2019-08-16 12:28:22 -07:00
|
|
|
"validator_callback_cname: got %s",
|
2011-02-21 23:37:31 +00:00
|
|
|
isc_result_totext(eresult));
|
|
|
|
validator_done(val, DNS_R_BROKENCHAIN);
|
|
|
|
}
|
2019-08-06 16:36:28 -07:00
|
|
|
|
2011-02-21 23:37:31 +00:00
|
|
|
want_destroy = exit_check(val);
|
|
|
|
UNLOCK(&val->lock);
|
2019-08-06 13:44:30 -07:00
|
|
|
if (want_destroy) {
|
2011-02-21 23:37:31 +00:00
|
|
|
destroy(val);
|
2019-08-06 13:44:30 -07:00
|
|
|
}
|
2011-02-21 23:37:31 +00:00
|
|
|
}
|
|
|
|
|
2005-11-03 00:51:55 +00:00
|
|
|
/*%
|
|
|
|
* Callback for when NSEC records have been validated.
|
|
|
|
*
|
2008-09-24 02:46:23 +00:00
|
|
|
* Looks for NOQNAME, NODATA and OPTOUT proofs.
|
2005-11-03 00:51:55 +00:00
|
|
|
*
|
2019-08-07 16:54:05 -07:00
|
|
|
* Resumes validate_nx.
|
2005-11-03 00:51:55 +00:00
|
|
|
*/
|
2000-05-17 18:24:59 +00:00
|
|
|
static void
|
2019-08-16 12:28:22 -07:00
|
|
|
validator_callback_nsec(isc_task_t *task, isc_event_t *event) {
|
2000-05-17 18:24:59 +00:00
|
|
|
dns_validatorevent_t *devent;
|
|
|
|
dns_validator_t *val;
|
2005-10-14 01:18:47 +00:00
|
|
|
dns_rdataset_t *rdataset;
|
2018-04-17 08:29:14 -07:00
|
|
|
bool want_destroy;
|
2000-05-17 18:24:59 +00:00
|
|
|
isc_result_t result;
|
2018-04-17 08:29:14 -07:00
|
|
|
bool exists, data;
|
2000-05-17 18:24:59 +00:00
|
|
|
|
|
|
|
UNUSED(task);
|
|
|
|
INSIST(event->ev_type == DNS_EVENT_VALIDATORDONE);
|
2000-08-15 00:21:05 +00:00
|
|
|
|
2000-08-15 01:22:33 +00:00
|
|
|
devent = (dns_validatorevent_t *)event;
|
|
|
|
rdataset = devent->rdataset;
|
|
|
|
val = devent->ev_arg;
|
2002-06-19 04:15:12 +00:00
|
|
|
result = devent->result;
|
2002-06-17 04:01:37 +00:00
|
|
|
dns_validator_destroy(&val->subvalidator);
|
2000-08-15 01:22:33 +00:00
|
|
|
|
2002-02-05 19:46:30 +00:00
|
|
|
INSIST(val->event != NULL);
|
2000-08-15 00:21:05 +00:00
|
|
|
|
2019-08-16 12:28:22 -07:00
|
|
|
validator_log(val, ISC_LOG_DEBUG(3), "in validator_callback_nsec");
|
2000-05-26 21:45:53 +00:00
|
|
|
LOCK(&val->lock);
|
2007-09-14 05:43:05 +00:00
|
|
|
if (CANCELED(val)) {
|
|
|
|
validator_done(val, ISC_R_CANCELED);
|
|
|
|
} else if (result != ISC_R_SUCCESS) {
|
2001-09-14 20:53:33 +00:00
|
|
|
validator_log(val, ISC_LOG_DEBUG(3),
|
2019-08-16 12:28:22 -07:00
|
|
|
"validator_callback_nsec: got %s",
|
2002-06-19 04:15:12 +00:00
|
|
|
isc_result_totext(result));
|
2019-08-06 13:44:30 -07:00
|
|
|
if (result == DNS_R_BROKENCHAIN) {
|
2010-02-25 04:39:13 +00:00
|
|
|
val->authfail++;
|
2019-08-06 13:44:30 -07:00
|
|
|
}
|
|
|
|
if (result == ISC_R_CANCELED) {
|
2000-07-27 18:42:08 +00:00
|
|
|
validator_done(val, result);
|
2019-08-06 13:44:30 -07:00
|
|
|
} else {
|
2019-08-07 16:54:05 -07:00
|
|
|
result = validate_nx(val, true);
|
2019-08-06 13:44:30 -07:00
|
|
|
if (result != DNS_R_WAIT) {
|
2002-06-17 04:01:37 +00:00
|
|
|
validator_done(val, result);
|
2019-08-06 13:44:30 -07:00
|
|
|
}
|
2002-06-17 04:01:37 +00:00
|
|
|
}
|
2000-05-26 21:45:53 +00:00
|
|
|
} else {
|
2004-01-14 02:06:51 +00:00
|
|
|
dns_name_t **proofs = val->event->proofs;
|
2006-12-07 06:47:36 +00:00
|
|
|
dns_name_t *wild = dns_fixedname_name(&val->wild);
|
2008-01-18 23:46:58 +00:00
|
|
|
|
2019-08-06 13:44:30 -07:00
|
|
|
if (rdataset->trust == dns_trust_secure) {
|
2018-04-17 08:29:14 -07:00
|
|
|
val->seensig = true;
|
2019-08-06 13:44:30 -07:00
|
|
|
}
|
2000-05-17 18:24:59 +00:00
|
|
|
|
2004-11-17 23:52:31 +00:00
|
|
|
if (rdataset->type == dns_rdatatype_nsec &&
|
2004-01-14 02:06:51 +00:00
|
|
|
rdataset->trust == dns_trust_secure &&
|
2010-05-14 00:13:43 +00:00
|
|
|
(NEEDNODATA(val) || NEEDNOQNAME(val)) &&
|
|
|
|
!FOUNDNODATA(val) && !FOUNDNOQNAME(val) &&
|
2012-12-19 09:55:02 +11:00
|
|
|
dns_nsec_noexistnodata(val->event->type, val->event->name,
|
|
|
|
devent->name, rdataset, &exists,
|
|
|
|
&data, wild, validator_log, val)
|
2019-08-06 13:44:30 -07:00
|
|
|
== ISC_R_SUCCESS)
|
2006-12-07 06:47:36 +00:00
|
|
|
{
|
2004-01-14 02:06:51 +00:00
|
|
|
if (exists && !data) {
|
|
|
|
val->attributes |= VALATTR_FOUNDNODATA;
|
2019-08-06 13:44:30 -07:00
|
|
|
if (NEEDNODATA(val)) {
|
2004-01-14 02:06:51 +00:00
|
|
|
proofs[DNS_VALIDATOR_NODATAPROOF] =
|
|
|
|
devent->name;
|
2019-08-06 13:44:30 -07:00
|
|
|
}
|
2004-01-14 02:06:51 +00:00
|
|
|
}
|
|
|
|
if (!exists) {
|
2014-09-05 12:10:55 +10:00
|
|
|
dns_name_t *closest;
|
|
|
|
unsigned int clabels;
|
|
|
|
|
2004-01-14 02:06:51 +00:00
|
|
|
val->attributes |= VALATTR_FOUNDNOQNAME;
|
2014-09-05 12:10:55 +10:00
|
|
|
|
|
|
|
closest = dns_fixedname_name(&val->closest);
|
|
|
|
clabels = dns_name_countlabels(closest);
|
|
|
|
/*
|
|
|
|
* If we are validating a wildcard response
|
|
|
|
* clabels will not be zero. We then need
|
|
|
|
* to check if the generated wilcard from
|
|
|
|
* dns_nsec_noexistnodata is consistent with
|
|
|
|
* the wildcard used to generate the response.
|
|
|
|
*/
|
|
|
|
if (clabels == 0 ||
|
|
|
|
dns_name_countlabels(wild) == clabels + 1)
|
2019-08-06 13:44:30 -07:00
|
|
|
{
|
2014-09-05 12:10:55 +10:00
|
|
|
val->attributes |= VALATTR_FOUNDCLOSEST;
|
2019-08-06 13:44:30 -07:00
|
|
|
}
|
2008-09-24 02:46:23 +00:00
|
|
|
/*
|
|
|
|
* The NSEC noqname proof also contains
|
|
|
|
* the closest encloser.
|
|
|
|
*/
|
2019-08-06 13:44:30 -07:00
|
|
|
if (NEEDNOQNAME(val)) {
|
2004-01-14 02:06:51 +00:00
|
|
|
proofs[DNS_VALIDATOR_NOQNAMEPROOF] =
|
|
|
|
devent->name;
|
2019-08-06 13:44:30 -07:00
|
|
|
}
|
2004-01-14 02:06:51 +00:00
|
|
|
}
|
|
|
|
}
|
2008-09-24 02:46:23 +00:00
|
|
|
|
2019-08-07 16:54:05 -07:00
|
|
|
result = validate_nx(val, true);
|
2019-08-06 13:44:30 -07:00
|
|
|
if (result != DNS_R_WAIT) {
|
2000-05-26 21:45:53 +00:00
|
|
|
validator_done(val, result);
|
2019-08-06 13:44:30 -07:00
|
|
|
}
|
2000-05-17 18:24:59 +00:00
|
|
|
}
|
2019-08-06 16:36:28 -07:00
|
|
|
|
2002-06-17 04:01:37 +00:00
|
|
|
want_destroy = exit_check(val);
|
2000-05-17 18:24:59 +00:00
|
|
|
UNLOCK(&val->lock);
|
2019-08-06 13:44:30 -07:00
|
|
|
if (want_destroy) {
|
2002-06-17 04:01:37 +00:00
|
|
|
destroy(val);
|
2019-08-06 13:44:30 -07:00
|
|
|
}
|
2000-05-17 18:24:59 +00:00
|
|
|
|
|
|
|
/*
|
2000-05-26 21:45:53 +00:00
|
|
|
* Free stuff from the event.
|
2000-05-17 18:24:59 +00:00
|
|
|
*/
|
2000-05-18 02:02:05 +00:00
|
|
|
isc_event_free(&event);
|
|
|
|
}
|
|
|
|
|
2005-11-03 00:51:55 +00:00
|
|
|
/*%
|
|
|
|
* Looks for the requested name and type in the view (zones and cache).
|
|
|
|
*
|
|
|
|
* Returns:
|
|
|
|
* \li ISC_R_SUCCESS
|
|
|
|
* \li ISC_R_NOTFOUND
|
|
|
|
* \li DNS_R_NCACHENXDOMAIN
|
|
|
|
* \li DNS_R_NCACHENXRRSET
|
|
|
|
* \li DNS_R_NXRRSET
|
|
|
|
* \li DNS_R_NXDOMAIN
|
2010-02-25 04:39:13 +00:00
|
|
|
* \li DNS_R_BROKENCHAIN
|
2005-11-03 00:51:55 +00:00
|
|
|
*/
|
2002-06-17 04:01:37 +00:00
|
|
|
static inline isc_result_t
|
|
|
|
view_find(dns_validator_t *val, dns_name_t *name, dns_rdatatype_t type) {
|
2004-05-14 04:45:58 +00:00
|
|
|
dns_fixedname_t fixedname;
|
|
|
|
dns_name_t *foundname;
|
|
|
|
isc_result_t result;
|
|
|
|
unsigned int options;
|
2010-02-25 04:39:13 +00:00
|
|
|
isc_time_t now;
|
|
|
|
char namebuf[DNS_NAME_FORMATSIZE];
|
|
|
|
char typebuf[DNS_RDATATYPE_FORMATSIZE];
|
2004-05-14 04:45:58 +00:00
|
|
|
|
2019-08-06 13:13:38 -07:00
|
|
|
disassociate_rdatasets(val);
|
2000-05-26 21:45:53 +00:00
|
|
|
|
2010-02-25 04:39:13 +00:00
|
|
|
if (isc_time_now(&now) == ISC_R_SUCCESS &&
|
2019-08-06 13:13:38 -07:00
|
|
|
dns_resolver_getbadcache(val->view->resolver, name, type, &now))
|
|
|
|
{
|
2010-02-25 04:39:13 +00:00
|
|
|
dns_name_format(name, namebuf, sizeof(namebuf));
|
|
|
|
dns_rdatatype_format(type, typebuf, sizeof(typebuf));
|
|
|
|
validator_log(val, ISC_LOG_INFO, "bad cache hit (%s/%s)",
|
|
|
|
namebuf, typebuf);
|
|
|
|
return (DNS_R_BROKENCHAIN);
|
|
|
|
}
|
|
|
|
|
2004-05-14 04:45:58 +00:00
|
|
|
options = DNS_DBFIND_PENDINGOK;
|
2018-03-28 14:38:09 +02:00
|
|
|
foundname = dns_fixedname_initname(&fixedname);
|
2004-05-14 04:45:58 +00:00
|
|
|
result = dns_view_find(val->view, name, type, 0, options,
|
2018-04-17 08:29:14 -07:00
|
|
|
false, false, NULL, NULL, foundname,
|
2004-05-14 04:45:58 +00:00
|
|
|
&val->frdataset, &val->fsigrdataset);
|
2010-02-25 04:39:13 +00:00
|
|
|
|
2004-05-14 04:45:58 +00:00
|
|
|
if (result == DNS_R_NXDOMAIN) {
|
2019-08-06 13:13:38 -07:00
|
|
|
goto notfound;
|
2004-05-14 04:45:58 +00:00
|
|
|
} else if (result != ISC_R_SUCCESS &&
|
2008-01-18 23:46:58 +00:00
|
|
|
result != DNS_R_NCACHENXDOMAIN &&
|
|
|
|
result != DNS_R_NCACHENXRRSET &&
|
2008-08-21 04:43:49 +00:00
|
|
|
result != DNS_R_EMPTYNAME &&
|
2008-01-18 23:46:58 +00:00
|
|
|
result != DNS_R_NXRRSET &&
|
2019-08-06 13:44:30 -07:00
|
|
|
result != ISC_R_NOTFOUND)
|
|
|
|
{
|
2019-08-06 13:13:38 -07:00
|
|
|
result = ISC_R_NOTFOUND;
|
|
|
|
goto notfound;
|
2004-05-14 04:45:58 +00:00
|
|
|
}
|
2019-08-06 13:13:38 -07:00
|
|
|
|
2004-05-14 04:45:58 +00:00
|
|
|
return (result);
|
|
|
|
|
|
|
|
notfound:
|
2019-08-06 13:13:38 -07:00
|
|
|
disassociate_rdatasets(val);
|
|
|
|
|
|
|
|
return (result);
|
2002-06-17 04:01:37 +00:00
|
|
|
}
|
2000-04-18 17:50:38 +00:00
|
|
|
|
2005-11-03 00:51:55 +00:00
|
|
|
/*%
|
2019-08-06 13:13:38 -07:00
|
|
|
* Checks to make sure we are not going to loop. As we use a SHARED fetch
|
|
|
|
* the validation process will stall if looping was to occur.
|
|
|
|
*/
|
2018-04-17 08:29:14 -07:00
|
|
|
static inline bool
|
2008-09-24 02:46:23 +00:00
|
|
|
check_deadlock(dns_validator_t *val, dns_name_t *name, dns_rdatatype_t type,
|
2019-08-06 13:13:38 -07:00
|
|
|
dns_rdataset_t *rdataset, dns_rdataset_t *sigrdataset)
|
2008-09-24 02:46:23 +00:00
|
|
|
{
|
2002-06-17 04:01:37 +00:00
|
|
|
dns_validator_t *parent;
|
2000-08-15 01:22:33 +00:00
|
|
|
|
2005-11-03 00:51:55 +00:00
|
|
|
for (parent = val; parent != NULL; parent = parent->parent) {
|
2002-06-17 04:01:37 +00:00
|
|
|
if (parent->event != NULL &&
|
2018-03-02 11:30:02 -08:00
|
|
|
parent->event->type == type &&
|
2008-09-24 02:46:23 +00:00
|
|
|
dns_name_equal(parent->event->name, name) &&
|
|
|
|
/*
|
|
|
|
* As NSEC3 records are meta data you sometimes
|
|
|
|
* need to prove a NSEC3 record which says that
|
|
|
|
* itself doesn't exist.
|
|
|
|
*/
|
|
|
|
(parent->event->type != dns_rdatatype_nsec3 ||
|
|
|
|
rdataset == NULL || sigrdataset == NULL ||
|
|
|
|
parent->event->message == NULL ||
|
|
|
|
parent->event->rdataset != NULL ||
|
|
|
|
parent->event->sigrdataset != NULL))
|
2002-06-17 04:01:37 +00:00
|
|
|
{
|
|
|
|
validator_log(val, ISC_LOG_DEBUG(3),
|
|
|
|
"continuing validation would lead to "
|
|
|
|
"deadlock: aborting validation");
|
2018-04-17 08:29:14 -07:00
|
|
|
return (true);
|
2002-06-17 04:01:37 +00:00
|
|
|
}
|
2000-04-18 17:50:38 +00:00
|
|
|
}
|
2018-04-17 08:29:14 -07:00
|
|
|
return (false);
|
2002-06-17 04:01:37 +00:00
|
|
|
}
|
2000-04-18 17:50:38 +00:00
|
|
|
|
2005-11-03 00:51:55 +00:00
|
|
|
/*%
|
|
|
|
* Start a fetch for the requested name and type.
|
|
|
|
*/
|
2002-06-17 04:01:37 +00:00
|
|
|
static inline isc_result_t
|
|
|
|
create_fetch(dns_validator_t *val, dns_name_t *name, dns_rdatatype_t type,
|
|
|
|
isc_taskaction_t callback, const char *caller)
|
|
|
|
{
|
2014-02-16 13:03:17 -08:00
|
|
|
unsigned int fopts = 0;
|
|
|
|
|
2019-08-06 13:13:38 -07:00
|
|
|
disassociate_rdatasets(val);
|
2002-06-17 04:01:37 +00:00
|
|
|
|
2009-11-16 07:56:06 +00:00
|
|
|
if (check_deadlock(val, name, type, NULL, NULL)) {
|
|
|
|
validator_log(val, ISC_LOG_DEBUG(3),
|
|
|
|
"deadlock found (create_fetch)");
|
2002-06-17 04:01:37 +00:00
|
|
|
return (DNS_R_NOVALIDSIG);
|
2009-11-16 07:56:06 +00:00
|
|
|
}
|
2002-06-17 04:01:37 +00:00
|
|
|
|
2019-08-06 13:44:30 -07:00
|
|
|
if ((val->options & DNS_VALIDATOR_NOCDFLAG) != 0) {
|
2014-02-16 13:03:17 -08:00
|
|
|
fopts |= DNS_FETCHOPT_NOCDFLAG;
|
2019-08-06 13:44:30 -07:00
|
|
|
}
|
2014-02-16 13:03:17 -08:00
|
|
|
|
2019-08-06 13:44:30 -07:00
|
|
|
if ((val->options & DNS_VALIDATOR_NONTA) != 0) {
|
2014-06-18 16:47:22 -07:00
|
|
|
fopts |= DNS_FETCHOPT_NONTA;
|
2019-08-06 13:44:30 -07:00
|
|
|
}
|
2014-06-18 16:47:22 -07:00
|
|
|
|
2002-06-17 04:01:37 +00:00
|
|
|
validator_logcreate(val, name, type, caller, "fetch");
|
|
|
|
return (dns_resolver_createfetch(val->view->resolver, name, type,
|
2018-04-03 16:05:11 +02:00
|
|
|
NULL, NULL, NULL, NULL, 0, fopts,
|
|
|
|
0, NULL, val->event->ev_sender,
|
2002-06-17 04:01:37 +00:00
|
|
|
callback, val,
|
|
|
|
&val->frdataset,
|
|
|
|
&val->fsigrdataset,
|
|
|
|
&val->fetch));
|
2000-04-18 17:50:38 +00:00
|
|
|
}
|
|
|
|
|
2005-11-03 00:51:55 +00:00
|
|
|
/*%
|
|
|
|
* Start a subvalidation process.
|
|
|
|
*/
|
2002-06-17 04:01:37 +00:00
|
|
|
static inline isc_result_t
|
|
|
|
create_validator(dns_validator_t *val, dns_name_t *name, dns_rdatatype_t type,
|
|
|
|
dns_rdataset_t *rdataset, dns_rdataset_t *sigrdataset,
|
|
|
|
isc_taskaction_t action, const char *caller)
|
|
|
|
{
|
2000-04-19 18:08:27 +00:00
|
|
|
isc_result_t result;
|
2014-02-16 13:03:17 -08:00
|
|
|
unsigned int vopts = 0;
|
2000-04-19 18:08:27 +00:00
|
|
|
|
2009-11-16 07:56:06 +00:00
|
|
|
if (check_deadlock(val, name, type, rdataset, sigrdataset)) {
|
|
|
|
validator_log(val, ISC_LOG_DEBUG(3),
|
|
|
|
"deadlock found (create_validator)");
|
2002-06-17 04:01:37 +00:00
|
|
|
return (DNS_R_NOVALIDSIG);
|
2009-11-16 07:56:06 +00:00
|
|
|
}
|
2002-06-17 04:01:37 +00:00
|
|
|
|
2014-07-02 14:12:15 +10:00
|
|
|
/* OK to clear other options, but preserve NOCDFLAG and NONTA. */
|
2019-08-06 13:44:30 -07:00
|
|
|
vopts |= (val->options & (DNS_VALIDATOR_NOCDFLAG |
|
|
|
|
DNS_VALIDATOR_NONTA));
|
2014-02-16 13:03:17 -08:00
|
|
|
|
2002-06-17 04:01:37 +00:00
|
|
|
validator_logcreate(val, name, type, caller, "validator");
|
|
|
|
result = dns_validator_create(val->view, name, type,
|
2014-02-16 13:03:17 -08:00
|
|
|
rdataset, sigrdataset, NULL, vopts,
|
2002-06-17 04:01:37 +00:00
|
|
|
val->task, action, val,
|
|
|
|
&val->subvalidator);
|
2005-08-25 00:56:08 +00:00
|
|
|
if (result == ISC_R_SUCCESS) {
|
2002-06-17 04:01:37 +00:00
|
|
|
val->subvalidator->parent = val;
|
2005-08-25 00:56:08 +00:00
|
|
|
val->subvalidator->depth = val->depth + 1;
|
|
|
|
}
|
2002-06-17 04:01:37 +00:00
|
|
|
return (result);
|
2000-04-19 18:08:27 +00:00
|
|
|
}
|
|
|
|
|
2005-11-03 00:51:55 +00:00
|
|
|
/*%
|
2000-04-06 23:09:01 +00:00
|
|
|
* Try to find a key that could have signed 'siginfo' among those
|
|
|
|
* in 'rdataset'. If found, build a dst_key_t for it and point
|
|
|
|
* val->key at it.
|
|
|
|
*
|
2000-05-18 23:22:14 +00:00
|
|
|
* If val->key is non-NULL, this returns the next matching key.
|
2000-04-06 23:09:01 +00:00
|
|
|
*/
|
2002-02-01 20:08:56 +00:00
|
|
|
static isc_result_t
|
2003-09-30 06:00:40 +00:00
|
|
|
get_dst_key(dns_validator_t *val, dns_rdata_rrsig_t *siginfo,
|
2000-03-17 00:01:28 +00:00
|
|
|
dns_rdataset_t *rdataset)
|
|
|
|
{
|
|
|
|
isc_result_t result;
|
|
|
|
isc_buffer_t b;
|
2000-10-25 04:26:57 +00:00
|
|
|
dns_rdata_t rdata = DNS_RDATA_INIT;
|
2000-05-18 23:22:14 +00:00
|
|
|
dst_key_t *oldkey = val->key;
|
2018-04-17 08:29:14 -07:00
|
|
|
bool foundold;
|
2000-05-18 23:22:14 +00:00
|
|
|
|
2019-08-06 13:44:30 -07:00
|
|
|
if (oldkey == NULL) {
|
2018-04-17 08:29:14 -07:00
|
|
|
foundold = true;
|
2019-08-06 13:44:30 -07:00
|
|
|
} else {
|
2018-04-17 08:29:14 -07:00
|
|
|
foundold = false;
|
2000-05-18 23:22:14 +00:00
|
|
|
val->key = NULL;
|
|
|
|
}
|
2000-03-17 00:01:28 +00:00
|
|
|
|
|
|
|
result = dns_rdataset_first(rdataset);
|
2019-08-06 13:44:30 -07:00
|
|
|
if (result != ISC_R_SUCCESS) {
|
2000-05-22 21:17:05 +00:00
|
|
|
goto failure;
|
2019-08-06 13:44:30 -07:00
|
|
|
}
|
2000-03-17 00:01:28 +00:00
|
|
|
do {
|
|
|
|
dns_rdataset_current(rdataset, &rdata);
|
|
|
|
|
103. [func] libisc buffer API changes for <isc/buffer.h>:
Added:
isc_buffer_base(b) (pointer)
isc_buffer_current(b) (pointer)
isc_buffer_active(b) (pointer)
isc_buffer_used(b) (pointer)
isc_buffer_length(b) (int)
isc_buffer_usedlength(b) (int)
isc_buffer_consumedlength(b) (int)
isc_buffer_remaininglength(b) (int)
isc_buffer_activelength(b) (int)
isc_buffer_availablelength(b) (int)
Removed:
ISC_BUFFER_USEDCOUNT(b)
ISC_BUFFER_AVAILABLECOUNT(b)
isc_buffer_type(b)
Changed names:
isc_buffer_used(b, r) ->
isc_buffer_usedregion(b, r)
isc_buffer_available(b, r) ->
isc_buffer_available_region(b, r)
isc_buffer_consumed(b, r) ->
isc_buffer_consumedregion(b, r)
isc_buffer_active(b, r) ->
isc_buffer_activeregion(b, r)
isc_buffer_remaining(b, r) ->
isc_buffer_remainingregion(b, r)
Buffer types were removed, so the ISC_BUFFERTYPE_*
macros are no more, and the type argument to
isc_buffer_init and isc_buffer_allocate were removed.
isc_buffer_putstr is now void (instead of isc_result_t)
and requires that the caller ensure that there
is enough available buffer space for the string.
2000-04-27 00:03:12 +00:00
|
|
|
isc_buffer_init(&b, rdata.data, rdata.length);
|
2000-03-17 00:01:28 +00:00
|
|
|
isc_buffer_add(&b, rdata.length);
|
|
|
|
INSIST(val->key == NULL);
|
2000-09-12 09:59:28 +00:00
|
|
|
result = dst_key_fromdns(&siginfo->signer, rdata.rdclass, &b,
|
|
|
|
val->view->mctx, &val->key);
|
2019-08-06 13:44:30 -07:00
|
|
|
if (result != ISC_R_SUCCESS) {
|
2000-05-22 21:17:05 +00:00
|
|
|
goto failure;
|
2019-08-06 13:44:30 -07:00
|
|
|
}
|
2000-03-17 00:01:28 +00:00
|
|
|
if (siginfo->algorithm ==
|
|
|
|
(dns_secalg_t)dst_key_alg(val->key) &&
|
2000-05-26 21:45:53 +00:00
|
|
|
siginfo->keyid ==
|
2000-03-17 00:01:28 +00:00
|
|
|
(dns_keytag_t)dst_key_id(val->key) &&
|
2000-04-12 15:52:12 +00:00
|
|
|
dst_key_iszonekey(val->key))
|
|
|
|
{
|
2019-08-06 13:44:30 -07:00
|
|
|
if (foundold) {
|
2000-05-18 23:22:14 +00:00
|
|
|
/*
|
|
|
|
* This is the key we're looking for.
|
|
|
|
*/
|
|
|
|
return (ISC_R_SUCCESS);
|
2019-08-16 12:28:22 -07:00
|
|
|
} else if (dst_key_compare(oldkey, val->key)) {
|
2018-04-17 08:29:14 -07:00
|
|
|
foundold = true;
|
2000-05-19 00:20:59 +00:00
|
|
|
dst_key_free(&oldkey);
|
2000-05-18 23:22:14 +00:00
|
|
|
}
|
2000-03-17 00:01:28 +00:00
|
|
|
}
|
2000-05-19 00:20:59 +00:00
|
|
|
dst_key_free(&val->key);
|
2000-10-31 03:22:05 +00:00
|
|
|
dns_rdata_reset(&rdata);
|
2000-03-17 00:01:28 +00:00
|
|
|
result = dns_rdataset_next(rdataset);
|
|
|
|
} while (result == ISC_R_SUCCESS);
|
2019-08-06 13:13:38 -07:00
|
|
|
|
2019-08-06 13:44:30 -07:00
|
|
|
if (result == ISC_R_NOMORE) {
|
2000-03-17 00:01:28 +00:00
|
|
|
result = ISC_R_NOTFOUND;
|
2019-08-06 13:44:30 -07:00
|
|
|
}
|
2000-03-17 00:01:28 +00:00
|
|
|
|
2000-05-22 21:17:05 +00:00
|
|
|
failure:
|
2019-08-06 13:44:30 -07:00
|
|
|
if (oldkey != NULL) {
|
2000-05-19 00:20:59 +00:00
|
|
|
dst_key_free(&oldkey);
|
2019-08-06 13:44:30 -07:00
|
|
|
}
|
2000-05-18 23:22:14 +00:00
|
|
|
|
2000-03-17 00:01:28 +00:00
|
|
|
return (result);
|
|
|
|
}
|
|
|
|
|
2005-11-03 00:51:55 +00:00
|
|
|
/*%
|
2009-01-17 15:12:26 +00:00
|
|
|
* Get the key that generated this signature.
|
2005-11-03 00:51:55 +00:00
|
|
|
*/
|
2002-02-01 20:08:56 +00:00
|
|
|
static isc_result_t
|
2003-09-30 06:00:40 +00:00
|
|
|
get_key(dns_validator_t *val, dns_rdata_rrsig_t *siginfo) {
|
2000-03-17 00:01:28 +00:00
|
|
|
isc_result_t result;
|
2003-10-25 00:31:12 +00:00
|
|
|
unsigned int nlabels;
|
2000-03-17 00:01:28 +00:00
|
|
|
int order;
|
|
|
|
dns_namereln_t namereln;
|
|
|
|
|
|
|
|
/*
|
2002-02-01 20:08:56 +00:00
|
|
|
* Is the signer name appropriate for this signature?
|
|
|
|
*
|
|
|
|
* The signer name must be at the same level as the owner name
|
2009-01-05 23:20:22 +00:00
|
|
|
* or closer to the DNS root.
|
2000-03-17 00:01:28 +00:00
|
|
|
*/
|
2002-02-01 20:08:56 +00:00
|
|
|
namereln = dns_name_fullcompare(val->event->name, &siginfo->signer,
|
2003-10-25 00:31:12 +00:00
|
|
|
&order, &nlabels);
|
2000-09-12 12:01:50 +00:00
|
|
|
if (namereln != dns_namereln_subdomain &&
|
2019-08-06 23:08:36 -07:00
|
|
|
namereln != dns_namereln_equal)
|
|
|
|
{
|
2000-03-17 00:01:28 +00:00
|
|
|
return (DNS_R_CONTINUE);
|
2019-08-06 13:44:30 -07:00
|
|
|
}
|
2000-03-17 00:01:28 +00:00
|
|
|
|
2002-06-17 04:01:37 +00:00
|
|
|
if (namereln == dns_namereln_equal) {
|
2000-05-12 17:41:30 +00:00
|
|
|
/*
|
2002-06-17 04:01:37 +00:00
|
|
|
* If this is a self-signed keyset, it must not be a zone key
|
|
|
|
* (since get_key is not called from validatezonekey).
|
2000-05-12 17:41:30 +00:00
|
|
|
*/
|
2019-08-06 13:44:30 -07:00
|
|
|
if (val->event->rdataset->type == dns_rdatatype_dnskey) {
|
2002-06-17 04:01:37 +00:00
|
|
|
return (DNS_R_CONTINUE);
|
2019-08-06 13:44:30 -07:00
|
|
|
}
|
2000-05-12 17:41:30 +00:00
|
|
|
|
2002-06-17 04:01:37 +00:00
|
|
|
/*
|
|
|
|
* Records appearing in the parent zone at delegation
|
|
|
|
* points cannot be self-signed.
|
|
|
|
*/
|
2019-08-06 13:44:30 -07:00
|
|
|
if (dns_rdatatype_atparent(val->event->rdataset->type)) {
|
2002-06-17 04:01:37 +00:00
|
|
|
return (DNS_R_CONTINUE);
|
2019-08-06 13:44:30 -07:00
|
|
|
}
|
2008-11-14 22:53:46 +00:00
|
|
|
} else {
|
|
|
|
/*
|
2008-11-14 23:47:33 +00:00
|
|
|
* SOA and NS RRsets can only be signed by a key with
|
2008-11-14 22:53:46 +00:00
|
|
|
* the same name.
|
|
|
|
*/
|
|
|
|
if (val->event->rdataset->type == dns_rdatatype_soa ||
|
2018-11-13 14:12:02 +11:00
|
|
|
val->event->rdataset->type == dns_rdatatype_ns)
|
|
|
|
{
|
|
|
|
const char *type;
|
2008-11-14 22:53:46 +00:00
|
|
|
|
2019-08-06 13:44:30 -07:00
|
|
|
if (val->event->rdataset->type == dns_rdatatype_soa) {
|
2018-11-13 14:12:02 +11:00
|
|
|
type = "SOA";
|
2019-08-06 13:44:30 -07:00
|
|
|
} else {
|
2018-11-13 14:12:02 +11:00
|
|
|
type = "NS";
|
2019-08-06 13:44:30 -07:00
|
|
|
}
|
2008-11-14 22:53:46 +00:00
|
|
|
validator_log(val, ISC_LOG_DEBUG(3),
|
2018-11-13 14:12:02 +11:00
|
|
|
"%s signer mismatch", type);
|
2008-11-14 22:53:46 +00:00
|
|
|
return (DNS_R_CONTINUE);
|
|
|
|
}
|
2000-09-12 12:01:50 +00:00
|
|
|
}
|
|
|
|
|
2000-03-17 00:01:28 +00:00
|
|
|
/*
|
|
|
|
* Do we know about this key?
|
|
|
|
*/
|
2003-09-30 06:00:40 +00:00
|
|
|
result = view_find(val, &siginfo->signer, dns_rdatatype_dnskey);
|
2019-08-16 16:27:50 -07:00
|
|
|
switch (result) {
|
|
|
|
case ISC_R_SUCCESS:
|
2000-03-17 00:01:28 +00:00
|
|
|
/*
|
|
|
|
* We have an rrset for the given keyname.
|
|
|
|
*/
|
2000-06-07 01:32:47 +00:00
|
|
|
val->keyset = &val->frdataset;
|
2010-05-14 00:13:43 +00:00
|
|
|
if ((DNS_TRUST_PENDING(val->frdataset.trust) ||
|
2010-05-14 23:50:40 +00:00
|
|
|
DNS_TRUST_ANSWER(val->frdataset.trust)) &&
|
2000-05-26 21:45:53 +00:00
|
|
|
dns_rdataset_isassociated(&val->fsigrdataset))
|
2000-05-18 23:22:14 +00:00
|
|
|
{
|
2000-03-17 00:01:28 +00:00
|
|
|
/*
|
2010-05-14 00:13:43 +00:00
|
|
|
* We know the key but haven't validated it yet or
|
2019-08-06 09:28:05 -07:00
|
|
|
* we have a key of trust answer but a DS
|
2010-05-14 00:13:43 +00:00
|
|
|
* record for the zone may have been added.
|
2000-03-17 00:01:28 +00:00
|
|
|
*/
|
2002-06-17 04:01:37 +00:00
|
|
|
result = create_validator(val, &siginfo->signer,
|
2003-09-30 06:00:40 +00:00
|
|
|
dns_rdatatype_dnskey,
|
2002-06-17 04:01:37 +00:00
|
|
|
&val->frdataset,
|
|
|
|
&val->fsigrdataset,
|
2019-08-16 12:28:22 -07:00
|
|
|
validator_callback_dnskey,
|
2002-06-17 04:01:37 +00:00
|
|
|
"get_key");
|
2019-08-06 13:44:30 -07:00
|
|
|
if (result != ISC_R_SUCCESS) {
|
2000-04-07 21:44:47 +00:00
|
|
|
return (result);
|
2019-08-06 13:44:30 -07:00
|
|
|
}
|
2000-04-07 21:44:47 +00:00
|
|
|
return (DNS_R_WAIT);
|
2009-11-17 23:55:18 +00:00
|
|
|
} else if (DNS_TRUST_PENDING(val->frdataset.trust)) {
|
2000-03-17 00:01:28 +00:00
|
|
|
/*
|
2000-05-18 23:22:14 +00:00
|
|
|
* Having a pending key with no signature means that
|
|
|
|
* something is broken.
|
2000-03-17 00:01:28 +00:00
|
|
|
*/
|
2000-05-18 23:22:14 +00:00
|
|
|
result = DNS_R_CONTINUE;
|
2000-05-26 21:45:53 +00:00
|
|
|
} else if (val->frdataset.trust < dns_trust_secure) {
|
2000-05-18 23:22:14 +00:00
|
|
|
/*
|
|
|
|
* The key is legitimately insecure. There's no
|
|
|
|
* point in even attempting verification.
|
|
|
|
*/
|
|
|
|
val->key = NULL;
|
|
|
|
result = ISC_R_SUCCESS;
|
|
|
|
} else {
|
2000-03-17 00:01:28 +00:00
|
|
|
/*
|
|
|
|
* See if we've got the key used in the signature.
|
|
|
|
*/
|
2001-09-14 20:53:33 +00:00
|
|
|
validator_log(val, ISC_LOG_DEBUG(3),
|
2011-05-26 04:35:02 +00:00
|
|
|
"keyset with trust %s",
|
|
|
|
dns_trust_totext(val->frdataset.trust));
|
2000-06-07 01:32:47 +00:00
|
|
|
result = get_dst_key(val, siginfo, val->keyset);
|
2000-03-17 00:01:28 +00:00
|
|
|
if (result != ISC_R_SUCCESS) {
|
|
|
|
/*
|
|
|
|
* Either the key we're looking for is not
|
|
|
|
* in the rrset, or something bad happened.
|
|
|
|
* Give up.
|
|
|
|
*/
|
|
|
|
result = DNS_R_CONTINUE;
|
|
|
|
}
|
|
|
|
}
|
2019-08-16 16:27:50 -07:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ISC_R_NOTFOUND:
|
2000-03-17 00:01:28 +00:00
|
|
|
/*
|
|
|
|
* We don't know anything about this key.
|
|
|
|
*/
|
2010-02-25 04:39:13 +00:00
|
|
|
result = create_fetch(val, &siginfo->signer,
|
|
|
|
dns_rdatatype_dnskey,
|
2019-08-16 12:28:22 -07:00
|
|
|
fetch_callback_dnskey, "get_key");
|
2019-08-06 13:44:30 -07:00
|
|
|
if (result != ISC_R_SUCCESS) {
|
2000-04-07 17:36:40 +00:00
|
|
|
return (result);
|
2019-08-06 13:44:30 -07:00
|
|
|
}
|
2000-04-07 17:36:40 +00:00
|
|
|
return (DNS_R_WAIT);
|
2019-08-16 16:27:50 -07:00
|
|
|
|
|
|
|
case DNS_R_NCACHENXDOMAIN:
|
|
|
|
case DNS_R_NCACHENXRRSET:
|
|
|
|
case DNS_R_EMPTYNAME:
|
|
|
|
case DNS_R_NXDOMAIN:
|
|
|
|
case DNS_R_NXRRSET:
|
2000-03-17 00:01:28 +00:00
|
|
|
/*
|
|
|
|
* This key doesn't exist.
|
|
|
|
*/
|
|
|
|
result = DNS_R_CONTINUE;
|
2019-08-16 16:27:50 -07:00
|
|
|
break;
|
|
|
|
|
|
|
|
case DNS_R_BROKENCHAIN:
|
2010-02-25 04:39:13 +00:00
|
|
|
return (result);
|
2019-08-16 16:27:50 -07:00
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
2019-08-06 13:44:30 -07:00
|
|
|
}
|
2000-03-17 00:01:28 +00:00
|
|
|
|
2000-06-07 01:32:47 +00:00
|
|
|
if (dns_rdataset_isassociated(&val->frdataset) &&
|
2019-08-06 13:13:38 -07:00
|
|
|
val->keyset != &val->frdataset)
|
|
|
|
{
|
2000-05-26 21:45:53 +00:00
|
|
|
dns_rdataset_disassociate(&val->frdataset);
|
2019-08-06 13:44:30 -07:00
|
|
|
}
|
|
|
|
if (dns_rdataset_isassociated(&val->fsigrdataset)) {
|
2000-05-26 21:45:53 +00:00
|
|
|
dns_rdataset_disassociate(&val->fsigrdataset);
|
2019-08-06 13:44:30 -07:00
|
|
|
}
|
2000-03-17 00:01:28 +00:00
|
|
|
|
|
|
|
return (result);
|
|
|
|
}
|
|
|
|
|
2002-06-17 04:01:37 +00:00
|
|
|
static dns_keytag_t
|
2018-10-25 10:27:49 +02:00
|
|
|
compute_keytag(dns_rdata_t *rdata) {
|
2002-06-17 04:01:37 +00:00
|
|
|
isc_region_t r;
|
|
|
|
|
|
|
|
dns_rdata_toregion(rdata, &r);
|
2018-10-25 10:27:49 +02:00
|
|
|
return (dst_region_computeid(&r));
|
2002-06-17 04:01:37 +00:00
|
|
|
}
|
|
|
|
|
2005-11-03 00:51:55 +00:00
|
|
|
/*%
|
2002-06-17 04:01:37 +00:00
|
|
|
* Is this keyset self-signed?
|
2000-07-07 00:44:01 +00:00
|
|
|
*/
|
2018-04-17 08:29:14 -07:00
|
|
|
static bool
|
2002-06-17 04:01:37 +00:00
|
|
|
isselfsigned(dns_validator_t *val) {
|
|
|
|
dns_rdataset_t *rdataset, *sigrdataset;
|
2000-10-25 04:26:57 +00:00
|
|
|
dns_rdata_t rdata = DNS_RDATA_INIT;
|
2002-06-17 04:01:37 +00:00
|
|
|
dns_rdata_t sigrdata = DNS_RDATA_INIT;
|
2003-09-30 06:00:40 +00:00
|
|
|
dns_rdata_dnskey_t key;
|
|
|
|
dns_rdata_rrsig_t sig;
|
2002-06-17 04:01:37 +00:00
|
|
|
dns_keytag_t keytag;
|
2010-05-14 04:38:52 +00:00
|
|
|
dns_name_t *name;
|
2000-07-07 00:44:01 +00:00
|
|
|
isc_result_t result;
|
2010-05-14 04:38:52 +00:00
|
|
|
dst_key_t *dstkey;
|
|
|
|
isc_mem_t *mctx;
|
2018-04-17 08:29:14 -07:00
|
|
|
bool answer = false;
|
2000-07-07 00:44:01 +00:00
|
|
|
|
|
|
|
rdataset = val->event->rdataset;
|
2002-06-17 04:01:37 +00:00
|
|
|
sigrdataset = val->event->sigrdataset;
|
2010-05-14 04:38:52 +00:00
|
|
|
name = val->event->name;
|
|
|
|
mctx = val->view->mctx;
|
2002-06-17 04:01:37 +00:00
|
|
|
|
2012-10-06 14:56:33 +10:00
|
|
|
if (rdataset->type == dns_rdatatype_cname ||
|
|
|
|
rdataset->type == dns_rdatatype_dname)
|
2019-08-06 13:44:30 -07:00
|
|
|
{
|
2012-10-06 14:56:33 +10:00
|
|
|
return (answer);
|
2019-08-06 13:44:30 -07:00
|
|
|
}
|
2012-10-06 14:56:33 +10:00
|
|
|
|
2003-09-30 06:00:40 +00:00
|
|
|
INSIST(rdataset->type == dns_rdatatype_dnskey);
|
2000-07-07 00:44:01 +00:00
|
|
|
|
|
|
|
for (result = dns_rdataset_first(rdataset);
|
|
|
|
result == ISC_R_SUCCESS;
|
|
|
|
result = dns_rdataset_next(rdataset))
|
|
|
|
{
|
2000-10-31 03:22:05 +00:00
|
|
|
dns_rdata_reset(&rdata);
|
2002-06-17 04:01:37 +00:00
|
|
|
dns_rdataset_current(rdataset, &rdata);
|
2008-01-14 23:24:24 +00:00
|
|
|
result = dns_rdata_tostruct(&rdata, &key, NULL);
|
|
|
|
RUNTIME_CHECK(result == ISC_R_SUCCESS);
|
2018-10-25 10:27:49 +02:00
|
|
|
keytag = compute_keytag(&rdata);
|
2002-06-17 04:01:37 +00:00
|
|
|
for (result = dns_rdataset_first(sigrdataset);
|
|
|
|
result == ISC_R_SUCCESS;
|
|
|
|
result = dns_rdataset_next(sigrdataset))
|
|
|
|
{
|
|
|
|
dns_rdata_reset(&sigrdata);
|
|
|
|
dns_rdataset_current(sigrdataset, &sigrdata);
|
2008-01-14 23:24:24 +00:00
|
|
|
result = dns_rdata_tostruct(&sigrdata, &sig, NULL);
|
|
|
|
RUNTIME_CHECK(result == ISC_R_SUCCESS);
|
2000-07-07 00:44:01 +00:00
|
|
|
|
2010-05-14 04:38:52 +00:00
|
|
|
if (sig.algorithm != key.algorithm ||
|
|
|
|
sig.keyid != keytag ||
|
|
|
|
!dns_name_equal(name, &sig.signer))
|
2019-08-06 13:44:30 -07:00
|
|
|
{
|
2010-05-14 04:38:52 +00:00
|
|
|
continue;
|
2019-08-06 13:44:30 -07:00
|
|
|
}
|
2010-05-14 04:38:52 +00:00
|
|
|
|
|
|
|
dstkey = NULL;
|
|
|
|
result = dns_dnssec_keyfromrdata(name, &rdata, mctx,
|
|
|
|
&dstkey);
|
2019-08-06 13:44:30 -07:00
|
|
|
if (result != ISC_R_SUCCESS) {
|
2010-05-14 04:38:52 +00:00
|
|
|
continue;
|
2019-08-06 13:44:30 -07:00
|
|
|
}
|
2010-05-14 04:38:52 +00:00
|
|
|
|
2018-04-03 15:24:33 +02:00
|
|
|
result = dns_dnssec_verify(name, rdataset, dstkey,
|
2018-04-17 08:29:14 -07:00
|
|
|
true,
|
2018-04-03 15:24:33 +02:00
|
|
|
val->view->maxbits,
|
|
|
|
mctx, &sigrdata, NULL);
|
2010-05-14 04:38:52 +00:00
|
|
|
dst_key_free(&dstkey);
|
2019-08-06 13:44:30 -07:00
|
|
|
if (result != ISC_R_SUCCESS) {
|
2010-05-14 04:38:52 +00:00
|
|
|
continue;
|
2019-08-06 13:44:30 -07:00
|
|
|
}
|
2010-05-14 04:38:52 +00:00
|
|
|
if ((key.flags & DNS_KEYFLAG_REVOKE) == 0) {
|
2018-04-17 08:29:14 -07:00
|
|
|
answer = true;
|
2010-05-14 04:38:52 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
dns_view_untrust(val->view, name, &key, mctx);
|
2002-06-17 04:01:37 +00:00
|
|
|
}
|
2000-07-07 00:44:01 +00:00
|
|
|
}
|
2010-05-14 04:38:52 +00:00
|
|
|
return (answer);
|
2002-06-17 04:01:37 +00:00
|
|
|
}
|
|
|
|
|
2005-11-03 00:51:55 +00:00
|
|
|
/*%
|
|
|
|
* Attempt to verify the rdataset using the given key and rdata (RRSIG).
|
|
|
|
* The signature was good and from a wildcard record and the QNAME does
|
|
|
|
* not match the wildcard we need to look for a NOQNAME proof.
|
|
|
|
*
|
|
|
|
* Returns:
|
|
|
|
* \li ISC_R_SUCCESS if the verification succeeds.
|
|
|
|
* \li Others if the verification fails.
|
|
|
|
*/
|
2002-06-17 04:01:37 +00:00
|
|
|
static isc_result_t
|
2005-11-03 00:51:55 +00:00
|
|
|
verify(dns_validator_t *val, dst_key_t *key, dns_rdata_t *rdata,
|
2018-03-28 14:19:37 +02:00
|
|
|
uint16_t keyid)
|
2005-11-03 00:51:55 +00:00
|
|
|
{
|
2002-06-17 04:01:37 +00:00
|
|
|
isc_result_t result;
|
2004-01-14 02:06:51 +00:00
|
|
|
dns_fixedname_t fixed;
|
2018-04-17 08:29:14 -07:00
|
|
|
bool ignore = false;
|
2011-10-20 21:42:11 +00:00
|
|
|
dns_name_t *wild;
|
2002-06-17 04:01:37 +00:00
|
|
|
|
|
|
|
val->attributes |= VALATTR_TRIEDVERIFY;
|
2018-03-28 14:38:09 +02:00
|
|
|
wild = dns_fixedname_initname(&fixed);
|
2006-01-04 02:35:49 +00:00
|
|
|
again:
|
2018-04-03 15:24:33 +02:00
|
|
|
result = dns_dnssec_verify(val->event->name, val->event->rdataset,
|
|
|
|
key, ignore, val->view->maxbits,
|
|
|
|
val->view->mctx, rdata, wild);
|
2011-11-04 05:36:28 +00:00
|
|
|
if ((result == DNS_R_SIGEXPIRED || result == DNS_R_SIGFUTURE) &&
|
|
|
|
val->view->acceptexpired)
|
|
|
|
{
|
2018-04-17 08:29:14 -07:00
|
|
|
ignore = true;
|
2006-01-04 02:35:49 +00:00
|
|
|
goto again;
|
|
|
|
}
|
2019-08-06 13:44:30 -07:00
|
|
|
|
|
|
|
if (ignore &&
|
|
|
|
(result == ISC_R_SUCCESS || result == DNS_R_FROMWILDCARD))
|
|
|
|
{
|
2006-01-04 02:35:49 +00:00
|
|
|
validator_log(val, ISC_LOG_INFO,
|
|
|
|
"accepted expired %sRRSIG (keyid=%u)",
|
|
|
|
(result == DNS_R_FROMWILDCARD) ?
|
2006-07-24 22:41:59 +00:00
|
|
|
"wildcard " : "", keyid);
|
2019-08-06 13:44:30 -07:00
|
|
|
} else if (result == DNS_R_SIGEXPIRED || result == DNS_R_SIGFUTURE) {
|
2011-11-04 05:36:28 +00:00
|
|
|
validator_log(val, ISC_LOG_INFO,
|
|
|
|
"verify failed due to bad signature (keyid=%u): "
|
|
|
|
"%s", keyid, isc_result_totext(result));
|
2019-08-06 13:44:30 -07:00
|
|
|
} else {
|
2006-01-04 02:35:49 +00:00
|
|
|
validator_log(val, ISC_LOG_DEBUG(3),
|
|
|
|
"verify rdataset (keyid=%u): %s",
|
|
|
|
keyid, isc_result_totext(result));
|
2019-08-06 13:44:30 -07:00
|
|
|
}
|
2004-01-14 02:06:51 +00:00
|
|
|
if (result == DNS_R_FROMWILDCARD) {
|
2011-10-20 21:42:11 +00:00
|
|
|
if (!dns_name_equal(val->event->name, wild)) {
|
|
|
|
dns_name_t *closest;
|
|
|
|
unsigned int labels;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Compute the closest encloser in case we need it
|
|
|
|
* for the NSEC3 NOQNAME proof.
|
|
|
|
*/
|
|
|
|
closest = dns_fixedname_name(&val->closest);
|
2019-09-10 14:42:41 +02:00
|
|
|
dns_name_copynf(wild, closest);
|
2011-10-20 21:42:11 +00:00
|
|
|
labels = dns_name_countlabels(closest) - 1;
|
|
|
|
dns_name_getlabelsequence(closest, 1, labels, closest);
|
2004-01-14 02:06:51 +00:00
|
|
|
val->attributes |= VALATTR_NEEDNOQNAME;
|
2011-10-20 21:42:11 +00:00
|
|
|
}
|
2004-01-14 02:06:51 +00:00
|
|
|
result = ISC_R_SUCCESS;
|
|
|
|
}
|
2002-06-17 04:01:37 +00:00
|
|
|
return (result);
|
2000-07-07 00:44:01 +00:00
|
|
|
}
|
|
|
|
|
2005-11-03 00:51:55 +00:00
|
|
|
/*%
|
2002-06-17 04:01:37 +00:00
|
|
|
* Attempts positive response validation of a normal RRset.
|
2000-05-11 22:58:17 +00:00
|
|
|
*
|
|
|
|
* Returns:
|
2005-11-03 00:51:55 +00:00
|
|
|
* \li ISC_R_SUCCESS Validation completed successfully
|
|
|
|
* \li DNS_R_WAIT Validation has started but is waiting
|
2000-05-11 22:58:17 +00:00
|
|
|
* for an event.
|
2005-11-03 00:51:55 +00:00
|
|
|
* \li Other return codes are possible and all indicate failure.
|
2000-05-11 22:58:17 +00:00
|
|
|
*/
|
2002-02-01 20:08:56 +00:00
|
|
|
static isc_result_t
|
2019-08-07 16:54:05 -07:00
|
|
|
validate_answer(dns_validator_t *val, bool resume) {
|
2014-02-16 13:03:17 -08:00
|
|
|
isc_result_t result, vresult = DNS_R_NOVALIDSIG;
|
2000-03-17 00:01:28 +00:00
|
|
|
dns_validatorevent_t *event;
|
2000-10-25 04:26:57 +00:00
|
|
|
dns_rdata_t rdata = DNS_RDATA_INIT;
|
2000-03-17 00:01:28 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Caller must be holding the validator lock.
|
|
|
|
*/
|
|
|
|
|
|
|
|
event = val->event;
|
|
|
|
|
2000-04-06 23:09:01 +00:00
|
|
|
if (resume) {
|
2000-05-08 14:38:29 +00:00
|
|
|
/*
|
2000-05-12 17:41:30 +00:00
|
|
|
* We already have a sigrdataset.
|
2000-05-08 14:38:29 +00:00
|
|
|
*/
|
2000-04-06 23:09:01 +00:00
|
|
|
result = ISC_R_SUCCESS;
|
2001-09-14 20:53:33 +00:00
|
|
|
validator_log(val, ISC_LOG_DEBUG(3), "resuming validate");
|
2000-04-06 23:09:01 +00:00
|
|
|
} else {
|
2000-03-17 00:01:28 +00:00
|
|
|
result = dns_rdataset_first(event->sigrdataset);
|
|
|
|
}
|
2000-04-06 23:09:01 +00:00
|
|
|
|
|
|
|
for (;
|
|
|
|
result == ISC_R_SUCCESS;
|
|
|
|
result = dns_rdataset_next(event->sigrdataset))
|
|
|
|
{
|
2000-10-31 03:22:05 +00:00
|
|
|
dns_rdata_reset(&rdata);
|
2000-03-17 00:01:28 +00:00
|
|
|
dns_rdataset_current(event->sigrdataset, &rdata);
|
2002-02-01 20:08:56 +00:00
|
|
|
if (val->siginfo == NULL) {
|
|
|
|
val->siginfo = isc_mem_get(val->view->mctx,
|
|
|
|
sizeof(*val->siginfo));
|
|
|
|
}
|
2001-11-30 01:59:49 +00:00
|
|
|
result = dns_rdata_tostruct(&rdata, val->siginfo, NULL);
|
2019-08-06 13:44:30 -07:00
|
|
|
if (result != ISC_R_SUCCESS) {
|
2001-11-30 01:59:49 +00:00
|
|
|
return (result);
|
2019-08-06 13:44:30 -07:00
|
|
|
}
|
2000-08-01 01:33:37 +00:00
|
|
|
|
2000-03-17 00:01:28 +00:00
|
|
|
/*
|
|
|
|
* At this point we could check that the signature algorithm
|
2004-01-14 02:06:51 +00:00
|
|
|
* was known and "sufficiently good".
|
2000-03-17 00:01:28 +00:00
|
|
|
*/
|
2004-01-14 02:06:51 +00:00
|
|
|
if (!dns_resolver_algorithm_supported(val->view->resolver,
|
2019-08-06 13:44:30 -07:00
|
|
|
event->name,
|
|
|
|
val->siginfo->algorithm))
|
|
|
|
{
|
2018-04-17 08:29:14 -07:00
|
|
|
resume = false;
|
2004-01-14 02:06:51 +00:00
|
|
|
continue;
|
2010-11-16 01:14:51 +00:00
|
|
|
}
|
2000-08-01 01:33:37 +00:00
|
|
|
|
2000-03-17 00:01:28 +00:00
|
|
|
if (!resume) {
|
2000-04-07 17:36:40 +00:00
|
|
|
result = get_key(val, val->siginfo);
|
2019-08-06 13:44:30 -07:00
|
|
|
if (result == DNS_R_CONTINUE) {
|
2000-04-06 23:09:01 +00:00
|
|
|
continue; /* Try the next SIG RR. */
|
2019-08-06 13:44:30 -07:00
|
|
|
}
|
|
|
|
if (result != ISC_R_SUCCESS) {
|
2000-03-17 00:01:28 +00:00
|
|
|
return (result);
|
2019-08-06 13:44:30 -07:00
|
|
|
}
|
2000-03-17 00:01:28 +00:00
|
|
|
}
|
|
|
|
|
2002-02-01 20:08:56 +00:00
|
|
|
/*
|
2010-11-16 01:14:51 +00:00
|
|
|
* There isn't a secure DNSKEY for this signature so move
|
|
|
|
* onto the next RRSIG.
|
2002-02-01 20:08:56 +00:00
|
|
|
*/
|
2000-05-18 23:22:14 +00:00
|
|
|
if (val->key == NULL) {
|
2018-04-17 08:29:14 -07:00
|
|
|
resume = false;
|
2010-11-16 01:14:51 +00:00
|
|
|
continue;
|
2000-05-18 23:22:14 +00:00
|
|
|
}
|
|
|
|
|
2000-05-19 18:39:49 +00:00
|
|
|
do {
|
2014-02-16 13:03:17 -08:00
|
|
|
vresult = verify(val, val->key, &rdata,
|
2019-08-06 13:44:30 -07:00
|
|
|
val->siginfo->keyid);
|
|
|
|
if (vresult == ISC_R_SUCCESS) {
|
2000-05-19 18:39:49 +00:00
|
|
|
break;
|
2019-08-06 13:44:30 -07:00
|
|
|
}
|
2000-05-19 18:39:49 +00:00
|
|
|
if (val->keynode != NULL) {
|
2000-05-19 20:25:55 +00:00
|
|
|
dns_keynode_t *nextnode = NULL;
|
|
|
|
result = dns_keytable_findnextkeynode(
|
2019-08-06 13:44:30 -07:00
|
|
|
val->keytable,
|
|
|
|
val->keynode,
|
|
|
|
&nextnode);
|
2000-05-19 20:25:55 +00:00
|
|
|
dns_keytable_detachkeynode(val->keytable,
|
|
|
|
&val->keynode);
|
|
|
|
val->keynode = nextnode;
|
|
|
|
if (result != ISC_R_SUCCESS) {
|
|
|
|
val->key = NULL;
|
2000-05-19 18:39:49 +00:00
|
|
|
break;
|
2000-05-19 20:25:55 +00:00
|
|
|
}
|
2017-10-12 10:53:35 -07:00
|
|
|
val->key = dns_keynode_key(val->keynode);
|
2019-08-06 13:44:30 -07:00
|
|
|
if (val->key == NULL) {
|
2009-06-30 02:53:46 +00:00
|
|
|
break;
|
2019-08-06 13:44:30 -07:00
|
|
|
}
|
2000-05-22 21:17:05 +00:00
|
|
|
} else {
|
2019-08-16 12:28:22 -07:00
|
|
|
isc_result_t tresult;
|
|
|
|
|
|
|
|
tresult = get_dst_key(val, val->siginfo,
|
|
|
|
val->keyset);
|
|
|
|
if (tresult != ISC_R_SUCCESS) {
|
2000-05-19 18:39:49 +00:00
|
|
|
break;
|
2019-08-06 13:44:30 -07:00
|
|
|
}
|
2000-05-22 21:17:05 +00:00
|
|
|
}
|
2000-05-19 18:39:49 +00:00
|
|
|
} while (1);
|
2019-08-06 13:44:30 -07:00
|
|
|
if (vresult != ISC_R_SUCCESS) {
|
2001-09-14 20:53:33 +00:00
|
|
|
validator_log(val, ISC_LOG_DEBUG(3),
|
2000-05-18 23:22:14 +00:00
|
|
|
"failed to verify rdataset");
|
2019-08-06 13:44:30 -07:00
|
|
|
} else {
|
2012-07-25 17:06:34 -05:00
|
|
|
dns_rdataset_trimttl(event->rdataset,
|
|
|
|
event->sigrdataset,
|
2014-05-29 22:22:53 -07:00
|
|
|
val->siginfo, val->start,
|
2012-07-25 17:06:34 -05:00
|
|
|
val->view->acceptexpired);
|
2000-05-31 22:01:39 +00:00
|
|
|
}
|
|
|
|
|
2019-08-06 13:44:30 -07:00
|
|
|
if (val->keynode != NULL) {
|
2000-04-13 18:10:07 +00:00
|
|
|
dns_keytable_detachkeynode(val->keytable,
|
|
|
|
&val->keynode);
|
2019-08-06 13:44:30 -07:00
|
|
|
} else {
|
|
|
|
if (val->key != NULL) {
|
2000-05-22 21:17:05 +00:00
|
|
|
dst_key_free(&val->key);
|
2019-08-06 13:44:30 -07:00
|
|
|
}
|
2000-05-26 21:45:53 +00:00
|
|
|
if (val->keyset != NULL) {
|
|
|
|
dns_rdataset_disassociate(val->keyset);
|
2000-05-22 21:17:05 +00:00
|
|
|
val->keyset = NULL;
|
2000-05-26 21:45:53 +00:00
|
|
|
}
|
2000-05-22 21:17:05 +00:00
|
|
|
}
|
2000-05-19 01:23:12 +00:00
|
|
|
val->key = NULL;
|
2010-05-14 00:13:43 +00:00
|
|
|
if (NEEDNOQNAME(val)) {
|
2004-01-14 02:06:51 +00:00
|
|
|
if (val->event->message == NULL) {
|
|
|
|
validator_log(val, ISC_LOG_DEBUG(3),
|
2019-08-06 13:44:30 -07:00
|
|
|
"no message available "
|
|
|
|
"for noqname proof");
|
2004-01-14 02:06:51 +00:00
|
|
|
return (DNS_R_NOVALIDSIG);
|
|
|
|
}
|
|
|
|
validator_log(val, ISC_LOG_DEBUG(3),
|
|
|
|
"looking for noqname proof");
|
2019-08-07 16:54:05 -07:00
|
|
|
return (validate_nx(val, false));
|
2014-02-16 13:03:17 -08:00
|
|
|
} else if (vresult == ISC_R_SUCCESS) {
|
2010-02-25 04:39:13 +00:00
|
|
|
marksecure(event);
|
2001-09-14 20:53:33 +00:00
|
|
|
validator_log(val, ISC_LOG_DEBUG(3),
|
2009-10-28 05:34:21 +00:00
|
|
|
"marking as secure, "
|
|
|
|
"noqname proof not needed");
|
2014-02-16 13:03:17 -08:00
|
|
|
return (ISC_R_SUCCESS);
|
2002-07-15 02:57:14 +00:00
|
|
|
} else {
|
2001-09-14 20:53:33 +00:00
|
|
|
validator_log(val, ISC_LOG_DEBUG(3),
|
2000-04-14 02:30:12 +00:00
|
|
|
"verify failure: %s",
|
2000-05-19 20:25:55 +00:00
|
|
|
isc_result_totext(result));
|
2018-04-17 08:29:14 -07:00
|
|
|
resume = false;
|
2002-07-15 02:57:14 +00:00
|
|
|
}
|
2000-04-06 23:09:01 +00:00
|
|
|
}
|
2000-12-05 18:53:43 +00:00
|
|
|
if (result != ISC_R_NOMORE) {
|
2001-09-14 20:53:33 +00:00
|
|
|
validator_log(val, ISC_LOG_DEBUG(3),
|
2000-12-05 18:53:43 +00:00
|
|
|
"failed to iterate signatures: %s",
|
|
|
|
isc_result_totext(result));
|
|
|
|
return (result);
|
|
|
|
}
|
2000-05-12 21:25:17 +00:00
|
|
|
|
|
|
|
validator_log(val, ISC_LOG_INFO, "no valid signature found");
|
2014-02-16 13:03:17 -08:00
|
|
|
return (vresult);
|
2000-03-17 00:01:28 +00:00
|
|
|
}
|
|
|
|
|
2010-05-14 04:38:52 +00:00
|
|
|
/*%
|
|
|
|
* Check whether this DNSKEY (keyrdata) signed the DNSKEY RRset
|
|
|
|
* (val->event->rdataset).
|
|
|
|
*/
|
|
|
|
static isc_result_t
|
2018-03-28 14:19:37 +02:00
|
|
|
checkkey(dns_validator_t *val, dns_rdata_t *keyrdata, uint16_t keyid,
|
2010-05-14 04:38:52 +00:00
|
|
|
dns_secalg_t algorithm)
|
|
|
|
{
|
|
|
|
dns_rdata_rrsig_t sig;
|
|
|
|
dst_key_t *dstkey = NULL;
|
|
|
|
isc_result_t result;
|
|
|
|
|
|
|
|
for (result = dns_rdataset_first(val->event->sigrdataset);
|
|
|
|
result == ISC_R_SUCCESS;
|
|
|
|
result = dns_rdataset_next(val->event->sigrdataset))
|
|
|
|
{
|
|
|
|
dns_rdata_t rdata = DNS_RDATA_INIT;
|
|
|
|
|
|
|
|
dns_rdataset_current(val->event->sigrdataset, &rdata);
|
|
|
|
result = dns_rdata_tostruct(&rdata, &sig, NULL);
|
|
|
|
RUNTIME_CHECK(result == ISC_R_SUCCESS);
|
2019-08-06 13:44:30 -07:00
|
|
|
if (keyid != sig.keyid || algorithm != sig.algorithm) {
|
2010-05-14 04:38:52 +00:00
|
|
|
continue;
|
2019-08-06 13:44:30 -07:00
|
|
|
}
|
2010-05-14 04:38:52 +00:00
|
|
|
if (dstkey == NULL) {
|
|
|
|
result = dns_dnssec_keyfromrdata(val->event->name,
|
|
|
|
keyrdata,
|
|
|
|
val->view->mctx,
|
|
|
|
&dstkey);
|
2019-08-06 13:44:30 -07:00
|
|
|
if (result != ISC_R_SUCCESS) {
|
2010-05-14 04:38:52 +00:00
|
|
|
/*
|
|
|
|
* This really shouldn't happen, but...
|
|
|
|
*/
|
|
|
|
continue;
|
2019-08-06 13:44:30 -07:00
|
|
|
}
|
2010-05-14 04:38:52 +00:00
|
|
|
}
|
|
|
|
result = verify(val, dstkey, &rdata, sig.keyid);
|
2019-08-06 13:44:30 -07:00
|
|
|
if (result == ISC_R_SUCCESS) {
|
2010-05-14 04:38:52 +00:00
|
|
|
break;
|
2019-08-06 13:44:30 -07:00
|
|
|
}
|
2010-05-14 04:38:52 +00:00
|
|
|
}
|
2019-08-06 13:44:30 -07:00
|
|
|
if (dstkey != NULL) {
|
2010-05-14 04:38:52 +00:00
|
|
|
dst_key_free(&dstkey);
|
2019-08-06 13:44:30 -07:00
|
|
|
}
|
2010-05-14 04:38:52 +00:00
|
|
|
return (result);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*%
|
|
|
|
* Find the DNSKEY that corresponds to the DS.
|
|
|
|
*/
|
|
|
|
static isc_result_t
|
|
|
|
keyfromds(dns_validator_t *val, dns_rdataset_t *rdataset, dns_rdata_t *dsrdata,
|
2019-02-08 17:54:56 +00:00
|
|
|
dns_dsdigest_t digest, uint16_t keyid, dns_secalg_t algorithm,
|
2010-05-14 04:38:52 +00:00
|
|
|
dns_rdata_t *keyrdata)
|
|
|
|
{
|
|
|
|
dns_keytag_t keytag;
|
|
|
|
dns_rdata_dnskey_t key;
|
|
|
|
isc_result_t result;
|
|
|
|
unsigned char dsbuf[DNS_DS_BUFFERSIZE];
|
|
|
|
|
|
|
|
for (result = dns_rdataset_first(rdataset);
|
|
|
|
result == ISC_R_SUCCESS;
|
|
|
|
result = dns_rdataset_next(rdataset))
|
|
|
|
{
|
|
|
|
dns_rdata_t newdsrdata = DNS_RDATA_INIT;
|
|
|
|
|
|
|
|
dns_rdata_reset(keyrdata);
|
|
|
|
dns_rdataset_current(rdataset, keyrdata);
|
|
|
|
result = dns_rdata_tostruct(keyrdata, &key, NULL);
|
|
|
|
RUNTIME_CHECK(result == ISC_R_SUCCESS);
|
2018-10-25 10:27:49 +02:00
|
|
|
keytag = compute_keytag(keyrdata);
|
2019-08-06 13:44:30 -07:00
|
|
|
if (keyid != keytag || algorithm != key.algorithm) {
|
2010-05-14 04:38:52 +00:00
|
|
|
continue;
|
2019-08-06 13:44:30 -07:00
|
|
|
}
|
2010-05-14 04:38:52 +00:00
|
|
|
dns_rdata_reset(&newdsrdata);
|
|
|
|
result = dns_ds_buildrdata(val->event->name, keyrdata, digest,
|
|
|
|
dsbuf, &newdsrdata);
|
|
|
|
if (result != ISC_R_SUCCESS) {
|
|
|
|
validator_log(val, ISC_LOG_DEBUG(3),
|
|
|
|
"dns_ds_buildrdata() -> %s",
|
|
|
|
dns_result_totext(result));
|
|
|
|
continue;
|
|
|
|
}
|
2019-08-06 13:44:30 -07:00
|
|
|
if (dns_rdata_compare(dsrdata, &newdsrdata) == 0) {
|
2010-05-14 04:38:52 +00:00
|
|
|
break;
|
2019-08-06 13:44:30 -07:00
|
|
|
}
|
2010-05-14 04:38:52 +00:00
|
|
|
}
|
|
|
|
return (result);
|
|
|
|
}
|
|
|
|
|
2005-11-03 00:51:55 +00:00
|
|
|
/*%
|
2009-06-30 02:53:46 +00:00
|
|
|
* Attempts positive response validation of an RRset containing zone keys
|
|
|
|
* (i.e. a DNSKEY rrset).
|
2002-06-17 04:01:37 +00:00
|
|
|
*
|
|
|
|
* Returns:
|
2005-11-03 00:51:55 +00:00
|
|
|
* \li ISC_R_SUCCESS Validation completed successfully
|
|
|
|
* \li DNS_R_WAIT Validation has started but is waiting
|
2002-06-17 04:01:37 +00:00
|
|
|
* for an event.
|
2005-11-03 00:51:55 +00:00
|
|
|
* \li Other return codes are possible and all indicate failure.
|
2002-06-17 04:01:37 +00:00
|
|
|
*/
|
|
|
|
static isc_result_t
|
2004-03-10 02:19:58 +00:00
|
|
|
validatezonekey(dns_validator_t *val) {
|
2002-06-17 04:01:37 +00:00
|
|
|
isc_result_t result;
|
|
|
|
dns_validatorevent_t *event;
|
|
|
|
dns_rdataset_t trdataset;
|
|
|
|
dns_rdata_t dsrdata = DNS_RDATA_INIT;
|
|
|
|
dns_rdata_t keyrdata = DNS_RDATA_INIT;
|
|
|
|
dns_rdata_t sigrdata = DNS_RDATA_INIT;
|
2005-12-04 23:54:01 +00:00
|
|
|
char namebuf[DNS_NAME_FORMATSIZE];
|
2002-06-17 04:01:37 +00:00
|
|
|
dns_rdata_ds_t ds;
|
2003-09-30 06:00:40 +00:00
|
|
|
dns_rdata_rrsig_t sig;
|
2002-06-17 04:01:37 +00:00
|
|
|
dst_key_t *dstkey;
|
2018-04-17 08:29:14 -07:00
|
|
|
bool supported_algorithm;
|
|
|
|
bool atsep = false;
|
2010-12-23 04:08:00 +00:00
|
|
|
char digest_types[256];
|
2002-06-17 04:01:37 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Caller must be holding the validator lock.
|
|
|
|
*/
|
|
|
|
|
|
|
|
event = val->event;
|
|
|
|
|
|
|
|
if (val->dsset == NULL) {
|
|
|
|
/*
|
|
|
|
* First, see if this key was signed by a trusted key.
|
|
|
|
*/
|
|
|
|
for (result = dns_rdataset_first(val->event->sigrdataset);
|
|
|
|
result == ISC_R_SUCCESS;
|
|
|
|
result = dns_rdataset_next(val->event->sigrdataset))
|
|
|
|
{
|
2010-03-26 17:12:48 +00:00
|
|
|
dns_keynode_t *keynode = NULL;
|
2010-05-14 00:13:43 +00:00
|
|
|
dns_fixedname_t fixed;
|
|
|
|
dns_name_t *found;
|
2002-06-17 04:01:37 +00:00
|
|
|
|
2018-03-28 14:38:09 +02:00
|
|
|
found = dns_fixedname_initname(&fixed);
|
2002-06-17 04:01:37 +00:00
|
|
|
dns_rdata_reset(&sigrdata);
|
|
|
|
dns_rdataset_current(val->event->sigrdataset,
|
|
|
|
&sigrdata);
|
2008-01-14 23:24:24 +00:00
|
|
|
result = dns_rdata_tostruct(&sigrdata, &sig, NULL);
|
|
|
|
RUNTIME_CHECK(result == ISC_R_SUCCESS);
|
2008-11-14 22:53:46 +00:00
|
|
|
|
2019-08-06 13:44:30 -07:00
|
|
|
if (!dns_name_equal(val->event->name, &sig.signer)) {
|
2008-11-14 22:53:46 +00:00
|
|
|
continue;
|
2019-08-06 13:44:30 -07:00
|
|
|
}
|
2008-11-14 22:53:46 +00:00
|
|
|
|
2002-06-17 04:01:37 +00:00
|
|
|
result = dns_keytable_findkeynode(val->keytable,
|
|
|
|
val->event->name,
|
|
|
|
sig.algorithm,
|
2010-05-14 04:38:52 +00:00
|
|
|
sig.keyid, &keynode);
|
2010-05-14 00:13:43 +00:00
|
|
|
if (result == ISC_R_NOTFOUND &&
|
|
|
|
dns_keytable_finddeepestmatch(val->keytable,
|
2019-08-06 13:44:30 -07:00
|
|
|
val->event->name,
|
|
|
|
found)
|
|
|
|
!= ISC_R_SUCCESS)
|
|
|
|
{
|
2019-09-04 21:28:34 +10:00
|
|
|
validator_log(val, ISC_LOG_DEBUG(3),
|
2019-08-06 16:36:28 -07:00
|
|
|
"not beneath secure root");
|
|
|
|
return (markanswer(val, "validatezonekey (1)",
|
|
|
|
"not beneath secure root"));
|
2010-05-14 00:13:43 +00:00
|
|
|
}
|
2005-12-04 23:54:01 +00:00
|
|
|
if (result == DNS_R_PARTIALMATCH ||
|
|
|
|
result == ISC_R_SUCCESS)
|
2019-08-06 13:44:30 -07:00
|
|
|
{
|
2018-04-17 08:29:14 -07:00
|
|
|
atsep = true;
|
2019-08-06 13:44:30 -07:00
|
|
|
}
|
2002-06-17 04:01:37 +00:00
|
|
|
while (result == ISC_R_SUCCESS) {
|
2010-03-26 17:12:48 +00:00
|
|
|
dns_keynode_t *nextnode = NULL;
|
2002-06-17 04:01:37 +00:00
|
|
|
dstkey = dns_keynode_key(keynode);
|
2009-06-30 02:53:46 +00:00
|
|
|
if (dstkey == NULL) {
|
|
|
|
dns_keytable_detachkeynode(
|
2019-08-06 13:44:30 -07:00
|
|
|
val->keytable,
|
|
|
|
&keynode);
|
2009-06-30 02:53:46 +00:00
|
|
|
break;
|
|
|
|
}
|
2017-10-12 10:53:35 -07:00
|
|
|
result = verify(val, dstkey, &sigrdata,
|
|
|
|
sig.keyid);
|
|
|
|
if (result == ISC_R_SUCCESS) {
|
|
|
|
dns_keytable_detachkeynode(
|
2009-06-30 02:53:46 +00:00
|
|
|
val->keytable,
|
|
|
|
&keynode);
|
2017-10-12 10:53:35 -07:00
|
|
|
break;
|
2002-06-17 04:01:37 +00:00
|
|
|
}
|
|
|
|
result = dns_keytable_findnextkeynode(
|
|
|
|
val->keytable,
|
|
|
|
keynode,
|
|
|
|
&nextnode);
|
|
|
|
dns_keytable_detachkeynode(val->keytable,
|
|
|
|
&keynode);
|
|
|
|
keynode = nextnode;
|
|
|
|
}
|
|
|
|
if (result == ISC_R_SUCCESS) {
|
2010-02-25 04:39:13 +00:00
|
|
|
marksecure(event);
|
2002-06-17 04:01:37 +00:00
|
|
|
validator_log(val, ISC_LOG_DEBUG(3),
|
|
|
|
"signed by trusted key; "
|
|
|
|
"marking as secure");
|
|
|
|
return (result);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-12-04 23:54:01 +00:00
|
|
|
if (atsep) {
|
|
|
|
/*
|
|
|
|
* We have not found a key to verify this DNSKEY
|
|
|
|
* RRset. As this is a SEP we have to assume that
|
|
|
|
* the RRset is invalid.
|
|
|
|
*/
|
|
|
|
dns_name_format(val->event->name, namebuf,
|
2008-01-18 23:46:58 +00:00
|
|
|
sizeof(namebuf));
|
2010-02-25 04:39:13 +00:00
|
|
|
validator_log(val, ISC_LOG_NOTICE,
|
2005-12-04 23:54:01 +00:00
|
|
|
"unable to find a DNSKEY which verifies "
|
2009-06-30 02:53:46 +00:00
|
|
|
"the DNSKEY RRset and also matches a "
|
2019-08-06 13:44:30 -07:00
|
|
|
"trusted key for '%s'", namebuf);
|
2005-12-04 23:54:01 +00:00
|
|
|
return (DNS_R_NOVALIDKEY);
|
|
|
|
}
|
|
|
|
|
2010-05-26 06:28:00 +00:00
|
|
|
/*
|
|
|
|
* If this is the root name and there was no trusted key,
|
|
|
|
* give up, since there's no DS at the root.
|
|
|
|
*/
|
|
|
|
if (dns_name_equal(event->name, dns_rootname)) {
|
|
|
|
if ((val->attributes & VALATTR_TRIEDVERIFY) != 0) {
|
|
|
|
validator_log(val, ISC_LOG_DEBUG(3),
|
|
|
|
"root key failed to validate");
|
|
|
|
return (DNS_R_NOVALIDSIG);
|
|
|
|
} else {
|
|
|
|
validator_log(val, ISC_LOG_DEBUG(3),
|
|
|
|
"no trusted root key");
|
|
|
|
return (DNS_R_NOVALIDDS);
|
|
|
|
}
|
|
|
|
}
|
2019-08-06 09:28:05 -07:00
|
|
|
|
2002-06-17 04:01:37 +00:00
|
|
|
/*
|
|
|
|
* Otherwise, try to find the DS record.
|
|
|
|
*/
|
|
|
|
result = view_find(val, val->event->name, dns_rdatatype_ds);
|
2019-08-07 17:49:59 -07:00
|
|
|
switch (result) {
|
|
|
|
case ISC_R_SUCCESS:
|
2002-06-17 04:01:37 +00:00
|
|
|
/*
|
|
|
|
* We have DS records.
|
|
|
|
*/
|
|
|
|
val->dsset = &val->frdataset;
|
2010-05-14 00:13:43 +00:00
|
|
|
if ((DNS_TRUST_PENDING(val->frdataset.trust) ||
|
|
|
|
DNS_TRUST_ANSWER(val->frdataset.trust)) &&
|
2002-06-17 04:01:37 +00:00
|
|
|
dns_rdataset_isassociated(&val->fsigrdataset))
|
|
|
|
{
|
|
|
|
result = create_validator(val,
|
|
|
|
val->event->name,
|
|
|
|
dns_rdatatype_ds,
|
|
|
|
&val->frdataset,
|
|
|
|
&val->fsigrdataset,
|
2019-08-16 12:28:22 -07:00
|
|
|
validator_callback_ds,
|
2002-06-17 04:01:37 +00:00
|
|
|
"validatezonekey");
|
2019-08-06 13:44:30 -07:00
|
|
|
if (result != ISC_R_SUCCESS) {
|
2002-06-17 04:01:37 +00:00
|
|
|
return (result);
|
2019-08-06 13:44:30 -07:00
|
|
|
}
|
2002-06-17 04:01:37 +00:00
|
|
|
return (DNS_R_WAIT);
|
2009-11-17 23:55:18 +00:00
|
|
|
} else if (DNS_TRUST_PENDING(val->frdataset.trust)) {
|
2002-06-17 04:01:37 +00:00
|
|
|
/*
|
|
|
|
* There should never be an unsigned DS.
|
|
|
|
*/
|
|
|
|
dns_rdataset_disassociate(&val->frdataset);
|
|
|
|
validator_log(val, ISC_LOG_DEBUG(2),
|
|
|
|
"unsigned DS record");
|
|
|
|
return (DNS_R_NOVALIDSIG);
|
2011-03-11 06:11:27 +00:00
|
|
|
} else {
|
2002-06-17 04:01:37 +00:00
|
|
|
result = ISC_R_SUCCESS;
|
2011-03-11 06:11:27 +00:00
|
|
|
POST(result);
|
|
|
|
}
|
2019-08-07 17:49:59 -07:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ISC_R_NOTFOUND:
|
2002-06-17 04:01:37 +00:00
|
|
|
/*
|
|
|
|
* We don't have the DS. Find it.
|
|
|
|
*/
|
|
|
|
result = create_fetch(val, val->event->name,
|
2019-08-16 12:28:22 -07:00
|
|
|
dns_rdatatype_ds,
|
|
|
|
fetch_callback_ds,
|
2002-06-17 04:01:37 +00:00
|
|
|
"validatezonekey");
|
2019-08-06 13:44:30 -07:00
|
|
|
if (result != ISC_R_SUCCESS) {
|
2002-06-17 04:01:37 +00:00
|
|
|
return (result);
|
2019-08-06 13:44:30 -07:00
|
|
|
}
|
2002-06-17 04:01:37 +00:00
|
|
|
return (DNS_R_WAIT);
|
2019-08-07 17:49:59 -07:00
|
|
|
|
|
|
|
case DNS_R_NCACHENXDOMAIN:
|
|
|
|
case DNS_R_NCACHENXRRSET:
|
|
|
|
case DNS_R_EMPTYNAME:
|
|
|
|
case DNS_R_NXDOMAIN:
|
|
|
|
case DNS_R_NXRRSET:
|
|
|
|
case DNS_R_CNAME:
|
2002-06-17 04:01:37 +00:00
|
|
|
/*
|
|
|
|
* The DS does not exist.
|
|
|
|
*/
|
2019-08-06 13:13:38 -07:00
|
|
|
disassociate_rdatasets(val);
|
2002-06-17 04:01:37 +00:00
|
|
|
validator_log(val, ISC_LOG_DEBUG(2), "no DS record");
|
|
|
|
return (DNS_R_NOVALIDSIG);
|
2019-08-07 17:49:59 -07:00
|
|
|
|
|
|
|
case DNS_R_BROKENCHAIN:
|
2010-02-25 04:39:13 +00:00
|
|
|
return (result);
|
2019-08-07 17:49:59 -07:00
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
2019-08-06 13:44:30 -07:00
|
|
|
}
|
2002-06-17 04:01:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* We have a DS set.
|
|
|
|
*/
|
|
|
|
INSIST(val->dsset != NULL);
|
|
|
|
|
|
|
|
if (val->dsset->trust < dns_trust_secure) {
|
2019-08-06 16:36:28 -07:00
|
|
|
return (markanswer(val, "validatezonekey (2)", "insecure DS"));
|
2002-06-17 04:01:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Look through the DS record and find the keys that can sign the
|
|
|
|
* key set and the matching signature. For each such key, attempt
|
|
|
|
* verification.
|
|
|
|
*/
|
|
|
|
|
2018-04-17 08:29:14 -07:00
|
|
|
supported_algorithm = false;
|
2004-01-14 02:06:51 +00:00
|
|
|
|
2006-02-21 23:49:51 +00:00
|
|
|
/*
|
2017-04-21 16:19:28 +05:30
|
|
|
* If DNS_DSDIGEST_SHA256 or DNS_DSDIGEST_SHA384 is present we
|
|
|
|
* are required to prefer it over DNS_DSDIGEST_SHA1. This in
|
|
|
|
* practice means that we need to ignore DNS_DSDIGEST_SHA1 if a
|
|
|
|
* DNS_DSDIGEST_SHA256 or DNS_DSDIGEST_SHA384 is present.
|
2006-02-21 23:49:51 +00:00
|
|
|
*/
|
2010-12-23 04:08:00 +00:00
|
|
|
memset(digest_types, 1, sizeof(digest_types));
|
2006-02-21 23:49:51 +00:00
|
|
|
for (result = dns_rdataset_first(val->dsset);
|
|
|
|
result == ISC_R_SUCCESS;
|
2019-08-06 13:44:30 -07:00
|
|
|
result = dns_rdataset_next(val->dsset))
|
|
|
|
{
|
2006-02-21 23:49:51 +00:00
|
|
|
dns_rdata_reset(&dsrdata);
|
|
|
|
dns_rdataset_current(val->dsset, &dsrdata);
|
2008-01-14 23:24:24 +00:00
|
|
|
result = dns_rdata_tostruct(&dsrdata, &ds, NULL);
|
|
|
|
RUNTIME_CHECK(result == ISC_R_SUCCESS);
|
2006-02-21 23:49:51 +00:00
|
|
|
|
2017-04-21 16:19:28 +05:30
|
|
|
if (!dns_resolver_ds_digest_supported(val->view->resolver,
|
|
|
|
val->event->name,
|
|
|
|
ds.digest_type))
|
2019-08-06 13:44:30 -07:00
|
|
|
{
|
2017-04-21 16:19:28 +05:30
|
|
|
continue;
|
2019-08-06 13:44:30 -07:00
|
|
|
}
|
2017-04-21 16:19:28 +05:30
|
|
|
|
2006-02-21 23:49:51 +00:00
|
|
|
if (!dns_resolver_algorithm_supported(val->view->resolver,
|
|
|
|
val->event->name,
|
|
|
|
ds.algorithm))
|
2019-08-06 13:44:30 -07:00
|
|
|
{
|
2006-02-21 23:49:51 +00:00
|
|
|
continue;
|
2019-08-06 13:44:30 -07:00
|
|
|
}
|
2006-02-21 23:49:51 +00:00
|
|
|
|
2017-04-21 16:19:28 +05:30
|
|
|
if ((ds.digest_type == DNS_DSDIGEST_SHA256 &&
|
|
|
|
ds.length == ISC_SHA256_DIGESTLENGTH) ||
|
|
|
|
(ds.digest_type == DNS_DSDIGEST_SHA384 &&
|
|
|
|
ds.length == ISC_SHA384_DIGESTLENGTH))
|
|
|
|
{
|
2010-12-23 04:08:00 +00:00
|
|
|
digest_types[DNS_DSDIGEST_SHA1] = 0;
|
2006-02-21 23:49:51 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-06-17 04:01:37 +00:00
|
|
|
for (result = dns_rdataset_first(val->dsset);
|
|
|
|
result == ISC_R_SUCCESS;
|
|
|
|
result = dns_rdataset_next(val->dsset))
|
|
|
|
{
|
|
|
|
dns_rdata_reset(&dsrdata);
|
|
|
|
dns_rdataset_current(val->dsset, &dsrdata);
|
2008-01-14 23:24:24 +00:00
|
|
|
result = dns_rdata_tostruct(&dsrdata, &ds, NULL);
|
|
|
|
RUNTIME_CHECK(result == ISC_R_SUCCESS);
|
2002-06-17 04:01:37 +00:00
|
|
|
|
2019-08-06 13:44:30 -07:00
|
|
|
if (digest_types[ds.digest_type] == 0) {
|
2005-03-04 03:53:22 +00:00
|
|
|
continue;
|
2019-08-06 13:44:30 -07:00
|
|
|
}
|
2005-03-04 03:53:22 +00:00
|
|
|
|
2012-10-03 12:38:43 +10:00
|
|
|
if (!dns_resolver_ds_digest_supported(val->view->resolver,
|
|
|
|
val->event->name,
|
|
|
|
ds.digest_type))
|
2019-08-06 13:44:30 -07:00
|
|
|
{
|
2006-02-21 23:49:51 +00:00
|
|
|
continue;
|
2019-08-06 13:44:30 -07:00
|
|
|
}
|
2006-02-21 23:49:51 +00:00
|
|
|
|
2004-01-14 02:06:51 +00:00
|
|
|
if (!dns_resolver_algorithm_supported(val->view->resolver,
|
|
|
|
val->event->name,
|
|
|
|
ds.algorithm))
|
2019-08-06 13:44:30 -07:00
|
|
|
{
|
2004-01-14 02:06:51 +00:00
|
|
|
continue;
|
2019-08-06 13:44:30 -07:00
|
|
|
}
|
2004-01-14 02:06:51 +00:00
|
|
|
|
2018-04-17 08:29:14 -07:00
|
|
|
supported_algorithm = true;
|
2004-01-14 02:06:51 +00:00
|
|
|
|
2002-06-17 04:01:37 +00:00
|
|
|
dns_rdataset_init(&trdataset);
|
|
|
|
dns_rdataset_clone(val->event->rdataset, &trdataset);
|
|
|
|
|
2005-11-03 00:51:55 +00:00
|
|
|
/*
|
2010-05-14 04:38:52 +00:00
|
|
|
* Find matching DNSKEY from DS.
|
2005-11-03 00:51:55 +00:00
|
|
|
*/
|
2010-05-14 04:38:52 +00:00
|
|
|
result = keyfromds(val, &trdataset, &dsrdata, ds.digest_type,
|
|
|
|
ds.key_tag, ds.algorithm, &keyrdata);
|
2002-06-17 04:01:37 +00:00
|
|
|
if (result != ISC_R_SUCCESS) {
|
2009-02-15 23:37:29 +00:00
|
|
|
dns_rdataset_disassociate(&trdataset);
|
2002-06-17 04:01:37 +00:00
|
|
|
validator_log(val, ISC_LOG_DEBUG(3),
|
2004-06-11 01:12:40 +00:00
|
|
|
"no DNSKEY matching DS");
|
2002-06-17 04:01:37 +00:00
|
|
|
continue;
|
|
|
|
}
|
2008-01-18 23:46:58 +00:00
|
|
|
|
2010-05-14 04:38:52 +00:00
|
|
|
/*
|
|
|
|
* Check that this DNSKEY signed the DNSKEY rrset.
|
|
|
|
*/
|
|
|
|
result = checkkey(val, &keyrdata, ds.key_tag, ds.algorithm);
|
|
|
|
|
2002-06-17 04:01:37 +00:00
|
|
|
dns_rdataset_disassociate(&trdataset);
|
2019-08-06 13:44:30 -07:00
|
|
|
if (result == ISC_R_SUCCESS) {
|
2002-06-17 04:01:37 +00:00
|
|
|
break;
|
2019-08-06 13:44:30 -07:00
|
|
|
}
|
2004-06-11 01:12:40 +00:00
|
|
|
validator_log(val, ISC_LOG_DEBUG(3),
|
|
|
|
"no RRSIG matching DS key");
|
2002-06-17 04:01:37 +00:00
|
|
|
}
|
|
|
|
if (result == ISC_R_SUCCESS) {
|
2010-02-25 04:39:13 +00:00
|
|
|
marksecure(event);
|
2009-10-28 05:34:21 +00:00
|
|
|
validator_log(val, ISC_LOG_DEBUG(3), "marking as secure (DS)");
|
2002-06-17 04:01:37 +00:00
|
|
|
return (result);
|
2004-01-14 02:06:51 +00:00
|
|
|
} else if (result == ISC_R_NOMORE && !supported_algorithm) {
|
|
|
|
validator_log(val, ISC_LOG_DEBUG(3),
|
2005-08-25 00:56:08 +00:00
|
|
|
"no supported algorithm/digest (DS)");
|
2019-08-06 16:36:28 -07:00
|
|
|
return (markanswer(val, "validatezonekey (3)",
|
|
|
|
"no supported algorithm/digest (DS)"));
|
2009-11-16 07:56:06 +00:00
|
|
|
} else {
|
|
|
|
validator_log(val, ISC_LOG_INFO,
|
|
|
|
"no valid signature found (DS)");
|
2002-06-17 04:01:37 +00:00
|
|
|
return (DNS_R_NOVALIDSIG);
|
2009-11-16 07:56:06 +00:00
|
|
|
}
|
2002-06-17 04:01:37 +00:00
|
|
|
}
|
|
|
|
|
2005-11-03 00:51:55 +00:00
|
|
|
/*%
|
2002-06-17 04:01:37 +00:00
|
|
|
* Starts a positive response validation.
|
|
|
|
*
|
|
|
|
* Returns:
|
2005-11-03 00:51:55 +00:00
|
|
|
* \li ISC_R_SUCCESS Validation completed successfully
|
|
|
|
* \li DNS_R_WAIT Validation has started but is waiting
|
2002-06-17 04:01:37 +00:00
|
|
|
* for an event.
|
2005-11-03 00:51:55 +00:00
|
|
|
* \li Other return codes are possible and all indicate failure.
|
2002-06-17 04:01:37 +00:00
|
|
|
*/
|
|
|
|
static isc_result_t
|
|
|
|
start_positive_validation(dns_validator_t *val) {
|
|
|
|
/*
|
2019-08-07 16:54:05 -07:00
|
|
|
* If this is not a key, go straight into validate_answer().
|
2002-06-17 04:01:37 +00:00
|
|
|
*/
|
2019-08-06 13:44:30 -07:00
|
|
|
if (val->event->type != dns_rdatatype_dnskey || !isselfsigned(val)) {
|
2019-08-07 16:54:05 -07:00
|
|
|
return (validate_answer(val, false));
|
2019-08-06 13:44:30 -07:00
|
|
|
}
|
2002-06-17 04:01:37 +00:00
|
|
|
|
2004-03-10 02:19:58 +00:00
|
|
|
return (validatezonekey(val));
|
2002-06-17 04:01:37 +00:00
|
|
|
}
|
2000-04-13 18:10:07 +00:00
|
|
|
|
2010-05-14 00:13:43 +00:00
|
|
|
/*%
|
|
|
|
* val_rdataset_first and val_rdataset_next provide iteration methods
|
2019-08-06 23:08:36 -07:00
|
|
|
* that hide whether we are iterating across a message or a negative
|
2010-05-14 00:13:43 +00:00
|
|
|
* cache rdataset.
|
|
|
|
*/
|
|
|
|
static isc_result_t
|
|
|
|
val_rdataset_first(dns_validator_t *val, dns_name_t **namep,
|
|
|
|
dns_rdataset_t **rdatasetp)
|
|
|
|
{
|
|
|
|
dns_message_t *message = val->event->message;
|
|
|
|
isc_result_t result;
|
|
|
|
|
|
|
|
REQUIRE(rdatasetp != NULL);
|
|
|
|
REQUIRE(namep != NULL);
|
|
|
|
if (message == NULL) {
|
|
|
|
REQUIRE(*rdatasetp != NULL);
|
|
|
|
REQUIRE(*namep != NULL);
|
|
|
|
} else {
|
|
|
|
REQUIRE(*rdatasetp == NULL);
|
|
|
|
REQUIRE(*namep == NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (message != NULL) {
|
|
|
|
result = dns_message_firstname(message, DNS_SECTION_AUTHORITY);
|
2019-08-06 13:44:30 -07:00
|
|
|
if (result != ISC_R_SUCCESS) {
|
2010-05-14 00:13:43 +00:00
|
|
|
return (result);
|
2019-08-06 13:44:30 -07:00
|
|
|
}
|
2010-05-14 00:13:43 +00:00
|
|
|
dns_message_currentname(message, DNS_SECTION_AUTHORITY, namep);
|
|
|
|
*rdatasetp = ISC_LIST_HEAD((*namep)->list);
|
|
|
|
INSIST(*rdatasetp != NULL);
|
|
|
|
} else {
|
|
|
|
result = dns_rdataset_first(val->event->rdataset);
|
2019-08-06 13:44:30 -07:00
|
|
|
if (result == ISC_R_SUCCESS) {
|
2010-05-14 00:13:43 +00:00
|
|
|
dns_ncache_current(val->event->rdataset, *namep,
|
|
|
|
*rdatasetp);
|
2019-08-06 13:44:30 -07:00
|
|
|
}
|
2010-05-14 00:13:43 +00:00
|
|
|
}
|
|
|
|
return (result);
|
|
|
|
}
|
|
|
|
|
|
|
|
static isc_result_t
|
|
|
|
val_rdataset_next(dns_validator_t *val, dns_name_t **namep,
|
2010-05-14 23:50:40 +00:00
|
|
|
dns_rdataset_t **rdatasetp)
|
2010-05-14 00:13:43 +00:00
|
|
|
{
|
|
|
|
dns_message_t *message = val->event->message;
|
|
|
|
isc_result_t result = ISC_R_SUCCESS;
|
|
|
|
|
|
|
|
REQUIRE(rdatasetp != NULL && *rdatasetp != NULL);
|
|
|
|
REQUIRE(namep != NULL && *namep != NULL);
|
|
|
|
|
|
|
|
if (message != NULL) {
|
|
|
|
dns_rdataset_t *rdataset = *rdatasetp;
|
|
|
|
rdataset = ISC_LIST_NEXT(rdataset, link);
|
|
|
|
if (rdataset == NULL) {
|
|
|
|
*namep = NULL;
|
|
|
|
result = dns_message_nextname(message,
|
|
|
|
DNS_SECTION_AUTHORITY);
|
|
|
|
if (result == ISC_R_SUCCESS) {
|
|
|
|
dns_message_currentname(message,
|
|
|
|
DNS_SECTION_AUTHORITY,
|
|
|
|
namep);
|
|
|
|
rdataset = ISC_LIST_HEAD((*namep)->list);
|
|
|
|
INSIST(rdataset != NULL);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
*rdatasetp = rdataset;
|
|
|
|
} else {
|
|
|
|
dns_rdataset_disassociate(*rdatasetp);
|
|
|
|
result = dns_rdataset_next(val->event->rdataset);
|
2019-08-06 13:44:30 -07:00
|
|
|
if (result == ISC_R_SUCCESS) {
|
2010-05-14 00:13:43 +00:00
|
|
|
dns_ncache_current(val->event->rdataset, *namep,
|
|
|
|
*rdatasetp);
|
2019-08-06 13:44:30 -07:00
|
|
|
}
|
2010-05-14 00:13:43 +00:00
|
|
|
}
|
|
|
|
return (result);
|
|
|
|
}
|
|
|
|
|
2005-11-03 00:51:55 +00:00
|
|
|
/*%
|
|
|
|
* Look for NODATA at the wildcard and NOWILDCARD proofs in the
|
|
|
|
* previously validated NSEC records. As these proofs are mutually
|
|
|
|
* exclusive we stop when one is found.
|
|
|
|
*
|
|
|
|
* Returns
|
2008-01-18 23:46:58 +00:00
|
|
|
* \li ISC_R_SUCCESS
|
2005-11-03 00:51:55 +00:00
|
|
|
*/
|
2004-01-14 02:06:51 +00:00
|
|
|
static isc_result_t
|
2019-08-06 13:44:30 -07:00
|
|
|
checkwildcard(dns_validator_t *val, dns_rdatatype_t type,
|
|
|
|
dns_name_t *zonename)
|
2008-09-24 02:46:23 +00:00
|
|
|
{
|
2010-05-14 00:13:43 +00:00
|
|
|
dns_name_t *name, *wild, tname;
|
2004-01-14 02:06:51 +00:00
|
|
|
isc_result_t result;
|
2018-04-17 08:29:14 -07:00
|
|
|
bool exists, data;
|
2004-01-14 02:06:51 +00:00
|
|
|
char namebuf[DNS_NAME_FORMATSIZE];
|
2010-05-14 00:13:43 +00:00
|
|
|
dns_rdataset_t *rdataset, trdataset;
|
2004-01-14 02:06:51 +00:00
|
|
|
|
2010-05-14 00:13:43 +00:00
|
|
|
dns_name_init(&tname, NULL);
|
|
|
|
dns_rdataset_init(&trdataset);
|
2004-01-14 02:06:51 +00:00
|
|
|
wild = dns_fixedname_name(&val->wild);
|
2008-09-24 02:46:23 +00:00
|
|
|
|
|
|
|
if (dns_name_countlabels(wild) == 0) {
|
|
|
|
validator_log(val, ISC_LOG_DEBUG(3),
|
|
|
|
"in checkwildcard: no wildcard to check");
|
|
|
|
return (ISC_R_SUCCESS);
|
|
|
|
}
|
|
|
|
|
2004-01-14 02:06:51 +00:00
|
|
|
dns_name_format(wild, namebuf, sizeof(namebuf));
|
|
|
|
validator_log(val, ISC_LOG_DEBUG(3), "in checkwildcard: %s", namebuf);
|
|
|
|
|
2010-05-14 00:13:43 +00:00
|
|
|
if (val->event->message == NULL) {
|
|
|
|
name = &tname;
|
|
|
|
rdataset = &trdataset;
|
|
|
|
} else {
|
|
|
|
name = NULL;
|
|
|
|
rdataset = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (result = val_rdataset_first(val, &name, &rdataset);
|
2004-01-14 02:06:51 +00:00
|
|
|
result == ISC_R_SUCCESS;
|
2010-05-14 00:13:43 +00:00
|
|
|
result = val_rdataset_next(val, &name, &rdataset))
|
2004-01-14 02:06:51 +00:00
|
|
|
{
|
2010-05-14 00:13:43 +00:00
|
|
|
if (rdataset->type != type ||
|
|
|
|
rdataset->trust != dns_trust_secure)
|
2019-08-06 13:44:30 -07:00
|
|
|
{
|
2010-05-14 00:13:43 +00:00
|
|
|
continue;
|
2019-08-06 13:44:30 -07:00
|
|
|
}
|
2004-01-14 02:06:51 +00:00
|
|
|
|
2010-05-14 00:13:43 +00:00
|
|
|
if (rdataset->type == dns_rdatatype_nsec &&
|
|
|
|
(NEEDNODATA(val) || NEEDNOWILDCARD(val)) &&
|
|
|
|
!FOUNDNODATA(val) && !FOUNDNOWILDCARD(val) &&
|
2012-12-19 09:55:02 +11:00
|
|
|
dns_nsec_noexistnodata(val->event->type, wild, name,
|
|
|
|
rdataset, &exists, &data, NULL,
|
|
|
|
validator_log, val)
|
2019-08-06 13:44:30 -07:00
|
|
|
== ISC_R_SUCCESS)
|
2004-01-14 02:06:51 +00:00
|
|
|
{
|
2010-05-14 00:13:43 +00:00
|
|
|
dns_name_t **proofs = val->event->proofs;
|
2019-08-06 13:44:30 -07:00
|
|
|
if (exists && !data) {
|
2010-05-14 00:13:43 +00:00
|
|
|
val->attributes |= VALATTR_FOUNDNODATA;
|
2019-08-06 13:44:30 -07:00
|
|
|
}
|
|
|
|
if (exists && !data && NEEDNODATA(val)) {
|
2010-05-14 00:13:43 +00:00
|
|
|
proofs[DNS_VALIDATOR_NODATAPROOF] =
|
2019-08-06 13:44:30 -07:00
|
|
|
name;
|
|
|
|
}
|
|
|
|
if (!exists) {
|
2010-05-14 00:13:43 +00:00
|
|
|
val->attributes |=
|
2019-08-06 13:44:30 -07:00
|
|
|
VALATTR_FOUNDNOWILDCARD;
|
|
|
|
}
|
|
|
|
if (!exists && NEEDNOQNAME(val)) {
|
|
|
|
proofs[DNS_VALIDATOR_NOWILDCARDPROOF] = name;
|
|
|
|
}
|
|
|
|
if (dns_rdataset_isassociated(&trdataset)) {
|
2010-05-14 00:13:43 +00:00
|
|
|
dns_rdataset_disassociate(&trdataset);
|
2019-08-06 13:44:30 -07:00
|
|
|
}
|
2010-05-14 00:13:43 +00:00
|
|
|
return (ISC_R_SUCCESS);
|
|
|
|
}
|
2008-09-24 02:46:23 +00:00
|
|
|
|
2010-05-14 00:13:43 +00:00
|
|
|
if (rdataset->type == dns_rdatatype_nsec3 &&
|
|
|
|
(NEEDNODATA(val) || NEEDNOWILDCARD(val)) &&
|
|
|
|
!FOUNDNODATA(val) && !FOUNDNOWILDCARD(val) &&
|
2012-12-19 09:55:02 +11:00
|
|
|
dns_nsec3_noexistnodata(val->event->type, wild, name,
|
|
|
|
rdataset, zonename, &exists, &data,
|
|
|
|
NULL, NULL, NULL, NULL, NULL, NULL,
|
|
|
|
validator_log, val)
|
2019-08-06 13:44:30 -07:00
|
|
|
== ISC_R_SUCCESS)
|
2010-05-14 00:13:43 +00:00
|
|
|
{
|
|
|
|
dns_name_t **proofs = val->event->proofs;
|
2019-08-06 13:44:30 -07:00
|
|
|
if (exists && !data) {
|
2010-05-14 00:13:43 +00:00
|
|
|
val->attributes |= VALATTR_FOUNDNODATA;
|
2019-08-06 13:44:30 -07:00
|
|
|
}
|
|
|
|
if (exists && !data && NEEDNODATA(val)) {
|
|
|
|
proofs[DNS_VALIDATOR_NODATAPROOF] = name;
|
|
|
|
}
|
|
|
|
if (!exists) {
|
|
|
|
val->attributes |= VALATTR_FOUNDNOWILDCARD;
|
|
|
|
}
|
|
|
|
if (!exists && NEEDNOQNAME(val)) {
|
|
|
|
proofs[DNS_VALIDATOR_NOWILDCARDPROOF] = name;
|
|
|
|
}
|
|
|
|
if (dns_rdataset_isassociated(&trdataset)) {
|
2010-05-14 00:13:43 +00:00
|
|
|
dns_rdataset_disassociate(&trdataset);
|
2019-08-06 13:44:30 -07:00
|
|
|
}
|
2010-05-14 00:13:43 +00:00
|
|
|
return (ISC_R_SUCCESS);
|
2004-01-14 02:06:51 +00:00
|
|
|
}
|
|
|
|
}
|
2019-08-06 13:44:30 -07:00
|
|
|
if (result == ISC_R_NOMORE) {
|
2004-01-14 02:06:51 +00:00
|
|
|
result = ISC_R_SUCCESS;
|
2019-08-06 13:44:30 -07:00
|
|
|
}
|
|
|
|
if (dns_rdataset_isassociated(&trdataset)) {
|
2010-05-14 00:13:43 +00:00
|
|
|
dns_rdataset_disassociate(&trdataset);
|
2019-08-06 13:44:30 -07:00
|
|
|
}
|
2004-01-14 02:06:51 +00:00
|
|
|
return (result);
|
|
|
|
}
|
|
|
|
|
2008-09-24 02:46:23 +00:00
|
|
|
static isc_result_t
|
|
|
|
findnsec3proofs(dns_validator_t *val) {
|
2010-05-14 00:13:43 +00:00
|
|
|
dns_name_t *name, tname;
|
2008-09-24 02:46:23 +00:00
|
|
|
isc_result_t result;
|
2018-04-17 08:29:14 -07:00
|
|
|
bool exists, data, optout, unknown;
|
|
|
|
bool setclosest, setnearest, *setclosestp;
|
2008-09-24 02:46:23 +00:00
|
|
|
dns_fixedname_t fclosest, fnearest, fzonename;
|
2011-10-20 21:42:11 +00:00
|
|
|
dns_name_t *closest, *nearest, *zonename, *closestp;
|
2008-09-24 02:46:23 +00:00
|
|
|
dns_name_t **proofs = val->event->proofs;
|
2010-05-14 00:13:43 +00:00
|
|
|
dns_rdataset_t *rdataset, trdataset;
|
2008-09-24 02:46:23 +00:00
|
|
|
|
2010-05-14 00:13:43 +00:00
|
|
|
dns_name_init(&tname, NULL);
|
|
|
|
dns_rdataset_init(&trdataset);
|
2018-03-28 14:38:09 +02:00
|
|
|
closest = dns_fixedname_initname(&fclosest);
|
|
|
|
nearest = dns_fixedname_initname(&fnearest);
|
|
|
|
zonename = dns_fixedname_initname(&fzonename);
|
2008-09-24 02:46:23 +00:00
|
|
|
|
2010-05-14 00:13:43 +00:00
|
|
|
if (val->event->message == NULL) {
|
|
|
|
name = &tname;
|
|
|
|
rdataset = &trdataset;
|
|
|
|
} else {
|
2008-09-24 02:46:23 +00:00
|
|
|
name = NULL;
|
2010-05-14 00:13:43 +00:00
|
|
|
rdataset = NULL;
|
|
|
|
}
|
2008-09-24 02:46:23 +00:00
|
|
|
|
2010-05-14 00:13:43 +00:00
|
|
|
for (result = val_rdataset_first(val, &name, &rdataset);
|
|
|
|
result == ISC_R_SUCCESS;
|
|
|
|
result = val_rdataset_next(val, &name, &rdataset))
|
|
|
|
{
|
|
|
|
if (rdataset->type != dns_rdatatype_nsec3 ||
|
|
|
|
rdataset->trust != dns_trust_secure)
|
2019-08-06 13:44:30 -07:00
|
|
|
{
|
2010-05-14 00:13:43 +00:00
|
|
|
continue;
|
2019-08-06 13:44:30 -07:00
|
|
|
}
|
2008-09-24 02:46:23 +00:00
|
|
|
|
2012-12-19 09:55:02 +11:00
|
|
|
result = dns_nsec3_noexistnodata(val->event->type,
|
|
|
|
val->event->name, name,
|
|
|
|
rdataset, zonename, NULL,
|
|
|
|
NULL, NULL, NULL, NULL, NULL,
|
|
|
|
NULL, NULL, validator_log,
|
|
|
|
val);
|
2010-05-14 00:13:43 +00:00
|
|
|
if (result != ISC_R_IGNORE && result != ISC_R_SUCCESS) {
|
2019-08-06 13:44:30 -07:00
|
|
|
if (dns_rdataset_isassociated(&trdataset)) {
|
2010-05-14 00:13:43 +00:00
|
|
|
dns_rdataset_disassociate(&trdataset);
|
2019-08-06 13:44:30 -07:00
|
|
|
}
|
2010-05-14 00:13:43 +00:00
|
|
|
return (result);
|
2008-09-24 02:46:23 +00:00
|
|
|
}
|
|
|
|
}
|
2019-08-06 13:44:30 -07:00
|
|
|
if (result != ISC_R_NOMORE) {
|
2008-09-24 02:46:23 +00:00
|
|
|
result = ISC_R_SUCCESS;
|
2019-08-06 13:44:30 -07:00
|
|
|
}
|
2011-03-11 06:11:27 +00:00
|
|
|
POST(result);
|
2008-09-24 02:46:23 +00:00
|
|
|
|
2019-08-06 13:44:30 -07:00
|
|
|
if (dns_name_countlabels(zonename) == 0) {
|
2008-09-24 02:46:23 +00:00
|
|
|
return (ISC_R_SUCCESS);
|
2019-08-06 13:44:30 -07:00
|
|
|
}
|
2008-09-24 02:46:23 +00:00
|
|
|
|
2011-10-20 21:42:11 +00:00
|
|
|
/*
|
|
|
|
* If the val->closest is set then we want to use it otherwise
|
|
|
|
* we need to discover it.
|
|
|
|
*/
|
|
|
|
if (dns_name_countlabels(dns_fixedname_name(&val->closest)) != 0) {
|
|
|
|
char namebuf[DNS_NAME_FORMATSIZE];
|
|
|
|
|
|
|
|
dns_name_format(dns_fixedname_name(&val->closest),
|
2019-08-06 13:44:30 -07:00
|
|
|
namebuf, sizeof(namebuf));
|
|
|
|
validator_log(val, ISC_LOG_DEBUG(3),
|
|
|
|
"closest encloser from wildcard signature '%s'",
|
|
|
|
namebuf);
|
2019-09-10 14:42:41 +02:00
|
|
|
dns_name_copynf(dns_fixedname_name(&val->closest), closest);
|
2011-10-20 21:42:11 +00:00
|
|
|
closestp = NULL;
|
|
|
|
setclosestp = NULL;
|
|
|
|
} else {
|
|
|
|
closestp = closest;
|
|
|
|
setclosestp = &setclosest;
|
|
|
|
}
|
|
|
|
|
2010-05-14 00:13:43 +00:00
|
|
|
for (result = val_rdataset_first(val, &name, &rdataset);
|
2008-09-24 02:46:23 +00:00
|
|
|
result == ISC_R_SUCCESS;
|
2010-05-14 00:13:43 +00:00
|
|
|
result = val_rdataset_next(val, &name, &rdataset))
|
2008-09-24 02:46:23 +00:00
|
|
|
{
|
2010-05-14 00:13:43 +00:00
|
|
|
if (rdataset->type != dns_rdatatype_nsec3 ||
|
|
|
|
rdataset->trust != dns_trust_secure)
|
2019-08-06 13:44:30 -07:00
|
|
|
{
|
2010-05-14 00:13:43 +00:00
|
|
|
continue;
|
2019-08-06 13:44:30 -07:00
|
|
|
}
|
2008-09-24 02:46:23 +00:00
|
|
|
|
2010-05-14 00:13:43 +00:00
|
|
|
/*
|
|
|
|
* We process all NSEC3 records to find the closest
|
|
|
|
* encloser and nearest name to the closest encloser.
|
|
|
|
*/
|
2018-04-17 08:29:14 -07:00
|
|
|
setclosest = setnearest = false;
|
|
|
|
optout = false;
|
|
|
|
unknown = false;
|
2012-12-19 09:55:02 +11:00
|
|
|
result = dns_nsec3_noexistnodata(val->event->type,
|
|
|
|
val->event->name,
|
2012-12-18 23:45:50 +00:00
|
|
|
name, rdataset, zonename,
|
2012-12-19 09:55:02 +11:00
|
|
|
&exists, &data, &optout,
|
|
|
|
&unknown, setclosestp,
|
|
|
|
&setnearest, closestp,
|
|
|
|
nearest, validator_log, val);
|
2019-08-06 13:44:30 -07:00
|
|
|
if (unknown) {
|
2010-05-14 00:13:43 +00:00
|
|
|
val->attributes |= VALATTR_FOUNDUNKNOWN;
|
2019-08-06 13:44:30 -07:00
|
|
|
}
|
|
|
|
if (result != ISC_R_SUCCESS) {
|
2010-05-14 00:13:43 +00:00
|
|
|
continue;
|
2019-08-06 13:44:30 -07:00
|
|
|
}
|
|
|
|
if (setclosest) {
|
2012-10-02 23:44:03 -07:00
|
|
|
proofs[DNS_VALIDATOR_CLOSESTENCLOSER] = name;
|
2019-08-06 13:44:30 -07:00
|
|
|
}
|
2010-05-14 00:13:43 +00:00
|
|
|
if (exists && !data && NEEDNODATA(val)) {
|
|
|
|
val->attributes |= VALATTR_FOUNDNODATA;
|
|
|
|
proofs[DNS_VALIDATOR_NODATAPROOF] = name;
|
|
|
|
}
|
|
|
|
if (!exists && setnearest) {
|
|
|
|
val->attributes |= VALATTR_FOUNDNOQNAME;
|
|
|
|
proofs[DNS_VALIDATOR_NOQNAMEPROOF] = name;
|
2019-08-06 13:44:30 -07:00
|
|
|
if (optout) {
|
2010-05-14 00:13:43 +00:00
|
|
|
val->attributes |= VALATTR_FOUNDOPTOUT;
|
2019-08-06 13:44:30 -07:00
|
|
|
}
|
2008-09-24 02:46:23 +00:00
|
|
|
}
|
|
|
|
}
|
2019-08-06 13:44:30 -07:00
|
|
|
if (result == ISC_R_NOMORE) {
|
2008-09-24 02:46:23 +00:00
|
|
|
result = ISC_R_SUCCESS;
|
2019-08-06 13:44:30 -07:00
|
|
|
}
|
2008-09-24 02:46:23 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* To know we have a valid noqname and optout proofs we need to also
|
|
|
|
* have a valid closest encloser. Otherwise we could still be looking
|
|
|
|
* at proofs from the parent zone.
|
|
|
|
*/
|
|
|
|
if (dns_name_countlabels(closest) > 0 &&
|
|
|
|
dns_name_countlabels(nearest) ==
|
|
|
|
dns_name_countlabels(closest) + 1 &&
|
|
|
|
dns_name_issubdomain(nearest, closest))
|
|
|
|
{
|
|
|
|
val->attributes |= VALATTR_FOUNDCLOSEST;
|
|
|
|
result = dns_name_concatenate(dns_wildcardname, closest,
|
|
|
|
dns_fixedname_name(&val->wild),
|
|
|
|
NULL);
|
|
|
|
RUNTIME_CHECK(result == ISC_R_SUCCESS);
|
|
|
|
} else {
|
|
|
|
val->attributes &= ~VALATTR_FOUNDNOQNAME;
|
|
|
|
val->attributes &= ~VALATTR_FOUNDOPTOUT;
|
|
|
|
proofs[DNS_VALIDATOR_NOQNAMEPROOF] = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Do we need to check for the wildcard?
|
|
|
|
*/
|
2010-05-14 00:13:43 +00:00
|
|
|
if (FOUNDNOQNAME(val) && FOUNDCLOSEST(val) &&
|
2019-08-06 13:44:30 -07:00
|
|
|
((NEEDNODATA(val) && !FOUNDNODATA(val)) || NEEDNOWILDCARD(val)))
|
|
|
|
{
|
2008-09-24 02:46:23 +00:00
|
|
|
result = checkwildcard(val, dns_rdatatype_nsec3, zonename);
|
2019-08-06 13:44:30 -07:00
|
|
|
if (result != ISC_R_SUCCESS) {
|
2008-09-24 02:46:23 +00:00
|
|
|
return (result);
|
2019-08-06 13:44:30 -07:00
|
|
|
}
|
2008-09-24 02:46:23 +00:00
|
|
|
}
|
|
|
|
return (result);
|
|
|
|
}
|
|
|
|
|
2019-08-06 23:08:36 -07:00
|
|
|
/*
|
|
|
|
* Start a validator for negative response data.
|
|
|
|
*
|
|
|
|
* Returns:
|
|
|
|
* \li DNS_R_CONTINUE Validation skipped, continue
|
|
|
|
* \li DNS_R_WAIT Validation is in progress
|
|
|
|
*
|
|
|
|
* \li Other return codes indicate failure.
|
|
|
|
*/
|
|
|
|
static isc_result_t
|
|
|
|
validate_neg_rrset(dns_validator_t *val, dns_name_t *name,
|
|
|
|
dns_rdataset_t *rdataset, dns_rdataset_t *sigrdataset)
|
|
|
|
{
|
|
|
|
isc_result_t result;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* If a signed zone is missing the zone key, bad
|
|
|
|
* things could happen. A query for data in the zone
|
|
|
|
* would lead to a query for the zone key, which
|
|
|
|
* would return a negative answer, which would contain
|
|
|
|
* an SOA and an NSEC signed by the missing key, which
|
|
|
|
* would trigger another query for the DNSKEY (since
|
|
|
|
* the first one is still in progress), and go into an
|
|
|
|
* infinite loop. Avoid that.
|
|
|
|
*/
|
|
|
|
if (val->event->type == dns_rdatatype_dnskey &&
|
|
|
|
rdataset->type == dns_rdatatype_nsec &&
|
|
|
|
dns_name_equal(name, val->event->name))
|
|
|
|
{
|
|
|
|
dns_rdata_t nsec = DNS_RDATA_INIT;
|
|
|
|
|
|
|
|
result = dns_rdataset_first(rdataset);
|
|
|
|
if (result != ISC_R_SUCCESS) {
|
|
|
|
return (result);
|
|
|
|
}
|
|
|
|
dns_rdataset_current(rdataset, &nsec);
|
|
|
|
if (dns_nsec_typepresent(&nsec, dns_rdatatype_soa)) {
|
|
|
|
return (DNS_R_CONTINUE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
val->currentset = rdataset;
|
|
|
|
result = create_validator(val, name, rdataset->type,
|
|
|
|
rdataset, sigrdataset,
|
2019-08-16 12:28:22 -07:00
|
|
|
validator_callback_nsec,
|
|
|
|
"validate_neg_rrset");
|
2019-08-06 23:08:36 -07:00
|
|
|
if (result != ISC_R_SUCCESS) {
|
|
|
|
return (result);
|
|
|
|
}
|
|
|
|
|
|
|
|
val->authcount++;
|
|
|
|
return (DNS_R_WAIT);
|
|
|
|
}
|
|
|
|
|
2005-11-03 00:51:55 +00:00
|
|
|
/*%
|
2010-05-14 00:13:43 +00:00
|
|
|
* Validate the authority section records.
|
2005-11-03 00:51:55 +00:00
|
|
|
*/
|
2002-02-01 20:08:56 +00:00
|
|
|
static isc_result_t
|
2018-04-17 08:29:14 -07:00
|
|
|
validate_authority(dns_validator_t *val, bool resume) {
|
2000-04-13 18:10:07 +00:00
|
|
|
dns_name_t *name;
|
|
|
|
dns_message_t *message = val->event->message;
|
|
|
|
isc_result_t result;
|
|
|
|
|
2019-08-06 13:44:30 -07:00
|
|
|
if (!resume) {
|
2000-04-13 18:10:07 +00:00
|
|
|
result = dns_message_firstname(message, DNS_SECTION_AUTHORITY);
|
2019-08-06 13:44:30 -07:00
|
|
|
} else {
|
2000-04-13 18:10:07 +00:00
|
|
|
result = ISC_R_SUCCESS;
|
2019-08-06 13:44:30 -07:00
|
|
|
}
|
2000-04-13 18:10:07 +00:00
|
|
|
|
|
|
|
for (;
|
|
|
|
result == ISC_R_SUCCESS;
|
|
|
|
result = dns_message_nextname(message, DNS_SECTION_AUTHORITY))
|
|
|
|
{
|
2000-05-17 18:24:59 +00:00
|
|
|
dns_rdataset_t *rdataset = NULL, *sigrdataset = NULL;
|
2000-04-13 18:10:07 +00:00
|
|
|
|
|
|
|
name = NULL;
|
|
|
|
dns_message_currentname(message, DNS_SECTION_AUTHORITY, &name);
|
2000-05-17 18:24:59 +00:00
|
|
|
if (resume) {
|
|
|
|
rdataset = ISC_LIST_NEXT(val->currentset, link);
|
|
|
|
val->currentset = NULL;
|
2018-04-17 08:29:14 -07:00
|
|
|
resume = false;
|
2019-08-06 13:44:30 -07:00
|
|
|
} else {
|
2000-05-17 18:24:59 +00:00
|
|
|
rdataset = ISC_LIST_HEAD(name->list);
|
2019-08-06 13:44:30 -07:00
|
|
|
}
|
2000-05-17 18:24:59 +00:00
|
|
|
|
|
|
|
for (;
|
|
|
|
rdataset != NULL;
|
|
|
|
rdataset = ISC_LIST_NEXT(rdataset, link))
|
|
|
|
{
|
2019-08-06 13:44:30 -07:00
|
|
|
if (rdataset->type == dns_rdatatype_rrsig) {
|
2000-04-13 18:10:07 +00:00
|
|
|
continue;
|
2019-08-06 13:44:30 -07:00
|
|
|
}
|
2000-05-17 18:24:59 +00:00
|
|
|
|
|
|
|
for (sigrdataset = ISC_LIST_HEAD(name->list);
|
|
|
|
sigrdataset != NULL;
|
2019-08-06 13:44:30 -07:00
|
|
|
sigrdataset = ISC_LIST_NEXT(sigrdataset, link))
|
2000-05-17 18:24:59 +00:00
|
|
|
{
|
2003-09-30 06:00:40 +00:00
|
|
|
if (sigrdataset->type == dns_rdatatype_rrsig &&
|
2000-05-17 18:24:59 +00:00
|
|
|
sigrdataset->covers == rdataset->type)
|
2019-08-06 13:44:30 -07:00
|
|
|
{
|
2000-05-17 18:24:59 +00:00
|
|
|
break;
|
2019-08-06 13:44:30 -07:00
|
|
|
}
|
2000-04-13 18:10:07 +00:00
|
|
|
}
|
2000-09-07 19:46:52 +00:00
|
|
|
|
2019-08-06 23:08:36 -07:00
|
|
|
result = validate_neg_rrset(val, name, rdataset,
|
|
|
|
sigrdataset);
|
|
|
|
if (result != DNS_R_CONTINUE) {
|
2000-05-17 18:24:59 +00:00
|
|
|
return (result);
|
2019-08-06 13:44:30 -07:00
|
|
|
}
|
2010-05-14 00:13:43 +00:00
|
|
|
}
|
|
|
|
}
|
2019-08-06 13:44:30 -07:00
|
|
|
if (result == ISC_R_NOMORE) {
|
2010-05-14 00:13:43 +00:00
|
|
|
result = ISC_R_SUCCESS;
|
2019-08-06 13:44:30 -07:00
|
|
|
}
|
2010-05-14 00:13:43 +00:00
|
|
|
return (result);
|
|
|
|
}
|
2000-08-01 01:33:37 +00:00
|
|
|
|
2010-05-14 00:13:43 +00:00
|
|
|
/*%
|
|
|
|
* Validate the ncache elements.
|
|
|
|
*/
|
|
|
|
static isc_result_t
|
2018-04-17 08:29:14 -07:00
|
|
|
validate_ncache(dns_validator_t *val, bool resume) {
|
2010-05-14 00:13:43 +00:00
|
|
|
dns_name_t *name;
|
|
|
|
isc_result_t result;
|
|
|
|
|
2019-08-06 13:44:30 -07:00
|
|
|
if (!resume) {
|
2010-05-14 00:13:43 +00:00
|
|
|
result = dns_rdataset_first(val->event->rdataset);
|
2019-08-06 13:44:30 -07:00
|
|
|
} else {
|
2010-05-14 00:13:43 +00:00
|
|
|
result = dns_rdataset_next(val->event->rdataset);
|
2019-08-06 13:44:30 -07:00
|
|
|
}
|
2010-05-14 00:13:43 +00:00
|
|
|
|
|
|
|
for (;
|
|
|
|
result == ISC_R_SUCCESS;
|
|
|
|
result = dns_rdataset_next(val->event->rdataset))
|
|
|
|
{
|
|
|
|
dns_rdataset_t *rdataset, *sigrdataset = NULL;
|
|
|
|
|
2019-08-06 13:13:38 -07:00
|
|
|
disassociate_rdatasets(val);
|
2010-05-14 00:13:43 +00:00
|
|
|
|
2018-03-28 14:38:09 +02:00
|
|
|
name = dns_fixedname_initname(&val->fname);
|
2010-05-14 00:13:43 +00:00
|
|
|
rdataset = &val->frdataset;
|
|
|
|
dns_ncache_current(val->event->rdataset, name, rdataset);
|
|
|
|
|
2019-08-06 13:44:30 -07:00
|
|
|
if (val->frdataset.type == dns_rdatatype_rrsig) {
|
2010-05-14 00:13:43 +00:00
|
|
|
continue;
|
2019-08-06 13:44:30 -07:00
|
|
|
}
|
2010-05-14 23:50:40 +00:00
|
|
|
|
2010-05-14 00:13:43 +00:00
|
|
|
result = dns_ncache_getsigrdataset(val->event->rdataset, name,
|
|
|
|
rdataset->type,
|
|
|
|
&val->fsigrdataset);
|
2019-08-06 13:44:30 -07:00
|
|
|
if (result == ISC_R_SUCCESS) {
|
2010-05-14 00:13:43 +00:00
|
|
|
sigrdataset = &val->fsigrdataset;
|
2019-08-06 13:44:30 -07:00
|
|
|
}
|
2010-05-14 00:13:43 +00:00
|
|
|
|
2019-08-06 23:08:36 -07:00
|
|
|
result = validate_neg_rrset(val, name, rdataset, sigrdataset);
|
|
|
|
if (result == DNS_R_CONTINUE) {
|
|
|
|
continue;
|
2019-08-06 13:44:30 -07:00
|
|
|
}
|
2019-08-06 23:08:36 -07:00
|
|
|
|
|
|
|
return (result);
|
2000-05-17 18:24:59 +00:00
|
|
|
}
|
2019-08-06 13:44:30 -07:00
|
|
|
if (result == ISC_R_NOMORE) {
|
2000-05-17 18:24:59 +00:00
|
|
|
result = ISC_R_SUCCESS;
|
2019-08-06 13:44:30 -07:00
|
|
|
}
|
2010-05-14 00:13:43 +00:00
|
|
|
return (result);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*%
|
|
|
|
* Prove a negative answer is good or that there is a NOQNAME when the
|
|
|
|
* answer is from a wildcard.
|
|
|
|
*
|
|
|
|
* Loop through the authority section looking for NODATA, NOWILDCARD
|
2019-08-16 12:28:22 -07:00
|
|
|
* and NOQNAME proofs in the NSEC records by calling
|
|
|
|
* validator_callback_nsec().
|
2010-05-14 00:13:43 +00:00
|
|
|
*
|
|
|
|
* If the required proofs are found we are done.
|
|
|
|
*
|
2019-08-07 16:54:05 -07:00
|
|
|
* If the proofs are not found attempt to prove this is an unsecure
|
2010-05-14 00:13:43 +00:00
|
|
|
* response.
|
|
|
|
*/
|
|
|
|
static isc_result_t
|
2019-08-07 16:54:05 -07:00
|
|
|
validate_nx(dns_validator_t *val, bool resume) {
|
2010-05-14 00:13:43 +00:00
|
|
|
isc_result_t result;
|
|
|
|
|
2019-08-06 13:44:30 -07:00
|
|
|
if (resume) {
|
2019-08-07 16:54:05 -07:00
|
|
|
validator_log(val, ISC_LOG_DEBUG(3), "resuming validate_nx");
|
2019-08-06 13:44:30 -07:00
|
|
|
}
|
2010-05-14 23:50:40 +00:00
|
|
|
|
2019-08-06 13:44:30 -07:00
|
|
|
if (val->event->message == NULL) {
|
2010-05-14 00:13:43 +00:00
|
|
|
result = validate_ncache(val, resume);
|
2019-08-06 13:44:30 -07:00
|
|
|
} else {
|
2010-05-14 00:13:43 +00:00
|
|
|
result = validate_authority(val, resume);
|
2019-08-06 13:44:30 -07:00
|
|
|
}
|
2010-05-14 00:13:43 +00:00
|
|
|
|
2019-08-06 13:44:30 -07:00
|
|
|
if (result != ISC_R_SUCCESS) {
|
2002-06-17 04:01:37 +00:00
|
|
|
return (result);
|
2019-08-06 13:44:30 -07:00
|
|
|
}
|
2000-04-14 02:30:12 +00:00
|
|
|
|
2004-01-14 02:06:51 +00:00
|
|
|
/*
|
2005-11-03 00:51:55 +00:00
|
|
|
* Do we only need to check for NOQNAME? To get here we must have
|
|
|
|
* had a secure wildcard answer.
|
2004-01-14 02:06:51 +00:00
|
|
|
*/
|
2010-05-14 00:13:43 +00:00
|
|
|
if (!NEEDNODATA(val) && !NEEDNOWILDCARD(val) && NEEDNOQNAME(val)) {
|
2019-08-06 13:44:30 -07:00
|
|
|
if (!FOUNDNOQNAME(val)) {
|
2008-09-24 02:46:23 +00:00
|
|
|
findnsec3proofs(val);
|
2019-08-06 13:44:30 -07:00
|
|
|
}
|
2019-08-06 23:08:36 -07:00
|
|
|
|
2014-09-05 12:10:55 +10:00
|
|
|
if (FOUNDNOQNAME(val) && FOUNDCLOSEST(val) &&
|
2019-08-06 23:08:36 -07:00
|
|
|
!FOUNDOPTOUT(val))
|
|
|
|
{
|
2004-01-14 02:06:51 +00:00
|
|
|
validator_log(val, ISC_LOG_DEBUG(3),
|
2009-10-28 05:34:21 +00:00
|
|
|
"marking as secure, noqname proof found");
|
2010-02-25 04:39:13 +00:00
|
|
|
marksecure(val->event);
|
2004-01-14 02:06:51 +00:00
|
|
|
return (ISC_R_SUCCESS);
|
2010-05-14 00:13:43 +00:00
|
|
|
} else if (FOUNDOPTOUT(val) &&
|
2019-08-06 16:36:28 -07:00
|
|
|
dns_name_countlabels(dns_fixedname_name(&val->wild)) != 0)
|
2019-08-06 13:44:30 -07:00
|
|
|
{
|
2008-09-24 02:46:23 +00:00
|
|
|
validator_log(val, ISC_LOG_DEBUG(3),
|
|
|
|
"optout proof found");
|
2018-04-17 08:29:14 -07:00
|
|
|
val->event->optout = true;
|
2019-08-07 16:54:05 -07:00
|
|
|
markanswer(val, "validate_nx (1)", NULL);
|
2008-09-24 02:46:23 +00:00
|
|
|
return (ISC_R_SUCCESS);
|
|
|
|
} else if ((val->attributes & VALATTR_FOUNDUNKNOWN) != 0) {
|
|
|
|
validator_log(val, ISC_LOG_DEBUG(3),
|
|
|
|
"unknown NSEC3 hash algorithm found");
|
2019-08-07 16:54:05 -07:00
|
|
|
markanswer(val, "validate_nx (2)", NULL);
|
2008-09-24 02:46:23 +00:00
|
|
|
return (ISC_R_SUCCESS);
|
2004-01-14 02:06:51 +00:00
|
|
|
}
|
2019-08-06 23:08:36 -07:00
|
|
|
|
2004-01-14 02:06:51 +00:00
|
|
|
validator_log(val, ISC_LOG_DEBUG(3),
|
|
|
|
"noqname proof not found");
|
|
|
|
return (DNS_R_NOVALIDNSEC);
|
|
|
|
}
|
|
|
|
|
2019-08-06 13:44:30 -07:00
|
|
|
if (!FOUNDNOQNAME(val) && !FOUNDNODATA(val)) {
|
2008-09-24 02:46:23 +00:00
|
|
|
findnsec3proofs(val);
|
2019-08-06 13:44:30 -07:00
|
|
|
}
|
2008-09-24 02:46:23 +00:00
|
|
|
|
2004-01-14 02:06:51 +00:00
|
|
|
/*
|
|
|
|
* Do we need to check for the wildcard?
|
|
|
|
*/
|
2010-05-14 00:13:43 +00:00
|
|
|
if (FOUNDNOQNAME(val) && FOUNDCLOSEST(val) &&
|
2019-08-06 13:44:30 -07:00
|
|
|
((NEEDNODATA(val) && !FOUNDNODATA(val)) || NEEDNOWILDCARD(val)))
|
|
|
|
{
|
2008-09-24 02:46:23 +00:00
|
|
|
result = checkwildcard(val, dns_rdatatype_nsec, NULL);
|
2019-08-06 13:44:30 -07:00
|
|
|
if (result != ISC_R_SUCCESS) {
|
2004-01-14 02:06:51 +00:00
|
|
|
return (result);
|
2019-08-06 13:44:30 -07:00
|
|
|
}
|
2004-01-14 02:06:51 +00:00
|
|
|
}
|
|
|
|
|
2010-05-14 00:13:43 +00:00
|
|
|
if ((NEEDNODATA(val) && (FOUNDNODATA(val) || FOUNDOPTOUT(val))) ||
|
|
|
|
(NEEDNOQNAME(val) && FOUNDNOQNAME(val) &&
|
|
|
|
NEEDNOWILDCARD(val) && FOUNDNOWILDCARD(val) &&
|
2019-08-06 13:44:30 -07:00
|
|
|
FOUNDCLOSEST(val)))
|
|
|
|
{
|
|
|
|
if ((val->attributes & VALATTR_FOUNDOPTOUT) != 0) {
|
2018-04-17 08:29:14 -07:00
|
|
|
val->event->optout = true;
|
2019-08-06 13:44:30 -07:00
|
|
|
}
|
2001-09-14 20:53:33 +00:00
|
|
|
validator_log(val, ISC_LOG_DEBUG(3),
|
2005-11-03 00:51:55 +00:00
|
|
|
"nonexistence proof(s) found");
|
2019-08-06 13:44:30 -07:00
|
|
|
if (val->event->message == NULL) {
|
2010-05-14 00:13:43 +00:00
|
|
|
marksecure(val->event);
|
2019-08-06 13:44:30 -07:00
|
|
|
} else {
|
2018-04-17 08:29:14 -07:00
|
|
|
val->event->secure = true;
|
2019-08-06 13:44:30 -07:00
|
|
|
}
|
2000-04-13 18:10:07 +00:00
|
|
|
return (ISC_R_SUCCESS);
|
|
|
|
}
|
2005-11-03 00:51:55 +00:00
|
|
|
|
2019-08-06 13:44:30 -07:00
|
|
|
if (val->authfail != 0 && val->authcount == val->authfail) {
|
2010-02-25 04:39:13 +00:00
|
|
|
return (DNS_R_BROKENCHAIN);
|
2019-08-06 13:44:30 -07:00
|
|
|
}
|
2019-08-06 23:08:36 -07:00
|
|
|
|
2005-11-03 00:51:55 +00:00
|
|
|
validator_log(val, ISC_LOG_DEBUG(3),
|
|
|
|
"nonexistence proof(s) not found");
|
2018-04-17 08:29:14 -07:00
|
|
|
return (proveunsecure(val, false, false));
|
2000-04-13 18:10:07 +00:00
|
|
|
}
|
|
|
|
|
2019-08-08 08:35:21 -07:00
|
|
|
/*%
|
|
|
|
* Check that DS rdataset has at least one record with
|
|
|
|
* a supported algorithm and digest.
|
|
|
|
*/
|
2018-04-17 08:29:14 -07:00
|
|
|
static bool
|
2005-08-25 00:56:08 +00:00
|
|
|
check_ds(dns_validator_t *val, dns_name_t *name, dns_rdataset_t *rdataset) {
|
2004-01-14 02:06:51 +00:00
|
|
|
dns_rdata_t dsrdata = DNS_RDATA_INIT;
|
|
|
|
dns_rdata_ds_t ds;
|
|
|
|
isc_result_t result;
|
|
|
|
|
|
|
|
for (result = dns_rdataset_first(rdataset);
|
|
|
|
result == ISC_R_SUCCESS;
|
2019-08-06 13:44:30 -07:00
|
|
|
result = dns_rdataset_next(rdataset))
|
|
|
|
{
|
2004-01-14 02:06:51 +00:00
|
|
|
dns_rdataset_current(rdataset, &dsrdata);
|
2008-01-14 23:24:24 +00:00
|
|
|
result = dns_rdata_tostruct(&dsrdata, &ds, NULL);
|
|
|
|
RUNTIME_CHECK(result == ISC_R_SUCCESS);
|
2004-01-14 02:06:51 +00:00
|
|
|
|
2012-10-03 12:38:43 +10:00
|
|
|
if (dns_resolver_ds_digest_supported(val->view->resolver,
|
|
|
|
name, ds.digest_type) &&
|
2005-03-04 03:53:22 +00:00
|
|
|
dns_resolver_algorithm_supported(val->view->resolver,
|
2019-08-06 13:44:30 -07:00
|
|
|
name, ds.algorithm))
|
|
|
|
{
|
2005-03-04 03:53:22 +00:00
|
|
|
dns_rdata_reset(&dsrdata);
|
2018-04-17 08:29:14 -07:00
|
|
|
return (true);
|
2005-03-04 03:53:22 +00:00
|
|
|
}
|
2004-01-14 02:06:51 +00:00
|
|
|
dns_rdata_reset(&dsrdata);
|
|
|
|
}
|
2018-04-17 08:29:14 -07:00
|
|
|
return (false);
|
2004-01-14 02:06:51 +00:00
|
|
|
}
|
|
|
|
|
2005-11-03 00:51:55 +00:00
|
|
|
/*%
|
2019-08-06 16:11:22 -07:00
|
|
|
* seek_ds looks for DS rrsets at the label indicated by val->labels,
|
|
|
|
* for an insecurity proof.
|
|
|
|
*
|
|
|
|
* Returns:
|
|
|
|
* \li ISC_R_COMPLETE a result has been determined and copied
|
|
|
|
* into `*resp`; ISC_R_SUCCESS indicates that
|
|
|
|
* the name has been proven insecure and any
|
|
|
|
* other result indicates failure.
|
|
|
|
* \li DNS_R_CONTINUE result is indeterminate; caller should
|
|
|
|
* continue walking down labels.
|
|
|
|
*/
|
|
|
|
static isc_result_t
|
|
|
|
seek_ds(dns_validator_t *val, isc_result_t *resp) {
|
|
|
|
isc_result_t result;
|
|
|
|
char namebuf[DNS_NAME_FORMATSIZE];
|
|
|
|
dns_fixedname_t fixedfound;
|
|
|
|
dns_name_t *found = dns_fixedname_initname(&fixedfound);
|
|
|
|
dns_name_t *tname = dns_fixedname_initname(&val->fname);
|
|
|
|
|
|
|
|
if (val->labels == dns_name_countlabels(val->event->name)) {
|
|
|
|
dns_name_copynf(val->event->name, tname);
|
|
|
|
} else {
|
|
|
|
dns_name_split(val->event->name, val->labels, NULL, tname);
|
|
|
|
}
|
|
|
|
|
|
|
|
dns_name_format(tname, namebuf, sizeof(namebuf));
|
|
|
|
validator_log(val, ISC_LOG_DEBUG(3),
|
|
|
|
"checking existence of DS at '%s'", namebuf);
|
|
|
|
|
|
|
|
result = view_find(val, tname, dns_rdatatype_ds);
|
|
|
|
switch (result) {
|
2019-08-08 08:35:21 -07:00
|
|
|
case ISC_R_SUCCESS:
|
|
|
|
/*
|
|
|
|
* There is a DS here. Verify that it's secure and
|
|
|
|
* continue walking down labels.
|
|
|
|
*/
|
|
|
|
if (val->frdataset.trust >= dns_trust_secure) {
|
|
|
|
if (!check_ds(val, tname, &val->frdataset)) {
|
|
|
|
validator_log(val, ISC_LOG_DEBUG(3),
|
|
|
|
"no supported algorithm/"
|
|
|
|
"digest (%s/DS)",
|
|
|
|
namebuf);
|
|
|
|
*resp = markanswer(val, "proveunsecure (5)",
|
|
|
|
"no supported "
|
|
|
|
"algorithm/digest (DS)");
|
|
|
|
return (ISC_R_COMPLETE);
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!dns_rdataset_isassociated(&val->fsigrdataset)) {
|
|
|
|
validator_log(val, ISC_LOG_DEBUG(3), "DS is unsigned");
|
|
|
|
*resp = DNS_R_NOVALIDSIG;
|
|
|
|
} else {
|
|
|
|
/*
|
|
|
|
* Validate / re-validate answer.
|
|
|
|
*/
|
|
|
|
result = create_validator(val, tname,
|
|
|
|
dns_rdatatype_ds,
|
|
|
|
&val->frdataset,
|
|
|
|
&val->fsigrdataset,
|
2019-08-16 12:28:22 -07:00
|
|
|
validator_callback_ds,
|
2019-08-08 08:35:21 -07:00
|
|
|
"proveunsecure");
|
|
|
|
*resp = DNS_R_WAIT;
|
|
|
|
if (result != ISC_R_SUCCESS) {
|
|
|
|
*resp = result;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return (ISC_R_COMPLETE);
|
|
|
|
|
|
|
|
case ISC_R_NOTFOUND:
|
|
|
|
/*
|
|
|
|
* We don't know anything about the DS. Find it.
|
|
|
|
*/
|
|
|
|
*resp = DNS_R_WAIT;
|
|
|
|
result = create_fetch(val, tname, dns_rdatatype_ds,
|
2019-08-16 12:28:22 -07:00
|
|
|
fetch_callback_ds, "proveunsecure");
|
2019-08-08 08:35:21 -07:00
|
|
|
if (result != ISC_R_SUCCESS) {
|
|
|
|
*resp = result;
|
|
|
|
}
|
|
|
|
return (ISC_R_COMPLETE);
|
|
|
|
|
2019-08-06 16:11:22 -07:00
|
|
|
case DNS_R_NXRRSET:
|
|
|
|
case DNS_R_NCACHENXRRSET:
|
|
|
|
/*
|
|
|
|
* There is no DS. If this is a delegation,
|
|
|
|
* we may be done.
|
|
|
|
*
|
|
|
|
* If we have "trust == answer" then this namespace
|
|
|
|
* has switched from insecure to should be secure.
|
|
|
|
*/
|
|
|
|
if (DNS_TRUST_PENDING(val->frdataset.trust) ||
|
|
|
|
DNS_TRUST_ANSWER(val->frdataset.trust))
|
|
|
|
{
|
|
|
|
result = create_validator(val, tname,
|
|
|
|
dns_rdatatype_ds,
|
2019-08-16 12:28:22 -07:00
|
|
|
&val->frdataset, NULL,
|
|
|
|
validator_callback_ds,
|
2019-08-06 16:11:22 -07:00
|
|
|
"proveunsecure");
|
|
|
|
*resp = DNS_R_WAIT;
|
|
|
|
if (result != ISC_R_SUCCESS) {
|
|
|
|
*resp = result;
|
|
|
|
}
|
|
|
|
return (ISC_R_COMPLETE);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Zones using NSEC3 don't return a NSEC RRset so
|
|
|
|
* we need to use dns_view_findzonecut2 to find
|
|
|
|
* the zone cut.
|
|
|
|
*/
|
|
|
|
if (result == DNS_R_NXRRSET &&
|
|
|
|
!dns_rdataset_isassociated(&val->frdataset) &&
|
|
|
|
dns_view_findzonecut(val->view, tname, found, NULL,
|
|
|
|
0, 0, false, false,
|
|
|
|
NULL, NULL) == ISC_R_SUCCESS &&
|
|
|
|
dns_name_equal(tname, found))
|
|
|
|
{
|
2019-08-06 16:36:28 -07:00
|
|
|
*resp = markanswer(val, "proveunsecure (3)",
|
|
|
|
"no DS at zone cut");
|
2019-08-06 16:11:22 -07:00
|
|
|
return (ISC_R_COMPLETE);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (val->frdataset.trust < dns_trust_secure) {
|
|
|
|
/*
|
|
|
|
* This shouldn't happen, since the negative
|
|
|
|
* response should have been validated. Since
|
|
|
|
* there's no way of validating existing
|
|
|
|
* negative response blobs, give up.
|
|
|
|
*/
|
|
|
|
validator_log(val, ISC_LOG_WARNING,
|
|
|
|
"can't validate existing "
|
|
|
|
"negative responses (no DS)");
|
|
|
|
*resp = DNS_R_MUSTBESECURE;
|
|
|
|
return (ISC_R_COMPLETE);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (isdelegation(tname, &val->frdataset, result)) {
|
2019-08-06 16:36:28 -07:00
|
|
|
*resp = markanswer(val, "proveunsecure (4)",
|
|
|
|
"this is a delegation");
|
2019-08-06 16:11:22 -07:00
|
|
|
return (ISC_R_COMPLETE);
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case DNS_R_NXDOMAIN:
|
|
|
|
case DNS_R_NCACHENXDOMAIN:
|
|
|
|
/*
|
|
|
|
* This is not a zone cut. Assuming things are
|
|
|
|
* as expected, continue.
|
|
|
|
*/
|
|
|
|
if (!dns_rdataset_isassociated(&val->frdataset)) {
|
|
|
|
/*
|
|
|
|
* There should be an NSEC here, since we
|
|
|
|
* are still in a secure zone.
|
|
|
|
*/
|
|
|
|
*resp = DNS_R_NOVALIDNSEC;
|
|
|
|
return (ISC_R_COMPLETE);
|
|
|
|
} else if (DNS_TRUST_PENDING(val->frdataset.trust) ||
|
|
|
|
DNS_TRUST_ANSWER(val->frdataset.trust))
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
* If we have "trust == answer" then this
|
|
|
|
* namespace has switched from insecure to
|
|
|
|
* should be secure.
|
|
|
|
*/
|
|
|
|
*resp = DNS_R_WAIT;
|
|
|
|
result = create_validator(val, tname,
|
|
|
|
dns_rdatatype_ds,
|
2019-08-16 12:28:22 -07:00
|
|
|
&val->frdataset, NULL,
|
|
|
|
validator_callback_ds,
|
2019-08-06 16:11:22 -07:00
|
|
|
"proveunsecure");
|
|
|
|
if (result != ISC_R_SUCCESS) {
|
|
|
|
*resp = result;
|
|
|
|
}
|
|
|
|
return (ISC_R_COMPLETE);
|
|
|
|
} else if (val->frdataset.trust < dns_trust_secure) {
|
|
|
|
/*
|
|
|
|
* This shouldn't happen, since the negative
|
|
|
|
* response should have been validated. Since
|
|
|
|
* there's no way of validating existing
|
|
|
|
* negative response blobs, give up.
|
|
|
|
*/
|
|
|
|
validator_log(val, ISC_LOG_WARNING,
|
|
|
|
"can't validate existing "
|
|
|
|
"negative responses "
|
|
|
|
"(not a zone cut)");
|
|
|
|
*resp = DNS_R_NOVALIDSIG;
|
|
|
|
return (ISC_R_COMPLETE);
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
2019-08-08 08:35:21 -07:00
|
|
|
case DNS_R_CNAME:
|
|
|
|
if (DNS_TRUST_PENDING(val->frdataset.trust) ||
|
|
|
|
DNS_TRUST_ANSWER(val->frdataset.trust))
|
|
|
|
{
|
|
|
|
result = create_validator(val, tname,
|
|
|
|
dns_rdatatype_cname,
|
2019-08-16 12:28:22 -07:00
|
|
|
&val->frdataset, NULL,
|
|
|
|
validator_callback_cname,
|
2019-08-08 08:35:21 -07:00
|
|
|
"proveunsecure "
|
|
|
|
"(cname)");
|
|
|
|
*resp = DNS_R_WAIT;
|
|
|
|
if (result != ISC_R_SUCCESS) {
|
|
|
|
*resp = result;
|
|
|
|
}
|
|
|
|
return (ISC_R_COMPLETE);
|
2019-08-06 16:11:22 -07:00
|
|
|
}
|
2019-08-08 08:35:21 -07:00
|
|
|
|
|
|
|
break;
|
2019-08-06 16:11:22 -07:00
|
|
|
|
|
|
|
default:
|
|
|
|
*resp = result;
|
|
|
|
return (ISC_R_COMPLETE);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* No definite answer yet; continue walking down labels.
|
|
|
|
*/
|
|
|
|
return (DNS_R_CONTINUE);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*%
|
|
|
|
* proveunsecure walks down, label by label, from the closest enclosing
|
|
|
|
* trust anchor to the name that is being validated, looking for an
|
|
|
|
* endpoint in the chain of trust. That occurs when we can prove that
|
|
|
|
* a DS record does not exist at a delegation point, or that a DS exists
|
|
|
|
* at a delegation point but we don't support its algorithm/digest. If
|
|
|
|
* no such endpoint is found, then the response should have been secure.
|
2005-11-03 00:51:55 +00:00
|
|
|
*
|
|
|
|
* Returns:
|
2019-08-07 16:54:05 -07:00
|
|
|
* \li ISC_R_SUCCESS val->event->name is in an unsecure zone
|
2005-11-03 00:51:55 +00:00
|
|
|
* \li DNS_R_WAIT validation is in progress.
|
|
|
|
* \li DNS_R_MUSTBESECURE val->event->name is supposed to be secure
|
|
|
|
* (policy) but we proved that it is unsecure.
|
|
|
|
* \li DNS_R_NOVALIDSIG
|
|
|
|
* \li DNS_R_NOVALIDNSEC
|
|
|
|
* \li DNS_R_NOTINSECURE
|
2010-02-25 04:39:13 +00:00
|
|
|
* \li DNS_R_BROKENCHAIN
|
2005-08-25 00:56:08 +00:00
|
|
|
*/
|
2002-02-01 20:08:56 +00:00
|
|
|
static isc_result_t
|
2019-08-06 09:28:05 -07:00
|
|
|
proveunsecure(dns_validator_t *val, bool have_ds, bool resume) {
|
2000-04-18 17:50:38 +00:00
|
|
|
isc_result_t result;
|
2005-08-25 00:56:08 +00:00
|
|
|
char namebuf[DNS_NAME_FORMATSIZE];
|
2019-08-06 13:44:30 -07:00
|
|
|
dns_fixedname_t fixedsecroot;
|
|
|
|
dns_name_t *secroot = dns_fixedname_initname(&fixedsecroot);
|
2019-08-06 09:28:05 -07:00
|
|
|
unsigned int labels;
|
2000-04-18 17:50:38 +00:00
|
|
|
|
2019-08-07 17:26:35 -07:00
|
|
|
/*
|
|
|
|
* We're attempting to prove insecurity.
|
|
|
|
*/
|
|
|
|
val->attributes |= VALATTR_INSECURITY;
|
|
|
|
|
2019-09-10 14:42:41 +02:00
|
|
|
dns_name_copynf(val->event->name, secroot);
|
2019-08-06 13:44:30 -07:00
|
|
|
|
2019-08-06 09:28:05 -07:00
|
|
|
/*
|
|
|
|
* If this is a response to a DS query, we need to look in
|
|
|
|
* the parent zone for the trust anchor.
|
|
|
|
*/
|
|
|
|
labels = dns_name_countlabels(secroot);
|
2019-08-06 13:44:30 -07:00
|
|
|
if (val->event->type == dns_rdatatype_ds && labels > 1U) {
|
|
|
|
dns_name_getlabelsequence(secroot, 1, labels - 1, secroot);
|
|
|
|
}
|
|
|
|
|
|
|
|
result = dns_keytable_finddeepestmatch(val->keytable, secroot, secroot);
|
2019-08-06 09:28:05 -07:00
|
|
|
if (result == ISC_R_NOTFOUND) {
|
2019-09-04 21:28:34 +10:00
|
|
|
validator_log(val, ISC_LOG_DEBUG(3),
|
|
|
|
"not beneath secure root");
|
2019-08-06 16:36:28 -07:00
|
|
|
return (markanswer(val, "proveunsecure (1)",
|
|
|
|
"not beneath secure root"));
|
2019-08-06 09:28:05 -07:00
|
|
|
} else if (result != ISC_R_SUCCESS) {
|
|
|
|
return (result);
|
2004-05-14 04:45:58 +00:00
|
|
|
}
|
2000-04-18 17:50:38 +00:00
|
|
|
|
2003-10-25 00:31:12 +00:00
|
|
|
if (!resume) {
|
2005-08-25 00:56:08 +00:00
|
|
|
/*
|
2019-08-06 16:11:22 -07:00
|
|
|
* We are looking for interruptions in the chain of trust.
|
|
|
|
* That can only happen *below* the trust anchor, so we
|
|
|
|
* start looking at the next label down.
|
2005-08-25 00:56:08 +00:00
|
|
|
*/
|
|
|
|
val->labels = dns_name_countlabels(secroot) + 1;
|
2003-10-25 00:31:12 +00:00
|
|
|
} else {
|
2001-09-14 20:53:33 +00:00
|
|
|
validator_log(val, ISC_LOG_DEBUG(3), "resuming proveunsecure");
|
2019-08-06 16:11:22 -07:00
|
|
|
|
2008-02-18 23:06:54 +00:00
|
|
|
/*
|
2019-08-06 16:11:22 -07:00
|
|
|
* If we have a DS rdataset and it is secure, check whether
|
|
|
|
* it has a supported algorithm combination. If not, this is
|
|
|
|
* an insecure delegation as far as this resolver is concerned.
|
2008-02-18 23:06:54 +00:00
|
|
|
*/
|
|
|
|
if (have_ds && val->frdataset.trust >= dns_trust_secure &&
|
2005-03-04 03:53:22 +00:00
|
|
|
!check_ds(val, dns_fixedname_name(&val->fname),
|
2019-08-06 09:28:05 -07:00
|
|
|
&val->frdataset))
|
|
|
|
{
|
2005-08-25 00:56:08 +00:00
|
|
|
dns_name_format(dns_fixedname_name(&val->fname),
|
|
|
|
namebuf, sizeof(namebuf));
|
2004-01-14 02:06:51 +00:00
|
|
|
validator_log(val, ISC_LOG_DEBUG(3),
|
2005-08-25 00:56:08 +00:00
|
|
|
"no supported algorithm/digest (%s/DS)",
|
|
|
|
namebuf);
|
2019-08-06 16:36:28 -07:00
|
|
|
result = markanswer(val, "proveunsecure (2)", namebuf);
|
2019-08-06 09:28:05 -07:00
|
|
|
goto out;
|
2004-01-14 02:06:51 +00:00
|
|
|
}
|
2000-04-18 17:50:38 +00:00
|
|
|
val->labels++;
|
2000-05-17 18:24:59 +00:00
|
|
|
}
|
|
|
|
|
2019-08-06 16:11:22 -07:00
|
|
|
/*
|
|
|
|
* Walk down through each of the remaining labels in the name,
|
|
|
|
* looking for DS records.
|
|
|
|
*/
|
|
|
|
while (val->labels <= dns_name_countlabels(val->event->name)) {
|
|
|
|
isc_result_t tresult;
|
2000-06-22 21:14:48 +00:00
|
|
|
|
2019-08-06 16:11:22 -07:00
|
|
|
result = seek_ds(val, &tresult);
|
|
|
|
if (result == ISC_R_COMPLETE) {
|
|
|
|
result = tresult;
|
|
|
|
goto out;
|
2019-08-06 13:44:30 -07:00
|
|
|
}
|
2019-08-06 16:11:22 -07:00
|
|
|
|
|
|
|
INSIST(result == DNS_R_CONTINUE);
|
|
|
|
val->labels++;
|
2000-04-18 17:50:38 +00:00
|
|
|
}
|
2008-09-24 02:46:23 +00:00
|
|
|
|
2019-08-06 16:11:22 -07:00
|
|
|
/* Couldn't complete insecurity proof. */
|
|
|
|
validator_log(val, ISC_LOG_DEBUG(3),
|
|
|
|
"insecurity proof failed: %s",
|
|
|
|
isc_result_totext(result));
|
2009-03-01 02:45:38 +00:00
|
|
|
return (DNS_R_NOTINSECURE);
|
2000-05-26 21:45:53 +00:00
|
|
|
|
|
|
|
out:
|
2019-08-06 16:11:22 -07:00
|
|
|
if (result != DNS_R_WAIT) {
|
|
|
|
disassociate_rdatasets(val);
|
|
|
|
}
|
2000-05-26 21:45:53 +00:00
|
|
|
return (result);
|
2000-04-18 17:50:38 +00:00
|
|
|
}
|
|
|
|
|
2005-11-03 00:51:55 +00:00
|
|
|
/*%
|
|
|
|
* Start the validation process.
|
|
|
|
*
|
2009-01-17 15:12:26 +00:00
|
|
|
* Attempt to validate the answer based on the category it appears to
|
2005-11-03 00:51:55 +00:00
|
|
|
* fall in.
|
|
|
|
* \li 1. secure positive answer.
|
|
|
|
* \li 2. unsecure positive answer.
|
|
|
|
* \li 3. a negative answer (secure or unsecure).
|
|
|
|
*
|
2019-08-07 16:54:05 -07:00
|
|
|
* Note an answer that appears to be a secure positive answer may actually
|
2009-03-01 02:45:38 +00:00
|
|
|
* be an unsecure positive answer.
|
2005-11-03 00:51:55 +00:00
|
|
|
*/
|
2000-04-07 17:36:40 +00:00
|
|
|
static void
|
|
|
|
validator_start(isc_task_t *task, isc_event_t *event) {
|
|
|
|
dns_validator_t *val;
|
|
|
|
dns_validatorevent_t *vevent;
|
2018-04-17 08:29:14 -07:00
|
|
|
bool want_destroy = false;
|
2000-05-18 02:02:05 +00:00
|
|
|
isc_result_t result = ISC_R_FAILURE;
|
2000-03-17 00:01:28 +00:00
|
|
|
|
2000-04-07 17:36:40 +00:00
|
|
|
UNUSED(task);
|
2000-04-17 19:22:44 +00:00
|
|
|
REQUIRE(event->ev_type == DNS_EVENT_VALIDATORSTART);
|
2000-05-26 17:46:16 +00:00
|
|
|
vevent = (dns_validatorevent_t *)event;
|
2000-04-07 17:36:40 +00:00
|
|
|
val = vevent->validator;
|
|
|
|
|
2009-01-17 15:12:26 +00:00
|
|
|
/* If the validator has been canceled, val->event == NULL */
|
2019-08-06 13:44:30 -07:00
|
|
|
if (val->event == NULL) {
|
2000-08-15 00:21:05 +00:00
|
|
|
return;
|
2019-08-06 13:44:30 -07:00
|
|
|
}
|
2000-08-15 00:21:05 +00:00
|
|
|
|
2019-08-06 09:28:05 -07:00
|
|
|
validator_log(val, ISC_LOG_DEBUG(3), "starting");
|
2000-08-01 01:33:37 +00:00
|
|
|
|
2000-03-17 00:01:28 +00:00
|
|
|
LOCK(&val->lock);
|
|
|
|
|
2019-08-06 09:28:05 -07:00
|
|
|
if (val->event->rdataset != NULL && val->event->sigrdataset != NULL) {
|
2000-07-25 01:24:18 +00:00
|
|
|
isc_result_t saved_result;
|
|
|
|
|
2000-03-17 00:01:28 +00:00
|
|
|
/*
|
|
|
|
* This looks like a simple validation. We say "looks like"
|
2002-02-01 20:08:56 +00:00
|
|
|
* because it might end up requiring an insecurity proof.
|
2000-03-17 00:01:28 +00:00
|
|
|
*/
|
2001-09-14 20:53:33 +00:00
|
|
|
validator_log(val, ISC_LOG_DEBUG(3),
|
2000-05-17 18:24:59 +00:00
|
|
|
"attempting positive response validation");
|
2000-08-01 01:33:37 +00:00
|
|
|
|
2002-06-17 04:01:37 +00:00
|
|
|
INSIST(dns_rdataset_isassociated(val->event->rdataset));
|
|
|
|
INSIST(dns_rdataset_isassociated(val->event->sigrdataset));
|
|
|
|
result = start_positive_validation(val);
|
2000-07-13 23:52:04 +00:00
|
|
|
if (result == DNS_R_NOVALIDSIG &&
|
|
|
|
(val->attributes & VALATTR_TRIEDVERIFY) == 0)
|
|
|
|
{
|
2000-07-25 01:24:18 +00:00
|
|
|
saved_result = result;
|
2001-09-14 20:53:33 +00:00
|
|
|
validator_log(val, ISC_LOG_DEBUG(3),
|
2000-07-13 23:52:04 +00:00
|
|
|
"falling back to insecurity proof");
|
2018-04-17 08:29:14 -07:00
|
|
|
result = proveunsecure(val, false, false);
|
2019-08-06 13:44:30 -07:00
|
|
|
if (result == DNS_R_NOTINSECURE) {
|
2000-07-25 01:24:18 +00:00
|
|
|
result = saved_result;
|
2019-08-06 13:44:30 -07:00
|
|
|
}
|
2000-07-13 23:52:04 +00:00
|
|
|
}
|
2010-05-14 00:13:43 +00:00
|
|
|
} else if (val->event->rdataset != NULL &&
|
2019-08-06 13:44:30 -07:00
|
|
|
val->event->rdataset->type != 0)
|
|
|
|
{
|
2000-04-18 17:50:38 +00:00
|
|
|
/*
|
2001-09-14 20:53:33 +00:00
|
|
|
* This is either an unsecure subdomain or a response from
|
|
|
|
* a broken server.
|
2000-04-18 17:50:38 +00:00
|
|
|
*/
|
2002-06-17 04:01:37 +00:00
|
|
|
INSIST(dns_rdataset_isassociated(val->event->rdataset));
|
2001-09-14 20:53:33 +00:00
|
|
|
validator_log(val, ISC_LOG_DEBUG(3),
|
2000-05-17 18:24:59 +00:00
|
|
|
"attempting insecurity proof");
|
2000-08-01 01:33:37 +00:00
|
|
|
|
2018-04-17 08:29:14 -07:00
|
|
|
result = proveunsecure(val, false, false);
|
2019-08-06 13:44:30 -07:00
|
|
|
if (result == DNS_R_NOTINSECURE) {
|
2009-03-01 02:45:38 +00:00
|
|
|
validator_log(val, ISC_LOG_INFO,
|
|
|
|
"got insecure response; "
|
2009-03-23 22:30:57 +00:00
|
|
|
"parent indicates it should be secure");
|
2019-08-06 13:44:30 -07:00
|
|
|
}
|
2019-08-06 13:13:38 -07:00
|
|
|
} else if ((val->event->rdataset == NULL &&
|
|
|
|
val->event->sigrdataset == NULL) ||
|
|
|
|
(val->event->rdataset != NULL &&
|
|
|
|
NEGATIVE(val->event->rdataset)))
|
2000-08-01 01:33:37 +00:00
|
|
|
|
2010-05-14 00:13:43 +00:00
|
|
|
{
|
|
|
|
/*
|
|
|
|
* This is a nonexistence validation.
|
|
|
|
*/
|
|
|
|
validator_log(val, ISC_LOG_DEBUG(3),
|
|
|
|
"attempting negative response validation");
|
|
|
|
|
2019-08-06 13:13:38 -07:00
|
|
|
if (val->event->message->rcode == dns_rcode_nxdomain) {
|
2010-05-14 00:13:43 +00:00
|
|
|
val->attributes |= VALATTR_NEEDNOQNAME;
|
2004-01-14 02:06:51 +00:00
|
|
|
val->attributes |= VALATTR_NEEDNOWILDCARD;
|
2019-08-06 13:44:30 -07:00
|
|
|
} else {
|
2004-01-14 02:06:51 +00:00
|
|
|
val->attributes |= VALATTR_NEEDNODATA;
|
2019-08-06 13:44:30 -07:00
|
|
|
}
|
2019-08-07 16:54:05 -07:00
|
|
|
result = validate_nx(val, false);
|
2000-04-18 17:50:38 +00:00
|
|
|
} else {
|
|
|
|
INSIST(0);
|
2018-11-07 15:00:07 +07:00
|
|
|
ISC_UNREACHABLE();
|
2000-03-17 00:01:28 +00:00
|
|
|
}
|
|
|
|
|
2002-06-17 04:01:37 +00:00
|
|
|
if (result != DNS_R_WAIT) {
|
|
|
|
want_destroy = exit_check(val);
|
2000-03-17 00:01:28 +00:00
|
|
|
validator_done(val, result);
|
2002-06-17 04:01:37 +00:00
|
|
|
}
|
2000-03-17 00:01:28 +00:00
|
|
|
|
|
|
|
UNLOCK(&val->lock);
|
2019-08-06 13:44:30 -07:00
|
|
|
if (want_destroy) {
|
2002-06-17 04:01:37 +00:00
|
|
|
destroy(val);
|
2019-08-06 13:44:30 -07:00
|
|
|
}
|
2000-03-17 00:01:28 +00:00
|
|
|
}
|
|
|
|
|
2000-02-23 23:31:33 +00:00
|
|
|
isc_result_t
|
2000-04-20 20:43:52 +00:00
|
|
|
dns_validator_create(dns_view_t *view, dns_name_t *name, dns_rdatatype_t type,
|
2000-02-23 23:31:33 +00:00
|
|
|
dns_rdataset_t *rdataset, dns_rdataset_t *sigrdataset,
|
|
|
|
dns_message_t *message, unsigned int options,
|
|
|
|
isc_task_t *task, isc_taskaction_t action, void *arg,
|
|
|
|
dns_validator_t **validatorp)
|
|
|
|
{
|
2011-03-11 06:11:27 +00:00
|
|
|
isc_result_t result = ISC_R_FAILURE;
|
2000-02-24 22:40:55 +00:00
|
|
|
dns_validator_t *val;
|
2011-03-11 06:11:27 +00:00
|
|
|
isc_task_t *tclone = NULL;
|
2000-02-24 22:40:55 +00:00
|
|
|
dns_validatorevent_t *event;
|
|
|
|
|
2000-04-20 20:43:52 +00:00
|
|
|
REQUIRE(name != NULL);
|
|
|
|
REQUIRE(rdataset != NULL ||
|
|
|
|
(rdataset == NULL && sigrdataset == NULL && message != NULL));
|
2000-02-23 23:31:33 +00:00
|
|
|
REQUIRE(validatorp != NULL && *validatorp == NULL);
|
|
|
|
|
2001-11-12 19:05:39 +00:00
|
|
|
val = isc_mem_get(view->mctx, sizeof(*val));
|
2000-03-23 20:24:28 +00:00
|
|
|
val->view = NULL;
|
2013-06-04 11:27:26 +10:00
|
|
|
dns_view_weakattach(view, &val->view);
|
2009-10-27 22:46:13 +00:00
|
|
|
|
2000-02-24 22:40:55 +00:00
|
|
|
event = (dns_validatorevent_t *)
|
2000-04-07 17:36:40 +00:00
|
|
|
isc_event_allocate(view->mctx, task,
|
|
|
|
DNS_EVENT_VALIDATORSTART,
|
|
|
|
validator_start, NULL,
|
2001-11-12 19:05:39 +00:00
|
|
|
sizeof(dns_validatorevent_t));
|
2019-08-06 16:11:22 -07:00
|
|
|
|
2000-02-24 22:40:55 +00:00
|
|
|
isc_task_attach(task, &tclone);
|
|
|
|
event->validator = val;
|
|
|
|
event->result = ISC_R_FAILURE;
|
|
|
|
event->name = name;
|
2000-04-20 20:43:52 +00:00
|
|
|
event->type = type;
|
2000-02-24 22:40:55 +00:00
|
|
|
event->rdataset = rdataset;
|
|
|
|
event->sigrdataset = sigrdataset;
|
|
|
|
event->message = message;
|
2004-01-14 02:06:51 +00:00
|
|
|
memset(event->proofs, 0, sizeof(event->proofs));
|
2018-04-17 08:29:14 -07:00
|
|
|
event->optout = false;
|
|
|
|
event->secure = false;
|
2018-11-16 15:33:22 +01:00
|
|
|
|
|
|
|
isc_mutex_init(&val->lock);
|
|
|
|
|
2000-02-24 22:40:55 +00:00
|
|
|
val->event = event;
|
|
|
|
val->options = options;
|
|
|
|
val->attributes = 0;
|
2000-03-17 00:01:28 +00:00
|
|
|
val->fetch = NULL;
|
2002-06-17 04:01:37 +00:00
|
|
|
val->subvalidator = NULL;
|
|
|
|
val->parent = NULL;
|
2009-10-27 22:46:13 +00:00
|
|
|
|
2002-02-01 20:08:56 +00:00
|
|
|
val->keytable = NULL;
|
2009-10-27 22:46:13 +00:00
|
|
|
result = dns_view_getsecroots(val->view, &val->keytable);
|
2019-08-06 13:44:30 -07:00
|
|
|
if (result != ISC_R_SUCCESS) {
|
2019-08-06 16:11:22 -07:00
|
|
|
goto cleanup;
|
2019-08-06 13:44:30 -07:00
|
|
|
}
|
2000-03-17 00:01:28 +00:00
|
|
|
val->keynode = NULL;
|
2000-04-07 21:44:47 +00:00
|
|
|
val->key = NULL;
|
2000-04-14 16:00:33 +00:00
|
|
|
val->siginfo = NULL;
|
2000-04-07 21:44:47 +00:00
|
|
|
val->task = task;
|
2000-04-07 17:36:40 +00:00
|
|
|
val->action = action;
|
|
|
|
val->arg = arg;
|
2000-04-18 17:50:38 +00:00
|
|
|
val->labels = 0;
|
2000-05-17 18:24:59 +00:00
|
|
|
val->currentset = NULL;
|
2000-05-22 21:17:05 +00:00
|
|
|
val->keyset = NULL;
|
2002-06-17 04:01:37 +00:00
|
|
|
val->dsset = NULL;
|
2018-04-17 08:29:14 -07:00
|
|
|
val->seensig = false;
|
2005-08-25 00:56:08 +00:00
|
|
|
val->depth = 0;
|
2010-02-25 04:39:13 +00:00
|
|
|
val->authcount = 0;
|
|
|
|
val->authfail = 0;
|
2004-04-15 23:40:27 +00:00
|
|
|
val->mustbesecure = dns_resolver_getmustbesecure(view->resolver, name);
|
2000-05-26 21:45:53 +00:00
|
|
|
dns_rdataset_init(&val->frdataset);
|
|
|
|
dns_rdataset_init(&val->fsigrdataset);
|
2004-01-14 02:06:51 +00:00
|
|
|
dns_fixedname_init(&val->wild);
|
2008-09-24 02:46:23 +00:00
|
|
|
dns_fixedname_init(&val->nearest);
|
|
|
|
dns_fixedname_init(&val->closest);
|
2014-05-29 22:22:53 -07:00
|
|
|
isc_stdtime_get(&val->start);
|
2000-08-15 00:21:05 +00:00
|
|
|
ISC_LINK_INIT(val, link);
|
2000-02-24 22:40:55 +00:00
|
|
|
val->magic = VALIDATOR_MAGIC;
|
|
|
|
|
2019-08-06 13:44:30 -07:00
|
|
|
if ((options & DNS_VALIDATOR_DEFER) == 0) {
|
2007-01-08 01:13:38 +00:00
|
|
|
isc_task_send(task, ISC_EVENT_PTR(&event));
|
2019-08-06 13:44:30 -07:00
|
|
|
}
|
2000-03-17 00:01:28 +00:00
|
|
|
|
|
|
|
*validatorp = val;
|
|
|
|
|
2000-02-24 22:40:55 +00:00
|
|
|
return (ISC_R_SUCCESS);
|
|
|
|
|
2019-08-06 16:11:22 -07:00
|
|
|
cleanup:
|
2018-11-19 10:31:09 +00:00
|
|
|
isc_mutex_destroy(&val->lock);
|
2013-05-31 12:31:01 +10:00
|
|
|
|
2000-02-24 22:40:55 +00:00
|
|
|
isc_task_detach(&tclone);
|
2005-11-30 05:01:34 +00:00
|
|
|
isc_event_free(ISC_EVENT_PTR(&event));
|
2000-02-24 22:40:55 +00:00
|
|
|
|
2013-06-04 11:27:26 +10:00
|
|
|
dns_view_weakdetach(&val->view);
|
2001-11-12 19:05:39 +00:00
|
|
|
isc_mem_put(view->mctx, val, sizeof(*val));
|
2000-08-01 01:33:37 +00:00
|
|
|
|
2000-02-24 22:40:55 +00:00
|
|
|
return (result);
|
2000-02-23 23:31:33 +00:00
|
|
|
}
|
|
|
|
|
2007-01-08 01:13:38 +00:00
|
|
|
void
|
|
|
|
dns_validator_send(dns_validator_t *validator) {
|
|
|
|
isc_event_t *event;
|
|
|
|
REQUIRE(VALID_VALIDATOR(validator));
|
|
|
|
|
|
|
|
LOCK(&validator->lock);
|
|
|
|
|
|
|
|
INSIST((validator->options & DNS_VALIDATOR_DEFER) != 0);
|
|
|
|
event = (isc_event_t *)validator->event;
|
|
|
|
validator->options &= ~DNS_VALIDATOR_DEFER;
|
|
|
|
UNLOCK(&validator->lock);
|
|
|
|
|
|
|
|
isc_task_send(validator->task, ISC_EVENT_PTR(&event));
|
|
|
|
}
|
|
|
|
|
2000-02-23 23:31:33 +00:00
|
|
|
void
|
|
|
|
dns_validator_cancel(dns_validator_t *validator) {
|
2012-10-23 22:04:06 -07:00
|
|
|
dns_fetch_t *fetch = NULL;
|
|
|
|
|
2000-02-24 22:40:55 +00:00
|
|
|
REQUIRE(VALID_VALIDATOR(validator));
|
|
|
|
|
|
|
|
LOCK(&validator->lock);
|
2000-04-20 18:03:12 +00:00
|
|
|
|
2001-09-14 20:53:33 +00:00
|
|
|
validator_log(validator, ISC_LOG_DEBUG(3), "dns_validator_cancel");
|
2000-08-15 00:21:05 +00:00
|
|
|
|
2010-03-04 22:25:31 +00:00
|
|
|
if ((validator->attributes & VALATTR_CANCELED) == 0) {
|
2007-09-14 05:43:05 +00:00
|
|
|
validator->attributes |= VALATTR_CANCELED;
|
2010-03-04 23:50:34 +00:00
|
|
|
if (validator->event != NULL) {
|
2012-10-23 22:04:06 -07:00
|
|
|
fetch = validator->fetch;
|
|
|
|
validator->fetch = NULL;
|
2010-03-04 22:25:31 +00:00
|
|
|
|
2019-08-06 13:44:30 -07:00
|
|
|
if (validator->subvalidator != NULL) {
|
2010-03-04 22:25:31 +00:00
|
|
|
dns_validator_cancel(validator->subvalidator);
|
2019-08-06 13:44:30 -07:00
|
|
|
}
|
2010-03-04 22:25:31 +00:00
|
|
|
if ((validator->options & DNS_VALIDATOR_DEFER) != 0) {
|
|
|
|
validator->options &= ~DNS_VALIDATOR_DEFER;
|
|
|
|
validator_done(validator, ISC_R_CANCELED);
|
|
|
|
}
|
|
|
|
}
|
2000-02-24 22:40:55 +00:00
|
|
|
}
|
|
|
|
UNLOCK(&validator->lock);
|
2012-10-23 22:04:06 -07:00
|
|
|
|
2012-11-15 11:16:28 +11:00
|
|
|
/* Need to cancel and destroy the fetch outside validator lock */
|
|
|
|
if (fetch != NULL) {
|
2012-10-23 22:04:06 -07:00
|
|
|
dns_resolver_cancelfetch(fetch);
|
2012-11-15 11:16:28 +11:00
|
|
|
dns_resolver_destroyfetch(&fetch);
|
|
|
|
}
|
2000-02-24 22:40:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
destroy(dns_validator_t *val) {
|
2000-03-23 20:33:15 +00:00
|
|
|
isc_mem_t *mctx;
|
2000-02-24 22:40:55 +00:00
|
|
|
|
2000-03-17 00:01:28 +00:00
|
|
|
REQUIRE(SHUTDOWN(val));
|
2000-02-24 22:40:55 +00:00
|
|
|
REQUIRE(val->event == NULL);
|
2000-03-17 00:01:28 +00:00
|
|
|
REQUIRE(val->fetch == NULL);
|
2000-02-24 22:40:55 +00:00
|
|
|
|
2019-08-06 13:44:30 -07:00
|
|
|
if (val->keynode != NULL) {
|
2000-03-17 00:01:28 +00:00
|
|
|
dns_keytable_detachkeynode(val->keytable, &val->keynode);
|
2019-08-06 13:44:30 -07:00
|
|
|
} else if (val->key != NULL) {
|
2000-05-19 00:20:59 +00:00
|
|
|
dst_key_free(&val->key);
|
2019-08-06 13:44:30 -07:00
|
|
|
}
|
|
|
|
if (val->keytable != NULL) {
|
2002-02-01 20:08:56 +00:00
|
|
|
dns_keytable_detach(&val->keytable);
|
2019-08-06 13:44:30 -07:00
|
|
|
}
|
|
|
|
if (val->subvalidator != NULL) {
|
2002-06-17 04:01:37 +00:00
|
|
|
dns_validator_destroy(&val->subvalidator);
|
2019-08-06 13:44:30 -07:00
|
|
|
}
|
2019-08-06 13:13:38 -07:00
|
|
|
disassociate_rdatasets(val);
|
2000-03-23 20:33:15 +00:00
|
|
|
mctx = val->view->mctx;
|
2019-08-06 13:44:30 -07:00
|
|
|
if (val->siginfo != NULL) {
|
2001-11-12 19:05:39 +00:00
|
|
|
isc_mem_put(mctx, val->siginfo, sizeof(*val->siginfo));
|
2019-08-06 13:44:30 -07:00
|
|
|
}
|
2018-11-19 10:31:09 +00:00
|
|
|
isc_mutex_destroy(&val->lock);
|
2013-06-04 11:27:26 +10:00
|
|
|
dns_view_weakdetach(&val->view);
|
2000-03-23 20:33:15 +00:00
|
|
|
val->magic = 0;
|
2001-11-12 19:05:39 +00:00
|
|
|
isc_mem_put(mctx, val, sizeof(*val));
|
2000-02-23 23:31:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
dns_validator_destroy(dns_validator_t **validatorp) {
|
2000-03-17 00:01:28 +00:00
|
|
|
dns_validator_t *val;
|
2018-04-17 08:29:14 -07:00
|
|
|
bool want_destroy = false;
|
2000-03-17 00:01:28 +00:00
|
|
|
|
|
|
|
REQUIRE(validatorp != NULL);
|
|
|
|
val = *validatorp;
|
|
|
|
REQUIRE(VALID_VALIDATOR(val));
|
|
|
|
|
|
|
|
LOCK(&val->lock);
|
|
|
|
|
2002-06-17 04:01:37 +00:00
|
|
|
val->attributes |= VALATTR_SHUTDOWN;
|
2014-02-16 13:03:17 -08:00
|
|
|
validator_log(val, ISC_LOG_DEBUG(4), "dns_validator_destroy");
|
2000-08-15 00:21:05 +00:00
|
|
|
|
2002-06-17 04:01:37 +00:00
|
|
|
want_destroy = exit_check(val);
|
2000-03-17 00:01:28 +00:00
|
|
|
UNLOCK(&val->lock);
|
2019-08-06 13:44:30 -07:00
|
|
|
if (want_destroy) {
|
2000-03-17 00:01:28 +00:00
|
|
|
destroy(val);
|
2019-08-06 13:44:30 -07:00
|
|
|
}
|
2000-03-17 00:01:28 +00:00
|
|
|
|
2000-02-24 22:40:55 +00:00
|
|
|
*validatorp = NULL;
|
2000-02-23 23:31:33 +00:00
|
|
|
}
|
2000-04-11 20:35:37 +00:00
|
|
|
|
|
|
|
static void
|
|
|
|
validator_logv(dns_validator_t *val, isc_logcategory_t *category,
|
2000-08-15 00:21:05 +00:00
|
|
|
isc_logmodule_t *module, int level, const char *fmt, va_list ap)
|
2000-04-11 20:35:37 +00:00
|
|
|
{
|
|
|
|
char msgbuf[2048];
|
2005-08-25 00:56:08 +00:00
|
|
|
static const char spaces[] = " *";
|
|
|
|
int depth = val->depth * 2;
|
2017-08-16 09:29:20 +10:00
|
|
|
const char *viewname, *sep1, *sep2;
|
2000-04-11 20:35:37 +00:00
|
|
|
|
|
|
|
vsnprintf(msgbuf, sizeof(msgbuf), fmt, ap);
|
|
|
|
|
2019-08-06 13:44:30 -07:00
|
|
|
if ((unsigned int) depth >= sizeof spaces) {
|
2005-08-25 00:56:08 +00:00
|
|
|
depth = sizeof spaces - 1;
|
2019-08-06 13:44:30 -07:00
|
|
|
}
|
2005-08-25 00:56:08 +00:00
|
|
|
|
2017-08-16 09:29:20 +10:00
|
|
|
/*
|
|
|
|
* Log the view name unless it's:
|
|
|
|
* * "_default/IN" (which means there's only one view
|
|
|
|
* configured in the server), or
|
|
|
|
* * "_dnsclient/IN" (which means this is being called
|
|
|
|
* from an application using dns/client.c).
|
|
|
|
*/
|
|
|
|
if (val->view->rdclass == dns_rdataclass_in &&
|
|
|
|
(strcmp(val->view->name, "_default") == 0 ||
|
|
|
|
strcmp(val->view->name, DNS_CLIENTVIEW_NAME) == 0))
|
|
|
|
{
|
|
|
|
sep1 = viewname = sep2 = "";
|
|
|
|
} else {
|
|
|
|
sep1 = "view ";
|
|
|
|
viewname = val->view->name;
|
|
|
|
sep2 = ": ";
|
|
|
|
}
|
|
|
|
|
2000-05-17 18:24:59 +00:00
|
|
|
if (val->event != NULL && val->event->name != NULL) {
|
2002-02-01 20:18:33 +00:00
|
|
|
char namebuf[DNS_NAME_FORMATSIZE];
|
|
|
|
char typebuf[DNS_RDATATYPE_FORMATSIZE];
|
2000-08-01 01:33:37 +00:00
|
|
|
|
2000-04-11 20:35:37 +00:00
|
|
|
dns_name_format(val->event->name, namebuf, sizeof(namebuf));
|
2002-02-01 20:18:33 +00:00
|
|
|
dns_rdatatype_format(val->event->type, typebuf,
|
|
|
|
sizeof(typebuf));
|
2000-04-11 20:35:37 +00:00
|
|
|
isc_log_write(dns_lctx, category, module, level,
|
2017-08-16 09:29:20 +10:00
|
|
|
"%s%s%s%.*svalidating %s/%s: %s",
|
|
|
|
sep1, viewname, sep2, depth, spaces,
|
2014-02-16 13:03:17 -08:00
|
|
|
namebuf, typebuf, msgbuf);
|
2000-04-11 20:35:37 +00:00
|
|
|
} else {
|
|
|
|
isc_log_write(dns_lctx, category, module, level,
|
2017-08-16 09:29:20 +10:00
|
|
|
"%s%s%s%.*svalidator @%p: %s",
|
|
|
|
sep1, viewname, sep2, depth, spaces,
|
|
|
|
val, msgbuf);
|
2000-04-11 20:35:37 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2012-12-19 09:55:02 +11:00
|
|
|
validator_log(void *val, int level, const char *fmt, ...) {
|
2000-12-11 19:24:30 +00:00
|
|
|
va_list ap;
|
2000-07-26 00:50:02 +00:00
|
|
|
|
2019-08-06 13:44:30 -07:00
|
|
|
if (!isc_log_wouldlog(dns_lctx, level)) {
|
2000-07-26 00:50:02 +00:00
|
|
|
return;
|
2019-08-06 13:44:30 -07:00
|
|
|
}
|
2000-07-26 00:50:02 +00:00
|
|
|
|
2000-04-11 20:35:37 +00:00
|
|
|
va_start(ap, fmt);
|
2001-09-14 20:53:33 +00:00
|
|
|
|
2000-04-11 20:35:37 +00:00
|
|
|
validator_logv(val, DNS_LOGCATEGORY_DNSSEC,
|
|
|
|
DNS_LOGMODULE_VALIDATOR, level, fmt, ap);
|
|
|
|
va_end(ap);
|
|
|
|
}
|
2002-06-17 04:01:37 +00:00
|
|
|
|
|
|
|
static void
|
2019-08-06 13:44:30 -07:00
|
|
|
validator_logcreate(dns_validator_t *val, dns_name_t *name,
|
|
|
|
dns_rdatatype_t type, const char *caller,
|
|
|
|
const char *operation)
|
2002-06-17 04:01:37 +00:00
|
|
|
{
|
|
|
|
char namestr[DNS_NAME_FORMATSIZE];
|
|
|
|
char typestr[DNS_RDATATYPE_FORMATSIZE];
|
|
|
|
|
|
|
|
dns_name_format(name, namestr, sizeof(namestr));
|
|
|
|
dns_rdatatype_format(type, typestr, sizeof(typestr));
|
|
|
|
validator_log(val, ISC_LOG_DEBUG(9), "%s: creating %s for %s %s",
|
|
|
|
caller, operation, namestr, typestr);
|
|
|
|
}
|