1999-10-26 15:39:59 +00:00
|
|
|
/*
|
2000-02-03 23:50:32 +00:00
|
|
|
* Copyright (C) 1999, 2000 Internet Software Consortium.
|
1999-10-26 15:39:59 +00:00
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
2000-06-23 01:51:35 +00:00
|
|
|
* $Id: tkey.c,v 1.47 2000/06/23 01:51:35 bwelling Exp $
|
1999-10-26 15:39:59 +00:00
|
|
|
* Principal Author: Brian Wellington
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
2000-05-30 22:28:37 +00:00
|
|
|
#include <isc/buffer.h>
|
2000-06-09 22:33:08 +00:00
|
|
|
#include <isc/entropy.h>
|
2000-06-07 02:33:46 +00:00
|
|
|
#include <isc/md5.h>
|
2000-01-21 20:18:41 +00:00
|
|
|
#include <isc/mem.h>
|
2000-05-08 14:38:29 +00:00
|
|
|
#include <isc/string.h>
|
2000-04-28 01:12:23 +00:00
|
|
|
#include <isc/util.h>
|
1999-10-26 15:39:59 +00:00
|
|
|
|
|
|
|
#include <dns/dnssec.h>
|
|
|
|
#include <dns/keyvalues.h>
|
2000-06-23 01:51:35 +00:00
|
|
|
#include <dns/log.h>
|
1999-10-26 15:39:59 +00:00
|
|
|
#include <dns/message.h>
|
2000-05-30 22:28:37 +00:00
|
|
|
#include <dns/name.h>
|
1999-10-26 15:39:59 +00:00
|
|
|
#include <dns/rdata.h>
|
|
|
|
#include <dns/rdatalist.h>
|
|
|
|
#include <dns/rdataset.h>
|
2000-05-30 22:28:37 +00:00
|
|
|
#include <dns/rdatastruct.h>
|
2000-05-02 03:54:17 +00:00
|
|
|
#include <dns/result.h>
|
1999-10-26 15:39:59 +00:00
|
|
|
#include <dns/tkey.h>
|
|
|
|
#include <dns/tsig.h>
|
|
|
|
|
1999-10-28 20:00:04 +00:00
|
|
|
#define TKEY_RANDOM_AMOUNT 16
|
|
|
|
|
1999-10-26 17:25:07 +00:00
|
|
|
#define RETERR(x) do { \
|
1999-10-26 15:39:59 +00:00
|
|
|
result = (x); \
|
|
|
|
if (result != ISC_R_SUCCESS) \
|
|
|
|
goto failure; \
|
|
|
|
} while (0)
|
|
|
|
|
2000-06-23 01:51:35 +00:00
|
|
|
#define TKEYTRACE(m) isc_log_write(dns_lctx, \
|
|
|
|
DNS_LOGCATEGORY_RESOLVER, \
|
|
|
|
DNS_LOGMODULE_RESOLVER, \
|
|
|
|
ISC_LOG_DEBUG(3), \
|
|
|
|
"tkey: %s", (m))
|
|
|
|
|
|
|
|
static void
|
|
|
|
tkey_log(const char *fmt, ...) {
|
|
|
|
va_list ap;
|
|
|
|
|
|
|
|
va_start(ap, fmt);
|
|
|
|
isc_log_vwrite(dns_lctx, DNS_LOGCATEGORY_GENERAL,
|
|
|
|
DNS_LOGMODULE_REQUEST, ISC_LOG_DEBUG(4), fmt, ap);
|
|
|
|
va_end(ap);
|
|
|
|
}
|
1999-10-26 15:39:59 +00:00
|
|
|
|
|
|
|
isc_result_t
|
2000-06-09 22:33:08 +00:00
|
|
|
dns_tkeyctx_create(isc_mem_t *mctx, isc_entropy_t *ectx, dns_tkeyctx_t **tctxp)
|
|
|
|
{
|
|
|
|
dns_tkeyctx_t *tctx;
|
|
|
|
|
1999-10-26 15:39:59 +00:00
|
|
|
REQUIRE(mctx != NULL);
|
2000-06-09 22:33:08 +00:00
|
|
|
REQUIRE(ectx != NULL);
|
|
|
|
REQUIRE(tctxp != NULL && *tctxp == NULL);
|
2000-01-21 20:18:41 +00:00
|
|
|
|
2000-06-09 22:33:08 +00:00
|
|
|
tctx = isc_mem_get(mctx, sizeof(dns_tkeyctx_t));
|
|
|
|
if (tctx == NULL)
|
2000-01-21 20:18:41 +00:00
|
|
|
return (ISC_R_NOMEMORY);
|
2000-06-09 22:33:08 +00:00
|
|
|
tctx->mctx = NULL;
|
|
|
|
isc_mem_attach(mctx, &tctx->mctx);
|
|
|
|
tctx->ectx = NULL;
|
|
|
|
isc_entropy_attach(ectx, &tctx->ectx);
|
|
|
|
tctx->dhkey = NULL;
|
|
|
|
tctx->domain = NULL;
|
|
|
|
|
|
|
|
*tctxp = tctx;
|
1999-10-26 15:39:59 +00:00
|
|
|
return (ISC_R_SUCCESS);
|
|
|
|
}
|
|
|
|
|
1999-11-05 16:53:47 +00:00
|
|
|
void
|
2000-06-09 22:33:08 +00:00
|
|
|
dns_tkeyctx_destroy(dns_tkeyctx_t **tctxp) {
|
2000-01-21 20:18:41 +00:00
|
|
|
isc_mem_t *mctx;
|
2000-06-09 22:33:08 +00:00
|
|
|
dns_tkeyctx_t *tctx;
|
2000-01-21 20:18:41 +00:00
|
|
|
|
2000-06-09 22:33:08 +00:00
|
|
|
REQUIRE(tctxp != NULL && *tctxp != NULL);
|
|
|
|
|
|
|
|
tctx = *tctxp;
|
|
|
|
mctx = tctx->mctx;
|
2000-01-21 20:18:41 +00:00
|
|
|
|
2000-06-09 22:33:08 +00:00
|
|
|
if (tctx->dhkey != NULL)
|
|
|
|
dst_key_free(&tctx->dhkey);
|
|
|
|
if (tctx->domain != NULL) {
|
|
|
|
dns_name_free(tctx->domain, mctx);
|
|
|
|
isc_mem_put(mctx, tctx->domain, sizeof(dns_name_t));
|
|
|
|
}
|
|
|
|
isc_entropy_detach(&tctx->ectx);
|
|
|
|
isc_mem_put(mctx, tctx, sizeof(dns_tkeyctx_t));
|
|
|
|
isc_mem_detach(&mctx);
|
|
|
|
*tctxp = NULL;
|
1999-11-05 16:53:47 +00:00
|
|
|
}
|
|
|
|
|
1999-10-26 15:39:59 +00:00
|
|
|
static isc_result_t
|
|
|
|
add_rdata_to_list(dns_message_t *msg, dns_name_t *name, dns_rdata_t *rdata,
|
|
|
|
isc_uint32_t ttl, dns_namelist_t *namelist)
|
|
|
|
{
|
|
|
|
isc_result_t result;
|
|
|
|
isc_region_t r, newr;
|
|
|
|
dns_rdata_t *newrdata = NULL;
|
|
|
|
dns_name_t *newname = NULL;
|
|
|
|
dns_rdatalist_t *newlist = NULL;
|
|
|
|
dns_rdataset_t *newset = NULL;
|
|
|
|
isc_buffer_t *tmprdatabuf = NULL, *tmpnamebuf = NULL;
|
|
|
|
|
1999-10-26 17:25:07 +00:00
|
|
|
RETERR(dns_message_gettemprdata(msg, &newrdata));
|
1999-10-26 15:39:59 +00:00
|
|
|
|
|
|
|
dns_rdata_toregion(rdata, &r);
|
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
|
|
|
RETERR(isc_buffer_allocate(msg->mctx, &tmprdatabuf, r.length));
|
|
|
|
isc_buffer_availableregion(tmprdatabuf, &newr);
|
1999-10-26 15:39:59 +00:00
|
|
|
memcpy(newr.base, r.base, r.length);
|
|
|
|
dns_rdata_fromregion(newrdata, rdata->rdclass, rdata->type, &newr);
|
|
|
|
dns_message_takebuffer(msg, &tmprdatabuf);
|
|
|
|
|
|
|
|
dns_name_toregion(name, &r);
|
|
|
|
RETERR(dns_message_gettempname(msg, &newname));
|
|
|
|
dns_name_init(newname, NULL);
|
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
|
|
|
RETERR(isc_buffer_allocate(msg->mctx, &tmpnamebuf, r.length));
|
|
|
|
isc_buffer_availableregion(tmpnamebuf, &newr);
|
1999-10-26 15:39:59 +00:00
|
|
|
memcpy(newr.base, r.base, r.length);
|
|
|
|
dns_name_fromregion(newname, &newr);
|
|
|
|
dns_message_takebuffer(msg, &tmpnamebuf);
|
|
|
|
|
|
|
|
RETERR(dns_message_gettemprdatalist(msg, &newlist));
|
|
|
|
newlist->rdclass = newrdata->rdclass;
|
|
|
|
newlist->type = newrdata->type;
|
2000-01-21 20:18:41 +00:00
|
|
|
newlist->covers = 0;
|
1999-10-26 15:39:59 +00:00
|
|
|
newlist->ttl = ttl;
|
|
|
|
ISC_LIST_INIT(newlist->rdata);
|
|
|
|
ISC_LIST_APPEND(newlist->rdata, newrdata, link);
|
|
|
|
|
|
|
|
RETERR(dns_message_gettemprdataset(msg, &newset));
|
|
|
|
dns_rdataset_init(newset);
|
|
|
|
RETERR(dns_rdatalist_tordataset(newlist, newset));
|
|
|
|
|
|
|
|
ISC_LIST_INIT(newname->list);
|
|
|
|
ISC_LIST_APPEND(newname->list, newset, link);
|
|
|
|
|
|
|
|
ISC_LIST_APPEND(*namelist, newname, link);
|
|
|
|
|
|
|
|
return (ISC_R_SUCCESS);
|
|
|
|
|
|
|
|
failure:
|
|
|
|
if (newrdata != NULL)
|
|
|
|
dns_message_puttemprdata(msg, &newrdata);
|
|
|
|
if (newname != NULL)
|
|
|
|
dns_message_puttempname(msg, &newname);
|
|
|
|
if (newlist != NULL)
|
|
|
|
dns_message_puttemprdatalist(msg, &newlist);
|
2000-01-21 20:18:41 +00:00
|
|
|
if (newset != NULL) {
|
|
|
|
dns_rdataset_disassociate(newset);
|
1999-10-26 15:39:59 +00:00
|
|
|
dns_message_puttemprdataset(msg, &newset);
|
2000-01-21 20:18:41 +00:00
|
|
|
}
|
1999-10-26 15:39:59 +00:00
|
|
|
return (result);
|
|
|
|
}
|
|
|
|
|
1999-10-28 20:00:04 +00:00
|
|
|
static isc_result_t
|
2000-01-21 20:18:41 +00:00
|
|
|
compute_secret(isc_buffer_t *shared, isc_region_t *queryrandomness,
|
2000-06-07 02:33:46 +00:00
|
|
|
isc_region_t *serverrandomness, isc_buffer_t *secret)
|
1999-10-28 20:00:04 +00:00
|
|
|
{
|
2000-06-07 02:33:46 +00:00
|
|
|
isc_md5_t md5ctx;
|
2000-01-21 20:18:41 +00:00
|
|
|
isc_region_t r, r2;
|
2000-06-08 06:16:09 +00:00
|
|
|
unsigned char digests[32];
|
2000-01-21 20:18:41 +00:00
|
|
|
unsigned int i;
|
1999-10-28 20:00:04 +00:00
|
|
|
|
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_usedregion(shared, &r);
|
2000-01-21 20:18:41 +00:00
|
|
|
|
2000-05-08 14:38:29 +00:00
|
|
|
/*
|
|
|
|
* MD5 ( query data | DH value ).
|
|
|
|
*/
|
2000-06-07 02:33:46 +00:00
|
|
|
isc_md5_init(&md5ctx);
|
|
|
|
isc_md5_update(&md5ctx, queryrandomness->base, queryrandomness->length);
|
|
|
|
isc_md5_update(&md5ctx, r.base, r.length);
|
|
|
|
isc_md5_final(&md5ctx, digests);
|
2000-06-02 18:59:33 +00:00
|
|
|
|
2000-05-08 14:38:29 +00:00
|
|
|
/*
|
|
|
|
* MD5 ( server data | DH value ).
|
|
|
|
*/
|
2000-06-07 02:33:46 +00:00
|
|
|
isc_md5_init(&md5ctx);
|
|
|
|
isc_md5_update(&md5ctx, serverrandomness->base,
|
|
|
|
serverrandomness->length);
|
|
|
|
isc_md5_update(&md5ctx, r.base, r.length);
|
|
|
|
isc_md5_final(&md5ctx, &digests[ISC_MD5_DIGESTLENGTH]);
|
2000-01-21 20:18:41 +00:00
|
|
|
|
2000-05-08 14:38:29 +00:00
|
|
|
/*
|
|
|
|
* XOR ( DH value, MD5-1 | MD5-2).
|
|
|
|
*/
|
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_availableregion(secret, &r);
|
|
|
|
isc_buffer_usedregion(shared, &r2);
|
2000-01-21 20:18:41 +00:00
|
|
|
if (r.length < sizeof(digests) || r.length < r2.length)
|
|
|
|
return (ISC_R_NOSPACE);
|
|
|
|
if (r2.length > sizeof(digests)) {
|
|
|
|
memcpy(r.base, r2.base, r2.length);
|
|
|
|
for (i = 0; i < sizeof(digests); i++)
|
|
|
|
r.base[i] ^= digests[i];
|
|
|
|
isc_buffer_add(secret, r2.length);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
memcpy(r.base, digests, sizeof(digests));
|
|
|
|
for (i = 0; i < r2.length; i++)
|
|
|
|
r.base[i] ^= r2.base[i];
|
|
|
|
isc_buffer_add(secret, sizeof(digests));
|
|
|
|
}
|
2000-06-07 02:33:46 +00:00
|
|
|
return (ISC_R_SUCCESS);
|
1999-10-28 20:00:04 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
1999-10-26 15:39:59 +00:00
|
|
|
static isc_result_t
|
2000-03-08 20:15:16 +00:00
|
|
|
process_dhtkey(dns_message_t *msg, dns_name_t *signer, dns_name_t *name,
|
2000-06-09 22:33:08 +00:00
|
|
|
dns_rdata_tkey_t *tkeyin, dns_tkeyctx_t *tctx,
|
2000-04-28 02:08:37 +00:00
|
|
|
dns_rdata_tkey_t *tkeyout,
|
2000-01-21 20:18:41 +00:00
|
|
|
dns_tsig_keyring_t *ring, dns_namelist_t *namelist)
|
1999-10-26 15:39:59 +00:00
|
|
|
{
|
|
|
|
isc_result_t result = ISC_R_SUCCESS;
|
2000-03-08 20:15:16 +00:00
|
|
|
dns_name_t *keyname, ourname;
|
1999-10-26 15:39:59 +00:00
|
|
|
dns_rdataset_t *keyset;
|
|
|
|
dns_rdata_t keyrdata, ourkeyrdata;
|
|
|
|
isc_boolean_t found_key = ISC_FALSE, found_incompatible = ISC_FALSE;
|
|
|
|
dst_key_t *pubkey = NULL;
|
2000-05-24 23:13:32 +00:00
|
|
|
isc_buffer_t ourkeybuf, *shared = NULL;
|
2000-01-21 20:18:41 +00:00
|
|
|
isc_region_t r, r2, ourkeyr;
|
1999-10-26 17:25:07 +00:00
|
|
|
isc_uint32_t ourttl;
|
1999-10-26 15:39:59 +00:00
|
|
|
unsigned char keydata[DST_KEY_MAXSIZE];
|
1999-10-28 20:00:04 +00:00
|
|
|
unsigned int sharedsize;
|
2000-06-09 22:33:08 +00:00
|
|
|
isc_buffer_t secret;
|
2000-01-21 20:18:41 +00:00
|
|
|
unsigned char *randomdata = NULL, secretdata[256];
|
2000-01-24 20:19:53 +00:00
|
|
|
isc_stdtime_t now;
|
1999-10-26 15:39:59 +00:00
|
|
|
|
2000-05-08 14:38:29 +00:00
|
|
|
/*
|
|
|
|
* Look for a DH KEY record that will work with ours.
|
|
|
|
*/
|
1999-10-26 15:39:59 +00:00
|
|
|
result = dns_message_firstname(msg, DNS_SECTION_ADDITIONAL);
|
|
|
|
while (result == ISC_R_SUCCESS) {
|
|
|
|
keyname = NULL;
|
|
|
|
dns_message_currentname(msg, DNS_SECTION_ADDITIONAL, &keyname);
|
|
|
|
keyset = NULL;
|
|
|
|
result = dns_message_findtype(keyname, dns_rdatatype_key, 0,
|
|
|
|
&keyset);
|
|
|
|
if (result == ISC_R_SUCCESS) {
|
|
|
|
result = dns_rdataset_first(keyset);
|
|
|
|
while (result == ISC_R_SUCCESS) {
|
|
|
|
dns_rdataset_current(keyset, &keyrdata);
|
|
|
|
pubkey = NULL;
|
|
|
|
result = dns_dnssec_keyfromrdata(keyname,
|
|
|
|
&keyrdata,
|
|
|
|
msg->mctx,
|
|
|
|
&pubkey);
|
|
|
|
if (result != ISC_R_SUCCESS) {
|
|
|
|
result = dns_rdataset_next(keyset);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (dst_key_alg(pubkey) == DNS_KEYALG_DH) {
|
|
|
|
if (dst_key_paramcompare(pubkey,
|
2000-01-21 20:18:41 +00:00
|
|
|
tctx->dhkey))
|
1999-10-26 15:39:59 +00:00
|
|
|
{
|
|
|
|
found_key = ISC_TRUE;
|
|
|
|
goto got_key;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
found_incompatible = ISC_TRUE;
|
|
|
|
}
|
2000-05-19 00:20:59 +00:00
|
|
|
dst_key_free(&pubkey);
|
1999-10-26 15:39:59 +00:00
|
|
|
result = dns_rdataset_next(keyset);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
result = dns_message_nextname(msg, DNS_SECTION_ADDITIONAL);
|
|
|
|
}
|
|
|
|
|
|
|
|
got_key:
|
|
|
|
if (!found_key) {
|
|
|
|
if (found_incompatible) {
|
2000-06-23 01:51:35 +00:00
|
|
|
tkey_log("process_dhtkey: found an incompatible key");
|
1999-10-26 15:39:59 +00:00
|
|
|
tkeyout->error = dns_tsigerror_badkey;
|
1999-10-28 20:00:04 +00:00
|
|
|
return (ISC_R_SUCCESS);
|
2000-06-23 01:51:35 +00:00
|
|
|
} else
|
|
|
|
tkey_log("process_dhtkey: failed to find a key");
|
1999-10-28 20:00:04 +00:00
|
|
|
return (DNS_R_FORMERR);
|
1999-10-26 15:39:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
RETERR(add_rdata_to_list(msg, keyname, &keyrdata, keyset->ttl,
|
|
|
|
namelist));
|
|
|
|
|
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(&ourkeybuf, keydata, sizeof(keydata));
|
2000-01-21 20:18:41 +00:00
|
|
|
RETERR(dst_key_todns(tctx->dhkey, &ourkeybuf));
|
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_usedregion(&ourkeybuf, &ourkeyr);
|
2000-01-24 22:22:51 +00:00
|
|
|
dns_rdata_fromregion(&ourkeyrdata, dns_rdataclass_any,
|
1999-10-26 15:39:59 +00:00
|
|
|
dns_rdatatype_key, &ourkeyr);
|
2000-05-24 23:13:32 +00:00
|
|
|
|
|
|
|
|
1999-10-26 15:39:59 +00:00
|
|
|
dns_name_init(&ourname, NULL);
|
2000-05-24 23:13:32 +00:00
|
|
|
dns_name_clone(dst_key_name(tctx->dhkey), &ourname);
|
1999-10-26 15:39:59 +00:00
|
|
|
ourttl = 0;
|
|
|
|
#if 0
|
2000-05-08 14:38:29 +00:00
|
|
|
/*
|
|
|
|
* Not sure how to do this without a view...
|
|
|
|
*/
|
1999-10-26 15:39:59 +00:00
|
|
|
db = NULL;
|
2000-04-19 18:50:00 +00:00
|
|
|
result = dns_dbtable_find(client->view->dbtable, &ourname, 0, &db);
|
1999-10-26 15:39:59 +00:00
|
|
|
if (result == ISC_R_SUCCESS) {
|
|
|
|
dns_rdataset_t set;
|
|
|
|
dns_fixedname_t foundname;
|
|
|
|
|
|
|
|
dns_rdataset_init(&set);
|
|
|
|
dns_fixedname_init(&foundname);
|
|
|
|
result = dns_db_find(db, &ourname, NULL, dns_rdatatype_key,
|
|
|
|
DNS_DBFIND_NOWILD, 0, NULL,
|
|
|
|
dns_fixedname_name(&foundname),
|
|
|
|
&set, NULL);
|
|
|
|
if (result == ISC_R_SUCCESS) {
|
|
|
|
ourttl = set.ttl;
|
|
|
|
dns_rdataset_disassociate(&set);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
RETERR(add_rdata_to_list(msg, &ourname, &ourkeyrdata, ourttl,
|
|
|
|
namelist));
|
|
|
|
|
2000-05-17 22:48:10 +00:00
|
|
|
RETERR(dst_key_secretsize(tctx->dhkey, &sharedsize));
|
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
|
|
|
RETERR(isc_buffer_allocate(msg->mctx, &shared, sharedsize));
|
1999-10-26 15:39:59 +00:00
|
|
|
|
2000-06-23 01:51:35 +00:00
|
|
|
result = dst_key_computesecret(pubkey, tctx->dhkey, shared);
|
|
|
|
if (result != ISC_R_SUCCESS) {
|
|
|
|
tkey_log("process_dhtkey: failed to compute shared secret: %s",
|
|
|
|
isc_result_totext(result));
|
|
|
|
goto failure;
|
|
|
|
}
|
1999-10-28 20:00:04 +00:00
|
|
|
|
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(&secret, secretdata, sizeof(secretdata));
|
1999-10-28 20:00:04 +00:00
|
|
|
|
|
|
|
randomdata = isc_mem_get(tkeyout->mctx, TKEY_RANDOM_AMOUNT);
|
|
|
|
if (randomdata == NULL) {
|
|
|
|
result = ISC_R_NOMEMORY;
|
1999-10-26 15:39:59 +00:00
|
|
|
goto failure;
|
|
|
|
}
|
2000-06-23 01:51:35 +00:00
|
|
|
result = isc_entropy_getdata(tctx->ectx, randomdata,
|
|
|
|
TKEY_RANDOM_AMOUNT, NULL, 0);
|
|
|
|
if (result != ISC_R_SUCCESS) {
|
|
|
|
tkey_log("process_dhtkey: failed to obtain entropy: %s",
|
|
|
|
isc_result_totext(result));
|
|
|
|
goto failure;
|
|
|
|
}
|
1999-10-28 20:00:04 +00:00
|
|
|
|
2000-06-09 22:33:08 +00:00
|
|
|
r.base = randomdata;
|
|
|
|
r.length = TKEY_RANDOM_AMOUNT;
|
2000-01-21 20:18:41 +00:00
|
|
|
r2.base = tkeyin->key;
|
|
|
|
r2.length = tkeyin->keylen;
|
2000-06-07 02:33:46 +00:00
|
|
|
RETERR(compute_secret(shared, &r2, &r, &secret));
|
1999-10-26 15:39:59 +00:00
|
|
|
|
2000-05-19 00:20:59 +00:00
|
|
|
dst_key_free(&pubkey);
|
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_usedregion(&secret, &r);
|
1999-10-26 15:39:59 +00:00
|
|
|
result = dns_tsigkey_create(name, &tkeyin->algorithm, r.base, r.length,
|
2000-03-08 20:15:16 +00:00
|
|
|
ISC_TRUE, signer, tkeyin->inception,
|
2000-01-24 22:22:51 +00:00
|
|
|
tkeyin->expire, msg->mctx, ring, NULL);
|
1999-10-28 20:00:04 +00:00
|
|
|
isc_buffer_free(&shared);
|
|
|
|
shared = NULL;
|
1999-10-26 15:39:59 +00:00
|
|
|
if (result == ISC_R_NOTFOUND) {
|
|
|
|
tkeyout->error = dns_tsigerror_badalg;
|
|
|
|
return (ISC_R_SUCCESS);
|
|
|
|
}
|
1999-10-27 17:50:58 +00:00
|
|
|
if (result != ISC_R_SUCCESS)
|
1999-10-26 15:39:59 +00:00
|
|
|
goto failure;
|
|
|
|
|
|
|
|
/* This key is good for a long time */
|
2000-01-24 20:19:53 +00:00
|
|
|
isc_stdtime_get(&now);
|
|
|
|
tkeyout->inception = tkeyin->inception;
|
|
|
|
tkeyout->expire = tkeyin->expire;
|
1999-10-26 15:39:59 +00:00
|
|
|
|
1999-10-28 20:00:04 +00:00
|
|
|
tkeyout->key = randomdata;
|
|
|
|
tkeyout->keylen = TKEY_RANDOM_AMOUNT;
|
|
|
|
|
1999-10-26 15:39:59 +00:00
|
|
|
return (ISC_R_SUCCESS);
|
|
|
|
|
|
|
|
failure:
|
|
|
|
if (!ISC_LIST_EMPTY(*namelist)) {
|
|
|
|
dns_name_t *tname = ISC_LIST_HEAD(*namelist);
|
|
|
|
while (tname != NULL) {
|
|
|
|
dns_name_t *next = ISC_LIST_NEXT(tname, link);
|
|
|
|
dns_rdataset_t *tset;
|
|
|
|
|
|
|
|
ISC_LIST_UNLINK(*namelist, tname, link);
|
|
|
|
tset = ISC_LIST_HEAD(tname->list);
|
2000-01-21 20:18:41 +00:00
|
|
|
dns_rdataset_disassociate(tset);
|
1999-10-26 15:39:59 +00:00
|
|
|
dns_message_puttemprdataset(msg, &tset);
|
|
|
|
dns_message_puttempname(msg, &tname);
|
|
|
|
tname = next;
|
|
|
|
}
|
|
|
|
}
|
1999-10-28 20:00:04 +00:00
|
|
|
if (shared != NULL)
|
|
|
|
isc_buffer_free(&shared);
|
1999-10-26 15:39:59 +00:00
|
|
|
return (result);
|
|
|
|
}
|
|
|
|
|
|
|
|
static isc_result_t
|
2000-03-08 20:15:16 +00:00
|
|
|
process_deletetkey(dns_message_t *msg, dns_name_t *signer, dns_name_t *name,
|
2000-04-28 02:08:37 +00:00
|
|
|
dns_rdata_tkey_t *tkeyin,
|
|
|
|
dns_rdata_tkey_t *tkeyout,
|
2000-01-21 20:18:41 +00:00
|
|
|
dns_tsig_keyring_t *ring,
|
1999-10-26 15:39:59 +00:00
|
|
|
dns_namelist_t *namelist)
|
|
|
|
{
|
|
|
|
isc_result_t result;
|
|
|
|
dns_tsigkey_t *tsigkey = NULL;
|
2000-03-08 20:15:16 +00:00
|
|
|
dns_name_t *identity;
|
1999-10-26 15:39:59 +00:00
|
|
|
|
|
|
|
/* Unused variables */
|
|
|
|
msg = msg;
|
|
|
|
tkeyout = tkeyout;
|
|
|
|
namelist = namelist;
|
|
|
|
|
2000-01-21 20:18:41 +00:00
|
|
|
result = dns_tsigkey_find(&tsigkey, name, &tkeyin->algorithm, ring);
|
1999-10-26 15:39:59 +00:00
|
|
|
if (result != ISC_R_SUCCESS)
|
|
|
|
tkeyout->error = dns_tsigerror_badname;
|
|
|
|
|
|
|
|
/*
|
1999-11-03 16:53:56 +00:00
|
|
|
* Only allow a delete if the identity that created the key is the
|
|
|
|
* same as the identity that signed the message.
|
1999-10-26 15:39:59 +00:00
|
|
|
*/
|
2000-03-08 20:15:16 +00:00
|
|
|
identity = dns_tsigkey_identity(tsigkey);
|
|
|
|
if (identity == NULL || !dns_name_equal(identity, signer))
|
1999-10-26 15:39:59 +00:00
|
|
|
return (DNS_R_REFUSED);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Set the key to be deleted when no references are left. If the key
|
|
|
|
* was not generated with TKEY and is in the config file, it may be
|
|
|
|
* reloaded later.
|
|
|
|
*/
|
|
|
|
dns_tsigkey_setdeleted(tsigkey);
|
|
|
|
/* Release the reference */
|
2000-05-26 00:16:46 +00:00
|
|
|
dns_tsigkey_detach(&tsigkey);
|
1999-10-26 15:39:59 +00:00
|
|
|
|
1999-11-05 16:53:47 +00:00
|
|
|
return (ISC_R_SUCCESS);
|
1999-10-26 15:39:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
isc_result_t
|
2000-06-09 22:33:08 +00:00
|
|
|
dns_tkey_processquery(dns_message_t *msg, dns_tkeyctx_t *tctx,
|
2000-01-21 20:18:41 +00:00
|
|
|
dns_tsig_keyring_t *ring)
|
|
|
|
{
|
1999-10-26 15:39:59 +00:00
|
|
|
isc_result_t result = ISC_R_SUCCESS;
|
2000-04-28 02:08:37 +00:00
|
|
|
dns_rdata_tkey_t tkeyin, tkeyout;
|
2000-03-08 20:15:16 +00:00
|
|
|
dns_name_t *qname, *name, *keyname, tempkeyname, signer;
|
1999-10-26 15:39:59 +00:00
|
|
|
dns_rdataset_t *tkeyset;
|
|
|
|
dns_rdata_t tkeyrdata, *rdata = NULL;
|
|
|
|
isc_buffer_t *dynbuf = NULL;
|
|
|
|
dns_namelist_t namelist;
|
2000-06-22 23:07:00 +00:00
|
|
|
isc_boolean_t freealg = ISC_FALSE;
|
1999-10-26 15:39:59 +00:00
|
|
|
|
2000-01-21 20:18:41 +00:00
|
|
|
REQUIRE(msg != NULL);
|
|
|
|
REQUIRE(tctx != NULL);
|
|
|
|
REQUIRE(ring != NULL);
|
|
|
|
|
2000-05-08 14:38:29 +00:00
|
|
|
/*
|
|
|
|
* Need to do this to determine if this should be freed later.
|
|
|
|
*/
|
2000-04-28 02:08:37 +00:00
|
|
|
memset(&tkeyin, 0, sizeof(dns_rdata_tkey_t));
|
1999-10-26 15:39:59 +00:00
|
|
|
|
2000-05-08 14:38:29 +00:00
|
|
|
/*
|
|
|
|
* Interpret the question section.
|
|
|
|
*/
|
1999-10-26 15:39:59 +00:00
|
|
|
result = dns_message_firstname(msg, DNS_SECTION_QUESTION);
|
2000-04-06 22:03:35 +00:00
|
|
|
INSIST(result == ISC_R_SUCCESS);
|
1999-10-26 15:39:59 +00:00
|
|
|
|
|
|
|
qname = NULL;
|
|
|
|
dns_message_currentname(msg, DNS_SECTION_QUESTION, &qname);
|
|
|
|
|
2000-05-08 14:38:29 +00:00
|
|
|
/*
|
|
|
|
* Look for a TKEY record that matches the question.
|
|
|
|
*/
|
1999-10-26 15:39:59 +00:00
|
|
|
tkeyset = NULL;
|
|
|
|
name = NULL;
|
|
|
|
result = dns_message_findname(msg, DNS_SECTION_ADDITIONAL, qname,
|
|
|
|
dns_rdatatype_tkey, 0, &name, &tkeyset);
|
|
|
|
if (result != ISC_R_SUCCESS) {
|
|
|
|
result = DNS_R_FORMERR;
|
2000-06-23 01:51:35 +00:00
|
|
|
tkey_log("dns_tkey_processquery: couldn't find a TKEY "
|
|
|
|
"matching the question");
|
1999-10-26 15:39:59 +00:00
|
|
|
goto failure;
|
|
|
|
}
|
|
|
|
result = dns_rdataset_first(tkeyset);
|
|
|
|
if (result != ISC_R_SUCCESS) {
|
|
|
|
result = DNS_R_FORMERR;
|
|
|
|
goto failure;
|
|
|
|
}
|
|
|
|
dns_rdataset_current(tkeyset, &tkeyrdata);
|
|
|
|
|
|
|
|
RETERR(dns_rdata_tostruct(&tkeyrdata, &tkeyin, msg->mctx));
|
|
|
|
|
|
|
|
if (tkeyin.error != dns_rcode_noerror) {
|
|
|
|
result = DNS_R_FORMERR;
|
|
|
|
goto failure;
|
|
|
|
}
|
|
|
|
|
2000-03-08 20:15:16 +00:00
|
|
|
/*
|
|
|
|
* Before we go any farther, verify that the message was signed.
|
|
|
|
* GSSAPI TKEY doesn't require a signature, the rest do.
|
|
|
|
*/
|
|
|
|
dns_name_init(&signer, NULL);
|
|
|
|
result = dns_message_signer(msg, &signer);
|
|
|
|
if (result != ISC_R_SUCCESS &&
|
|
|
|
(tkeyin.mode != DNS_TKEYMODE_GSSAPI || result != ISC_R_NOTFOUND))
|
|
|
|
{
|
2000-06-23 01:51:35 +00:00
|
|
|
tkey_log("dns_tkey_processquery: query was not properly "
|
|
|
|
"signed - rejecting");
|
2000-03-08 20:15:16 +00:00
|
|
|
result = DNS_R_FORMERR;
|
|
|
|
goto failure;
|
|
|
|
}
|
|
|
|
|
1999-10-26 15:39:59 +00:00
|
|
|
ISC_LIST_INIT(namelist);
|
|
|
|
|
|
|
|
tkeyout.common.rdclass = tkeyin.common.rdclass;
|
|
|
|
tkeyout.common.rdtype = tkeyin.common.rdtype;
|
|
|
|
ISC_LINK_INIT(&tkeyout.common, link);
|
|
|
|
tkeyout.mctx = msg->mctx;
|
|
|
|
|
|
|
|
dns_name_init(&tkeyout.algorithm, NULL);
|
|
|
|
RETERR(dns_name_dup(&tkeyin.algorithm, msg->mctx, &tkeyout.algorithm));
|
2000-06-22 23:07:00 +00:00
|
|
|
freealg = ISC_TRUE;
|
1999-10-26 15:39:59 +00:00
|
|
|
|
|
|
|
tkeyout.inception = tkeyout.expire = 0;
|
|
|
|
tkeyout.mode = tkeyin.mode;
|
|
|
|
tkeyout.error = 0;
|
|
|
|
tkeyout.keylen = tkeyout.otherlen = 0;
|
|
|
|
tkeyout.key = tkeyout.other = NULL;
|
|
|
|
|
|
|
|
/*
|
1999-11-05 16:53:47 +00:00
|
|
|
* A delete operation must have a fully specified key name. If this
|
|
|
|
* is not a delete, we do the following:
|
|
|
|
* if (qname != ".")
|
1999-10-26 15:39:59 +00:00
|
|
|
* keyname = qname + defaultdomain
|
|
|
|
* else
|
|
|
|
* keyname = <random hex> + defaultdomain
|
|
|
|
*/
|
|
|
|
if (tkeyin.mode != DNS_TKEYMODE_DELETE) {
|
|
|
|
dns_name_t prefix;
|
|
|
|
isc_buffer_t *buf = NULL;
|
|
|
|
unsigned char tdata[64];
|
|
|
|
dns_tsigkey_t *tsigkey = NULL;
|
|
|
|
|
2000-01-22 04:45:17 +00:00
|
|
|
dns_name_init(&tempkeyname, NULL);
|
|
|
|
keyname = &tempkeyname;
|
1999-10-26 15:39:59 +00:00
|
|
|
dns_name_init(&prefix, NULL);
|
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
|
|
|
RETERR(isc_buffer_allocate(msg->mctx, &buf, 256));
|
1999-10-26 15:39:59 +00:00
|
|
|
|
|
|
|
if (!dns_name_equal(qname, dns_rootname)) {
|
|
|
|
unsigned int n = dns_name_countlabels(qname);
|
|
|
|
dns_name_getlabelsequence(qname, 0, n - 1, &prefix);
|
|
|
|
}
|
|
|
|
else {
|
1999-10-29 05:41:49 +00:00
|
|
|
static char hexdigits[16] = {
|
|
|
|
'0', '1', '2', '3', '4', '5', '6', '7',
|
|
|
|
'8', '9', 'A', 'B', 'C', 'D', 'E', 'F' };
|
1999-10-26 15:39:59 +00:00
|
|
|
unsigned char randomtext[32];
|
|
|
|
isc_buffer_t b, b2;
|
|
|
|
int i;
|
|
|
|
|
2000-06-09 22:33:08 +00:00
|
|
|
result = isc_entropy_getdata(tctx->ectx,
|
|
|
|
randomtext,
|
|
|
|
sizeof(randomtext),
|
|
|
|
NULL, 0);
|
1999-10-26 15:39:59 +00:00
|
|
|
if (result != ISC_R_SUCCESS) {
|
|
|
|
dns_message_takebuffer(msg, &buf);
|
|
|
|
goto failure;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i = sizeof(randomtext) - 2; i >= 0; i -= 2) {
|
|
|
|
unsigned char val = randomtext[i/2];
|
|
|
|
randomtext[i] = hexdigits[val >> 4];
|
|
|
|
randomtext[i+1] = hexdigits[val & 0xF];
|
|
|
|
}
|
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, randomtext, sizeof(randomtext));
|
|
|
|
isc_buffer_init(&b2, tdata, sizeof(tdata));
|
1999-10-26 15:39:59 +00:00
|
|
|
isc_buffer_add(&b, sizeof(randomtext));
|
|
|
|
result = dns_name_fromtext(&prefix, &b, NULL,
|
|
|
|
ISC_FALSE, &b2);
|
|
|
|
if (result != ISC_R_SUCCESS) {
|
|
|
|
dns_message_takebuffer(msg, &buf);
|
|
|
|
goto failure;
|
|
|
|
}
|
|
|
|
}
|
2000-01-21 20:18:41 +00:00
|
|
|
result = dns_name_concatenate(&prefix, tctx->domain,
|
1999-10-26 15:39:59 +00:00
|
|
|
keyname, buf);
|
|
|
|
dns_message_takebuffer(msg, &buf);
|
|
|
|
if (result != ISC_R_SUCCESS)
|
|
|
|
goto failure;
|
|
|
|
|
2000-01-21 20:18:41 +00:00
|
|
|
result = dns_tsigkey_find(&tsigkey, keyname, NULL, ring);
|
1999-10-26 15:39:59 +00:00
|
|
|
if (result == ISC_R_SUCCESS) {
|
|
|
|
tkeyout.error = dns_tsigerror_badname;
|
2000-05-26 00:16:46 +00:00
|
|
|
dns_tsigkey_detach(&tsigkey);
|
1999-10-26 15:39:59 +00:00
|
|
|
goto failure_with_tkey;
|
|
|
|
}
|
|
|
|
else if (result != ISC_R_NOTFOUND)
|
|
|
|
goto failure;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
keyname = qname;
|
|
|
|
|
|
|
|
if (!dns_name_equal(&tkeyin.algorithm, DNS_TSIG_HMACMD5_NAME)) {
|
2000-06-23 01:51:35 +00:00
|
|
|
tkey_log("dns_tkey_processquery: tkey modes other than "
|
|
|
|
"hmac-md5 are not supported");
|
1999-10-26 15:39:59 +00:00
|
|
|
tkeyout.error = dns_tsigerror_badkey;
|
|
|
|
goto failure_with_tkey;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (tkeyin.mode) {
|
|
|
|
case DNS_TKEYMODE_DIFFIEHELLMAN:
|
2000-03-08 20:15:16 +00:00
|
|
|
RETERR(process_dhtkey(msg, &signer, keyname, &tkeyin,
|
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
|
|
|
tctx, &tkeyout, ring,
|
|
|
|
&namelist));
|
1999-10-26 15:39:59 +00:00
|
|
|
tkeyout.error = dns_rcode_noerror;
|
|
|
|
break;
|
|
|
|
case DNS_TKEYMODE_DELETE:
|
2000-03-08 20:15:16 +00:00
|
|
|
RETERR(process_deletetkey(msg, &signer, keyname,
|
|
|
|
&tkeyin, &tkeyout,
|
|
|
|
ring, &namelist));
|
1999-10-26 15:39:59 +00:00
|
|
|
tkeyout.error = dns_rcode_noerror;
|
|
|
|
break;
|
|
|
|
case DNS_TKEYMODE_SERVERASSIGNED:
|
|
|
|
case DNS_TKEYMODE_GSSAPI:
|
|
|
|
case DNS_TKEYMODE_RESOLVERASSIGNED:
|
1999-10-26 21:57:53 +00:00
|
|
|
result = DNS_R_NOTIMP;
|
1999-10-26 15:39:59 +00:00
|
|
|
goto failure;
|
|
|
|
default:
|
|
|
|
tkeyout.error = dns_tsigerror_badmode;
|
|
|
|
}
|
|
|
|
|
|
|
|
failure_with_tkey:
|
|
|
|
dns_rdata_freestruct(&tkeyin);
|
|
|
|
|
|
|
|
RETERR(dns_message_gettemprdata(msg, &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
|
|
|
RETERR(isc_buffer_allocate(msg->mctx, &dynbuf, 128));
|
1999-10-26 15:39:59 +00:00
|
|
|
result = dns_rdata_fromstruct(rdata, tkeyout.common.rdclass,
|
|
|
|
tkeyout.common.rdtype, &tkeyout, dynbuf);
|
2000-05-19 22:11:20 +00:00
|
|
|
dns_name_free(&tkeyout.algorithm, msg->mctx);
|
|
|
|
if (tkeyout.key != NULL)
|
|
|
|
isc_mem_put(msg->mctx, tkeyout.key, tkeyout.keylen);
|
|
|
|
if (tkeyout.other != NULL)
|
|
|
|
isc_mem_put(msg->mctx, tkeyout.other, tkeyout.otherlen);
|
1999-10-26 15:39:59 +00:00
|
|
|
if (result != ISC_R_SUCCESS)
|
|
|
|
goto failure;
|
|
|
|
|
|
|
|
RETERR(add_rdata_to_list(msg, keyname, rdata, 0, &namelist));
|
|
|
|
|
|
|
|
isc_buffer_free(&dynbuf);
|
|
|
|
|
|
|
|
RETERR(dns_message_reply(msg, ISC_TRUE));
|
|
|
|
|
|
|
|
name = ISC_LIST_HEAD(namelist);
|
|
|
|
while (name != NULL) {
|
|
|
|
dns_name_t *next = ISC_LIST_NEXT(name, link);
|
|
|
|
ISC_LIST_UNLINK(namelist, name, link);
|
2000-03-28 03:16:40 +00:00
|
|
|
dns_message_addname(msg, name, DNS_SECTION_ANSWER);
|
1999-10-26 15:39:59 +00:00
|
|
|
name = next;
|
|
|
|
}
|
|
|
|
|
|
|
|
return (ISC_R_SUCCESS);
|
|
|
|
|
|
|
|
failure:
|
2000-06-22 23:07:00 +00:00
|
|
|
if (freealg)
|
|
|
|
dns_name_free(&tkeyout.algorithm, msg->mctx);
|
1999-10-26 15:39:59 +00:00
|
|
|
if (tkeyin.common.rdtype == dns_rdatatype_tkey)
|
|
|
|
dns_rdata_freestruct(&tkeyin);
|
|
|
|
if (rdata != NULL)
|
|
|
|
dns_message_puttemprdata(msg, &rdata);
|
|
|
|
if (dynbuf != NULL)
|
|
|
|
isc_buffer_free(&dynbuf);
|
|
|
|
return (result);
|
|
|
|
}
|
|
|
|
|
|
|
|
static isc_result_t
|
|
|
|
buildquery(dns_message_t *msg, dns_name_t *name,
|
2000-04-28 02:08:37 +00:00
|
|
|
dns_rdata_tkey_t *tkey)
|
1999-10-26 15:39:59 +00:00
|
|
|
{
|
|
|
|
dns_name_t *qname = NULL, *aname = NULL;
|
|
|
|
dns_rdataset_t *question = NULL, *tkeyset = NULL;
|
|
|
|
dns_rdatalist_t *tkeylist = NULL;
|
|
|
|
dns_rdata_t *rdata = NULL;
|
|
|
|
isc_buffer_t *dynbuf = NULL;
|
|
|
|
isc_result_t result;
|
|
|
|
|
|
|
|
REQUIRE(msg != NULL);
|
|
|
|
REQUIRE(name != NULL);
|
|
|
|
REQUIRE(tkey != NULL);
|
|
|
|
|
|
|
|
RETERR(dns_message_gettempname(msg, &qname));
|
|
|
|
RETERR(dns_message_gettempname(msg, &aname));
|
|
|
|
|
|
|
|
RETERR(dns_message_gettemprdataset(msg, &question));
|
|
|
|
dns_rdataset_init(question);
|
2000-01-24 22:22:51 +00:00
|
|
|
dns_rdataset_makequestion(question, dns_rdataclass_any,
|
1999-10-26 19:32:37 +00:00
|
|
|
dns_rdatatype_tkey);
|
1999-10-26 15:39:59 +00:00
|
|
|
|
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
|
|
|
RETERR(isc_buffer_allocate(msg->mctx, &dynbuf, 512));
|
1999-10-26 15:39:59 +00:00
|
|
|
RETERR(dns_message_gettemprdata(msg, &rdata));
|
2000-01-24 22:22:51 +00:00
|
|
|
RETERR(dns_rdata_fromstruct(rdata, dns_rdataclass_any,
|
1999-10-26 19:32:37 +00:00
|
|
|
dns_rdatatype_tkey, tkey, dynbuf));
|
1999-10-26 15:39:59 +00:00
|
|
|
dns_message_takebuffer(msg, &dynbuf);
|
|
|
|
|
|
|
|
RETERR(dns_message_gettemprdatalist(msg, &tkeylist));
|
2000-01-24 22:22:51 +00:00
|
|
|
tkeylist->rdclass = dns_rdataclass_any;
|
1999-10-26 15:39:59 +00:00
|
|
|
tkeylist->type = dns_rdatatype_tkey;
|
1999-10-26 19:32:37 +00:00
|
|
|
tkeylist->covers = 0;
|
1999-10-26 15:39:59 +00:00
|
|
|
tkeylist->ttl = 0;
|
|
|
|
ISC_LIST_INIT(tkeylist->rdata);
|
|
|
|
ISC_LIST_APPEND(tkeylist->rdata, rdata, link);
|
|
|
|
|
|
|
|
RETERR(dns_message_gettemprdataset(msg, &tkeyset));
|
|
|
|
dns_rdataset_init(tkeyset);
|
|
|
|
RETERR(dns_rdatalist_tordataset(tkeylist, tkeyset));
|
|
|
|
|
|
|
|
dns_name_init(qname, NULL);
|
|
|
|
dns_name_clone(name, qname);
|
|
|
|
|
|
|
|
dns_name_init(aname, NULL);
|
|
|
|
dns_name_clone(name, aname);
|
|
|
|
|
|
|
|
ISC_LIST_APPEND(qname->list, question, link);
|
|
|
|
ISC_LIST_APPEND(aname->list, tkeyset, link);
|
|
|
|
|
|
|
|
dns_message_addname(msg, qname, DNS_SECTION_QUESTION);
|
|
|
|
dns_message_addname(msg, aname, DNS_SECTION_ADDITIONAL);
|
|
|
|
|
|
|
|
return (ISC_R_SUCCESS);
|
|
|
|
|
|
|
|
failure:
|
|
|
|
if (qname != NULL)
|
|
|
|
dns_message_puttempname(msg, &qname);
|
|
|
|
if (aname != NULL)
|
|
|
|
dns_message_puttempname(msg, &aname);
|
2000-01-21 20:18:41 +00:00
|
|
|
if (question != NULL) {
|
|
|
|
dns_rdataset_disassociate(question);
|
1999-10-26 15:39:59 +00:00
|
|
|
dns_message_puttemprdataset(msg, &question);
|
2000-01-21 20:18:41 +00:00
|
|
|
}
|
1999-10-26 15:39:59 +00:00
|
|
|
if (dynbuf != NULL)
|
|
|
|
isc_buffer_free(&dynbuf);
|
|
|
|
return (result);
|
|
|
|
}
|
|
|
|
|
|
|
|
isc_result_t
|
|
|
|
dns_tkey_builddhquery(dns_message_t *msg, dst_key_t *key, dns_name_t *name,
|
2000-01-24 20:19:53 +00:00
|
|
|
dns_name_t *algorithm, isc_buffer_t *nonce,
|
|
|
|
isc_uint32_t lifetime)
|
1999-10-26 15:39:59 +00:00
|
|
|
{
|
2000-04-28 02:08:37 +00:00
|
|
|
dns_rdata_tkey_t tkey;
|
1999-10-26 15:39:59 +00:00
|
|
|
dns_rdata_t *rdata = NULL;
|
2000-05-24 23:13:32 +00:00
|
|
|
isc_buffer_t *dynbuf = NULL;
|
1999-10-26 15:39:59 +00:00
|
|
|
isc_region_t r;
|
2000-05-23 23:36:39 +00:00
|
|
|
dns_name_t keyname;
|
1999-10-26 15:39:59 +00:00
|
|
|
dns_namelist_t namelist;
|
|
|
|
isc_result_t result;
|
2000-01-24 20:19:53 +00:00
|
|
|
isc_stdtime_t now;
|
1999-10-26 15:39:59 +00:00
|
|
|
|
|
|
|
REQUIRE(msg != NULL);
|
|
|
|
REQUIRE(key != NULL);
|
|
|
|
REQUIRE(dst_key_alg(key) == DNS_KEYALG_DH);
|
|
|
|
REQUIRE(dst_key_isprivate(key));
|
|
|
|
REQUIRE(name != NULL);
|
|
|
|
REQUIRE(algorithm != NULL);
|
|
|
|
|
2000-01-24 22:22:51 +00:00
|
|
|
tkey.common.rdclass = dns_rdataclass_any;
|
1999-10-26 15:39:59 +00:00
|
|
|
tkey.common.rdtype = dns_rdatatype_tkey;
|
|
|
|
ISC_LINK_INIT(&tkey.common, link);
|
|
|
|
tkey.mctx = msg->mctx;
|
|
|
|
dns_name_init(&tkey.algorithm, NULL);
|
|
|
|
dns_name_clone(algorithm, &tkey.algorithm);
|
2000-01-24 20:19:53 +00:00
|
|
|
isc_stdtime_get(&now);
|
|
|
|
tkey.inception = now;
|
|
|
|
tkey.expire = now + lifetime;
|
1999-10-26 15:39:59 +00:00
|
|
|
tkey.mode = DNS_TKEYMODE_DIFFIEHELLMAN;
|
2000-01-24 20:19:53 +00:00
|
|
|
if (nonce != NULL)
|
|
|
|
isc_buffer_region(nonce, &r);
|
|
|
|
else {
|
2000-03-17 19:50:22 +00:00
|
|
|
r.base = isc_mem_get(msg->mctx, 0);
|
2000-01-24 20:19:53 +00:00
|
|
|
r.length = 0;
|
|
|
|
}
|
1999-10-26 15:39:59 +00:00
|
|
|
tkey.error = 0;
|
2000-01-21 20:18:41 +00:00
|
|
|
tkey.key = r.base;
|
|
|
|
tkey.keylen = r.length;
|
|
|
|
tkey.other = NULL;
|
|
|
|
tkey.otherlen = 0;
|
1999-10-26 15:39:59 +00:00
|
|
|
|
|
|
|
RETERR(buildquery(msg, name, &tkey));
|
|
|
|
|
2000-03-17 19:50:22 +00:00
|
|
|
if (nonce == NULL)
|
|
|
|
isc_mem_put(msg->mctx, r.base, 0);
|
|
|
|
|
1999-10-26 15:39:59 +00:00
|
|
|
RETERR(dns_message_gettemprdata(msg, &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
|
|
|
RETERR(isc_buffer_allocate(msg->mctx, &dynbuf, 1024));
|
1999-10-26 15:39:59 +00:00
|
|
|
RETERR(dst_key_todns(key, dynbuf));
|
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_usedregion(dynbuf, &r);
|
2000-01-24 22:22:51 +00:00
|
|
|
dns_rdata_fromregion(rdata, dns_rdataclass_any,
|
1999-10-26 15:39:59 +00:00
|
|
|
dns_rdatatype_key, &r);
|
|
|
|
dns_message_takebuffer(msg, &dynbuf);
|
2000-05-24 23:13:32 +00:00
|
|
|
|
2000-05-23 23:36:39 +00:00
|
|
|
dns_name_init(&keyname, NULL);
|
2000-05-24 23:13:32 +00:00
|
|
|
dns_name_clone(dst_key_name(key), &keyname);
|
|
|
|
|
1999-10-26 15:39:59 +00:00
|
|
|
ISC_LIST_INIT(namelist);
|
2000-05-23 23:36:39 +00:00
|
|
|
RETERR(add_rdata_to_list(msg, &keyname, rdata, 0, &namelist));
|
1999-10-26 15:39:59 +00:00
|
|
|
dns_message_addname(msg, ISC_LIST_HEAD(namelist),
|
|
|
|
DNS_SECTION_ADDITIONAL);
|
|
|
|
|
|
|
|
return (ISC_R_SUCCESS);
|
|
|
|
|
|
|
|
failure:
|
|
|
|
|
|
|
|
if (dynbuf != NULL)
|
|
|
|
isc_buffer_free(&dynbuf);
|
|
|
|
return (result);
|
|
|
|
}
|
|
|
|
|
|
|
|
isc_result_t
|
|
|
|
dns_tkey_builddeletequery(dns_message_t *msg, dns_tsigkey_t *key) {
|
2000-04-28 02:08:37 +00:00
|
|
|
dns_rdata_tkey_t tkey;
|
1999-10-26 15:39:59 +00:00
|
|
|
|
|
|
|
REQUIRE(msg != NULL);
|
|
|
|
REQUIRE(key != NULL);
|
|
|
|
|
2000-01-24 22:22:51 +00:00
|
|
|
tkey.common.rdclass = dns_rdataclass_any;
|
1999-10-26 15:39:59 +00:00
|
|
|
tkey.common.rdtype = dns_rdatatype_tkey;
|
|
|
|
ISC_LINK_INIT(&tkey.common, link);
|
|
|
|
tkey.mctx = msg->mctx;
|
|
|
|
dns_name_init(&tkey.algorithm, NULL);
|
|
|
|
dns_name_clone(&key->algorithm, &tkey.algorithm);
|
|
|
|
tkey.inception = tkey.expire = 0;
|
|
|
|
tkey.mode = DNS_TKEYMODE_DELETE;
|
|
|
|
tkey.error = 0;
|
|
|
|
tkey.keylen = tkey.otherlen = 0;
|
|
|
|
tkey.key = tkey.other = NULL;
|
|
|
|
|
|
|
|
return (buildquery(msg, &key->name, &tkey));
|
|
|
|
}
|
|
|
|
|
|
|
|
static isc_result_t
|
2000-03-28 03:16:40 +00:00
|
|
|
find_tkey(dns_message_t *msg, dns_name_t **name, dns_rdata_t *rdata,
|
|
|
|
int section)
|
|
|
|
{
|
1999-10-26 15:39:59 +00:00
|
|
|
dns_rdataset_t *tkeyset;
|
|
|
|
isc_result_t result;
|
|
|
|
|
2000-03-28 03:16:40 +00:00
|
|
|
result = dns_message_firstname(msg, section);
|
1999-10-26 15:39:59 +00:00
|
|
|
while (result == ISC_R_SUCCESS) {
|
|
|
|
*name = NULL;
|
2000-03-28 03:16:40 +00:00
|
|
|
dns_message_currentname(msg, section, name);
|
1999-10-26 15:39:59 +00:00
|
|
|
tkeyset = NULL;
|
|
|
|
result = dns_message_findtype(*name, dns_rdatatype_tkey, 0,
|
|
|
|
&tkeyset);
|
|
|
|
if (result == ISC_R_SUCCESS) {
|
|
|
|
result = dns_rdataset_first(tkeyset);
|
|
|
|
if (result != ISC_R_SUCCESS)
|
|
|
|
return (result);
|
|
|
|
dns_rdataset_current(tkeyset, rdata);
|
|
|
|
return (ISC_R_SUCCESS);
|
|
|
|
}
|
2000-03-28 03:16:40 +00:00
|
|
|
result = dns_message_nextname(msg, section);
|
1999-10-26 15:39:59 +00:00
|
|
|
}
|
|
|
|
if (result == ISC_R_NOMORE)
|
|
|
|
return (ISC_R_NOTFOUND);
|
|
|
|
return (result);
|
|
|
|
}
|
|
|
|
|
|
|
|
isc_result_t
|
|
|
|
dns_tkey_processdhresponse(dns_message_t *qmsg, dns_message_t *rmsg,
|
2000-01-21 20:18:41 +00:00
|
|
|
dst_key_t *key, isc_buffer_t *nonce,
|
|
|
|
dns_tsigkey_t **outkey, dns_tsig_keyring_t *ring)
|
1999-10-26 15:39:59 +00:00
|
|
|
{
|
|
|
|
dns_rdata_t qtkeyrdata, rtkeyrdata;
|
|
|
|
dns_name_t keyname, *tkeyname, *theirkeyname, *ourkeyname, *tempname;
|
|
|
|
dns_rdataset_t *theirkeyset = NULL, *ourkeyset = NULL;
|
|
|
|
dns_rdata_t theirkeyrdata;
|
|
|
|
dst_key_t *theirkey;
|
2000-04-28 02:08:37 +00:00
|
|
|
dns_rdata_tkey_t qtkey, rtkey;
|
2000-05-24 23:13:32 +00:00
|
|
|
unsigned char secretdata[256];
|
1999-10-28 20:00:04 +00:00
|
|
|
unsigned int sharedsize;
|
2000-05-24 23:13:32 +00:00
|
|
|
isc_buffer_t *shared = NULL, secret;
|
2000-01-21 20:18:41 +00:00
|
|
|
isc_region_t r, r2;
|
1999-10-26 15:39:59 +00:00
|
|
|
isc_result_t result;
|
2000-05-26 00:16:46 +00:00
|
|
|
isc_boolean_t freertkey = ISC_FALSE;
|
1999-10-26 15:39:59 +00:00
|
|
|
|
|
|
|
REQUIRE(qmsg != NULL);
|
|
|
|
REQUIRE(rmsg != NULL);
|
|
|
|
REQUIRE(key != NULL);
|
|
|
|
REQUIRE(dst_key_alg(key) == DNS_KEYALG_DH);
|
|
|
|
REQUIRE(dst_key_isprivate(key));
|
1999-10-26 21:57:53 +00:00
|
|
|
if (outkey != NULL)
|
|
|
|
REQUIRE(*outkey == NULL);
|
2000-01-21 20:18:41 +00:00
|
|
|
REQUIRE(ring != NULL);
|
1999-10-26 15:39:59 +00:00
|
|
|
|
2000-01-24 20:19:53 +00:00
|
|
|
if (rmsg->rcode != dns_rcode_noerror)
|
2000-05-26 00:16:46 +00:00
|
|
|
return (ISC_RESULTCLASS_DNSRCODE + rmsg->rcode);
|
2000-03-28 03:16:40 +00:00
|
|
|
RETERR(find_tkey(rmsg, &tkeyname, &rtkeyrdata, DNS_SECTION_ANSWER));
|
1999-10-26 15:39:59 +00:00
|
|
|
RETERR(dns_rdata_tostruct(&rtkeyrdata, &rtkey, rmsg->mctx));
|
2000-05-26 00:16:46 +00:00
|
|
|
freertkey = ISC_TRUE;
|
1999-10-26 15:39:59 +00:00
|
|
|
|
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
|
|
|
RETERR(find_tkey(qmsg, &tempname, &qtkeyrdata,
|
|
|
|
DNS_SECTION_ADDITIONAL));
|
1999-10-26 15:39:59 +00:00
|
|
|
RETERR(dns_rdata_tostruct(&qtkeyrdata, &qtkey, qmsg->mctx));
|
|
|
|
|
|
|
|
if (rtkey.error != dns_rcode_noerror ||
|
|
|
|
rtkey.mode != DNS_TKEYMODE_DIFFIEHELLMAN ||
|
|
|
|
rtkey.mode != qtkey.mode ||
|
1999-10-26 21:57:53 +00:00
|
|
|
!dns_name_equal(&rtkey.algorithm, &qtkey.algorithm) ||
|
|
|
|
rmsg->rcode != dns_rcode_noerror)
|
1999-10-26 15:39:59 +00:00
|
|
|
{
|
2000-06-23 01:51:35 +00:00
|
|
|
tkey_log("dns_tkey_processdhresponse: tkey mode invalid "
|
|
|
|
"or error set");
|
1999-10-26 19:32:37 +00:00
|
|
|
result = DNS_R_INVALIDTKEY;
|
2000-05-26 00:16:46 +00:00
|
|
|
dns_rdata_freestruct(&qtkey);
|
1999-10-26 15:39:59 +00:00
|
|
|
goto failure;
|
|
|
|
}
|
|
|
|
|
2000-05-26 00:16:46 +00:00
|
|
|
dns_rdata_freestruct(&qtkey);
|
|
|
|
|
1999-10-26 15:39:59 +00:00
|
|
|
dns_name_init(&keyname, NULL);
|
2000-05-24 23:13:32 +00:00
|
|
|
dns_name_clone(dst_key_name(key), &keyname);
|
1999-10-26 15:39:59 +00:00
|
|
|
|
|
|
|
ourkeyname = NULL;
|
|
|
|
ourkeyset = NULL;
|
2000-03-28 03:16:40 +00:00
|
|
|
RETERR(dns_message_findname(rmsg, DNS_SECTION_ANSWER, &keyname,
|
1999-10-26 15:39:59 +00:00
|
|
|
dns_rdatatype_key, 0, &ourkeyname,
|
|
|
|
&ourkeyset));
|
|
|
|
|
2000-03-28 03:16:40 +00:00
|
|
|
result = dns_message_firstname(rmsg, DNS_SECTION_ANSWER);
|
1999-10-26 15:39:59 +00:00
|
|
|
while (result == ISC_R_SUCCESS) {
|
|
|
|
theirkeyname = NULL;
|
2000-03-28 03:16:40 +00:00
|
|
|
dns_message_currentname(rmsg, DNS_SECTION_ANSWER,
|
1999-10-26 15:39:59 +00:00
|
|
|
&theirkeyname);
|
|
|
|
if (dns_name_equal(theirkeyname, ourkeyname))
|
|
|
|
goto next;
|
|
|
|
theirkeyset = NULL;
|
|
|
|
result = dns_message_findtype(theirkeyname, dns_rdatatype_key,
|
|
|
|
0, &theirkeyset);
|
|
|
|
if (result == ISC_R_SUCCESS) {
|
|
|
|
RETERR(dns_rdataset_first(theirkeyset));
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
next:
|
2000-03-28 03:16:40 +00:00
|
|
|
result = dns_message_nextname(rmsg, DNS_SECTION_ANSWER);
|
1999-10-26 15:39:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (theirkeyset == NULL) {
|
2000-06-23 01:51:35 +00:00
|
|
|
tkey_log("dns_tkey_processdhresponse: failed to find server "
|
|
|
|
"key");
|
|
|
|
result = DNS_R_INVALIDTKEY;
|
1999-10-26 15:39:59 +00:00
|
|
|
result = ISC_R_NOTFOUND;
|
|
|
|
goto failure;
|
|
|
|
}
|
|
|
|
|
|
|
|
dns_rdataset_current(theirkeyset, &theirkeyrdata);
|
|
|
|
theirkey = NULL;
|
|
|
|
RETERR(dns_dnssec_keyfromrdata(theirkeyname, &theirkeyrdata,
|
|
|
|
rmsg->mctx, &theirkey));
|
|
|
|
|
2000-05-17 22:48:10 +00:00
|
|
|
RETERR(dst_key_secretsize(key, &sharedsize));
|
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
|
|
|
RETERR(isc_buffer_allocate(rmsg->mctx, &shared, sharedsize));
|
1999-10-26 15:39:59 +00:00
|
|
|
|
2000-05-17 22:48:10 +00:00
|
|
|
RETERR(dst_key_computesecret(theirkey, key, shared));
|
1999-10-28 20:00:04 +00:00
|
|
|
|
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(&secret, secretdata, sizeof(secretdata));
|
1999-10-28 20:00:04 +00:00
|
|
|
|
|
|
|
r.base = rtkey.key;
|
|
|
|
r.length = rtkey.keylen;
|
2000-01-24 20:19:53 +00:00
|
|
|
if (nonce != NULL)
|
|
|
|
isc_buffer_region(nonce, &r2);
|
|
|
|
else {
|
2000-03-17 19:50:22 +00:00
|
|
|
r2.base = isc_mem_get(rmsg->mctx, 0);
|
2000-01-24 20:19:53 +00:00
|
|
|
r2.length = 0;
|
|
|
|
}
|
2000-06-07 02:33:46 +00:00
|
|
|
RETERR(compute_secret(shared, &r2, &r, &secret));
|
2000-03-17 19:50:22 +00:00
|
|
|
if (nonce == NULL)
|
|
|
|
isc_mem_put(rmsg->mctx, r2.base, 0);
|
1999-10-26 15:39:59 +00:00
|
|
|
|
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_usedregion(&secret, &r);
|
1999-10-26 15:39:59 +00:00
|
|
|
result = dns_tsigkey_create(tkeyname, &rtkey.algorithm,
|
|
|
|
r.base, r.length, ISC_TRUE,
|
2000-01-24 22:22:51 +00:00
|
|
|
NULL, rtkey.inception, rtkey.expire,
|
|
|
|
rmsg->mctx, ring, outkey);
|
1999-10-28 20:00:04 +00:00
|
|
|
isc_buffer_free(&shared);
|
2000-05-26 00:16:46 +00:00
|
|
|
dns_rdata_freestruct(&rtkey);
|
|
|
|
dst_key_free(&theirkey);
|
1999-10-26 15:39:59 +00:00
|
|
|
return (result);
|
|
|
|
|
|
|
|
failure:
|
1999-10-28 20:00:04 +00:00
|
|
|
if (shared != NULL)
|
|
|
|
isc_buffer_free(&shared);
|
1999-10-26 15:39:59 +00:00
|
|
|
|
2000-05-26 00:16:46 +00:00
|
|
|
if (theirkey != NULL)
|
|
|
|
dst_key_free(&theirkey);
|
|
|
|
|
|
|
|
if (freertkey)
|
|
|
|
dns_rdata_freestruct(&rtkey);
|
|
|
|
|
1999-10-26 15:39:59 +00:00
|
|
|
return (result);
|
|
|
|
}
|
|
|
|
|
|
|
|
isc_result_t
|
2000-01-21 20:18:41 +00:00
|
|
|
dns_tkey_processdeleteresponse(dns_message_t *qmsg, dns_message_t *rmsg,
|
|
|
|
dns_tsig_keyring_t *ring)
|
|
|
|
{
|
1999-10-26 15:39:59 +00:00
|
|
|
dns_rdata_t qtkeyrdata, rtkeyrdata;
|
|
|
|
dns_name_t *tkeyname, *tempname;
|
2000-04-28 02:08:37 +00:00
|
|
|
dns_rdata_tkey_t qtkey, rtkey;
|
1999-10-26 15:39:59 +00:00
|
|
|
dns_tsigkey_t *tsigkey = NULL;
|
|
|
|
isc_result_t result;
|
|
|
|
|
|
|
|
REQUIRE(qmsg != NULL);
|
|
|
|
REQUIRE(rmsg != NULL);
|
|
|
|
|
2000-01-24 20:19:53 +00:00
|
|
|
if (rmsg->rcode != dns_rcode_noerror)
|
|
|
|
return(ISC_RESULTCLASS_DNSRCODE + rmsg->rcode);
|
|
|
|
|
2000-03-28 03:16:40 +00:00
|
|
|
RETERR(find_tkey(rmsg, &tkeyname, &rtkeyrdata, DNS_SECTION_ANSWER));
|
1999-10-26 15:39:59 +00:00
|
|
|
RETERR(dns_rdata_tostruct(&rtkeyrdata, &rtkey, rmsg->mctx));
|
|
|
|
|
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
|
|
|
RETERR(find_tkey(qmsg, &tempname, &qtkeyrdata,
|
|
|
|
DNS_SECTION_ADDITIONAL));
|
1999-10-26 15:39:59 +00:00
|
|
|
RETERR(dns_rdata_tostruct(&qtkeyrdata, &qtkey, qmsg->mctx));
|
|
|
|
|
|
|
|
if (rtkey.error != dns_rcode_noerror ||
|
|
|
|
rtkey.mode != DNS_TKEYMODE_DELETE ||
|
|
|
|
rtkey.mode != qtkey.mode ||
|
1999-10-26 21:57:53 +00:00
|
|
|
!dns_name_equal(&rtkey.algorithm, &qtkey.algorithm) ||
|
|
|
|
rmsg->rcode != dns_rcode_noerror)
|
1999-10-26 15:39:59 +00:00
|
|
|
{
|
2000-06-23 01:51:35 +00:00
|
|
|
tkey_log("dns_tkey_processdeleteresponse: tkey mode invalid "
|
|
|
|
"or error set");
|
1999-10-26 19:32:37 +00:00
|
|
|
result = DNS_R_INVALIDTKEY;
|
2000-05-26 00:16:46 +00:00
|
|
|
dns_rdata_freestruct(&qtkey);
|
1999-10-26 15:39:59 +00:00
|
|
|
dns_rdata_freestruct(&rtkey);
|
|
|
|
goto failure;
|
|
|
|
}
|
|
|
|
|
2000-05-26 00:16:46 +00:00
|
|
|
dns_rdata_freestruct(&qtkey);
|
|
|
|
|
2000-01-22 04:45:17 +00:00
|
|
|
RETERR(dns_tsigkey_find(&tsigkey, tkeyname, &rtkey.algorithm, ring));
|
1999-10-26 15:39:59 +00:00
|
|
|
|
2000-05-26 00:16:46 +00:00
|
|
|
dns_rdata_freestruct(&rtkey);
|
|
|
|
|
2000-05-08 14:38:29 +00:00
|
|
|
/*
|
|
|
|
* Mark the key as deleted.
|
|
|
|
*/
|
1999-10-26 15:39:59 +00:00
|
|
|
dns_tsigkey_setdeleted(tsigkey);
|
2000-05-08 14:38:29 +00:00
|
|
|
/*
|
|
|
|
* Release the reference.
|
|
|
|
*/
|
2000-05-26 00:16:46 +00:00
|
|
|
dns_tsigkey_detach(&tsigkey);
|
1999-10-26 15:39:59 +00:00
|
|
|
|
|
|
|
failure:
|
|
|
|
return (result);
|
|
|
|
}
|