Commit 3f6dc170 authored by Brian Wellington's avatar Brian Wellington

tsig structure/function name change

parent 139154bd
......@@ -15,7 +15,7 @@
* SOFTWARE.
*/
/* $Id: xfrin.c,v 1.10 1999/10/02 02:54:12 tale Exp $ */
/* $Id: xfrin.c,v 1.11 1999/10/08 18:37:23 bwelling Exp $ */
#include <config.h>
......@@ -140,7 +140,7 @@ struct xfrin_ctx {
unsigned int nmsg; /* Number of messages recvd */
dns_tsig_key_t *tsigkey; /* Key used to create TSIG */
dns_tsigkey_t *tsigkey; /* Key used to create TSIG */
dns_rdata_any_tsig_t *lasttsig; /* The last TSIG */
void *tsigctx; /* TSIG verification context */
unsigned int sincetsig; /* recvd since the last TSIG */
......@@ -180,7 +180,7 @@ xfrin_create(isc_mem_t *mctx,
dns_rdatatype_t reqtype,
char *addrstr, /* XXX */
in_port_t port,
dns_tsig_key_t *tsigkey,
dns_tsigkey_t *tsigkey,
xfrin_ctx_t **xfrp);
static dns_result_t axfr_init(xfrin_ctx_t *xfr);
......@@ -536,7 +536,7 @@ xfrin_test_dbi(ns_dbinfo_t *dbi) {
dns_db_t *db;
dns_rdatatype_t xfrtype;
unsigned int len;
dns_tsig_key_t *key = NULL;
dns_tsigkey_t *key = NULL;
printf("attempting zone transfer of zone \"%s\"...\n", dbi->origin);
......@@ -619,7 +619,7 @@ xfrin_create(isc_mem_t *mctx,
dns_rdatatype_t reqtype,
char *addrstr, /* XXX */
in_port_t port,
dns_tsig_key_t *tsigkey,
dns_tsigkey_t *tsigkey,
xfrin_ctx_t **xfrp)
{
xfrin_ctx_t *xfr = NULL;
......
......@@ -15,7 +15,7 @@
* SOFTWARE.
*/
/* $Id: xfrout.c,v 1.11 1999/10/07 19:33:12 halley Exp $ */
/* $Id: xfrout.c,v 1.12 1999/10/08 18:37:24 bwelling Exp $ */
#include <config.h>
......@@ -713,7 +713,7 @@ typedef struct {
unsigned int txmemlen;
unsigned int nmsg; /* Number of messages sent */
dns_tsig_key_t *tsigkey; /* Key used to create TSIG */
dns_tsigkey_t *tsigkey; /* Key used to create TSIG */
dns_rdata_any_tsig_t *lasttsig; /* the last TSIG */
} xfrout_ctx_t;
......@@ -721,7 +721,7 @@ static dns_result_t
xfrout_ctx_create(isc_mem_t *mctx, ns_client_t *client,
unsigned int id, dns_name_t *qname, dns_rdatatype_t qtype,
dns_db_t *db, dns_dbversion_t *ver,
rrstream_t *stream, dns_tsig_key_t *tsigkey,
rrstream_t *stream, dns_tsigkey_t *tsigkey,
dns_rdata_any_tsig_t *lasttsig, xfrout_ctx_t **xfrp);
static void sendstream(xfrout_ctx_t *xfr);
......@@ -948,7 +948,7 @@ static dns_result_t
xfrout_ctx_create(isc_mem_t *mctx, ns_client_t *client, unsigned int id,
dns_name_t *qname, dns_rdatatype_t qtype,
dns_db_t *db, dns_dbversion_t *ver,
rrstream_t *stream, dns_tsig_key_t *tsigkey,
rrstream_t *stream, dns_tsigkey_t *tsigkey,
dns_rdata_any_tsig_t *lasttsig, xfrout_ctx_t **xfrp)
{
xfrout_ctx_t *xfr;
......
......@@ -184,7 +184,7 @@ struct dns_message {
dns_rcode_t querytsigstatus;
dns_rdata_any_tsig_t *tsig;
dns_rdata_any_tsig_t *querytsig;
dns_tsig_key_t *tsigkey;
dns_tsigkey_t *tsigkey;
void *tsigctx;
int tsigstart;
};
......
......@@ -36,21 +36,22 @@ extern dns_name_t *dns_tsig_hmacmd5_name;
/* Default fudge value. */
#define DNS_TSIG_FUDGE 300
struct dns_tsig_key {
unsigned int magic; /* Magic number. */
isc_mem_t *mctx;
dst_key_t *key; /* Key */
dns_name_t name; /* Key name */
dns_name_t algorithm; /* Algorithm name */
ISC_LINK(dns_tsig_key_t) link;
struct dns_tsigkey {
unsigned int magic; /* Magic number. */
isc_mem_t *mctx;
dst_key_t *key; /* Key */
dns_name_t name; /* Key name */
dns_name_t algorithm; /* Algorithm name */
isc_boolean_t transient; /* dynamically created? */
ISC_LINK(dns_tsigkey_t) link;
};
#define dns_tsig_emptykey(tsigkey) ((tsigkey)->key == NULL)
#define dns_tsigkey_empty(tsigkey) ((tsigkey)->key == NULL)
isc_result_t
dns_tsig_key_create(dns_name_t *name, dns_name_t *algorithm,
unsigned char *secret, int length, isc_mem_t *mctx,
dns_tsig_key_t **key);
dns_tsigkey_create(dns_name_t *name, dns_name_t *algorithm,
unsigned char *secret, int length, isc_boolean_t transient,
isc_mem_t *mctx, dns_tsigkey_t **key);
/*
* Creates a tsig key structure pointed to by 'key'.
*
......@@ -70,7 +71,7 @@ dns_tsig_key_create(dns_name_t *name, dns_name_t *algorithm,
*/
void
dns_tsig_key_free(dns_tsig_key_t **key);
dns_tsigkey_free(dns_tsigkey_t **key);
/*
* Frees the tsig key structure pointed to by 'key'.
*
......@@ -137,7 +138,7 @@ dns_tsig_verify_tcp(isc_buffer_t *source, dns_message_t *msg);
*/
isc_result_t
dns_tsig_findkey(dns_tsig_key_t **tsigkey, dns_name_t *name,
dns_tsigkey_find(dns_tsigkey_t **tsigkey, dns_name_t *name,
dns_name_t *algorithm);
/*
* Returns the TSIG key corresponding to this name and algorithm
......
......@@ -72,7 +72,7 @@ typedef isc_uint16_t dns_trust_t;
typedef struct dns_dispatch dns_dispatch_t;
typedef struct dns_dispentry dns_dispentry_t;
typedef struct dns_dispatchevent dns_dispatchevent_t;
typedef struct dns_tsig_key dns_tsig_key_t;
typedef struct dns_tsigkey dns_tsigkey_t;
typedef struct dns_view dns_view_t;
typedef ISC_LIST(dns_view_t) dns_viewlist_t;
typedef struct dns_zone dns_zone_t;
......
......@@ -434,8 +434,8 @@ msgreset(dns_message_t *msg, isc_boolean_t everything)
sizeof(dns_rdata_any_tsig_t));
}
if (msg->tsigkey != NULL && dns_tsig_emptykey(msg->tsigkey))
dns_tsig_key_free(&msg->tsigkey);
if (msg->tsigkey != NULL && dns_tsigkey_empty(msg->tsigkey))
dns_tsigkey_free(&msg->tsigkey);
/*
* cleanup the buffer cleanup list
......
......@@ -72,7 +72,7 @@ typedef struct query {
ISC_LINK(struct query) link;
isc_buffer_t buffer;
dns_rdata_any_tsig_t *tsig;
dns_tsig_key_t *tsigkey;
dns_tsigkey_t *tsigkey;
unsigned char data[512];
} resquery_t;
......
......@@ -16,7 +16,7 @@
*/
/*
* $Id: tsig.c,v 1.15 1999/10/08 16:39:17 bwelling Exp $
* $Id: tsig.c,v 1.16 1999/10/08 18:36:51 bwelling Exp $
* Principal Author: Brian Wellington
*/
......@@ -52,7 +52,7 @@
#define VALID_TSIG_KEY(x) ((x) != NULL && (x)->magic == TSIG_MAGIC)
/* XXXBEW If an unsorted list isn't good enough, this can be updated */
static ISC_LIST(dns_tsig_key_t) tsigkeys;
static ISC_LIST(dns_tsigkey_t) tsigkeys;
static isc_rwlock_t tsiglock;
static isc_mem_t *tsig_mctx = NULL;
......@@ -61,14 +61,14 @@ dns_name_t *dns_tsig_hmacmd5_name = NULL;
#define is_response(msg) (msg->flags & DNS_MESSAGEFLAG_QR)
isc_result_t
dns_tsig_key_create(dns_name_t *name, dns_name_t *algorithm,
unsigned char *secret, int length,
isc_mem_t *mctx, dns_tsig_key_t **key)
dns_tsigkey_create(dns_name_t *name, dns_name_t *algorithm,
unsigned char *secret, int length, isc_boolean_t transient,
isc_mem_t *mctx, dns_tsigkey_t **key)
{
isc_buffer_t b, nameb;
char namestr[1024];
isc_uint16_t alg;
dns_tsig_key_t *tkey;
dns_tsigkey_t *tkey;
isc_result_t ret;
REQUIRE(key != NULL);
......@@ -85,7 +85,7 @@ dns_tsig_key_create(dns_name_t *name, dns_name_t *algorithm,
else
alg = DST_ALG_HMACMD5;
*key = (dns_tsig_key_t *) isc_mem_get(mctx, sizeof(dns_tsig_key_t));
*key = (dns_tsigkey_t *) isc_mem_get(mctx, sizeof(dns_tsigkey_t));
if (*key == NULL)
return (ISC_R_NOMEMORY);
tkey = *key;
......@@ -125,6 +125,7 @@ dns_tsig_key_create(dns_name_t *name, dns_name_t *algorithm,
else
tkey->key = NULL;
tkey->transient = transient;
tkey->mctx = mctx;
tkey->magic = TSIG_MAGIC;
return (ISC_R_SUCCESS);
......@@ -134,15 +135,15 @@ cleanup_algorithm:
cleanup_name:
dns_name_free(&tkey->name, mctx);
cleanup_key:
isc_mem_put(mctx, *key, sizeof(dns_tsig_key_t));
isc_mem_put(mctx, *key, sizeof(dns_tsigkey_t));
return (ret);
}
/* Caller must be sure that this key is not in use. */
void
dns_tsig_key_free(dns_tsig_key_t **key) {
dns_tsig_key_t *tkey;
dns_tsigkey_free(dns_tsigkey_t **key) {
dns_tsigkey_t *tkey;
REQUIRE(key != NULL);
REQUIRE(VALID_TSIG_KEY(*key));
......@@ -158,12 +159,12 @@ dns_tsig_key_free(dns_tsig_key_t **key) {
dns_name_free(&tkey->algorithm, tkey->mctx);
if (tkey->key != NULL)
dst_key_free(tkey->key);
isc_mem_put(tkey->mctx, tkey, sizeof(dns_tsig_key_t));
isc_mem_put(tkey->mctx, tkey, sizeof(dns_tsigkey_t));
}
isc_result_t
dns_tsig_sign(dns_message_t *msg) {
dns_tsig_key_t *key;
dns_tsigkey_t *key;
dns_rdata_any_tsig_t *tsig;
unsigned char data[128];
isc_buffer_t databuf, sigbuf;
......@@ -214,14 +215,14 @@ dns_tsig_sign(dns_message_t *msg) {
isc_buffer_init(&databuf, data, sizeof(data), ISC_BUFFERTYPE_BINARY);
if (!dns_tsig_emptykey(key)) {
if (!dns_tsigkey_empty(key)) {
ret = dst_sign(DST_SIGMODE_INIT, key->key, &ctx, NULL, NULL);
if (ret != ISC_R_SUCCESS)
goto cleanup_algorithm;
}
if (is_response(msg)) {
if (!dns_tsig_emptykey(key)) {
if (!dns_tsigkey_empty(key)) {
isc_buffer_putuint16(&databuf, msg->querytsig->siglen);
isc_buffer_available(&databuf, &r);
if (r.length < msg->querytsig->siglen)
......@@ -258,7 +259,7 @@ dns_tsig_sign(dns_message_t *msg) {
isc_buffer_putuint32(&otherbuf, tsig->timesigned & 0xFFFFFFFF);
}
if (!dns_tsig_emptykey(key)) {
if (!dns_tsigkey_empty(key)) {
unsigned char header[DNS_MESSAGE_HEADERLEN];
isc_buffer_t headerbuf;
......@@ -451,7 +452,7 @@ dns_tsig_verify(isc_buffer_t *source, dns_message_t *msg) {
dns_rdata_t rdata;
isc_stdtime_t now;
isc_result_t ret;
dns_tsig_key_t *tsigkey = NULL;
dns_tsigkey_t *tsigkey = NULL;
dst_key_t *key = NULL;
unsigned char header[DNS_MESSAGE_HEADERLEN];
dst_context_t ctx;
......@@ -511,17 +512,17 @@ dns_tsig_verify(isc_buffer_t *source, dns_message_t *msg) {
return (DNS_R_TSIGVERIFYFAILURE);
}
/* Find dns_tsig_key_t based on keyname */
ret = dns_tsig_findkey(&tsigkey, keyname, &tsig->algorithm);
/* Find dns_tsigkey_t based on keyname */
ret = dns_tsigkey_find(&tsigkey, keyname, &tsig->algorithm);
if (ret != ISC_R_SUCCESS) {
msg->tsigstatus = dns_tsigerror_badkey;
msg->tsigkey = NULL;
/*
* this key must be deleted later - an empty key can be found
* by calling dns_tsig_emptykey()
* by calling dns_tsigkey_empty()
*/
ret = dns_tsig_key_create(keyname, &tsig->algorithm, NULL, 0,
mctx, &msg->tsigkey);
ret = dns_tsigkey_create(keyname, &tsig->algorithm, NULL, 0,
ISC_TRUE, mctx, &msg->tsigkey);
if (ret != ISC_R_SUCCESS)
goto cleanup_struct;
return (DNS_R_TSIGVERIFYFAILURE);
......@@ -664,8 +665,8 @@ dns_tsig_verify(isc_buffer_t *source, dns_message_t *msg) {
return (ISC_R_SUCCESS);
cleanup_key:
if (dns_tsig_emptykey(msg->tsigkey)) {
dns_tsig_key_free(&msg->tsigkey);
if (dns_tsigkey_empty(msg->tsigkey)) {
dns_tsigkey_free(&msg->tsigkey);
msg->tsigkey = NULL;
}
cleanup_struct:
......@@ -839,10 +840,10 @@ cleanup_emptystruct:
}
isc_result_t
dns_tsig_findkey(dns_tsig_key_t **tsigkey, dns_name_t *name,
dns_tsigkey_find(dns_tsigkey_t **tsigkey, dns_name_t *name,
dns_name_t *algorithm)
{
dns_tsig_key_t *key;
dns_tsigkey_t *key;
REQUIRE(tsigkey != NULL);
REQUIRE(name != NULL);
......@@ -909,8 +910,8 @@ dns_tsig_init(isc_mem_t *mctx) {
void
dns_tsig_destroy() {
while (!ISC_LIST_EMPTY(tsigkeys)) {
dns_tsig_key_t *key = ISC_LIST_HEAD(tsigkeys);
dns_tsig_key_free(&key);
dns_tsigkey_t *key = ISC_LIST_HEAD(tsigkeys);
dns_tsigkey_free(&key);
}
dns_name_free(dns_tsig_hmacmd5_name, tsig_mctx);
isc_mem_put(tsig_mctx, dns_tsig_hmacmd5_name, sizeof(dns_name_t));
......
......@@ -15,7 +15,7 @@
* SOFTWARE.
*/
/* $Id: xfrin.c,v 1.10 1999/10/02 02:54:12 tale Exp $ */
/* $Id: xfrin.c,v 1.11 1999/10/08 18:37:23 bwelling Exp $ */
#include <config.h>
......@@ -140,7 +140,7 @@ struct xfrin_ctx {
unsigned int nmsg; /* Number of messages recvd */
dns_tsig_key_t *tsigkey; /* Key used to create TSIG */
dns_tsigkey_t *tsigkey; /* Key used to create TSIG */
dns_rdata_any_tsig_t *lasttsig; /* The last TSIG */
void *tsigctx; /* TSIG verification context */
unsigned int sincetsig; /* recvd since the last TSIG */
......@@ -180,7 +180,7 @@ xfrin_create(isc_mem_t *mctx,
dns_rdatatype_t reqtype,
char *addrstr, /* XXX */
in_port_t port,
dns_tsig_key_t *tsigkey,
dns_tsigkey_t *tsigkey,
xfrin_ctx_t **xfrp);
static dns_result_t axfr_init(xfrin_ctx_t *xfr);
......@@ -536,7 +536,7 @@ xfrin_test_dbi(ns_dbinfo_t *dbi) {
dns_db_t *db;
dns_rdatatype_t xfrtype;
unsigned int len;
dns_tsig_key_t *key = NULL;
dns_tsigkey_t *key = NULL;
printf("attempting zone transfer of zone \"%s\"...\n", dbi->origin);
......@@ -619,7 +619,7 @@ xfrin_create(isc_mem_t *mctx,
dns_rdatatype_t reqtype,
char *addrstr, /* XXX */
in_port_t port,
dns_tsig_key_t *tsigkey,
dns_tsigkey_t *tsigkey,
xfrin_ctx_t **xfrp)
{
xfrin_ctx_t *xfr = NULL;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment