tkey.c revision 352e28b5eedc250149352990c3a8f14d5af0267f
19c7b1a0293498a3e36692c59646ed6e15ffc8d0Tinderbox User * Copyright (C) 1999, 2000 Internet Software Consortium.
4b01d45a49f1c2cc4bddc9a1b4c78232867de134Andreas Gustafsson * Permission to use, copy, modify, and distribute this software for any
ec5347e2c775f027573ce5648b910361aa926c01Automatic Updater * purpose with or without fee is hereby granted, provided that the above
4b01d45a49f1c2cc4bddc9a1b4c78232867de134Andreas Gustafsson * copyright notice and this permission notice appear in all copies.
4b01d45a49f1c2cc4bddc9a1b4c78232867de134Andreas Gustafsson * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews * DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews * INTERNET SOFTWARE CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT,
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
14a656f94b1fd0ababd84a772228dfa52276ba15Evan Hunt * $Id: tkey.c,v 1.51 2000/09/20 00:01:26 bwelling Exp $
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein#define RETERR(x) do { \
4b01d45a49f1c2cc4bddc9a1b4c78232867de134Andreas Gustafsson "tkey: %s", (m))
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein isc_log_vwrite(dns_lctx, DNS_LOGCATEGORY_GENERAL,
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein DNS_LOGMODULE_REQUEST, ISC_LOG_DEBUG(4), fmt, ap);
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austeindns_tkeyctx_create(isc_mem_t *mctx, isc_entropy_t *ectx, dns_tkeyctx_t **tctxp)
30eec077db2bdcb6f2a0dc388a3cdde2ede75ec1Mark Andrews tctx = isc_mem_get(mctx, sizeof(dns_tkeyctx_t));
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein isc_mem_put(mctx, tctx->domain, sizeof(dns_name_t));
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austeinadd_rdata_to_list(dns_message_t *msg, dns_name_t *name, dns_rdata_t *rdata,
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein isc_buffer_t *tmprdatabuf = NULL, *tmpnamebuf = NULL;
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein RETERR(dns_message_gettemprdata(msg, &newrdata));
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein RETERR(isc_buffer_allocate(msg->mctx, &tmprdatabuf, r.length));
30eec077db2bdcb6f2a0dc388a3cdde2ede75ec1Mark Andrews dns_rdata_fromregion(newrdata, rdata->rdclass, rdata->type, &newr);
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein RETERR(isc_buffer_allocate(msg->mctx, &tmpnamebuf, r.length));
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein RETERR(dns_message_gettemprdatalist(msg, &newlist));
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein RETERR(dns_message_gettemprdataset(msg, &newset));
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein RETERR(dns_rdatalist_tordataset(newlist, newset));
14a656f94b1fd0ababd84a772228dfa52276ba15Evan Huntcompute_secret(isc_buffer_t *shared, isc_region_t *queryrandomness,
14a656f94b1fd0ababd84a772228dfa52276ba15Evan Hunt isc_region_t *serverrandomness, isc_buffer_t *secret)
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein unsigned int i;
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein * MD5 ( query data | DH value ).
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein isc_md5_update(&md5ctx, queryrandomness->base, queryrandomness->length);
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein * MD5 ( server data | DH value ).
14a656f94b1fd0ababd84a772228dfa52276ba15Evan Hunt isc_md5_final(&md5ctx, &digests[ISC_MD5_DIGESTLENGTH]);
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein * XOR ( DH value, MD5-1 | MD5-2).
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein if (r.length < sizeof(digests) || r.length < r2.length)
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein for (i = 0; i < sizeof(digests); i++)
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austeinprocess_dhtkey(dns_message_t *msg, dns_name_t *signer, dns_name_t *name,
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein dns_tsig_keyring_t *ring, dns_namelist_t *namelist)
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein isc_boolean_t found_key = ISC_FALSE, found_incompatible = ISC_FALSE;
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein unsigned char *randomdata = NULL, secretdata[256];
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein * Look for a DH KEY record that will work with ours.
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein result = dns_message_firstname(msg, DNS_SECTION_ADDITIONAL);
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein dns_message_currentname(msg, DNS_SECTION_ADDITIONAL, &keyname);
268a4475065fe6a8cd7cc707820982cf5e98f430Rob Austein result = dns_message_findtype(keyname, dns_rdatatype_key, 0,
&pubkey);
goto got_key;
if (!found_key) {
if (found_incompatible) {
return (ISC_R_SUCCESS);
return (DNS_R_FORMERR);
namelist));
ourttl = 0;
namelist));
goto failure;
goto failure;
goto failure;
return (ISC_R_SUCCESS);
goto failure;
return (ISC_R_SUCCESS);
return (result);
static isc_result_t
return (DNS_R_REFUSED);
return (ISC_R_SUCCESS);
goto failure;
goto failure;
goto failure;
goto failure;
sizeof(randomtext),
NULL, 0);
goto failure;
goto failure;
goto failure;
goto failure_with_tkey;
goto failure;
goto failure_with_tkey;
&namelist));
case DNS_TKEYMODE_DELETE:
case DNS_TKEYMODE_GSSAPI:
goto failure;
goto failure;
return (ISC_R_SUCCESS);
if (freealg)
return (result);
static isc_result_t
return (ISC_R_SUCCESS);
return (result);
isc_region_t r;
r.length = 0;
dns_rdatatype_key, &r);
return (ISC_R_SUCCESS);
return (result);
static isc_result_t
int section)
&tkeyset);
return (result);
return (ISC_R_SUCCESS);
return (ISC_R_NOTFOUND);
return (result);
unsigned int sharedsize;
goto failure;
&ourkeyset));
&theirkeyname);
goto next;
0, &theirkeyset);
next:
goto failure;
return (result);
if (freertkey)
return (result);
goto failure;
return (result);