1999-02-04 02:09:04 +00:00
|
|
|
/*
|
2018-02-23 09:53:12 +01:00
|
|
|
* Copyright (C) Internet Systems Consortium, Inc. ("ISC")
|
2000-08-01 01:33:37 +00:00
|
|
|
*
|
2021-06-03 08:37:05 +02:00
|
|
|
* SPDX-License-Identifier: MPL-2.0
|
|
|
|
*
|
2016-06-27 14:56:38 +10:00
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
2020-09-14 16:20:40 -07:00
|
|
|
* file, you can obtain one at https://mozilla.org/MPL/2.0/.
|
2018-02-23 09:53:12 +01:00
|
|
|
*
|
|
|
|
* See the COPYRIGHT file distributed with this work for additional
|
|
|
|
* information regarding copyright ownership.
|
1999-02-04 02:09:04 +00:00
|
|
|
*/
|
|
|
|
|
2000-03-17 21:13:02 +00:00
|
|
|
/* draft-ietf-dnsext-tkey-01.txt */
|
1999-02-04 02:09:04 +00:00
|
|
|
|
1999-05-05 00:19:04 +00:00
|
|
|
#ifndef RDATA_GENERIC_TKEY_249_C
|
|
|
|
#define RDATA_GENERIC_TKEY_249_C
|
1999-02-04 02:09:04 +00:00
|
|
|
|
2000-04-07 03:54:52 +00:00
|
|
|
#define RRTYPE_TKEY_ATTRIBUTES (DNS_RDATATYPEATTR_META)
|
|
|
|
|
2021-10-11 13:43:12 +02:00
|
|
|
static isc_result_t
|
2020-02-13 14:44:37 -08:00
|
|
|
fromtext_tkey(ARGS_FROMTEXT) {
|
|
|
|
isc_token_t token;
|
|
|
|
dns_rcode_t rcode;
|
|
|
|
dns_name_t name;
|
1999-02-04 06:38:43 +00:00
|
|
|
isc_buffer_t buffer;
|
2020-02-13 14:44:37 -08:00
|
|
|
long i;
|
|
|
|
char *e;
|
1999-02-04 02:09:04 +00:00
|
|
|
|
2015-08-17 12:23:35 +05:30
|
|
|
REQUIRE(type == dns_rdatatype_tkey);
|
1999-02-04 06:38:43 +00:00
|
|
|
|
2001-03-16 22:53:20 +00:00
|
|
|
UNUSED(type);
|
|
|
|
UNUSED(rdclass);
|
2001-07-16 03:06:53 +00:00
|
|
|
UNUSED(callbacks);
|
2001-03-16 22:53:20 +00:00
|
|
|
|
2000-05-13 22:46:07 +00:00
|
|
|
/*
|
|
|
|
* Algorithm.
|
|
|
|
*/
|
2000-11-08 01:56:15 +00:00
|
|
|
RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_string,
|
2018-04-17 08:29:14 -07:00
|
|
|
false));
|
1999-02-04 06:38:43 +00:00
|
|
|
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);
|
2020-02-13 21:48:23 +01:00
|
|
|
if (origin == NULL) {
|
2015-09-18 07:43:43 +10:00
|
|
|
origin = dns_rootname;
|
2020-02-13 21:48:23 +01:00
|
|
|
}
|
2004-02-27 20:41:51 +00:00
|
|
|
RETTOK(dns_name_fromtext(&name, &buffer, origin, options, target));
|
1999-02-04 02:09:04 +00:00
|
|
|
|
2000-05-13 22:46:07 +00:00
|
|
|
/*
|
|
|
|
* Inception.
|
|
|
|
*/
|
2000-11-08 01:56:15 +00:00
|
|
|
RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_number,
|
2018-04-17 08:29:14 -07:00
|
|
|
false));
|
1999-02-04 02:09:04 +00:00
|
|
|
RETERR(uint32_tobuffer(token.value.as_ulong, target));
|
|
|
|
|
2000-05-13 22:46:07 +00:00
|
|
|
/*
|
|
|
|
* Expiration.
|
|
|
|
*/
|
2000-11-08 01:56:15 +00:00
|
|
|
RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_number,
|
2018-04-17 08:29:14 -07:00
|
|
|
false));
|
1999-02-04 02:09:04 +00:00
|
|
|
RETERR(uint32_tobuffer(token.value.as_ulong, target));
|
|
|
|
|
2000-05-13 22:46:07 +00:00
|
|
|
/*
|
|
|
|
* Mode.
|
|
|
|
*/
|
2000-11-08 01:56:15 +00:00
|
|
|
RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_number,
|
2018-04-17 08:29:14 -07:00
|
|
|
false));
|
2020-02-13 21:48:23 +01:00
|
|
|
if (token.value.as_ulong > 0xffffU) {
|
2001-03-06 22:11:18 +00:00
|
|
|
RETTOK(ISC_R_RANGE);
|
2020-02-13 21:48:23 +01:00
|
|
|
}
|
1999-02-04 02:09:04 +00:00
|
|
|
RETERR(uint16_tobuffer(token.value.as_ulong, target));
|
|
|
|
|
2000-05-13 22:46:07 +00:00
|
|
|
/*
|
|
|
|
* Error.
|
|
|
|
*/
|
2000-11-08 01:56:15 +00:00
|
|
|
RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_string,
|
2018-04-17 08:29:14 -07:00
|
|
|
false));
|
2020-02-12 13:59:18 +01:00
|
|
|
if (dns_tsigrcode_fromtext(&rcode, &token.value.as_textregion) !=
|
|
|
|
ISC_R_SUCCESS) {
|
2002-01-21 01:07:32 +00:00
|
|
|
i = strtol(DNS_AS_STR(token), &e, 10);
|
2020-02-13 21:48:23 +01:00
|
|
|
if (*e != 0) {
|
2001-03-06 22:11:18 +00:00
|
|
|
RETTOK(DNS_R_UNKNOWN);
|
2020-02-13 21:48:23 +01:00
|
|
|
}
|
|
|
|
if (i < 0 || i > 0xffff) {
|
2001-03-06 22:11:18 +00:00
|
|
|
RETTOK(ISC_R_RANGE);
|
2020-02-13 21:48:23 +01:00
|
|
|
}
|
1999-10-08 21:45:01 +00:00
|
|
|
rcode = (dns_rcode_t)i;
|
1999-02-04 06:38:43 +00:00
|
|
|
}
|
|
|
|
RETERR(uint16_tobuffer(rcode, target));
|
1999-02-04 02:09:04 +00:00
|
|
|
|
2000-05-13 22:46:07 +00:00
|
|
|
/*
|
|
|
|
* Key Size.
|
|
|
|
*/
|
2000-11-08 01:56:15 +00:00
|
|
|
RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_number,
|
2018-04-17 08:29:14 -07:00
|
|
|
false));
|
2020-02-13 21:48:23 +01:00
|
|
|
if (token.value.as_ulong > 0xffffU) {
|
2001-03-06 22:11:18 +00:00
|
|
|
RETTOK(ISC_R_RANGE);
|
2020-02-13 21:48:23 +01:00
|
|
|
}
|
1999-02-04 02:09:04 +00:00
|
|
|
RETERR(uint16_tobuffer(token.value.as_ulong, target));
|
|
|
|
|
2000-05-13 22:46:07 +00:00
|
|
|
/*
|
|
|
|
* Key Data.
|
|
|
|
*/
|
|
|
|
RETERR(isc_base64_tobuffer(lexer, target, (int)token.value.as_ulong));
|
1999-02-04 02:09:04 +00:00
|
|
|
|
2000-05-13 22:46:07 +00:00
|
|
|
/*
|
|
|
|
* Other Size.
|
|
|
|
*/
|
2000-11-08 01:56:15 +00:00
|
|
|
RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_number,
|
2018-04-17 08:29:14 -07:00
|
|
|
false));
|
2020-02-13 21:48:23 +01:00
|
|
|
if (token.value.as_ulong > 0xffffU) {
|
2001-03-06 22:11:18 +00:00
|
|
|
RETTOK(ISC_R_RANGE);
|
2020-02-13 21:48:23 +01:00
|
|
|
}
|
1999-02-04 02:09:04 +00:00
|
|
|
RETERR(uint16_tobuffer(token.value.as_ulong, target));
|
|
|
|
|
2000-05-13 22:46:07 +00:00
|
|
|
/*
|
|
|
|
* Other Data.
|
|
|
|
*/
|
|
|
|
return (isc_base64_tobuffer(lexer, target, (int)token.value.as_ulong));
|
1999-02-04 02:09:04 +00:00
|
|
|
}
|
|
|
|
|
2021-10-11 13:43:12 +02:00
|
|
|
static isc_result_t
|
2020-02-13 14:44:37 -08:00
|
|
|
totext_tkey(ARGS_TOTEXT) {
|
|
|
|
isc_region_t sr, dr;
|
|
|
|
char buf[sizeof("4294967295 ")];
|
1999-02-04 02:09:04 +00:00
|
|
|
unsigned long n;
|
2020-02-13 14:44:37 -08:00
|
|
|
dns_name_t name;
|
|
|
|
dns_name_t prefix;
|
|
|
|
bool sub;
|
1999-02-04 02:09:04 +00:00
|
|
|
|
2015-08-17 12:23:35 +05:30
|
|
|
REQUIRE(rdata->type == dns_rdatatype_tkey);
|
2000-10-25 05:44:10 +00:00
|
|
|
REQUIRE(rdata->length != 0);
|
1999-02-04 02:09:04 +00:00
|
|
|
|
|
|
|
dns_rdata_toregion(rdata, &sr);
|
|
|
|
|
2000-05-13 22:46:07 +00:00
|
|
|
/*
|
|
|
|
* Algorithm.
|
|
|
|
*/
|
1999-02-04 06:38:43 +00:00
|
|
|
dns_name_init(&name, NULL);
|
|
|
|
dns_name_init(&prefix, NULL);
|
1999-02-04 07:00:32 +00:00
|
|
|
dns_name_fromregion(&name, &sr);
|
1999-06-08 10:35:23 +00:00
|
|
|
sub = name_prefix(&name, tctx->origin, &prefix);
|
1999-02-04 06:38:43 +00:00
|
|
|
RETERR(dns_name_totext(&prefix, sub, target));
|
1999-02-05 05:15:16 +00:00
|
|
|
RETERR(str_totext(" ", target));
|
1999-02-04 06:38:43 +00:00
|
|
|
isc_region_consume(&sr, name_length(&name));
|
|
|
|
|
2000-05-13 22:46:07 +00:00
|
|
|
/*
|
|
|
|
* Inception.
|
|
|
|
*/
|
1999-02-04 02:09:04 +00:00
|
|
|
n = uint32_fromregion(&sr);
|
|
|
|
isc_region_consume(&sr, 4);
|
2017-10-03 14:54:19 +11:00
|
|
|
snprintf(buf, sizeof(buf), "%lu ", n);
|
1999-02-04 02:09:04 +00:00
|
|
|
RETERR(str_totext(buf, target));
|
|
|
|
|
2000-05-13 22:46:07 +00:00
|
|
|
/*
|
|
|
|
* Expiration.
|
|
|
|
*/
|
1999-02-04 02:09:04 +00:00
|
|
|
n = uint32_fromregion(&sr);
|
|
|
|
isc_region_consume(&sr, 4);
|
2017-10-03 14:54:19 +11:00
|
|
|
snprintf(buf, sizeof(buf), "%lu ", n);
|
1999-02-04 02:09:04 +00:00
|
|
|
RETERR(str_totext(buf, target));
|
|
|
|
|
2000-05-13 22:46:07 +00:00
|
|
|
/*
|
|
|
|
* Mode.
|
|
|
|
*/
|
1999-02-04 02:09:04 +00:00
|
|
|
n = uint16_fromregion(&sr);
|
|
|
|
isc_region_consume(&sr, 2);
|
2017-10-03 14:54:19 +11:00
|
|
|
snprintf(buf, sizeof(buf), "%lu ", n);
|
1999-02-04 02:09:04 +00:00
|
|
|
RETERR(str_totext(buf, target));
|
|
|
|
|
2000-05-13 22:46:07 +00:00
|
|
|
/*
|
|
|
|
* Error.
|
|
|
|
*/
|
1999-02-04 02:09:04 +00:00
|
|
|
n = uint16_fromregion(&sr);
|
|
|
|
isc_region_consume(&sr, 2);
|
2020-02-13 21:48:23 +01:00
|
|
|
if (dns_tsigrcode_totext((dns_rcode_t)n, target) == ISC_R_SUCCESS) {
|
1999-02-04 06:38:43 +00:00
|
|
|
RETERR(str_totext(" ", target));
|
2020-02-13 21:48:23 +01:00
|
|
|
} else {
|
2017-10-03 14:54:19 +11:00
|
|
|
snprintf(buf, sizeof(buf), "%lu ", n);
|
1999-02-04 06:38:43 +00:00
|
|
|
RETERR(str_totext(buf, target));
|
|
|
|
}
|
1999-02-04 02:09:04 +00:00
|
|
|
|
2000-05-13 22:46:07 +00:00
|
|
|
/*
|
|
|
|
* Key Size.
|
|
|
|
*/
|
1999-02-04 02:09:04 +00:00
|
|
|
n = uint16_fromregion(&sr);
|
|
|
|
isc_region_consume(&sr, 2);
|
2017-10-03 14:54:19 +11:00
|
|
|
snprintf(buf, sizeof(buf), "%lu", n);
|
1999-02-04 02:09:04 +00:00
|
|
|
RETERR(str_totext(buf, target));
|
|
|
|
|
2000-05-13 22:46:07 +00:00
|
|
|
/*
|
|
|
|
* Key Data.
|
|
|
|
*/
|
1999-02-04 02:09:04 +00:00
|
|
|
REQUIRE(n <= sr.length);
|
2000-03-17 21:13:02 +00:00
|
|
|
dr = sr;
|
|
|
|
dr.length = n;
|
2020-02-13 21:48:23 +01:00
|
|
|
if ((tctx->flags & DNS_STYLEFLAG_MULTILINE) != 0) {
|
1999-06-08 20:41:31 +00:00
|
|
|
RETERR(str_totext(" (", target));
|
2020-02-13 21:48:23 +01:00
|
|
|
}
|
1999-06-08 10:35:23 +00:00
|
|
|
RETERR(str_totext(tctx->linebreak, target));
|
2020-02-13 21:48:23 +01:00
|
|
|
if (tctx->width == 0) { /* No splitting */
|
2011-03-05 19:39:07 +00:00
|
|
|
RETERR(isc_base64_totext(&dr, 60, "", target));
|
2020-02-13 21:48:23 +01:00
|
|
|
} else {
|
2020-02-12 13:59:18 +01:00
|
|
|
RETERR(isc_base64_totext(&dr, tctx->width - 2, tctx->linebreak,
|
|
|
|
target));
|
2020-02-13 21:48:23 +01:00
|
|
|
}
|
|
|
|
if ((tctx->flags & DNS_STYLEFLAG_MULTILINE) != 0) {
|
1999-06-08 20:41:31 +00:00
|
|
|
RETERR(str_totext(" ) ", target));
|
2020-02-13 21:48:23 +01:00
|
|
|
} else {
|
2000-08-01 01:33:37 +00:00
|
|
|
RETERR(str_totext(" ", target));
|
2020-02-13 21:48:23 +01:00
|
|
|
}
|
1999-02-04 02:09:04 +00:00
|
|
|
isc_region_consume(&sr, n);
|
|
|
|
|
2000-05-13 22:46:07 +00:00
|
|
|
/*
|
|
|
|
* Other Size.
|
|
|
|
*/
|
1999-02-04 02:09:04 +00:00
|
|
|
n = uint16_fromregion(&sr);
|
|
|
|
isc_region_consume(&sr, 2);
|
2017-10-03 14:54:19 +11:00
|
|
|
snprintf(buf, sizeof(buf), "%lu", n);
|
1999-02-04 02:09:04 +00:00
|
|
|
RETERR(str_totext(buf, target));
|
|
|
|
|
2000-05-13 22:46:07 +00:00
|
|
|
/*
|
|
|
|
* Other Data.
|
|
|
|
*/
|
2000-03-17 21:13:02 +00:00
|
|
|
REQUIRE(n <= sr.length);
|
2003-07-25 00:01:16 +00:00
|
|
|
if (n != 0U) {
|
2020-02-12 13:59:18 +01:00
|
|
|
dr = sr;
|
|
|
|
dr.length = n;
|
2020-02-13 21:48:23 +01:00
|
|
|
if ((tctx->flags & DNS_STYLEFLAG_MULTILINE) != 0) {
|
2020-02-12 13:59:18 +01:00
|
|
|
RETERR(str_totext(" (", target));
|
2020-02-13 21:48:23 +01:00
|
|
|
}
|
2020-02-12 13:59:18 +01:00
|
|
|
RETERR(str_totext(tctx->linebreak, target));
|
2020-02-13 21:48:23 +01:00
|
|
|
if (tctx->width == 0) { /* No splitting */
|
2011-03-05 19:39:07 +00:00
|
|
|
RETERR(isc_base64_totext(&dr, 60, "", target));
|
2020-02-13 21:48:23 +01:00
|
|
|
} else {
|
2011-03-05 19:39:07 +00:00
|
|
|
RETERR(isc_base64_totext(&dr, tctx->width - 2,
|
|
|
|
tctx->linebreak, target));
|
2020-02-13 21:48:23 +01:00
|
|
|
}
|
|
|
|
if ((tctx->flags & DNS_STYLEFLAG_MULTILINE) != 0) {
|
2020-02-12 13:59:18 +01:00
|
|
|
RETERR(str_totext(" )", target));
|
2020-02-13 21:48:23 +01:00
|
|
|
}
|
2000-03-20 18:40:28 +00:00
|
|
|
}
|
2000-03-17 21:13:02 +00:00
|
|
|
return (ISC_R_SUCCESS);
|
1999-02-04 02:09:04 +00:00
|
|
|
}
|
|
|
|
|
2021-10-11 13:43:12 +02:00
|
|
|
static isc_result_t
|
2020-02-13 14:44:37 -08:00
|
|
|
fromwire_tkey(ARGS_FROMWIRE) {
|
|
|
|
isc_region_t sr;
|
1999-02-04 02:09:04 +00:00
|
|
|
unsigned long n;
|
2020-02-13 14:44:37 -08:00
|
|
|
dns_name_t name;
|
1999-02-04 02:09:04 +00:00
|
|
|
|
2015-08-17 12:23:35 +05:30
|
|
|
REQUIRE(type == dns_rdatatype_tkey);
|
1999-02-24 06:31:35 +00:00
|
|
|
|
2001-03-16 22:53:20 +00:00
|
|
|
UNUSED(type);
|
|
|
|
UNUSED(rdclass);
|
|
|
|
|
2022-05-05 16:36:52 +01:00
|
|
|
dctx = dns_decompress_setpermitted(dctx, false);
|
2000-08-01 01:33:37 +00:00
|
|
|
|
2000-05-13 22:46:07 +00:00
|
|
|
/*
|
|
|
|
* Algorithm.
|
|
|
|
*/
|
1999-02-04 06:38:43 +00:00
|
|
|
dns_name_init(&name, NULL);
|
2004-02-27 20:41:51 +00:00
|
|
|
RETERR(dns_name_fromwire(&name, source, dctx, options, target));
|
1999-02-04 06:38:43 +00:00
|
|
|
|
2000-05-13 22:46:07 +00:00
|
|
|
/*
|
1999-02-04 02:09:04 +00:00
|
|
|
* Inception: 4
|
|
|
|
* Expiration: 4
|
|
|
|
* Mode: 2
|
|
|
|
* Error: 2
|
|
|
|
*/
|
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);
|
2020-02-13 21:48:23 +01:00
|
|
|
if (sr.length < 12) {
|
2000-04-06 22:03:35 +00:00
|
|
|
return (ISC_R_UNEXPECTEDEND);
|
2020-02-13 21:48:23 +01:00
|
|
|
}
|
1999-02-04 02:09:04 +00:00
|
|
|
RETERR(mem_tobuffer(target, sr.base, 12));
|
|
|
|
isc_region_consume(&sr, 12);
|
|
|
|
isc_buffer_forward(source, 12);
|
|
|
|
|
2000-05-13 22:46:07 +00:00
|
|
|
/*
|
|
|
|
* Key Length + Key Data.
|
|
|
|
*/
|
2020-02-13 21:48:23 +01:00
|
|
|
if (sr.length < 2) {
|
2000-04-06 22:03:35 +00:00
|
|
|
return (ISC_R_UNEXPECTEDEND);
|
2020-02-13 21:48:23 +01:00
|
|
|
}
|
1999-02-04 02:09:04 +00:00
|
|
|
n = uint16_fromregion(&sr);
|
2020-02-13 21:48:23 +01:00
|
|
|
if (sr.length < n + 2) {
|
2000-04-06 22:03:35 +00:00
|
|
|
return (ISC_R_UNEXPECTEDEND);
|
2020-02-13 21:48:23 +01:00
|
|
|
}
|
1999-02-04 02:09:04 +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:46:07 +00:00
|
|
|
/*
|
|
|
|
* Other Length + Other Data.
|
|
|
|
*/
|
2020-02-13 21:48:23 +01:00
|
|
|
if (sr.length < 2) {
|
2000-04-06 22:03:35 +00:00
|
|
|
return (ISC_R_UNEXPECTEDEND);
|
2020-02-13 21:48:23 +01:00
|
|
|
}
|
1999-02-04 02:09:04 +00:00
|
|
|
n = uint16_fromregion(&sr);
|
2020-02-13 21:48:23 +01:00
|
|
|
if (sr.length < n + 2) {
|
2000-04-06 22:03:35 +00:00
|
|
|
return (ISC_R_UNEXPECTEDEND);
|
2020-02-13 21:48:23 +01:00
|
|
|
}
|
1999-02-04 02:09:04 +00:00
|
|
|
isc_buffer_forward(source, n + 2);
|
|
|
|
return (mem_tobuffer(target, sr.base, n + 2));
|
|
|
|
}
|
|
|
|
|
2021-10-11 13:43:12 +02:00
|
|
|
static isc_result_t
|
2020-02-13 14:44:37 -08:00
|
|
|
towire_tkey(ARGS_TOWIRE) {
|
|
|
|
isc_region_t sr;
|
|
|
|
dns_name_t name;
|
2001-02-12 03:05:05 +00:00
|
|
|
dns_offsets_t offsets;
|
1999-02-04 02:09:04 +00:00
|
|
|
|
2015-08-17 12:23:35 +05:30
|
|
|
REQUIRE(rdata->type == dns_rdatatype_tkey);
|
2000-10-25 05:44:10 +00:00
|
|
|
REQUIRE(rdata->length != 0);
|
1999-02-04 02:09:04 +00:00
|
|
|
|
2022-05-05 14:52:44 +01:00
|
|
|
dns_compress_setpermitted(cctx, false);
|
2000-05-13 22:46:07 +00:00
|
|
|
/*
|
|
|
|
* Algorithm.
|
|
|
|
*/
|
1999-02-04 02:09:04 +00:00
|
|
|
dns_rdata_toregion(rdata, &sr);
|
2001-02-12 03:05:05 +00:00
|
|
|
dns_name_init(&name, offsets);
|
1999-02-04 06:38:43 +00:00
|
|
|
dns_name_fromregion(&name, &sr);
|
|
|
|
RETERR(dns_name_towire(&name, cctx, target));
|
|
|
|
isc_region_consume(&sr, name_length(&name));
|
|
|
|
|
1999-02-04 02:09:04 +00:00
|
|
|
return (mem_tobuffer(target, sr.base, sr.length));
|
|
|
|
}
|
|
|
|
|
2021-10-11 13:43:12 +02:00
|
|
|
static int
|
2020-02-13 14:44:37 -08:00
|
|
|
compare_tkey(ARGS_COMPARE) {
|
1999-02-04 02:09:04 +00:00
|
|
|
isc_region_t r1;
|
|
|
|
isc_region_t r2;
|
2020-02-13 14:44:37 -08:00
|
|
|
dns_name_t name1;
|
|
|
|
dns_name_t name2;
|
|
|
|
int order;
|
1999-02-04 02:09:04 +00:00
|
|
|
|
|
|
|
REQUIRE(rdata1->type == rdata2->type);
|
1999-08-02 22:18:31 +00:00
|
|
|
REQUIRE(rdata1->rdclass == rdata2->rdclass);
|
2015-08-17 12:23:35 +05:30
|
|
|
REQUIRE(rdata1->type == dns_rdatatype_tkey);
|
2000-10-25 05:44:10 +00:00
|
|
|
REQUIRE(rdata1->length != 0);
|
|
|
|
REQUIRE(rdata2->length != 0);
|
2000-08-01 01:33:37 +00:00
|
|
|
|
2000-05-13 22:46:07 +00:00
|
|
|
/*
|
|
|
|
* Algorithm.
|
|
|
|
*/
|
1999-02-04 02:09:04 +00:00
|
|
|
dns_rdata_toregion(rdata1, &r1);
|
|
|
|
dns_rdata_toregion(rdata2, &r2);
|
1999-02-04 06:38:43 +00:00
|
|
|
dns_name_init(&name1, NULL);
|
|
|
|
dns_name_init(&name2, NULL);
|
|
|
|
dns_name_fromregion(&name1, &r1);
|
1999-02-04 07:00:32 +00:00
|
|
|
dns_name_fromregion(&name2, &r2);
|
2020-02-13 21:48:23 +01:00
|
|
|
if ((order = dns_name_rdatacompare(&name1, &name2)) != 0) {
|
2000-03-20 22:44:36 +00:00
|
|
|
return (order);
|
2020-02-13 21:48:23 +01:00
|
|
|
}
|
1999-02-04 06:38:43 +00:00
|
|
|
isc_region_consume(&r1, name_length(&name1));
|
|
|
|
isc_region_consume(&r2, name_length(&name2));
|
2002-01-05 07:05:28 +00:00
|
|
|
return (isc_region_compare(&r1, &r2));
|
1999-02-04 02:09:04 +00:00
|
|
|
}
|
|
|
|
|
2021-10-11 13:43:12 +02:00
|
|
|
static isc_result_t
|
2020-02-13 14:44:37 -08:00
|
|
|
fromstruct_tkey(ARGS_FROMSTRUCT) {
|
2000-05-22 12:38:12 +00:00
|
|
|
dns_rdata_tkey_t *tkey = source;
|
2000-03-17 21:13:02 +00:00
|
|
|
|
2015-08-17 12:23:35 +05:30
|
|
|
REQUIRE(type == dns_rdatatype_tkey);
|
2019-09-27 10:40:51 +02:00
|
|
|
REQUIRE(tkey != NULL);
|
2000-05-22 12:38:12 +00:00
|
|
|
REQUIRE(tkey->common.rdtype == type);
|
|
|
|
REQUIRE(tkey->common.rdclass == rdclass);
|
1999-10-07 21:49:39 +00:00
|
|
|
|
2001-03-16 22:53:20 +00:00
|
|
|
UNUSED(type);
|
2000-12-01 01:40:59 +00:00
|
|
|
UNUSED(rdclass);
|
|
|
|
|
2000-05-13 22:46:07 +00:00
|
|
|
/*
|
|
|
|
* Algorithm Name.
|
|
|
|
*/
|
2000-05-05 18:15:02 +00:00
|
|
|
RETERR(name_tobuffer(&tkey->algorithm, target));
|
1999-10-07 21:49:39 +00:00
|
|
|
|
2000-05-13 22:46:07 +00:00
|
|
|
/*
|
|
|
|
* Inception: 32 bits.
|
|
|
|
*/
|
1999-10-07 21:49:39 +00:00
|
|
|
RETERR(uint32_tobuffer(tkey->inception, target));
|
|
|
|
|
2000-05-13 22:46:07 +00:00
|
|
|
/*
|
|
|
|
* Expire: 32 bits.
|
|
|
|
*/
|
1999-10-07 21:49:39 +00:00
|
|
|
RETERR(uint32_tobuffer(tkey->expire, target));
|
|
|
|
|
2000-05-13 22:46:07 +00:00
|
|
|
/*
|
|
|
|
* Mode: 16 bits.
|
|
|
|
*/
|
1999-10-07 21:49:39 +00:00
|
|
|
RETERR(uint16_tobuffer(tkey->mode, target));
|
|
|
|
|
2000-05-13 22:46:07 +00:00
|
|
|
/*
|
|
|
|
* Error: 16 bits.
|
|
|
|
*/
|
1999-10-07 21:49:39 +00:00
|
|
|
RETERR(uint16_tobuffer(tkey->error, target));
|
|
|
|
|
2000-05-13 22:46:07 +00:00
|
|
|
/*
|
|
|
|
* Key size: 16 bits.
|
|
|
|
*/
|
1999-10-07 21:49:39 +00:00
|
|
|
RETERR(uint16_tobuffer(tkey->keylen, target));
|
|
|
|
|
2000-05-13 22:46:07 +00:00
|
|
|
/*
|
|
|
|
* Key.
|
|
|
|
*/
|
2000-05-22 12:38:12 +00:00
|
|
|
RETERR(mem_tobuffer(target, tkey->key, tkey->keylen));
|
1999-10-07 21:49:39 +00:00
|
|
|
|
2000-05-13 22:46:07 +00:00
|
|
|
/*
|
|
|
|
* Other size: 16 bits.
|
|
|
|
*/
|
1999-10-07 21:49:39 +00:00
|
|
|
RETERR(uint16_tobuffer(tkey->otherlen, target));
|
|
|
|
|
2000-05-13 22:46:07 +00:00
|
|
|
/*
|
|
|
|
* Other data.
|
|
|
|
*/
|
2000-05-22 12:38:12 +00:00
|
|
|
return (mem_tobuffer(target, tkey->other, tkey->otherlen));
|
1999-02-04 02:09:04 +00:00
|
|
|
}
|
|
|
|
|
2021-10-11 13:43:12 +02:00
|
|
|
static isc_result_t
|
2020-02-13 14:44:37 -08:00
|
|
|
tostruct_tkey(ARGS_TOSTRUCT) {
|
2000-05-05 05:50:14 +00:00
|
|
|
dns_rdata_tkey_t *tkey = target;
|
2020-02-13 14:44:37 -08:00
|
|
|
dns_name_t alg;
|
|
|
|
isc_region_t sr;
|
1999-02-04 02:09:04 +00:00
|
|
|
|
2015-08-17 12:23:35 +05:30
|
|
|
REQUIRE(rdata->type == dns_rdatatype_tkey);
|
2019-09-27 10:40:51 +02:00
|
|
|
REQUIRE(tkey != NULL);
|
2000-10-25 05:44:10 +00:00
|
|
|
REQUIRE(rdata->length != 0);
|
1999-10-07 21:49:39 +00:00
|
|
|
|
|
|
|
tkey->common.rdclass = rdata->rdclass;
|
|
|
|
tkey->common.rdtype = rdata->type;
|
|
|
|
ISC_LINK_INIT(&tkey->common, link);
|
2000-05-05 05:50:14 +00:00
|
|
|
|
1999-10-07 21:49:39 +00:00
|
|
|
dns_rdata_toregion(rdata, &sr);
|
|
|
|
|
2000-05-13 22:46:07 +00:00
|
|
|
/*
|
|
|
|
* Algorithm Name.
|
|
|
|
*/
|
1999-10-07 21:49:39 +00:00
|
|
|
dns_name_init(&alg, NULL);
|
|
|
|
dns_name_fromregion(&alg, &sr);
|
|
|
|
dns_name_init(&tkey->algorithm, NULL);
|
2021-10-06 12:57:24 +02:00
|
|
|
name_duporclone(&alg, mctx, &tkey->algorithm);
|
1999-10-07 21:49:39 +00:00
|
|
|
isc_region_consume(&sr, name_length(&tkey->algorithm));
|
|
|
|
|
2000-05-13 22:46:07 +00:00
|
|
|
/*
|
|
|
|
* Inception.
|
|
|
|
*/
|
1999-10-07 21:49:39 +00:00
|
|
|
tkey->inception = uint32_fromregion(&sr);
|
|
|
|
isc_region_consume(&sr, 4);
|
|
|
|
|
2000-05-13 22:46:07 +00:00
|
|
|
/*
|
|
|
|
* Expire.
|
|
|
|
*/
|
1999-10-07 21:49:39 +00:00
|
|
|
tkey->expire = uint32_fromregion(&sr);
|
|
|
|
isc_region_consume(&sr, 4);
|
|
|
|
|
2000-05-13 22:46:07 +00:00
|
|
|
/*
|
|
|
|
* Mode.
|
|
|
|
*/
|
1999-10-07 21:49:39 +00:00
|
|
|
tkey->mode = uint16_fromregion(&sr);
|
|
|
|
isc_region_consume(&sr, 2);
|
|
|
|
|
2000-05-13 22:46:07 +00:00
|
|
|
/*
|
|
|
|
* Error.
|
|
|
|
*/
|
1999-10-07 21:49:39 +00:00
|
|
|
tkey->error = uint16_fromregion(&sr);
|
|
|
|
isc_region_consume(&sr, 2);
|
|
|
|
|
2000-05-13 22:46:07 +00:00
|
|
|
/*
|
|
|
|
* Key size.
|
|
|
|
*/
|
1999-10-07 21:49:39 +00:00
|
|
|
tkey->keylen = uint16_fromregion(&sr);
|
|
|
|
isc_region_consume(&sr, 2);
|
|
|
|
|
2000-05-13 22:46:07 +00:00
|
|
|
/*
|
|
|
|
* Key.
|
|
|
|
*/
|
2014-06-12 11:12:22 +10:00
|
|
|
INSIST(tkey->keylen + 2U <= sr.length);
|
2001-06-21 04:00:47 +00:00
|
|
|
tkey->key = mem_maybedup(mctx, sr.base, tkey->keylen);
|
|
|
|
isc_region_consume(&sr, tkey->keylen);
|
1999-10-07 21:49:39 +00:00
|
|
|
|
2000-05-13 22:46:07 +00:00
|
|
|
/*
|
|
|
|
* Other size.
|
|
|
|
*/
|
1999-10-07 21:49:39 +00:00
|
|
|
tkey->otherlen = uint16_fromregion(&sr);
|
|
|
|
isc_region_consume(&sr, 2);
|
|
|
|
|
2000-05-13 22:46:07 +00:00
|
|
|
/*
|
|
|
|
* Other.
|
|
|
|
*/
|
2014-06-12 10:42:39 +10:00
|
|
|
INSIST(tkey->otherlen <= sr.length);
|
2001-06-21 04:00:47 +00:00
|
|
|
tkey->other = mem_maybedup(mctx, sr.base, tkey->otherlen);
|
2000-05-05 05:50:14 +00:00
|
|
|
tkey->mctx = mctx;
|
2000-04-06 22:03:35 +00:00
|
|
|
return (ISC_R_SUCCESS);
|
1999-02-04 02:09:04 +00:00
|
|
|
}
|
1999-05-07 03:24:15 +00:00
|
|
|
|
2021-10-11 13:43:12 +02:00
|
|
|
static void
|
2020-02-13 14:44:37 -08:00
|
|
|
freestruct_tkey(ARGS_FREESTRUCT) {
|
2020-02-12 13:59:18 +01:00
|
|
|
dns_rdata_tkey_t *tkey = (dns_rdata_tkey_t *)source;
|
1999-10-07 21:49:39 +00:00
|
|
|
|
2019-09-27 10:40:51 +02:00
|
|
|
REQUIRE(tkey != NULL);
|
1999-10-07 21:49:39 +00:00
|
|
|
|
2020-02-13 21:48:23 +01:00
|
|
|
if (tkey->mctx == NULL) {
|
2000-05-05 05:50:14 +00:00
|
|
|
return;
|
2020-02-13 21:48:23 +01:00
|
|
|
}
|
2000-05-05 05:50:14 +00:00
|
|
|
|
1999-10-07 21:49:39 +00:00
|
|
|
dns_name_free(&tkey->algorithm, tkey->mctx);
|
2020-02-13 21:48:23 +01:00
|
|
|
if (tkey->key != NULL) {
|
2000-05-05 05:50:14 +00:00
|
|
|
isc_mem_free(tkey->mctx, tkey->key);
|
2020-02-13 21:48:23 +01:00
|
|
|
}
|
|
|
|
if (tkey->other != NULL) {
|
2000-05-05 05:50:14 +00:00
|
|
|
isc_mem_free(tkey->mctx, tkey->other);
|
2020-02-13 21:48:23 +01:00
|
|
|
}
|
2000-05-05 05:50:14 +00:00
|
|
|
tkey->mctx = NULL;
|
1999-05-07 03:24:15 +00:00
|
|
|
}
|
1999-08-02 22:18:31 +00:00
|
|
|
|
2021-10-11 13:43:12 +02:00
|
|
|
static isc_result_t
|
2020-02-13 14:44:37 -08:00
|
|
|
additionaldata_tkey(ARGS_ADDLDATA) {
|
2019-07-05 16:20:20 +10:00
|
|
|
REQUIRE(rdata->type == dns_rdatatype_tkey);
|
|
|
|
|
2000-04-28 01:24:18 +00:00
|
|
|
UNUSED(rdata);
|
2019-07-05 16:20:20 +10:00
|
|
|
UNUSED(owner);
|
2000-03-17 21:13:02 +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
|
|
|
}
|
|
|
|
|
2021-10-11 13:43:12 +02:00
|
|
|
static isc_result_t
|
2020-02-13 14:44:37 -08:00
|
|
|
digest_tkey(ARGS_DIGEST) {
|
2000-04-28 01:24:18 +00:00
|
|
|
UNUSED(rdata);
|
2000-03-17 21:13:02 +00:00
|
|
|
UNUSED(digest);
|
|
|
|
UNUSED(arg);
|
1999-08-31 22:05:55 +00:00
|
|
|
|
2015-08-17 12:23:35 +05:30
|
|
|
REQUIRE(rdata->type == dns_rdatatype_tkey);
|
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
|
|
|
}
|
|
|
|
|
2021-10-11 13:43:12 +02:00
|
|
|
static bool
|
2020-02-13 14:44:37 -08:00
|
|
|
checkowner_tkey(ARGS_CHECKOWNER) {
|
2015-08-17 12:23:35 +05:30
|
|
|
REQUIRE(type == dns_rdatatype_tkey);
|
2004-02-27 20:41:51 +00:00
|
|
|
|
|
|
|
UNUSED(name);
|
|
|
|
UNUSED(type);
|
|
|
|
UNUSED(rdclass);
|
|
|
|
UNUSED(wildcard);
|
|
|
|
|
2018-04-17 08:29:14 -07:00
|
|
|
return (true);
|
2004-02-27 20:41:51 +00:00
|
|
|
}
|
|
|
|
|
2021-10-11 13:43:12 +02:00
|
|
|
static bool
|
2020-02-13 14:44:37 -08:00
|
|
|
checknames_tkey(ARGS_CHECKNAMES) {
|
2015-08-17 12:23:35 +05:30
|
|
|
REQUIRE(rdata->type == dns_rdatatype_tkey);
|
2004-02-27 20:41:51 +00:00
|
|
|
|
|
|
|
UNUSED(rdata);
|
|
|
|
UNUSED(owner);
|
|
|
|
UNUSED(bad);
|
|
|
|
|
2018-04-17 08:29:14 -07:00
|
|
|
return (true);
|
2004-02-27 20:41:51 +00:00
|
|
|
}
|
|
|
|
|
2021-10-11 13:43:12 +02:00
|
|
|
static int
|
2020-02-13 14:44:37 -08:00
|
|
|
casecompare_tkey(ARGS_COMPARE) {
|
2009-12-04 21:09:34 +00:00
|
|
|
return (compare_tkey(rdata1, rdata2));
|
|
|
|
}
|
2020-02-12 13:59:18 +01:00
|
|
|
#endif /* RDATA_GENERIC_TKEY_249_C */
|