tsigconf.c revision 90c099e88e9f16bfee9edee3ac1a51fc98843772
499b34cea04a46823d003d4c0520c8b03e8513cbBrian Wellington * Copyright (C) 1999-2001 Internet Software Consortium.
f93d33e24fdf76eb2558168f018b8992bcfc5681Andreas Gustafsson * Permission to use, copy, modify, and distribute this software for any
f93d33e24fdf76eb2558168f018b8992bcfc5681Andreas Gustafsson * purpose with or without fee is hereby granted, provided that the above
f93d33e24fdf76eb2558168f018b8992bcfc5681Andreas Gustafsson * copyright notice and this permission notice appear in all copies.
15a44745412679c30a6d022733925af70a38b715David Lawrence * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM
15a44745412679c30a6d022733925af70a38b715David Lawrence * DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
15a44745412679c30a6d022733925af70a38b715David Lawrence * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
15a44745412679c30a6d022733925af70a38b715David Lawrence * INTERNET SOFTWARE CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT,
15a44745412679c30a6d022733925af70a38b715David Lawrence * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
15a44745412679c30a6d022733925af70a38b715David Lawrence * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
15a44745412679c30a6d022733925af70a38b715David Lawrence * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
15a44745412679c30a6d022733925af70a38b715David Lawrence * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington/* $Id: tsigconf.c,v 1.16 2001/03/04 21:21:28 bwelling Exp $ */
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellingtonadd_initial_keys(cfg_obj_t *list, dns_tsig_keyring_t *ring, isc_mem_t *mctx) {
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington keyid = cfg_obj_asstring(cfg_map_getname(key));
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington (void)cfg_map_get(key, "algorithm", &algobj);
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington (void)cfg_map_get(key, "secret", &secretobj);
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington INSIST(algobj != NULL && secretobj != NULL);
1a69a1a78cfaa86f3b68bbc965232b7876d4da2aDavid Lawrence * Create the key name.
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington isc_buffer_init(&keynamesrc, keyid, strlen(keyid));
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington isc_buffer_add(&keynamesrc, strlen(keyid));
6e49e91bd08778d7eae45a2229dcf41ed97cc636David Lawrence isc_buffer_init(&keynamebuf, keynamedata, sizeof(keynamedata));
f93d33e24fdf76eb2558168f018b8992bcfc5681Andreas Gustafsson ret = dns_name_fromtext(&keyname, &keynamesrc, dns_rootname,
1a69a1a78cfaa86f3b68bbc965232b7876d4da2aDavid Lawrence * Create the algorithm.
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington if (strcasecmp(cfg_obj_asstring(algobj), "hmac-md5") == 0)
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington cfg_obj_log(algobj, ns_g_lctx, ISC_LOG_ERROR,
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington "key '%s': the only supported algorithm "
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington secretalloc = secretlen = strlen(secretstr) * 3 / 4;
6e49e91bd08778d7eae45a2229dcf41ed97cc636David Lawrence isc_buffer_init(&secretbuf, secret, secretlen);
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington ret = isc_base64_decodestring(mctx, secretstr, &secretbuf);
6e49e91bd08778d7eae45a2229dcf41ed97cc636David Lawrence secretlen = isc_buffer_usedlength(&secretbuf);
7a184cd4e5a54a4e530f9bff8a4e46be392d0b52Brian Wellington ret = dns_tsigkey_create(&keyname, alg, secret, secretlen,
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellingtonns_tsigkeyring_fromconfig(cfg_obj_t *config, cfg_obj_t *vconfig,
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington isc_mem_t *mctx, dns_tsig_keyring_t **ringp)
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington maps[i++] = cfg_tuple_get(vconfig, "options");
f93d33e24fdf76eb2558168f018b8992bcfc5681Andreas Gustafsson result = dns_tsigkeyring_create(mctx, &ring);
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington for (i = 0; ; i++) {
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington result = cfg_map_get(maps[i], "key", &keylist);