1999-02-04 01:06:40 +00:00
|
|
|
/*
|
2000-02-03 23:50:32 +00:00
|
|
|
* Copyright (C) 1999, 2000 Internet Software Consortium.
|
1999-09-15 23:03:43 +00:00
|
|
|
*
|
1999-02-04 01:06:40 +00:00
|
|
|
* Permission to use, copy, modify, and distribute this software for any
|
|
|
|
* purpose with or without fee is hereby granted, provided that the above
|
|
|
|
* copyright notice and this permission notice appear in all copies.
|
1999-09-15 23:03:43 +00:00
|
|
|
*
|
1999-02-04 01:06:40 +00:00
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
|
|
|
|
* ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
|
|
|
|
* OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
|
|
|
|
* CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
|
|
|
|
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
|
|
|
|
* PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
|
|
|
|
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
|
|
|
|
* SOFTWARE.
|
|
|
|
*/
|
|
|
|
|
2000-05-22 12:38:12 +00:00
|
|
|
/* $Id: tsig_250.c,v 1.38 2000/05/22 12:37:28 marka Exp $ */
|
1999-02-04 01:06:40 +00:00
|
|
|
|
2000-03-16 21:50:14 +00:00
|
|
|
/* Reviewed: Thu Mar 16 13:39:43 PST 2000 by gson */
|
|
|
|
|
|
|
|
/* draft-ietf-dnsext-tsig-00.txt */
|
1999-02-04 01:06:40 +00:00
|
|
|
|
1999-05-05 00:19:04 +00:00
|
|
|
#ifndef RDATA_ANY_255_TSIG_250_C
|
|
|
|
#define RDATA_ANY_255_TSIG_250_C
|
2000-03-16 21:50:14 +00:00
|
|
|
|
2000-04-28 22:40:10 +00:00
|
|
|
#define RRTYPE_TSIG_ATTRIBUTES \
|
|
|
|
(DNS_RDATATYPEATTR_META | DNS_RDATATYPEATTR_NOTQUESTION)
|
2000-04-07 03:54:52 +00:00
|
|
|
|
1999-12-23 00:09:04 +00:00
|
|
|
static inline isc_result_t
|
1999-08-02 22:18:31 +00:00
|
|
|
fromtext_any_tsig(dns_rdataclass_t rdclass, dns_rdatatype_t type,
|
1999-02-04 01:06:40 +00:00
|
|
|
isc_lex_t *lexer, dns_name_t *origin,
|
|
|
|
isc_boolean_t downcase, isc_buffer_t *target)
|
|
|
|
{
|
|
|
|
isc_token_t token;
|
|
|
|
dns_name_t name;
|
1999-02-05 04:57:20 +00:00
|
|
|
isc_uint64_t sigtime;
|
1999-02-04 01:06:40 +00:00
|
|
|
isc_buffer_t buffer;
|
|
|
|
char *e;
|
|
|
|
|
|
|
|
REQUIRE(type == 250);
|
1999-08-02 22:18:31 +00:00
|
|
|
REQUIRE(rdclass == 255);
|
1999-02-04 01:06:40 +00:00
|
|
|
|
2000-05-13 22:50:49 +00:00
|
|
|
/*
|
|
|
|
* Algorithm Name.
|
|
|
|
*/
|
1999-02-04 01:06:40 +00:00
|
|
|
RETERR(gettoken(lexer, &token, isc_tokentype_string, ISC_FALSE));
|
|
|
|
dns_name_init(&name, NULL);
|
103. [func] libisc buffer API changes for <isc/buffer.h>:
Added:
isc_buffer_base(b) (pointer)
isc_buffer_current(b) (pointer)
isc_buffer_active(b) (pointer)
isc_buffer_used(b) (pointer)
isc_buffer_length(b) (int)
isc_buffer_usedlength(b) (int)
isc_buffer_consumedlength(b) (int)
isc_buffer_remaininglength(b) (int)
isc_buffer_activelength(b) (int)
isc_buffer_availablelength(b) (int)
Removed:
ISC_BUFFER_USEDCOUNT(b)
ISC_BUFFER_AVAILABLECOUNT(b)
isc_buffer_type(b)
Changed names:
isc_buffer_used(b, r) ->
isc_buffer_usedregion(b, r)
isc_buffer_available(b, r) ->
isc_buffer_available_region(b, r)
isc_buffer_consumed(b, r) ->
isc_buffer_consumedregion(b, r)
isc_buffer_active(b, r) ->
isc_buffer_activeregion(b, r)
isc_buffer_remaining(b, r) ->
isc_buffer_remainingregion(b, r)
Buffer types were removed, so the ISC_BUFFERTYPE_*
macros are no more, and the type argument to
isc_buffer_init and isc_buffer_allocate were removed.
isc_buffer_putstr is now void (instead of isc_result_t)
and requires that the caller ensure that there
is enough available buffer space for the string.
2000-04-27 00:03:12 +00:00
|
|
|
buffer_fromregion(&buffer, &token.value.as_region);
|
1999-02-04 01:06:40 +00:00
|
|
|
origin = (origin != NULL) ? origin : dns_rootname;
|
|
|
|
RETERR(dns_name_fromtext(&name, &buffer, origin, downcase, target));
|
|
|
|
|
2000-05-13 22:50:49 +00:00
|
|
|
/*
|
|
|
|
* Time Signed: 48 bits.
|
|
|
|
*/
|
1999-02-04 01:06:40 +00:00
|
|
|
RETERR(gettoken(lexer, &token, isc_tokentype_string, ISC_FALSE));
|
2000-04-28 22:40:10 +00:00
|
|
|
sigtime = isc_string_touint64(token.value.as_pointer, &e, 10);
|
1999-02-04 01:06:40 +00:00
|
|
|
if (*e != 0)
|
|
|
|
return (DNS_R_SYNTAX);
|
|
|
|
if ((sigtime >> 48) != 0)
|
2000-05-15 21:14:38 +00:00
|
|
|
return (ISC_R_RANGE);
|
1999-10-08 22:48:13 +00:00
|
|
|
RETERR(uint16_tobuffer((isc_uint16_t)(sigtime >> 32), target));
|
2000-03-16 21:50:14 +00:00
|
|
|
RETERR(uint32_tobuffer((isc_uint32_t)(sigtime & 0xffffffffU), target));
|
1999-02-04 01:06:40 +00:00
|
|
|
|
2000-05-13 22:50:49 +00:00
|
|
|
/*
|
|
|
|
* Fudge.
|
|
|
|
*/
|
1999-02-04 01:06:40 +00:00
|
|
|
RETERR(gettoken(lexer, &token, isc_tokentype_number, ISC_FALSE));
|
|
|
|
if (token.value.as_ulong > 0xffff)
|
2000-05-15 21:14:38 +00:00
|
|
|
return (ISC_R_RANGE);
|
1999-02-04 01:06:40 +00:00
|
|
|
RETERR(uint16_tobuffer(token.value.as_ulong, target));
|
|
|
|
|
2000-05-13 22:50:49 +00:00
|
|
|
/*
|
|
|
|
* Signature Size.
|
|
|
|
*/
|
1999-02-04 01:06:40 +00:00
|
|
|
RETERR(gettoken(lexer, &token, isc_tokentype_number, ISC_FALSE));
|
|
|
|
if (token.value.as_ulong > 0xffff)
|
2000-05-15 21:14:38 +00:00
|
|
|
return (ISC_R_RANGE);
|
1999-02-04 01:06:40 +00:00
|
|
|
RETERR(uint16_tobuffer(token.value.as_ulong, target));
|
|
|
|
|
2000-05-13 22:50:49 +00:00
|
|
|
/*
|
|
|
|
* Signature.
|
|
|
|
*/
|
|
|
|
RETERR(isc_base64_tobuffer(lexer, target, (int)token.value.as_ulong));
|
1999-02-04 01:06:40 +00:00
|
|
|
|
2000-05-13 22:50:49 +00:00
|
|
|
/*
|
|
|
|
* Original ID.
|
|
|
|
*/
|
1999-02-04 01:06:40 +00:00
|
|
|
RETERR(gettoken(lexer, &token, isc_tokentype_number, ISC_FALSE));
|
|
|
|
if (token.value.as_ulong > 0xffff)
|
2000-05-15 21:14:38 +00:00
|
|
|
return (ISC_R_RANGE);
|
1999-02-04 01:06:40 +00:00
|
|
|
RETERR(uint16_tobuffer(token.value.as_ulong, target));
|
|
|
|
|
2000-05-13 22:50:49 +00:00
|
|
|
/*
|
|
|
|
* Error.
|
|
|
|
*/
|
1999-02-04 01:06:40 +00:00
|
|
|
RETERR(gettoken(lexer, &token, isc_tokentype_number, ISC_FALSE));
|
|
|
|
if (token.value.as_ulong > 0xffff)
|
2000-05-15 21:14:38 +00:00
|
|
|
return (ISC_R_RANGE);
|
1999-02-04 01:06:40 +00:00
|
|
|
RETERR(uint16_tobuffer(token.value.as_ulong, target));
|
|
|
|
|
2000-05-13 22:50:49 +00:00
|
|
|
/*
|
|
|
|
* Other Len.
|
|
|
|
*/
|
1999-02-04 01:06:40 +00:00
|
|
|
RETERR(gettoken(lexer, &token, isc_tokentype_number, ISC_FALSE));
|
|
|
|
if (token.value.as_ulong > 0xffff)
|
2000-05-15 21:14:38 +00:00
|
|
|
return (ISC_R_RANGE);
|
1999-02-04 01:06:40 +00:00
|
|
|
RETERR(uint16_tobuffer(token.value.as_ulong, target));
|
|
|
|
|
2000-05-13 22:50:49 +00:00
|
|
|
/*
|
|
|
|
* Other Data.
|
|
|
|
*/
|
|
|
|
return (isc_base64_tobuffer(lexer, target, (int)token.value.as_ulong));
|
1999-02-04 01:06:40 +00:00
|
|
|
}
|
|
|
|
|
1999-12-23 00:09:04 +00:00
|
|
|
static inline isc_result_t
|
1999-06-08 10:35:23 +00:00
|
|
|
totext_any_tsig(dns_rdata_t *rdata, dns_rdata_textctx_t *tctx,
|
|
|
|
isc_buffer_t *target)
|
|
|
|
{
|
1999-02-04 01:06:40 +00:00
|
|
|
isc_region_t sr;
|
|
|
|
isc_region_t sigr;
|
|
|
|
char buf[sizeof "281474976710655 "];
|
1999-02-05 05:15:16 +00:00
|
|
|
char *bufp;
|
1999-02-04 01:06:40 +00:00
|
|
|
dns_name_t name;
|
|
|
|
dns_name_t prefix;
|
|
|
|
isc_boolean_t sub;
|
1999-02-05 04:57:20 +00:00
|
|
|
isc_uint64_t sigtime;
|
1999-02-04 01:06:40 +00:00
|
|
|
unsigned short n;
|
|
|
|
|
|
|
|
REQUIRE(rdata->type == 250);
|
1999-08-02 22:18:31 +00:00
|
|
|
REQUIRE(rdata->rdclass == 255);
|
1999-02-04 01:06:40 +00:00
|
|
|
|
|
|
|
dns_rdata_toregion(rdata, &sr);
|
2000-05-13 22:50:49 +00:00
|
|
|
/*
|
|
|
|
* Algorithm Name.
|
|
|
|
*/
|
1999-02-04 01:06:40 +00:00
|
|
|
dns_name_init(&name, NULL);
|
|
|
|
dns_name_init(&prefix, NULL);
|
|
|
|
dns_name_fromregion(&name, &sr);
|
1999-06-08 10:35:23 +00:00
|
|
|
sub = name_prefix(&name, tctx->origin, &prefix);
|
1999-02-04 01:06:40 +00:00
|
|
|
RETERR(dns_name_totext(&prefix, sub, target));
|
|
|
|
RETERR(str_totext(" ", target));
|
|
|
|
isc_region_consume(&sr, name_length(&name));
|
|
|
|
|
2000-05-13 22:50:49 +00:00
|
|
|
/*
|
|
|
|
* Time Signed.
|
|
|
|
*/
|
1999-02-05 04:57:20 +00:00
|
|
|
sigtime = ((isc_uint64_t)sr.base[0] << 40) |
|
|
|
|
((isc_uint64_t)sr.base[1] << 32) |
|
1999-02-04 01:06:40 +00:00
|
|
|
(sr.base[2] << 24) | (sr.base[3] << 16) |
|
|
|
|
(sr.base[4] << 8) | sr.base[5];
|
|
|
|
isc_region_consume(&sr, 6);
|
1999-02-05 05:15:16 +00:00
|
|
|
bufp = &buf[sizeof buf - 1];
|
|
|
|
*bufp-- = 0;
|
|
|
|
*bufp-- = ' ';
|
|
|
|
do {
|
|
|
|
*bufp-- = decdigits[sigtime % 10];
|
|
|
|
sigtime /= 10;
|
|
|
|
} while (sigtime != 0);
|
|
|
|
bufp++;
|
|
|
|
RETERR(str_totext(bufp, target));
|
1999-02-04 01:06:40 +00:00
|
|
|
|
2000-05-13 22:50:49 +00:00
|
|
|
/*
|
|
|
|
* Fudge.
|
|
|
|
*/
|
1999-02-04 01:06:40 +00:00
|
|
|
n = uint16_fromregion(&sr);
|
|
|
|
isc_region_consume(&sr, 2);
|
|
|
|
sprintf(buf, "%u ", n);
|
|
|
|
RETERR(str_totext(buf, target));
|
|
|
|
|
2000-05-13 22:50:49 +00:00
|
|
|
/*
|
|
|
|
* Signature Size.
|
|
|
|
*/
|
1999-02-04 01:06:40 +00:00
|
|
|
n = uint16_fromregion(&sr);
|
|
|
|
isc_region_consume(&sr, 2);
|
1999-06-08 20:41:31 +00:00
|
|
|
sprintf(buf, "%u", n);
|
1999-02-04 01:06:40 +00:00
|
|
|
RETERR(str_totext(buf, target));
|
|
|
|
|
2000-05-13 22:50:49 +00:00
|
|
|
/*
|
|
|
|
* Signature.
|
|
|
|
*/
|
1999-02-04 01:06:40 +00:00
|
|
|
REQUIRE(n <= sr.length);
|
|
|
|
sigr = sr;
|
|
|
|
sigr.length = n;
|
1999-06-08 20:41:31 +00:00
|
|
|
if ((tctx->flags & DNS_STYLEFLAG_MULTILINE) != 0)
|
|
|
|
RETERR(str_totext(" (", target));
|
1999-06-08 10:35:23 +00:00
|
|
|
RETERR(str_totext(tctx->linebreak, target));
|
|
|
|
RETERR(isc_base64_totext(&sigr, tctx->width - 2,
|
|
|
|
tctx->linebreak, target));
|
1999-06-08 20:41:31 +00:00
|
|
|
if ((tctx->flags & DNS_STYLEFLAG_MULTILINE) != 0)
|
|
|
|
RETERR(str_totext(" ) ", target));
|
|
|
|
else
|
|
|
|
RETERR(str_totext(" ", target));
|
1999-02-04 01:06:40 +00:00
|
|
|
isc_region_consume(&sr, n);
|
|
|
|
|
2000-05-13 22:50:49 +00:00
|
|
|
/*
|
|
|
|
* Original ID.
|
|
|
|
*/
|
1999-02-04 01:06:40 +00:00
|
|
|
n = uint16_fromregion(&sr);
|
|
|
|
isc_region_consume(&sr, 2);
|
|
|
|
sprintf(buf, "%u ", n);
|
|
|
|
RETERR(str_totext(buf, target));
|
|
|
|
|
2000-05-13 22:50:49 +00:00
|
|
|
/*
|
|
|
|
* Error.
|
|
|
|
*/
|
1999-02-04 01:06:40 +00:00
|
|
|
n = uint16_fromregion(&sr);
|
|
|
|
isc_region_consume(&sr, 2);
|
|
|
|
sprintf(buf, "%u ", n);
|
|
|
|
RETERR(str_totext(buf, target));
|
|
|
|
|
2000-05-13 22:50:49 +00:00
|
|
|
/*
|
|
|
|
* Other Size.
|
|
|
|
*/
|
1999-02-04 01:06:40 +00:00
|
|
|
n = uint16_fromregion(&sr);
|
|
|
|
isc_region_consume(&sr, 2);
|
|
|
|
sprintf(buf, "%u ", n);
|
|
|
|
RETERR(str_totext(buf, target));
|
|
|
|
|
2000-05-13 22:50:49 +00:00
|
|
|
/*
|
|
|
|
* Other.
|
|
|
|
*/
|
1999-06-08 10:35:23 +00:00
|
|
|
return (isc_base64_totext(&sr, 60, " ", target));
|
1999-02-04 01:06:40 +00:00
|
|
|
}
|
|
|
|
|
1999-12-23 00:09:04 +00:00
|
|
|
static inline isc_result_t
|
1999-08-02 22:18:31 +00:00
|
|
|
fromwire_any_tsig(dns_rdataclass_t rdclass, dns_rdatatype_t type,
|
1999-02-04 01:06:40 +00:00
|
|
|
isc_buffer_t *source, dns_decompress_t *dctx,
|
|
|
|
isc_boolean_t downcase, isc_buffer_t *target)
|
|
|
|
{
|
|
|
|
isc_region_t sr;
|
|
|
|
dns_name_t name;
|
|
|
|
unsigned long n;
|
|
|
|
|
|
|
|
REQUIRE(type == 250);
|
1999-08-02 22:18:31 +00:00
|
|
|
REQUIRE(rdclass == 255);
|
1999-02-04 01:06:40 +00:00
|
|
|
|
2000-05-04 22:19:34 +00:00
|
|
|
dns_decompress_setmethods(dctx, DNS_COMPRESS_NONE);
|
1999-02-24 06:31:35 +00:00
|
|
|
|
2000-05-13 22:50:49 +00:00
|
|
|
/*
|
|
|
|
* Algorithm Name.
|
|
|
|
*/
|
1999-02-04 01:06:40 +00:00
|
|
|
dns_name_init(&name, NULL);
|
|
|
|
RETERR(dns_name_fromwire(&name, source, dctx, downcase, target));
|
|
|
|
|
103. [func] libisc buffer API changes for <isc/buffer.h>:
Added:
isc_buffer_base(b) (pointer)
isc_buffer_current(b) (pointer)
isc_buffer_active(b) (pointer)
isc_buffer_used(b) (pointer)
isc_buffer_length(b) (int)
isc_buffer_usedlength(b) (int)
isc_buffer_consumedlength(b) (int)
isc_buffer_remaininglength(b) (int)
isc_buffer_activelength(b) (int)
isc_buffer_availablelength(b) (int)
Removed:
ISC_BUFFER_USEDCOUNT(b)
ISC_BUFFER_AVAILABLECOUNT(b)
isc_buffer_type(b)
Changed names:
isc_buffer_used(b, r) ->
isc_buffer_usedregion(b, r)
isc_buffer_available(b, r) ->
isc_buffer_available_region(b, r)
isc_buffer_consumed(b, r) ->
isc_buffer_consumedregion(b, r)
isc_buffer_active(b, r) ->
isc_buffer_activeregion(b, r)
isc_buffer_remaining(b, r) ->
isc_buffer_remainingregion(b, r)
Buffer types were removed, so the ISC_BUFFERTYPE_*
macros are no more, and the type argument to
isc_buffer_init and isc_buffer_allocate were removed.
isc_buffer_putstr is now void (instead of isc_result_t)
and requires that the caller ensure that there
is enough available buffer space for the string.
2000-04-27 00:03:12 +00:00
|
|
|
isc_buffer_activeregion(source, &sr);
|
2000-05-13 22:50:49 +00:00
|
|
|
/*
|
|
|
|
* Time Signed + Fudge.
|
|
|
|
*/
|
1999-02-04 01:06:40 +00:00
|
|
|
if (sr.length < 8)
|
2000-04-06 22:03:35 +00:00
|
|
|
return (ISC_R_UNEXPECTEDEND);
|
1999-02-04 01:06:40 +00:00
|
|
|
RETERR(mem_tobuffer(target, sr.base, 8));
|
|
|
|
isc_region_consume(&sr, 8);
|
|
|
|
isc_buffer_forward(source, 8);
|
|
|
|
|
2000-05-13 22:50:49 +00:00
|
|
|
/*
|
|
|
|
* Signature Length + Signature.
|
|
|
|
*/
|
1999-02-04 01:06:40 +00:00
|
|
|
if (sr.length < 2)
|
2000-04-06 22:03:35 +00:00
|
|
|
return (ISC_R_UNEXPECTEDEND);
|
1999-02-04 01:06:40 +00:00
|
|
|
n = uint16_fromregion(&sr);
|
|
|
|
if (sr.length < n + 2)
|
2000-04-06 22:03:35 +00:00
|
|
|
return (ISC_R_UNEXPECTEDEND);
|
1999-02-04 01:06:40 +00:00
|
|
|
RETERR(mem_tobuffer(target, sr.base, n + 2));
|
|
|
|
isc_region_consume(&sr, n + 2);
|
|
|
|
isc_buffer_forward(source, n + 2);
|
|
|
|
|
2000-05-13 22:50:49 +00:00
|
|
|
/*
|
|
|
|
* Original ID + Error.
|
|
|
|
*/
|
1999-02-04 01:06:40 +00:00
|
|
|
if (sr.length < 4)
|
2000-04-06 22:03:35 +00:00
|
|
|
return (ISC_R_UNEXPECTEDEND);
|
1999-02-04 01:06:40 +00:00
|
|
|
RETERR(mem_tobuffer(target, sr.base, 4));
|
|
|
|
isc_region_consume(&sr, 4);
|
|
|
|
isc_buffer_forward(source, 4);
|
|
|
|
|
2000-05-13 22:50:49 +00:00
|
|
|
/*
|
|
|
|
* Other Length + Other.
|
|
|
|
*/
|
1999-02-04 01:06:40 +00:00
|
|
|
if (sr.length < 2)
|
2000-04-06 22:03:35 +00:00
|
|
|
return (ISC_R_UNEXPECTEDEND);
|
1999-02-04 01:06:40 +00:00
|
|
|
n = uint16_fromregion(&sr);
|
|
|
|
if (sr.length < n + 2)
|
2000-04-06 22:03:35 +00:00
|
|
|
return (ISC_R_UNEXPECTEDEND);
|
1999-02-04 01:06:40 +00:00
|
|
|
isc_buffer_forward(source, n + 2);
|
|
|
|
return (mem_tobuffer(target, sr.base, n + 2));
|
|
|
|
}
|
|
|
|
|
1999-12-23 00:09:04 +00:00
|
|
|
static inline isc_result_t
|
2000-04-28 22:40:10 +00:00
|
|
|
towire_any_tsig(dns_rdata_t *rdata, dns_compress_t *cctx,
|
|
|
|
isc_buffer_t *target)
|
|
|
|
{
|
1999-02-04 01:06:40 +00:00
|
|
|
isc_region_t sr;
|
|
|
|
dns_name_t name;
|
|
|
|
|
|
|
|
REQUIRE(rdata->type == 250);
|
1999-08-02 22:18:31 +00:00
|
|
|
REQUIRE(rdata->rdclass == 255);
|
1999-02-04 01:06:40 +00:00
|
|
|
|
2000-05-04 22:19:34 +00:00
|
|
|
dns_compress_setmethods(cctx, DNS_COMPRESS_NONE);
|
1999-02-04 01:06:40 +00:00
|
|
|
dns_rdata_toregion(rdata, &sr);
|
|
|
|
dns_name_init(&name, NULL);
|
|
|
|
dns_name_fromregion(&name, &sr);
|
|
|
|
RETERR(dns_name_towire(&name, cctx, target));
|
|
|
|
isc_region_consume(&sr, name_length(&name));
|
|
|
|
return (mem_tobuffer(target, sr.base, sr.length));
|
|
|
|
}
|
|
|
|
|
1999-08-12 01:32:42 +00:00
|
|
|
static inline int
|
1999-02-04 01:06:40 +00:00
|
|
|
compare_any_tsig(dns_rdata_t *rdata1, dns_rdata_t *rdata2) {
|
|
|
|
isc_region_t r1;
|
|
|
|
isc_region_t r2;
|
|
|
|
dns_name_t name1;
|
|
|
|
dns_name_t name2;
|
2000-03-20 22:44:36 +00:00
|
|
|
int order;
|
1999-02-04 01:06:40 +00:00
|
|
|
|
|
|
|
REQUIRE(rdata1->type == rdata2->type);
|
1999-08-02 22:18:31 +00:00
|
|
|
REQUIRE(rdata1->rdclass == rdata2->rdclass);
|
1999-02-04 01:06:40 +00:00
|
|
|
REQUIRE(rdata1->type == 250);
|
1999-08-02 22:18:31 +00:00
|
|
|
REQUIRE(rdata1->rdclass == 255);
|
1999-02-04 01:06:40 +00:00
|
|
|
|
|
|
|
dns_rdata_toregion(rdata1, &r1);
|
|
|
|
dns_rdata_toregion(rdata2, &r2);
|
|
|
|
dns_name_init(&name1, NULL);
|
|
|
|
dns_name_init(&name2, NULL);
|
|
|
|
dns_name_fromregion(&name1, &r1);
|
|
|
|
dns_name_fromregion(&name2, &r2);
|
2000-03-20 22:44:36 +00:00
|
|
|
order = dns_name_rdatacompare(&name1, &name2);
|
|
|
|
if (order != 0)
|
|
|
|
return (order);
|
1999-02-04 01:06:40 +00:00
|
|
|
isc_region_consume(&r1, name_length(&name1));
|
|
|
|
isc_region_consume(&r2, name_length(&name2));
|
|
|
|
return (compare_region(&r1, &r2));
|
|
|
|
}
|
|
|
|
|
1999-12-23 00:09:04 +00:00
|
|
|
static inline isc_result_t
|
1999-08-02 22:18:31 +00:00
|
|
|
fromstruct_any_tsig(dns_rdataclass_t rdclass, dns_rdatatype_t type,
|
1999-02-16 22:42:33 +00:00
|
|
|
void *source, isc_buffer_t *target)
|
|
|
|
{
|
2000-05-22 12:38:12 +00:00
|
|
|
dns_rdata_any_tsig_t *tsig = source;
|
1999-08-20 18:56:24 +00:00
|
|
|
isc_region_t tr;
|
1999-02-04 01:06:40 +00:00
|
|
|
|
|
|
|
REQUIRE(type == 250);
|
1999-08-02 22:18:31 +00:00
|
|
|
REQUIRE(rdclass == 255);
|
2000-05-22 12:38:12 +00:00
|
|
|
REQUIRE(source != NULL);
|
|
|
|
REQUIRE(tsig->common.rdclass == rdclass);
|
|
|
|
REQUIRE(tsig->common.rdtype == type);
|
1999-08-20 18:56:24 +00:00
|
|
|
|
2000-05-13 22:50:49 +00:00
|
|
|
/*
|
|
|
|
* Algorithm Name.
|
|
|
|
*/
|
2000-05-05 18:15:02 +00:00
|
|
|
RETERR(name_tobuffer(&tsig->algorithm, target));
|
1999-08-20 18:56:24 +00:00
|
|
|
|
103. [func] libisc buffer API changes for <isc/buffer.h>:
Added:
isc_buffer_base(b) (pointer)
isc_buffer_current(b) (pointer)
isc_buffer_active(b) (pointer)
isc_buffer_used(b) (pointer)
isc_buffer_length(b) (int)
isc_buffer_usedlength(b) (int)
isc_buffer_consumedlength(b) (int)
isc_buffer_remaininglength(b) (int)
isc_buffer_activelength(b) (int)
isc_buffer_availablelength(b) (int)
Removed:
ISC_BUFFER_USEDCOUNT(b)
ISC_BUFFER_AVAILABLECOUNT(b)
isc_buffer_type(b)
Changed names:
isc_buffer_used(b, r) ->
isc_buffer_usedregion(b, r)
isc_buffer_available(b, r) ->
isc_buffer_available_region(b, r)
isc_buffer_consumed(b, r) ->
isc_buffer_consumedregion(b, r)
isc_buffer_active(b, r) ->
isc_buffer_activeregion(b, r)
isc_buffer_remaining(b, r) ->
isc_buffer_remainingregion(b, r)
Buffer types were removed, so the ISC_BUFFERTYPE_*
macros are no more, and the type argument to
isc_buffer_init and isc_buffer_allocate were removed.
isc_buffer_putstr is now void (instead of isc_result_t)
and requires that the caller ensure that there
is enough available buffer space for the string.
2000-04-27 00:03:12 +00:00
|
|
|
isc_buffer_availableregion(target, &tr);
|
1999-08-20 18:56:24 +00:00
|
|
|
if (tr.length < 6 + 2 + 2)
|
2000-04-06 22:03:35 +00:00
|
|
|
return (ISC_R_NOSPACE);
|
1999-08-20 18:56:24 +00:00
|
|
|
|
2000-05-13 22:50:49 +00:00
|
|
|
/*
|
|
|
|
* Time Signed: 48 bits.
|
|
|
|
*/
|
|
|
|
RETERR(uint16_tobuffer((isc_uint16_t)(tsig->timesigned >> 32),
|
|
|
|
target));
|
2000-03-16 21:50:14 +00:00
|
|
|
RETERR(uint32_tobuffer((isc_uint32_t)(tsig->timesigned & 0xffffffffU),
|
1999-10-08 22:48:13 +00:00
|
|
|
target));
|
1999-08-20 18:56:24 +00:00
|
|
|
|
2000-05-13 22:50:49 +00:00
|
|
|
/*
|
|
|
|
* Fudge.
|
|
|
|
*/
|
1999-08-20 18:56:24 +00:00
|
|
|
RETERR(uint16_tobuffer(tsig->fudge, target));
|
|
|
|
|
2000-05-13 22:50:49 +00:00
|
|
|
/*
|
|
|
|
* Signature Size.
|
|
|
|
*/
|
1999-08-20 18:56:24 +00:00
|
|
|
RETERR(uint16_tobuffer(tsig->siglen, target));
|
|
|
|
|
2000-05-13 22:50:49 +00:00
|
|
|
/*
|
|
|
|
* Signature.
|
|
|
|
*/
|
2000-05-22 12:38:12 +00:00
|
|
|
RETERR(mem_tobuffer(target, tsig->signature, tsig->siglen));
|
1999-08-20 18:56:24 +00:00
|
|
|
|
103. [func] libisc buffer API changes for <isc/buffer.h>:
Added:
isc_buffer_base(b) (pointer)
isc_buffer_current(b) (pointer)
isc_buffer_active(b) (pointer)
isc_buffer_used(b) (pointer)
isc_buffer_length(b) (int)
isc_buffer_usedlength(b) (int)
isc_buffer_consumedlength(b) (int)
isc_buffer_remaininglength(b) (int)
isc_buffer_activelength(b) (int)
isc_buffer_availablelength(b) (int)
Removed:
ISC_BUFFER_USEDCOUNT(b)
ISC_BUFFER_AVAILABLECOUNT(b)
isc_buffer_type(b)
Changed names:
isc_buffer_used(b, r) ->
isc_buffer_usedregion(b, r)
isc_buffer_available(b, r) ->
isc_buffer_available_region(b, r)
isc_buffer_consumed(b, r) ->
isc_buffer_consumedregion(b, r)
isc_buffer_active(b, r) ->
isc_buffer_activeregion(b, r)
isc_buffer_remaining(b, r) ->
isc_buffer_remainingregion(b, r)
Buffer types were removed, so the ISC_BUFFERTYPE_*
macros are no more, and the type argument to
isc_buffer_init and isc_buffer_allocate were removed.
isc_buffer_putstr is now void (instead of isc_result_t)
and requires that the caller ensure that there
is enough available buffer space for the string.
2000-04-27 00:03:12 +00:00
|
|
|
isc_buffer_availableregion(target, &tr);
|
1999-08-20 18:56:24 +00:00
|
|
|
if (tr.length < 2 + 2 + 2)
|
2000-04-06 22:03:35 +00:00
|
|
|
return (ISC_R_NOSPACE);
|
1999-08-20 18:56:24 +00:00
|
|
|
|
2000-05-13 22:50:49 +00:00
|
|
|
/*
|
|
|
|
* Original ID.
|
|
|
|
*/
|
1999-08-20 18:56:24 +00:00
|
|
|
RETERR(uint16_tobuffer(tsig->originalid, target));
|
|
|
|
|
2000-05-13 22:50:49 +00:00
|
|
|
/*
|
|
|
|
* Error.
|
|
|
|
*/
|
1999-08-20 18:56:24 +00:00
|
|
|
RETERR(uint16_tobuffer(tsig->error, target));
|
|
|
|
|
2000-05-13 22:50:49 +00:00
|
|
|
/*
|
|
|
|
* Other Len.
|
|
|
|
*/
|
1999-08-20 18:56:24 +00:00
|
|
|
RETERR(uint16_tobuffer(tsig->otherlen, target));
|
|
|
|
|
2000-05-13 22:50:49 +00:00
|
|
|
/*
|
|
|
|
* Other Data.
|
|
|
|
*/
|
2000-05-22 12:38:12 +00:00
|
|
|
return (mem_tobuffer(target, tsig->other, tsig->otherlen));
|
1999-02-04 01:06:40 +00:00
|
|
|
}
|
|
|
|
|
1999-12-23 00:09:04 +00:00
|
|
|
static inline isc_result_t
|
1999-05-07 03:24:15 +00:00
|
|
|
tostruct_any_tsig(dns_rdata_t *rdata, void *target, isc_mem_t *mctx) {
|
1999-08-20 18:56:24 +00:00
|
|
|
dns_rdata_any_tsig_t *tsig;
|
|
|
|
dns_name_t alg;
|
|
|
|
isc_region_t sr;
|
1999-02-04 01:06:40 +00:00
|
|
|
|
|
|
|
REQUIRE(rdata->type == 250);
|
1999-08-02 22:18:31 +00:00
|
|
|
REQUIRE(rdata->rdclass == 255);
|
1999-02-04 01:06:40 +00:00
|
|
|
|
1999-08-20 18:56:24 +00:00
|
|
|
tsig = (dns_rdata_any_tsig_t *) target;
|
|
|
|
tsig->common.rdclass = rdata->rdclass;
|
|
|
|
tsig->common.rdtype = rdata->type;
|
|
|
|
ISC_LINK_INIT(&tsig->common, link);
|
2000-05-19 13:04:45 +00:00
|
|
|
|
1999-08-20 18:56:24 +00:00
|
|
|
dns_rdata_toregion(rdata, &sr);
|
|
|
|
|
2000-05-13 22:50:49 +00:00
|
|
|
/*
|
|
|
|
* Algorithm Name.
|
|
|
|
*/
|
1999-08-20 18:56:24 +00:00
|
|
|
dns_name_init(&alg, NULL);
|
|
|
|
dns_name_fromregion(&alg, &sr);
|
1999-10-07 21:49:39 +00:00
|
|
|
dns_name_init(&tsig->algorithm, NULL);
|
2000-05-19 13:04:45 +00:00
|
|
|
RETERR(name_duporclone(&alg, mctx, &tsig->algorithm));
|
1999-08-20 18:56:24 +00:00
|
|
|
|
1999-10-07 21:49:39 +00:00
|
|
|
isc_region_consume(&sr, name_length(&tsig->algorithm));
|
1999-08-20 18:56:24 +00:00
|
|
|
|
2000-05-13 22:50:49 +00:00
|
|
|
/*
|
|
|
|
* Time Signed.
|
|
|
|
*/
|
2000-05-19 13:04:45 +00:00
|
|
|
INSIST(sr.length >= 6);
|
1999-08-20 18:56:24 +00:00
|
|
|
tsig->timesigned = ((isc_uint64_t)sr.base[0] << 40) |
|
|
|
|
((isc_uint64_t)sr.base[1] << 32) |
|
|
|
|
(sr.base[2] << 24) | (sr.base[3] << 16) |
|
|
|
|
(sr.base[4] << 8) | sr.base[5];
|
|
|
|
isc_region_consume(&sr, 6);
|
|
|
|
|
2000-05-13 22:50:49 +00:00
|
|
|
/*
|
|
|
|
* Fudge.
|
|
|
|
*/
|
1999-08-20 18:56:24 +00:00
|
|
|
tsig->fudge = uint16_fromregion(&sr);
|
|
|
|
isc_region_consume(&sr, 2);
|
|
|
|
|
2000-05-13 22:50:49 +00:00
|
|
|
/*
|
|
|
|
* Signature Size.
|
|
|
|
*/
|
1999-08-20 18:56:24 +00:00
|
|
|
tsig->siglen = uint16_fromregion(&sr);
|
|
|
|
isc_region_consume(&sr, 2);
|
|
|
|
|
2000-05-13 22:50:49 +00:00
|
|
|
/*
|
|
|
|
* Signature.
|
|
|
|
*/
|
2000-05-19 13:04:45 +00:00
|
|
|
INSIST(sr.length >= tsig->siglen);
|
|
|
|
if (tsig->siglen != 0) {
|
|
|
|
tsig->signature = mem_maybedup(mctx, sr.base, tsig->siglen);
|
|
|
|
if (tsig->signature == NULL)
|
|
|
|
goto cleanup;
|
|
|
|
isc_region_consume(&sr, tsig->siglen);
|
|
|
|
} else
|
|
|
|
tsig->signature = NULL;
|
1999-08-20 18:56:24 +00:00
|
|
|
|
2000-05-13 22:50:49 +00:00
|
|
|
/*
|
|
|
|
* Original ID.
|
|
|
|
*/
|
1999-08-20 18:56:24 +00:00
|
|
|
tsig->originalid = uint16_fromregion(&sr);
|
|
|
|
isc_region_consume(&sr, 2);
|
|
|
|
|
2000-05-13 22:50:49 +00:00
|
|
|
/*
|
|
|
|
* Error.
|
|
|
|
*/
|
1999-08-20 18:56:24 +00:00
|
|
|
tsig->error = uint16_fromregion(&sr);
|
|
|
|
isc_region_consume(&sr, 2);
|
|
|
|
|
2000-05-13 22:50:49 +00:00
|
|
|
/*
|
|
|
|
* Other Size.
|
|
|
|
*/
|
1999-08-20 18:56:24 +00:00
|
|
|
tsig->otherlen = uint16_fromregion(&sr);
|
|
|
|
isc_region_consume(&sr, 2);
|
|
|
|
|
2000-05-13 22:50:49 +00:00
|
|
|
/*
|
|
|
|
* Other.
|
|
|
|
*/
|
2000-05-19 13:04:45 +00:00
|
|
|
INSIST(sr.length == tsig->otherlen);
|
|
|
|
if (tsig->otherlen != 0) {
|
|
|
|
tsig->other = mem_maybedup(mctx, sr.base, tsig->otherlen);
|
|
|
|
if (tsig->other == NULL)
|
|
|
|
goto cleanup;
|
|
|
|
} else
|
|
|
|
tsig->other = NULL;
|
1999-08-20 18:56:24 +00:00
|
|
|
|
2000-05-19 13:04:45 +00:00
|
|
|
tsig->mctx = mctx;
|
2000-04-06 22:03:35 +00:00
|
|
|
return (ISC_R_SUCCESS);
|
2000-05-19 13:04:45 +00:00
|
|
|
|
|
|
|
cleanup:
|
|
|
|
if (mctx != NULL)
|
|
|
|
dns_name_free(&tsig->algorithm, tsig->mctx);
|
|
|
|
if (mctx != NULL && tsig->signature != NULL)
|
|
|
|
isc_mem_free(mctx, tsig->signature);
|
|
|
|
return (ISC_R_NOMEMORY);
|
1999-02-04 01:06:40 +00:00
|
|
|
}
|
1999-05-07 03:24:15 +00:00
|
|
|
|
1999-08-12 01:32:42 +00:00
|
|
|
static inline void
|
1999-05-07 03:24:15 +00:00
|
|
|
freestruct_any_tsig(void *source) {
|
1999-08-20 18:56:24 +00:00
|
|
|
dns_rdata_any_tsig_t *tsig = (dns_rdata_any_tsig_t *) source;
|
1999-05-07 03:24:15 +00:00
|
|
|
|
|
|
|
REQUIRE(source != NULL);
|
|
|
|
REQUIRE(tsig->common.rdclass == 255);
|
|
|
|
REQUIRE(tsig->common.rdtype == 250);
|
|
|
|
|
2000-05-19 13:04:45 +00:00
|
|
|
if (tsig->mctx == NULL)
|
|
|
|
return;
|
|
|
|
|
1999-10-07 21:49:39 +00:00
|
|
|
dns_name_free(&tsig->algorithm, tsig->mctx);
|
2000-03-16 23:13:02 +00:00
|
|
|
if (tsig->signature != NULL)
|
2000-05-19 13:04:45 +00:00
|
|
|
isc_mem_free(tsig->mctx, tsig->signature);
|
2000-03-16 23:13:02 +00:00
|
|
|
if (tsig->other != NULL)
|
2000-05-19 13:04:45 +00:00
|
|
|
isc_mem_free(tsig->mctx, tsig->other);
|
|
|
|
tsig->mctx = NULL;
|
1999-05-07 03:24:15 +00:00
|
|
|
}
|
1999-08-02 22:18:31 +00:00
|
|
|
|
1999-12-23 00:09:04 +00:00
|
|
|
static inline isc_result_t
|
1999-08-02 22:18:31 +00:00
|
|
|
additionaldata_any_tsig(dns_rdata_t *rdata, dns_additionaldatafunc_t add,
|
|
|
|
void *arg)
|
|
|
|
{
|
|
|
|
REQUIRE(rdata->type == 250);
|
|
|
|
REQUIRE(rdata->rdclass == 255);
|
|
|
|
|
2000-04-28 01:24:18 +00:00
|
|
|
UNUSED(rdata);
|
2000-03-16 21:50:14 +00:00
|
|
|
UNUSED(add);
|
|
|
|
UNUSED(arg);
|
1999-08-02 22:18:31 +00:00
|
|
|
|
2000-04-06 22:03:35 +00:00
|
|
|
return (ISC_R_SUCCESS);
|
1999-08-02 22:18:31 +00:00
|
|
|
}
|
|
|
|
|
1999-12-23 00:09:04 +00:00
|
|
|
static inline isc_result_t
|
1999-08-31 22:05:55 +00:00
|
|
|
digest_any_tsig(dns_rdata_t *rdata, dns_digestfunc_t digest, void *arg) {
|
|
|
|
|
|
|
|
REQUIRE(rdata->type == 250);
|
|
|
|
REQUIRE(rdata->rdclass == 255);
|
|
|
|
|
2000-04-28 01:24:18 +00:00
|
|
|
UNUSED(rdata);
|
2000-03-16 21:50:14 +00:00
|
|
|
UNUSED(digest);
|
|
|
|
UNUSED(arg);
|
1999-08-31 22:05:55 +00:00
|
|
|
|
2000-04-06 22:03:35 +00:00
|
|
|
return (ISC_R_NOTIMPLEMENTED);
|
1999-08-31 22:05:55 +00:00
|
|
|
}
|
|
|
|
|
1999-05-05 00:19:04 +00:00
|
|
|
#endif /* RDATA_ANY_255_TSIG_250_C */
|