tsigconf.c revision 1a69a1a78cfaa86f3b68bbc965232b7876d4da2a
04b5785fde2948599bf259d2ca3235a3d9f55172Tinderbox User * Copyright (C) 1999, 2000 Internet Software Consortium.
40f53fa8d9c6a4fc38c0014495e7a42b08f52481David Lawrence * 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
2cde028c51055c9fd4837337116cd4fdfe8ff623James Brister * copyright notice and this permission notice appear in all copies.
40f53fa8d9c6a4fc38c0014495e7a42b08f52481David Lawrence * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews * CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
590f840d3484114576d9f8a7f7d73fbe31228888Brian Wellingtonadd_initial_keys(dns_c_kdeflist_t *list, dns_tsig_keyring_t *ring,
a920fb9dc2ff16f32dd73e53469d0febcdcc6c11Mark Andrews isc_buffer_t keynamesrc, keynamebuf, algsrc, algbuf;
b3e77535185043f089b346166440402d092030c3David Lawrence * Create the key name.
1f1d36a87b65186d9f89aac7f456ab1fd2a39ef6Andreas Gustafsson isc_buffer_init(&keynamesrc, key->keyid, strlen(key->keyid));
2cde028c51055c9fd4837337116cd4fdfe8ff623James Brister isc_buffer_add(&keynamesrc, strlen(key->keyid));
2cde028c51055c9fd4837337116cd4fdfe8ff623James Brister isc_buffer_init(&keynamebuf, keynamedata, sizeof(keynamedata));
b3e77535185043f089b346166440402d092030c3David Lawrence ret = dns_name_fromtext(&keyname, &keynamesrc, dns_rootname,
1f1d36a87b65186d9f89aac7f456ab1fd2a39ef6Andreas Gustafsson * Create the algorithm.
40f53fa8d9c6a4fc38c0014495e7a42b08f52481David Lawrence if (strcasecmp(key->algorithm, "hmac-md5") == 0)
40f53fa8d9c6a4fc38c0014495e7a42b08f52481David Lawrence isc_buffer_add(&algsrc, strlen(key->algorithm));
2cde028c51055c9fd4837337116cd4fdfe8ff623James Brister isc_buffer_init(&algbuf, algdata, sizeof(algdata));
40f53fa8d9c6a4fc38c0014495e7a42b08f52481David Lawrence ret = dns_name_fromtext(&alg, &algsrc, dns_rootname,
2cde028c51055c9fd4837337116cd4fdfe8ff623James Brister secretalloc = secretlen = strlen(key->secret) * 3 / 4;
2cde028c51055c9fd4837337116cd4fdfe8ff623James Brister isc_buffer_init(&secretsrc, key->secret, strlen(key->secret));
2cde028c51055c9fd4837337116cd4fdfe8ff623James Brister isc_buffer_add(&secretsrc, strlen(key->secret));
b3e77535185043f089b346166440402d092030c3David Lawrence isc_buffer_init(&secretbuf, secret, secretlen);
2cde028c51055c9fd4837337116cd4fdfe8ff623James Brister ret = isc_lex_create(mctx, strlen(key->secret), &lex);
2cde028c51055c9fd4837337116cd4fdfe8ff623James Brister ret = isc_base64_tobuffer(lex, &secretbuf, -1);
2cde028c51055c9fd4837337116cd4fdfe8ff623James Brister secretlen = isc_buffer_usedlength(&secretbuf);
1f1d36a87b65186d9f89aac7f456ab1fd2a39ef6Andreas Gustafsson ret = dns_tsigkey_create(&keyname, &alg, secret, secretlen,
2cde028c51055c9fd4837337116cd4fdfe8ff623James Bristerdns_tsigkeyring_fromconfig(dns_c_ctx_t *confctx, isc_mem_t *mctx,
2cde028c51055c9fd4837337116cd4fdfe8ff623James Brister result = dns_c_ctx_getkdeflist(confctx, &keylist);