tsigconf.c revision 307d2084502eddc7ce921e5ce439aec3531d90e0
4a979d35776321abc952346ba128d1a3cef730ceAutomatic Updater * Copyright (C) 2004-2007, 2009 Internet Systems Consortium, Inc. ("ISC")
1fa26403d7679235a30fbf6289f68fed5872df30Mark Andrews * Copyright (C) 1999-2001 Internet Software Consortium.
ec5347e2c775f027573ce5648b910361aa926c01Automatic Updater * Permission to use, copy, modify, and/or distribute this software for any
6ceca14e5ea7972a9ba8bc1dca0de1f63f669cfdDanny Mayer * purpose with or without fee is hereby granted, provided that the above
6ceca14e5ea7972a9ba8bc1dca0de1f63f669cfdDanny Mayer * copyright notice and this permission notice appear in all copies.
1fa26403d7679235a30fbf6289f68fed5872df30Mark Andrews * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
1fa26403d7679235a30fbf6289f68fed5872df30Mark Andrews * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
1fa26403d7679235a30fbf6289f68fed5872df30Mark Andrews * AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
1fa26403d7679235a30fbf6289f68fed5872df30Mark Andrews * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
1fa26403d7679235a30fbf6289f68fed5872df30Mark Andrews * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
1fa26403d7679235a30fbf6289f68fed5872df30Mark Andrews * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
1fa26403d7679235a30fbf6289f68fed5872df30Mark Andrews * PERFORMANCE OF THIS SOFTWARE.
891b61c3909afdae7e5d7ba14cd12d16186f4a68Mark Andrews/* $Id: tsigconf.c,v 1.33 2009/09/01 00:22:25 jinmei Exp $ */
d3243476c280d3a98cadbfd6343437fa2b29356bDanny Mayeradd_initial_keys(const cfg_obj_t *list, dns_tsig_keyring_t *ring,
487e6abc16c1b2958d371b0d4e808953646b520aDavid Lawrence keyid = cfg_obj_asstring(cfg_map_getname(key));
487e6abc16c1b2958d371b0d4e808953646b520aDavid Lawrence (void)cfg_map_get(key, "algorithm", &algobj);
487e6abc16c1b2958d371b0d4e808953646b520aDavid Lawrence (void)cfg_map_get(key, "secret", &secretobj);
487e6abc16c1b2958d371b0d4e808953646b520aDavid Lawrence * Create the key name.
487e6abc16c1b2958d371b0d4e808953646b520aDavid Lawrence isc_buffer_init(&keynamesrc, keyid, strlen(keyid));
487e6abc16c1b2958d371b0d4e808953646b520aDavid Lawrence isc_buffer_init(&keynamebuf, keynamedata, sizeof(keynamedata));
487e6abc16c1b2958d371b0d4e808953646b520aDavid Lawrence ret = dns_name_fromtext(&keyname, &keynamesrc, dns_rootname,
487e6abc16c1b2958d371b0d4e808953646b520aDavid Lawrence * Create the algorithm.
487e6abc16c1b2958d371b0d4e808953646b520aDavid Lawrence if (ns_config_getkeyalgorithm(algstr, &alg, &bits)
487e6abc16c1b2958d371b0d4e808953646b520aDavid Lawrence cfg_obj_log(algobj, ns_g_lctx, ISC_LOG_ERROR,
487e6abc16c1b2958d371b0d4e808953646b520aDavid Lawrence "key '%s': has a unsupported algorithm '%s'",
487e6abc16c1b2958d371b0d4e808953646b520aDavid Lawrence secretalloc = secretlen = strlen(secretstr) * 3 / 4;
487e6abc16c1b2958d371b0d4e808953646b520aDavid Lawrence isc_buffer_init(&secretbuf, secret, secretlen);
487e6abc16c1b2958d371b0d4e808953646b520aDavid Lawrence ret = isc_base64_decodestring(secretstr, &secretbuf);
487e6abc16c1b2958d371b0d4e808953646b520aDavid Lawrence secretlen = isc_buffer_usedlength(&secretbuf);
487e6abc16c1b2958d371b0d4e808953646b520aDavid Lawrence ret = dns_tsigkey_create(&keyname, alg, secret, secretlen,
ecffc3aae3e72c5c65b1911ec3f4e1d180dc4bbcMark Andrews * Set digest bits.
d3243476c280d3a98cadbfd6343437fa2b29356bDanny Mayerns_tsigkeyring_fromconfig(const cfg_obj_t *config, const cfg_obj_t *vconfig,
487e6abc16c1b2958d371b0d4e808953646b520aDavid Lawrence result = dns_tsigkeyring_create(mctx, &ring);
d3243476c280d3a98cadbfd6343437fa2b29356bDanny Mayer for (i = 0; ; i++) {