validator.c revision 60ab03125c137c48a6b2ed6df1d2c8657757e09d
/*
* Copyright (C) 2004, 2005 Internet Systems Consortium, Inc. ("ISC")
* Copyright (C) 2000-2003 Internet Software Consortium.
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
* REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
* INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
* LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
* OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*/
/* $Id: validator.c,v 1.135 2005/11/03 00:51:55 marka Exp $ */
/*! \file */
#include <config.h>
#include <dns/keytable.h>
#include <dns/rdatastruct.h>
#include <dns/rdataset.h>
#include <dns/rdatatype.h>
#include <dns/resolver.h>
#include <dns/validator.h>
/*! \file
* \brief
* Basic processing sequences.
*
* \li When called with rdataset and sigrdataset:
* validator_start -> validate -> proveunsecure -> startfinddlvsep ->
* dlv_validator_start -> validator_start -> validate -> proveunsecure
*
* validator_start -> validate -> nsecvalidate (secure wildcard answer)
*
* \li When called with rdataset, sigrdataset and with DNS_VALIDATOR_DLV:
* validator_start -> startfinddlvsep -> dlv_validator_start ->
* validator_start -> validate -> proveunsecure
*
* \li When called with rdataset:
* validator_start -> proveunsecure -> startfinddlvsep ->
* dlv_validator_start -> validator_start -> proveunsecure
*
* \li When called with rdataset and with DNS_VALIDATOR_DLV:
* validator_start -> startfinddlvsep -> dlv_validator_start ->
* validator_start -> proveunsecure
*
* \li When called without a rdataset:
* validator_start -> nsecvalidate -> proveunsecure -> startfinddlvsep ->
* dlv_validator_start -> validator_start -> nsecvalidate -> proveunsecure
*
* \li When called without a rdataset and with DNS_VALIDATOR_DLV:
* validator_start -> startfinddlvsep -> dlv_validator_start ->
* validator_start -> nsecvalidate -> proveunsecure
*
* validator_start: determines what type of validation to do.
* validate: attempts to perform a positive validation.
* proveunsecure: attempts to prove the answer comes from a unsecure zone.
* nsecvalidate: attempts to prove a negative response.
* startfinddlvsep: starts the DLV record lookup.
* dlv_validator_start: resets state and restarts the lookup using the
* DLV RRset found by startfinddlvsep.
*/
* have attempted a verify. */
/*!
* NSEC proofs to be looked for.
*/
#define VALATTR_NEEDNOQNAME 0x0100
#define VALATTR_NEEDNOWILDCARD 0x0200
#define VALATTR_NEEDNODATA 0x0400
/*!
* NSEC proofs that have been found.
*/
#define VALATTR_FOUNDNOQNAME 0x1000
#define VALATTR_FOUNDNOWILDCARD 0x2000
#define VALATTR_FOUNDNODATA 0x4000
static void
static isc_result_t
static isc_result_t
static isc_result_t
static isc_result_t
static isc_result_t
static void
ISC_FORMAT_PRINTF(5, 0);
static void
static void
static isc_result_t
static void
static isc_result_t
static void
static isc_result_t
/*%
* Mark the RRsets as a answer.
*
* If VALATTR_AUTHNONPENDING is set then this is a negative answer
* in a insecure zone. We need to mark any pending RRsets as
* dns_trust_authauthority answers (this is deferred from resolver.c).
*/
static inline void
}
static void
return;
/*
* Caller must be holding the lock.
*/
}
static inline isc_boolean_t
/*
* Caller must be holding the lock.
*/
return (ISC_FALSE);
return (ISC_FALSE);
return (ISC_TRUE);
}
/*%
* Mark pending answers in the authority section as dns_trust_authauthority.
*/
static void
result == ISC_R_SUCCESS;
{
{
}
}
}
/*%
* 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.
*/
static isc_boolean_t
{
if (dbresult == DNS_R_NXRRSET)
else {
if (result != ISC_R_SUCCESS)
return (ISC_FALSE);
}
if (result == ISC_R_SUCCESS) {
}
return (found);
}
/*%
* We have been asked to to look for a key.
* If found resume the validation process.
* If not found fail the validation process.
*/
static void
/* Free resources which are not of interest. */
if (eresult == ISC_R_SUCCESS) {
/*
* Only extract the dst key if the keyset is secure.
*/
if (result == ISC_R_SUCCESS)
}
if (result != DNS_R_WAIT)
} else {
"fetch_callback_validator: got %s",
if (eresult == ISC_R_CANCELED)
else
}
if (want_destroy)
}
/*%
* We were asked to look for a DS record as part of following a key chain
* upwards. If found resume the validation process. If not found fail the
* validation process.
*/
static void
/* Free resources which are not of interest. */
if (eresult == ISC_R_SUCCESS) {
if (result != DNS_R_WAIT)
} else if (eresult == DNS_R_NXRRSET ||
{
"falling back to insecurity proof");
if (result != DNS_R_WAIT)
} else {
"dsfetched: got %s",
if (eresult == ISC_R_CANCELED)
else
}
if (want_destroy)
}
/*%
* We were asked to look for the DS record as part of proving that a
* name is unsecure.
*
* If the DS record doesn't exist and the query name corresponds to
* a delegation point we are transitioning from a secure zone to a
* unsecure zone.
*
* If the DS record exists it will be secure. We can continue looking
* for the break point in the chain of trust.
*/
static void
/* Free resources which are not of interest. */
/*
* There is no DS. If this is a delegation, we're done.
*/
if (val->mustbesecure) {
"must be secure failure");
} else {
if (result != DNS_R_WAIT)
}
} else {
if (result != DNS_R_WAIT)
}
} else if (eresult == ISC_R_SUCCESS ||
eresult == DNS_R_NXDOMAIN ||
{
/*
* There is a DS which may or may not be a zone cut.
* In either case we are still in a secure zone resume
* validation.
*/
if (result != DNS_R_WAIT)
} else {
if (eresult == ISC_R_CANCELED)
else
}
if (want_destroy)
}
/*%
* Callback from when a DNSKEY RRset has been validated.
*
* Resumes the stalled validation process.
*/
static void
if (eresult == ISC_R_SUCCESS) {
/*
* Only extract the dst key if the keyset is secure.
*/
if (result != DNS_R_WAIT)
} else {
"keyvalidated: got %s",
}
if (want_destroy)
}
/*%
* Callback when the DS record has been validated.
*
* Resumes validation of the zone key or the unsecure zone proof.
*/
static void
if (eresult == ISC_R_SUCCESS) {
else
if (result != DNS_R_WAIT)
} else {
"dsvalidated: got %s",
}
if (want_destroy)
}
/*%
* Return ISC_R_SUCCESS if we can determine that the name doesn't exist
* or we can determine whether there is data or not at the name.
* If the name does not exist return the wildcard name.
*
* Return ISC_R_IGNORE when the NSEC is not the appropriate one.
*/
static isc_result_t
{
int order;
if (result != ISC_R_SUCCESS) {
"failure processing NSEC set");
return (result);
}
if (order < 0) {
/*
* The name is not within the NSEC range.
*/
"NSEC does not cover name, before NSEC");
return (ISC_R_IGNORE);
}
if (order == 0) {
/*
* The names are the same.
*/
{
if (!atparent) {
/*
* This NSEC record is from somewhere higher in
* the DNS, and at the parent of a delegation.
* It can not be legitimately used here.
*/
"ignoring parent nsec");
return (ISC_R_IGNORE);
}
} else if (atparent) {
/*
* This NSEC record is from the child.
* It can not be legitimately used here.
*/
"ignoring child nsec");
return (ISC_R_IGNORE);
}
"nsec proves name exists (owner) data=%d",
*data);
return (ISC_R_SUCCESS);
}
if (relation == dns_namereln_subdomain &&
{
/*
* This NSEC record is from somewhere higher in
* the DNS, and at the parent of a delegation.
* It can not be legitimately used here.
*/
return (ISC_R_IGNORE);
}
if (result != ISC_R_SUCCESS)
return (result);
if (order == 0) {
"ignoring nsec matches next name");
return (ISC_R_IGNORE);
}
/*
* The name is not within the NSEC range.
*/
"ignoring nsec because name is past end of range");
return (ISC_R_IGNORE);
}
"nsec proves name exist (empty)");
return (ISC_R_SUCCESS);
}
} else {
}
if (result != ISC_R_SUCCESS) {
"failure generating wilcard name");
return (result);
}
}
return (ISC_R_SUCCESS);
}
/*%
* Callback for when NSEC records have been validated.
*
* Looks for NOQNAME and NODATA proofs.
*
* Resumes nsecvalidate.
*/
static void
if (result != ISC_R_SUCCESS) {
"authvalidated: got %s",
if (result == ISC_R_CANCELED)
else {
if (result != DNS_R_WAIT)
}
} else {
== ISC_R_SUCCESS)
{
if (NEEDNODATA(val))
}
if (!exists) {
if (NEEDNOQNAME(val))
}
}
if (result != DNS_R_WAIT)
}
if (want_destroy)
/*
* Free stuff from the event.
*/
}
/*%
* Looks for the requested name and type in the view (zones and cache).
*
* When looking for a DLV record also checks to make sure the NSEC record
* returns covers the query name as part of aggressive negative caching.
*
* 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
*/
static inline isc_result_t
unsigned int options;
char buf1[DNS_NAME_FORMATSIZE];
char buf2[DNS_NAME_FORMATSIZE];
char buf3[DNS_NAME_FORMATSIZE];
return (ISC_R_CANCELED);
if (type == dns_rdatatype_dlv)
if (result == DNS_R_NXDOMAIN) {
} else if (result == DNS_R_COVERINGNSEC) {
/*
* Check if the returned NSEC covers the name.
*/
"covering nsec: trust %u",
goto notfound;
}
if (result != ISC_R_SUCCESS)
goto notfound;
/* Parent NSEC record. */
"covering nsec: for parent");
goto notfound;
}
}
if (result != ISC_R_SUCCESS)
goto notfound;
/* End of zone chain. */
/*
* XXXMPA We could look for a parent NSEC
* at nsec.next and if found retest with
* this NSEC.
*/
"covering nsec: not in zone");
goto notfound;
}
/*
* XXXMPA We could check if this NSEC is at a zone
* apex and if the qname is not below it and look for
* a parent NSEC with the same name. This requires
* that we can cache both NSEC records which we
* currently don't support.
*/
"covering nsec: not in range");
goto notfound;
}
"covering nsec found: '%s' '%s' '%s'",
}
} else if (result != ISC_R_SUCCESS &&
result != DNS_R_NCACHENXDOMAIN &&
result != DNS_R_NCACHENXRRSET &&
result != DNS_R_NXRRSET &&
result != ISC_R_NOTFOUND) {
goto notfound;
}
return (result);
return (ISC_R_NOTFOUND);
}
/*%
* 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.
*/
static inline isc_boolean_t
{
"continuing validation would lead to "
"deadlock: aborting validation");
return (ISC_TRUE);
}
}
return (ISC_FALSE);
}
/*%
* Start a fetch for the requested name and type.
*/
static inline isc_result_t
{
return (DNS_R_NOVALIDSIG);
&val->fsigrdataset,
}
/*%
* Start a subvalidation process.
*/
static inline isc_result_t
{
return (DNS_R_NOVALIDSIG);
&val->subvalidator);
if (result == ISC_R_SUCCESS) {
}
return (result);
}
/*%
* 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.
*
* If val->key is non-NULL, this returns the next matching key.
*/
static isc_result_t
{
isc_buffer_t b;
else {
}
if (result != ISC_R_SUCCESS)
goto failure;
do {
if (result != ISC_R_SUCCESS)
goto failure;
{
if (foundold)
/*
* This is the key we're looking for.
*/
return (ISC_R_SUCCESS);
{
}
}
} while (result == ISC_R_SUCCESS);
if (result == ISC_R_NOMORE)
return (result);
}
/*%
* Get the key that genertated this signature.
*/
static isc_result_t
unsigned int nlabels;
int order;
/*
* Is the signer name appropriate for this signature?
*
* The signer name must be at the same level as the owner name
* or closer to the the DNS root.
*/
if (namereln != dns_namereln_subdomain &&
return (DNS_R_CONTINUE);
if (namereln == dns_namereln_equal) {
/*
* If this is a self-signed keyset, it must not be a zone key
* (since get_key is not called from validatezonekey).
*/
return (DNS_R_CONTINUE);
/*
* Records appearing in the parent zone at delegation
* points cannot be self-signed.
*/
return (DNS_R_CONTINUE);
}
/*
* Do we know about this key?
*/
if (result == ISC_R_SUCCESS) {
/*
* We have an rrset for the given keyname.
*/
{
/*
* We know the key but haven't validated it yet.
*/
&val->fsigrdataset,
"get_key");
if (result != ISC_R_SUCCESS)
return (result);
return (DNS_R_WAIT);
/*
* Having a pending key with no signature means that
* something is broken.
*/
/*
* The key is legitimately insecure. There's no
* point in even attempting verification.
*/
} else {
/*
* See if we've got the key used in the signature.
*/
"keyset with trust %d",
if (result != ISC_R_SUCCESS) {
/*
* Either the key we're looking for is not
* in the rrset, or something bad happened.
* Give up.
*/
}
}
} else if (result == ISC_R_NOTFOUND) {
/*
* We don't know anything about this key.
*/
fetch_callback_validator, "get_key");
if (result != ISC_R_SUCCESS)
return (result);
return (DNS_R_WAIT);
} else if (result == DNS_R_NCACHENXDOMAIN ||
result == DNS_R_NCACHENXRRSET ||
result == DNS_R_NXDOMAIN ||
result == DNS_R_NXRRSET)
{
/*
* This key doesn't exist.
*/
}
return (result);
}
static dns_keytag_t
isc_region_t r;
dns_rdata_toregion(rdata, &r);
}
/*%
* Is this keyset self-signed?
*/
static isc_boolean_t
result == ISC_R_SUCCESS;
{
result == ISC_R_SUCCESS;
{
return (ISC_TRUE);
}
}
return (ISC_FALSE);
}
/*%
* 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.
*/
static isc_result_t
{
"verify rdataset (keyid=%u): %s",
if (result == DNS_R_FROMWILDCARD) {
}
return (result);
}
/*%
* Attempts positive response validation of a normal RRset.
*
* Returns:
* \li ISC_R_SUCCESS Validation completed successfully
* \li DNS_R_WAIT Validation has started but is waiting
* for an event.
* \li Other return codes are possible and all indicate failure.
*/
static isc_result_t
/*
* Caller must be holding the validator lock.
*/
if (resume) {
/*
* We already have a sigrdataset.
*/
} else {
}
for (;
result == ISC_R_SUCCESS;
{
return (ISC_R_NOMEMORY);
}
if (result != ISC_R_SUCCESS)
return (result);
/*
* At this point we could check that the signature algorithm
* was known and "sufficiently good".
*/
continue;
if (!resume) {
if (result == DNS_R_CONTINUE)
continue; /* Try the next SIG RR. */
if (result != ISC_R_SUCCESS)
return (result);
}
/*
* The key is insecure, so mark the data as insecure also.
*/
if (val->mustbesecure) {
"must be secure failure");
return (DNS_R_MUSTBESECURE);
}
return (ISC_R_SUCCESS);
}
do {
if (result == ISC_R_SUCCESS)
break;
&nextnode);
if (result != ISC_R_SUCCESS) {
break;
}
} else {
!= ISC_R_SUCCESS)
break;
}
} while (1);
if (result != ISC_R_SUCCESS)
"failed to verify rdataset");
else {
}
else {
}
}
"no message available for noqname proof");
return (DNS_R_NOVALIDSIG);
}
"looking for noqname proof");
} else if (result == ISC_R_SUCCESS) {
"marking as secure");
return (result);
} else {
"verify failure: %s",
}
}
if (result != ISC_R_NOMORE) {
"failed to iterate signatures: %s",
return (result);
}
return (DNS_R_NOVALIDSIG);
}
/*%
* Validate the DNSKEY RRset by looking for a DNSKEY that matches a
* DLV record and that also verifies the DNSKEY RRset.
*/
static isc_result_t
unsigned char dsbuf[DNS_DS_BUFFERSIZE];
/*
* Look through the DLV record and find the keys that can sign the
* key set and the matching signature. For each such key, attempt
* verification.
*/
result == ISC_R_SUCCESS;
{
continue;
continue;
result == ISC_R_SUCCESS;
{
continue;
dsbuf, &newdsrdata);
if (result != ISC_R_SUCCESS) {
"dns_ds_buildrdata() -> %s",
continue;
}
/* Covert to DLV */
break;
}
if (result != ISC_R_SUCCESS) {
"no DNSKEY matching DLV");
continue;
}
"Found matching DLV record: checking for signature");
result == ISC_R_SUCCESS;
{
&sigrdata);
continue;
&keyrdata,
&dstkey);
if (result != ISC_R_SUCCESS)
/*
* This really shouldn't happen, but...
*/
continue;
if (result == ISC_R_SUCCESS)
break;
}
if (result == ISC_R_SUCCESS)
break;
"no RRSIG matching DLV key");
}
if (result == ISC_R_SUCCESS) {
return (result);
if (val->mustbesecure) {
"must be secure failure");
return (DNS_R_MUSTBESECURE);
}
return (ISC_R_SUCCESS);
} else
return (DNS_R_NOVALIDSIG);
}
/*%
* Attempts positive response validation of an RRset containing zone keys.
*
* Returns:
* \li ISC_R_SUCCESS Validation completed successfully
* \li DNS_R_WAIT Validation has started but is waiting
* for an event.
* \li Other return codes are possible and all indicate failure.
*/
static isc_result_t
unsigned char dsbuf[DNS_DS_BUFFERSIZE];
/*
* Caller must be holding the validator lock.
*/
return (dlv_validatezonekey(val));
/*
* First, see if this key was signed by a trusted key.
*/
result == ISC_R_SUCCESS;
{
&sigrdata);
&keynode);
while (result == ISC_R_SUCCESS) {
if (result == ISC_R_SUCCESS) {
&keynode);
break;
}
&nextnode);
&keynode);
}
if (result == ISC_R_SUCCESS) {
"signed by trusted key; "
"marking as secure");
return (result);
}
}
/*
* If this is the root name and there was no trusted key,
* give up, since there's no DS at the root.
*/
return (DNS_R_NOVALIDSIG);
else
return (DNS_R_NOVALIDDS);
}
/*
* Otherwise, try to find the DS record.
*/
if (result == ISC_R_SUCCESS) {
/*
* We have DS records.
*/
{
&val->fsigrdataset,
"validatezonekey");
if (result != ISC_R_SUCCESS)
return (result);
return (DNS_R_WAIT);
/*
* There should never be an unsigned DS.
*/
"unsigned DS record");
return (DNS_R_NOVALIDSIG);
} else
} else if (result == ISC_R_NOTFOUND) {
/*
* We don't have the DS. Find it.
*/
"validatezonekey");
if (result != ISC_R_SUCCESS)
return (result);
return (DNS_R_WAIT);
} else if (result == DNS_R_NCACHENXDOMAIN ||
result == DNS_R_NCACHENXRRSET ||
result == DNS_R_NXDOMAIN ||
result == DNS_R_NXRRSET)
{
/*
* The DS does not exist.
*/
return (DNS_R_NOVALIDSIG);
}
}
/*
* We have a DS set.
*/
if (val->mustbesecure) {
"must be secure failure");
return (DNS_R_MUSTBESECURE);
}
return (ISC_R_SUCCESS);
}
/*
* 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.
*/
result == ISC_R_SUCCESS;
{
continue;
continue;
/*
* Look for the KEY that matches the DS record.
*/
result == ISC_R_SUCCESS;
{
continue;
dsbuf, &newdsrdata);
if (result != ISC_R_SUCCESS)
continue;
break;
}
if (result != ISC_R_SUCCESS) {
"no DNSKEY matching DS");
continue;
}
result == ISC_R_SUCCESS;
{
&sigrdata);
continue;
&keyrdata,
&dstkey);
if (result != ISC_R_SUCCESS)
/*
* This really shouldn't happen, but...
*/
continue;
if (result == ISC_R_SUCCESS)
break;
}
if (result == ISC_R_SUCCESS)
break;
"no RRSIG matching DS key");
}
if (result == ISC_R_SUCCESS) {
return (result);
if (val->mustbesecure) {
"must be secure failure");
return (DNS_R_MUSTBESECURE);
}
return (ISC_R_SUCCESS);
} else
return (DNS_R_NOVALIDSIG);
}
/*%
* Starts a positive response validation.
*
* Returns:
* \li ISC_R_SUCCESS Validation completed successfully
* \li DNS_R_WAIT Validation has started but is waiting
* for an event.
* \li Other return codes are possible and all indicate failure.
*/
static isc_result_t
/*
* If this is not a key, go straight into validate().
*/
return (validatezonekey(val));
}
/*%
* 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
* \li ISC_R_SUCCESS
*/
static isc_result_t
char namebuf[DNS_NAME_FORMATSIZE];
result == ISC_R_SUCCESS;
{
{
continue;
sigrdataset != NULL;
{
break;
}
if (sigrdataset == NULL)
continue;
continue;
== ISC_R_SUCCESS)
{
name;
if (!exists)
val->attributes |=
name;
return (ISC_R_SUCCESS);
}
}
}
if (result == ISC_R_NOMORE)
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
* and NOQNAME proofs in the NSEC records by calling authvalidated().
*
* If the required proofs are found we are done.
*
* If the proofs are not found attempt to prove this is a unsecure
* response.
*/
static isc_result_t
if (!resume)
else {
}
for (;
result == ISC_R_SUCCESS;
{
if (resume) {
} else
for (;
{
continue;
sigrdataset != NULL;
link))
{
break;
}
if (sigrdataset == NULL)
continue;
/*
* 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.
*/
{
continue;
if (result != ISC_R_SUCCESS)
return (result);
if (dns_nsec_typepresent(&nsec,
continue;
}
"nsecvalidate");
if (result != ISC_R_SUCCESS)
return (result);
return (DNS_R_WAIT);
}
}
if (result == ISC_R_NOMORE)
if (result != ISC_R_SUCCESS)
return (result);
/*
* Do we only need to check for NOQNAME? To get here we must have
* had a secure wildcard answer.
*/
"noqname proof found");
"marking as secure");
return (ISC_R_SUCCESS);
}
"noqname proof not found");
return (DNS_R_NOVALIDNSEC);
}
/*
* Do we need to check for the wildcard?
*/
if (result != ISC_R_SUCCESS)
return (result);
}
"nonexistence proof(s) found");
return (ISC_R_SUCCESS);
}
"nonexistence proof(s) not found");
}
static isc_boolean_t
result == ISC_R_SUCCESS;
ds.digest_type) &&
return (ISC_TRUE);
}
}
return (ISC_FALSE);
}
/*%
* Callback from fetching a DLV record.
*
* Resumes the DLV lookup process.
*/
static void
char namebuf[DNS_NAME_FORMATSIZE];
/* Free resources which are not of interest. */
if (eresult == ISC_R_SUCCESS) {
sizeof(namebuf));
} else if (eresult == DNS_R_NXRRSET ||
eresult == DNS_R_NXDOMAIN ||
eresult == DNS_R_NCACHENXRRSET ||
eresult == DNS_R_NCACHENXDOMAIN) {
if (result == ISC_R_SUCCESS) {
namebuf);
} else if (result == ISC_R_NOTFOUND) {
} else {
if (result != DNS_R_WAIT)
}
} else {
}
if (want_destroy)
}
/*%
* Start the DLV lookup proccess.
*
* Returns
* \li ISC_R_SUCCESS
* \li DNS_R_WAIT
* \li Others on validation failures.
*/
static isc_result_t
char namebuf[DNS_NAME_FORMATSIZE];
"plain DNSSEC returns unsecure (%s): looking for DLV",
namebuf);
return (DNS_R_MUSTBESECURE);
}
if (result == ISC_R_NOTFOUND) {
return (ISC_R_SUCCESS);
}
if (result != ISC_R_SUCCESS) {
return (result);
}
sizeof(namebuf));
return (DNS_R_WAIT);
}
/*%
* Continue the DLV lookup process.
*
* Returns
* \li ISC_R_SUCCESS
* \li ISC_R_NOTFOUND
* \li DNS_R_WAIT
* \li Others on validation failure.
*/
static isc_result_t
char namebuf[DNS_NAME_FORMATSIZE];
unsigned int labels;
if (!resume) {
"must be secure failure");
return (DNS_R_MUSTBESECURE);
}
if (labels == 0)
return (ISC_R_NOTFOUND);
dlvsep);
}
} else {
}
if (labels == 0)
return (ISC_R_NOTFOUND);
while (result == ISC_R_NOSPACE) {
}
if (result != ISC_R_SUCCESS) {
return (DNS_R_NOVALIDSIG);
}
while (dns_name_countlabels(dlvname) >=
namebuf);
if (result == ISC_R_SUCCESS) {
return (DNS_R_NOVALIDSIG);
return (ISC_R_SUCCESS);
}
if (result == ISC_R_NOTFOUND) {
dlvfetched, "finddlvsep");
if (result != ISC_R_SUCCESS)
return (result);
return (DNS_R_WAIT);
}
if (result != DNS_R_NXRRSET &&
result != DNS_R_NXDOMAIN &&
result != DNS_R_NCACHENXRRSET &&
return (result);
/*
* Strip first labels from both dlvsep and dlvname.
*/
if (labels == 0)
break;
}
return (ISC_R_NOTFOUND);
}
/*%
* proveunsecure walks down from the SEP looking for a break in the
* chain of trust. That occurs when we can prove the DS record does
* not exist at a delegation point or the DS exists at a delegation
*
* If DLV is active and we look for a DLV record at or below the
* point we go insecure. If found we restart the validation process.
* If not found or DLV isn't active we mark the response as a answer.
*
* Returns:
* \li ISC_R_SUCCESS val->event->name is in a unsecure zone
* \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
*/
static isc_result_t
char namebuf[DNS_NAME_FORMATSIZE];
if (val->havedlvsep)
else {
secroot);
if (result == ISC_R_NOTFOUND) {
"not beneath secure root");
if (val->mustbesecure) {
"must be secure failure");
goto out;
}
return (ISC_R_SUCCESS);
}
} else if (result != ISC_R_SUCCESS)
return (result);
}
if (!resume) {
/*
* We are looking for breaks below the SEP so add a label.
*/
} else {
if (val->mustbesecure) {
"must be secure failure at '%s'",
namebuf);
goto out;
}
namebuf);
goto out;
}
goto out;
}
}
for (;
{
else
"checking existence of DS at '%s'",
namebuf);
/*
* There is no DS. If this is a delegation,
* we maybe done.
*/
/*
* 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.
*/
goto out;
}
if (val->mustbesecure) {
"must be secure failure");
return (DNS_R_MUSTBESECURE);
}
return (ISC_R_SUCCESS);
}
}
continue;
} else if (result == ISC_R_SUCCESS) {
/*
* There is a DS here. Verify that it's secure and
* continue.
*/
"no supported algorithm/"
if (val->mustbesecure) {
"must be secure failure");
goto out;
}
goto out;
}
goto out;
}
continue;
}
{
goto out;
}
&val->fsigrdataset,
"proveunsecure");
if (result != ISC_R_SUCCESS)
goto out;
return (DNS_R_WAIT);
} else if (result == DNS_R_NXDOMAIN ||
result == DNS_R_NCACHENXDOMAIN) {
/*
* This is not a zone cut. Assuming things are
* as expected, continue.
*/
/*
* There should be an NSEC here, since we
* are still in a secure zone.
*/
goto out;
/*
* 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.
*/
goto out;
}
continue;
} else if (result == ISC_R_NOTFOUND) {
/*
* We don't know anything about the DS. Find it.
*/
dsfetched2, "proveunsecure");
if (result != ISC_R_SUCCESS)
goto out;
return (DNS_R_WAIT);
}
}
return (DNS_R_NOTINSECURE); /* Couldn't complete insecurity proof */
out:
return (result);
}
/*%
* Reset state and revalidate the answer using DLV.
*/
static void
/*
* Reset state and try again.
*/
}
/*%
* Start the validation process.
*
* Attempt to valididate the answer based on the category it appears to
* fall in.
* \li 1. secure positive answer.
* \li 2. unsecure positive answer.
* \li 3. a negative answer (secure or unsecure).
*
* Note a answer that appears to be a secure positive answer may actually
* be a unsecure positive answer.
*/
static void
/* If the validator has been cancelled, val->event == NULL */
return;
else
/*
* This looks like a simple validation. We say "looks like"
* because it might end up requiring an insecurity proof.
*/
"attempting positive response validation");
if (result == DNS_R_NOVALIDSIG &&
{
"falling back to insecurity proof");
if (result == DNS_R_NOTINSECURE)
}
/*
* This is either an unsecure subdomain or a response from
* a broken server.
*/
"attempting insecurity proof");
{
/*
* This is a nonexistence validation.
*/
"attempting negative response validation");
} else
} else {
/*
* This shouldn't happen.
*/
INSIST(0);
}
if (result != DNS_R_WAIT) {
}
if (want_destroy)
}
{
return (ISC_R_NOMEMORY);
event = (dns_validatorevent_t *)
sizeof(dns_validatorevent_t));
goto cleanup_val;
}
if (result != ISC_R_SUCCESS)
goto cleanup_event;
val->attributes = 0;
*validatorp = val;
return (ISC_R_SUCCESS);
return (result);
}
void
}
}
static void
if (val->havedlvsep)
}
void
val = *validatorp;
if (want_destroy)
*validatorp = NULL;
}
static void
{
char msgbuf[2048];
static const char spaces[] = " *";
char namebuf[DNS_NAME_FORMATSIZE];
char typebuf[DNS_RDATATYPE_FORMATSIZE];
sizeof(typebuf));
} else {
}
}
static void
return;
}
static void
{
char namestr[DNS_NAME_FORMATSIZE];
char typestr[DNS_RDATATYPE_FORMATSIZE];
}