dnssec.c revision ccad3c9ecbe8a1060ff7b407a318ccd592de536e
/*
* Copyright (C) 1999 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 INTERNET SOFTWARE CONSORTIUM DISCLAIMS
* ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
* CONSORTIUM 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: dnssec.c,v 1.1 1999/09/01 20:50:49 bwelling Exp $
* Principal Author: Brian Wellington
*/
#include <config.h>
#include <stdlib.h>
#include <string.h>
#include <isc/assertions.h>
#include <dns/keyvalues.h>
#include <dns/rdataset.h>
#include <dns/rdatastruct.h>
typedef struct dns_trusted_key dns_trusted_key_t;
struct dns_trusted_key {
unsigned int magic; /* Magic number. */
};
#define TYPE_SIGN 0
#define TYPE_VERIFY 1
typedef struct digestctx {
} digestctx_t;
/* XXXBEW If an unsorted list isn't good enough, this can be updated */
static isc_rwlock_t trusted_key_lock;
dns_name_t *name);
static isc_result_t
else
return (result);
}
/* converts the name of a key into a canonical isc_name_t */
static isc_result_t
unsigned char data[1024];
if (ret != ISC_R_SUCCESS)
return (ret);
return (ret);
}
/* make qsort happy */
static int
}
/* sort the rdataset into an array */
static isc_result_t
{
int i = 0, n = 1;
if (ret != ISC_R_SUCCESS)
return (ret);
/* count the records */
n++;
if (ret != ISC_R_SUCCESS)
return (ret);
/* put them in the array */
do {
/* This better not change. Should this be locked somehow? XXXBEW */
INSIST(i == n);
/* sort the array */
*nrdata = n;
return (ISC_R_SUCCESS);
}
return (ISC_R_NOMEMORY);
if (ret != ISC_R_SUCCESS)
goto cleanup;
return (ISC_R_SUCCESS);
return (ret);
}
{
int nrdatas, i;
isc_region_t r;
unsigned char data[300];
return (DNS_R_INVALIDTIME);
/* Is the key allowed to sign data? */
if (flags & DNS_KEYTYPE_NOAUTH)
return (DNS_R_KEYUNAUTHORIZED);
return (DNS_R_KEYUNAUTHORIZED);
}
if (ret != ISC_R_SUCCESS)
goto cleanup_signer;
if (dns_name_iswildcard(name))
goto cleanup_name;
if (ret != ISC_R_SUCCESS)
goto cleanup_signature;
isc_buffer_used(&b, &r);
/* Digest the SIG rdata */
if (ret != ISC_R_SUCCESS)
goto cleanup_signature;
dns_name_toregion(name, &r);
/* create an envelope for each rdata: <name|type|class|ttl> */
if (ret != ISC_R_SUCCESS)
goto cleanup_signature;
isc_buffer_used(&envbuf, &r);
for (i = 0; i < nrdatas; i++) {
/* Digest the envelope */
if (ret != ISC_R_SUCCESS)
goto cleanup_array;
/* Digest the length of the rdata */
if (ret != ISC_R_SUCCESS)
goto cleanup_array;
/* Digest the rdata */
if (ret != ISC_R_SUCCESS)
goto cleanup_array;
}
if (ret != ISC_R_SUCCESS)
goto cleanup_array;
isc_buffer_used(&sigbuf, &r);
ret = DNS_R_NOSPACE;
goto cleanup_array;
}
return (ret);
}
{
isc_region_t r;
int nrdatas, i;
unsigned char data[300];
int labels;
if (ret != ISC_R_SUCCESS)
return (ret);
if (ret != ISC_R_SUCCESS)
goto cleanup_struct;
/* Is SIG temporally valid? */
return (DNS_R_SIGFUTURE);
return (DNS_R_SIGEXPIRED);
/* Is the key allowed to sign data? */
if (flags & DNS_KEYTYPE_NOAUTH)
return (DNS_R_KEYUNAUTHORIZED);
return (DNS_R_KEYUNAUTHORIZED);
/* Digest the SIG rdata (not including the signature) */
dns_rdata_toregion(sigrdata, &r);
if (r.length < 20) {
ret = DNS_R_RANGE;
goto cleanup_struct;
}
/* if the name is an expanded wildcard, use the wildcard name */
&newname);
dns_name_toregion(&newname, &r);
/* create an envelope for each rdata: <name|type|class|ttl> */
}
else
if (ret != ISC_R_SUCCESS)
goto cleanup_struct;
isc_buffer_used(&envbuf, &r);
for (i = 0; i < nrdatas; i++) {
/* Digest the envelope */
if (ret != ISC_R_SUCCESS)
goto cleanup_array;
/* Digest the rdata length */
/* Digest the rdata */
if (ret != ISC_R_SUCCESS)
goto cleanup_array;
if (ret != ISC_R_SUCCESS)
goto cleanup_array;
}
if (ret == DST_R_VERIFYFINALFAILURE)
return (ret);
}
dns_dnssec_init() {
if (ret != ISC_R_SUCCESS) {
"isc_rwlock_init() failed: %s",
return (DNS_R_UNEXPECTED);
}
return (ISC_R_SUCCESS);
}
void
while (!ISC_LIST_EMPTY(trusted_keys)) {
}
}