1999-01-27 13:38:21 +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
|
|
|
*
|
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-01-27 13:38:21 +00:00
|
|
|
*/
|
|
|
|
|
2005-04-27 04:57:32 +00:00
|
|
|
/* RFC2535 */
|
1999-01-27 13:38:21 +00:00
|
|
|
|
1999-05-05 00:19:04 +00:00
|
|
|
#ifndef RDATA_GENERIC_SIG_24_C
|
|
|
|
#define RDATA_GENERIC_SIG_24_C
|
1999-01-27 13:38:21 +00:00
|
|
|
|
2003-09-30 06:00:40 +00:00
|
|
|
#define RRTYPE_SIG_ATTRIBUTES (0)
|
2000-04-07 03:54:52 +00:00
|
|
|
|
2020-02-13 14:44:37 -08:00
|
|
|
static inline isc_result_t
|
|
|
|
fromtext_sig(ARGS_FROMTEXT) {
|
|
|
|
isc_token_t token;
|
|
|
|
unsigned char c;
|
|
|
|
long i;
|
1999-01-27 13:38:21 +00:00
|
|
|
dns_rdatatype_t covered;
|
2020-02-13 14:44:37 -08:00
|
|
|
char *e;
|
|
|
|
isc_result_t result;
|
|
|
|
dns_name_t name;
|
|
|
|
isc_buffer_t buffer;
|
|
|
|
uint32_t time_signed, time_expire;
|
1999-01-27 13:38:21 +00:00
|
|
|
|
2015-08-17 12:23:35 +05:30
|
|
|
REQUIRE(type == dns_rdatatype_sig);
|
1999-01-27 13:38:21 +00:00
|
|
|
|
2001-03-16 22:53:20 +00:00
|
|
|
UNUSED(type);
|
2000-03-17 17:08:36 +00:00
|
|
|
UNUSED(rdclass);
|
2001-07-16 03:06:53 +00:00
|
|
|
UNUSED(callbacks);
|
1999-01-27 13:38:21 +00:00
|
|
|
|
2000-05-15 21:14:38 +00:00
|
|
|
/*
|
|
|
|
* Type covered.
|
|
|
|
*/
|
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));
|
2000-03-17 17:08:36 +00:00
|
|
|
result = dns_rdatatype_fromtext(&covered, &token.value.as_textregion);
|
2000-04-06 22:03:35 +00:00
|
|
|
if (result != ISC_R_SUCCESS && result != ISC_R_NOTIMPLEMENTED) {
|
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 (i < 0 || i > 65535) {
|
2001-03-06 22:11:18 +00:00
|
|
|
RETTOK(ISC_R_RANGE);
|
2020-02-13 21:48:23 +01:00
|
|
|
}
|
|
|
|
if (*e != 0) {
|
2001-03-06 22:11:18 +00:00
|
|
|
RETTOK(result);
|
2020-02-13 21:48:23 +01:00
|
|
|
}
|
1999-10-08 21:42:23 +00:00
|
|
|
covered = (dns_rdatatype_t)i;
|
1999-01-27 13:38:21 +00:00
|
|
|
}
|
|
|
|
RETERR(uint16_tobuffer(covered, target));
|
|
|
|
|
2000-05-15 21:14:38 +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));
|
2001-03-06 22:11:18 +00:00
|
|
|
RETTOK(dns_secalg_fromtext(&c, &token.value.as_textregion));
|
1999-01-27 13:38:21 +00:00
|
|
|
RETERR(mem_tobuffer(target, &c, 1));
|
|
|
|
|
2000-05-15 21:14:38 +00:00
|
|
|
/*
|
|
|
|
* Labels.
|
|
|
|
*/
|
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 > 0xffU) {
|
2001-03-06 22:11:18 +00:00
|
|
|
RETTOK(ISC_R_RANGE);
|
2020-02-13 21:48:23 +01:00
|
|
|
}
|
1999-10-08 23:54:40 +00:00
|
|
|
c = (unsigned char)token.value.as_ulong;
|
1999-01-27 13:38:21 +00:00
|
|
|
RETERR(mem_tobuffer(target, &c, 1));
|
|
|
|
|
2000-05-15 21:14:38 +00:00
|
|
|
/*
|
|
|
|
* Original ttl.
|
|
|
|
*/
|
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-01-27 13:38:21 +00:00
|
|
|
RETERR(uint32_tobuffer(token.value.as_ulong, target));
|
|
|
|
|
2000-05-15 21:14:38 +00:00
|
|
|
/*
|
|
|
|
* Signature expiration.
|
|
|
|
*/
|
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));
|
2002-01-21 01:07:32 +00:00
|
|
|
RETTOK(dns_time32_fromtext(DNS_AS_STR(token), &time_expire));
|
1999-06-08 10:35:23 +00:00
|
|
|
RETERR(uint32_tobuffer(time_expire, target));
|
1999-01-27 13:38:21 +00:00
|
|
|
|
2000-05-15 21:14:38 +00:00
|
|
|
/*
|
|
|
|
* Time signed.
|
|
|
|
*/
|
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));
|
2002-01-21 01:07:32 +00:00
|
|
|
RETTOK(dns_time32_fromtext(DNS_AS_STR(token), &time_signed));
|
1999-06-08 10:35:23 +00:00
|
|
|
RETERR(uint32_tobuffer(time_signed, target));
|
1999-01-27 13:38:21 +00:00
|
|
|
|
2000-05-15 21:14:38 +00:00
|
|
|
/*
|
|
|
|
* Key footprint.
|
|
|
|
*/
|
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-01-27 13:38:21 +00:00
|
|
|
RETERR(uint16_tobuffer(token.value.as_ulong, target));
|
2000-08-01 01:33:37 +00:00
|
|
|
|
2000-05-15 21:14:38 +00:00
|
|
|
/*
|
|
|
|
* Signer.
|
|
|
|
*/
|
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-01-27 13:38:21 +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-01-27 13:38:21 +00:00
|
|
|
|
2000-05-15 21:14:38 +00:00
|
|
|
/*
|
|
|
|
* Sig.
|
|
|
|
*/
|
2019-01-04 15:20:04 +11:00
|
|
|
return (isc_base64_tobuffer(lexer, target, -2));
|
1999-01-27 13:38:21 +00:00
|
|
|
}
|
|
|
|
|
2020-02-13 14:44:37 -08:00
|
|
|
static inline isc_result_t
|
|
|
|
totext_sig(ARGS_TOTEXT) {
|
|
|
|
isc_region_t sr;
|
|
|
|
char buf[sizeof("4294967295")];
|
1999-01-27 13:38:21 +00:00
|
|
|
dns_rdatatype_t covered;
|
2020-02-13 14:44:37 -08:00
|
|
|
unsigned long ttl;
|
|
|
|
unsigned long when;
|
|
|
|
unsigned long exp;
|
|
|
|
unsigned long foot;
|
|
|
|
dns_name_t name;
|
|
|
|
dns_name_t prefix;
|
|
|
|
bool sub;
|
1999-01-27 13:38:21 +00:00
|
|
|
|
2015-08-17 12:23:35 +05:30
|
|
|
REQUIRE(rdata->type == dns_rdatatype_sig);
|
2000-10-25 05:44:10 +00:00
|
|
|
REQUIRE(rdata->length != 0);
|
1999-01-27 13:38:21 +00:00
|
|
|
|
|
|
|
dns_rdata_toregion(rdata, &sr);
|
|
|
|
|
2000-05-15 21:14:38 +00:00
|
|
|
/*
|
|
|
|
* Type covered.
|
|
|
|
*/
|
1999-01-27 13:38:21 +00:00
|
|
|
covered = uint16_fromregion(&sr);
|
|
|
|
isc_region_consume(&sr, 2);
|
2000-05-22 21:42:47 +00:00
|
|
|
/*
|
|
|
|
* XXXAG We should have something like dns_rdatatype_isknown()
|
|
|
|
* that does the right thing with type 0.
|
|
|
|
*/
|
|
|
|
if (dns_rdatatype_isknown(covered) && covered != 0) {
|
|
|
|
RETERR(dns_rdatatype_totext(covered, target));
|
|
|
|
} else {
|
2017-10-03 14:54:19 +11:00
|
|
|
snprintf(buf, sizeof(buf), "%u", covered);
|
2000-05-22 21:42:47 +00:00
|
|
|
RETERR(str_totext(buf, target));
|
|
|
|
}
|
1999-01-27 13:38:21 +00:00
|
|
|
RETERR(str_totext(" ", target));
|
|
|
|
|
2000-05-15 21:14:38 +00:00
|
|
|
/*
|
|
|
|
* Algorithm.
|
|
|
|
*/
|
2017-10-03 14:54:19 +11:00
|
|
|
snprintf(buf, sizeof(buf), "%u", sr.base[0]);
|
1999-01-27 13:38:21 +00:00
|
|
|
isc_region_consume(&sr, 1);
|
|
|
|
RETERR(str_totext(buf, target));
|
|
|
|
RETERR(str_totext(" ", target));
|
|
|
|
|
2000-05-15 21:14:38 +00:00
|
|
|
/*
|
|
|
|
* Labels.
|
|
|
|
*/
|
2017-10-03 14:54:19 +11:00
|
|
|
snprintf(buf, sizeof(buf), "%u", sr.base[0]);
|
1999-01-27 13:38:21 +00:00
|
|
|
isc_region_consume(&sr, 1);
|
|
|
|
RETERR(str_totext(buf, target));
|
|
|
|
RETERR(str_totext(" ", target));
|
|
|
|
|
2000-05-15 21:14:38 +00:00
|
|
|
/*
|
|
|
|
* Ttl.
|
|
|
|
*/
|
1999-01-27 13:38:21 +00:00
|
|
|
ttl = uint32_fromregion(&sr);
|
|
|
|
isc_region_consume(&sr, 4);
|
2017-10-03 14:54:19 +11:00
|
|
|
snprintf(buf, sizeof(buf), "%lu", ttl);
|
1999-01-27 13:38:21 +00:00
|
|
|
RETERR(str_totext(buf, target));
|
|
|
|
RETERR(str_totext(" ", target));
|
|
|
|
|
2000-05-15 21:14:38 +00:00
|
|
|
/*
|
|
|
|
* Sig exp.
|
|
|
|
*/
|
1999-01-27 13:38:21 +00:00
|
|
|
exp = uint32_fromregion(&sr);
|
|
|
|
isc_region_consume(&sr, 4);
|
1999-06-08 10:35:23 +00:00
|
|
|
RETERR(dns_time32_totext(exp, target));
|
1999-01-27 13:38:21 +00:00
|
|
|
|
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));
|
|
|
|
|
2000-05-15 21:14:38 +00:00
|
|
|
/*
|
|
|
|
* Time signed.
|
|
|
|
*/
|
1999-01-27 13:38:21 +00:00
|
|
|
when = uint32_fromregion(&sr);
|
|
|
|
isc_region_consume(&sr, 4);
|
1999-06-08 10:35:23 +00:00
|
|
|
RETERR(dns_time32_totext(when, target));
|
1999-01-27 13:38:21 +00:00
|
|
|
RETERR(str_totext(" ", target));
|
|
|
|
|
2000-05-15 21:14:38 +00:00
|
|
|
/*
|
|
|
|
* Footprint.
|
|
|
|
*/
|
1999-01-27 13:38:21 +00:00
|
|
|
foot = uint16_fromregion(&sr);
|
|
|
|
isc_region_consume(&sr, 2);
|
2017-10-03 14:54:19 +11:00
|
|
|
snprintf(buf, sizeof(buf), "%lu", foot);
|
1999-01-27 13:38:21 +00:00
|
|
|
RETERR(str_totext(buf, target));
|
|
|
|
RETERR(str_totext(" ", target));
|
|
|
|
|
2000-05-15 21:14:38 +00:00
|
|
|
/*
|
|
|
|
* Signer.
|
|
|
|
*/
|
1999-01-27 13:38:21 +00:00
|
|
|
dns_name_init(&name, NULL);
|
|
|
|
dns_name_init(&prefix, NULL);
|
|
|
|
dns_name_fromregion(&name, &sr);
|
1999-01-29 08:04:13 +00:00
|
|
|
isc_region_consume(&sr, name_length(&name));
|
1999-06-08 10:35:23 +00:00
|
|
|
sub = name_prefix(&name, tctx->origin, &prefix);
|
1999-01-27 13:38:21 +00:00
|
|
|
RETERR(dns_name_totext(&prefix, sub, target));
|
|
|
|
|
2000-05-15 21:14:38 +00:00
|
|
|
/*
|
|
|
|
* Sig.
|
|
|
|
*/
|
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(&sr, 60, "", target));
|
2020-02-13 21:48:23 +01:00
|
|
|
} else {
|
2020-02-12 13:59:18 +01:00
|
|
|
RETERR(isc_base64_totext(&sr, 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
|
|
|
}
|
2000-08-01 01:33:37 +00:00
|
|
|
|
2000-04-06 22:03:35 +00:00
|
|
|
return (ISC_R_SUCCESS);
|
1999-01-27 13:38:21 +00:00
|
|
|
}
|
|
|
|
|
2020-02-13 14:44:37 -08:00
|
|
|
static inline isc_result_t
|
|
|
|
fromwire_sig(ARGS_FROMWIRE) {
|
1999-01-27 13:38:21 +00:00
|
|
|
isc_region_t sr;
|
2020-02-13 14:44:37 -08:00
|
|
|
dns_name_t name;
|
1999-01-27 13:38:21 +00:00
|
|
|
|
2015-08-17 12:23:35 +05:30
|
|
|
REQUIRE(type == dns_rdatatype_sig);
|
1999-02-24 06:31:35 +00:00
|
|
|
|
2001-03-16 22:53:20 +00:00
|
|
|
UNUSED(type);
|
2000-03-17 17:08:36 +00:00
|
|
|
UNUSED(rdclass);
|
1999-01-27 13:38:21 +00:00
|
|
|
|
2001-03-16 22:53:20 +00:00
|
|
|
dns_decompress_setmethods(dctx, DNS_COMPRESS_NONE);
|
|
|
|
|
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);
|
1999-01-27 13:38:21 +00:00
|
|
|
/*
|
|
|
|
* type covered: 2
|
|
|
|
* algorithm: 1
|
|
|
|
* labels: 1
|
|
|
|
* original ttl: 4
|
|
|
|
* signature expiration: 4
|
|
|
|
* time signed: 4
|
|
|
|
* key footprint: 2
|
|
|
|
*/
|
2020-02-13 21:48:23 +01:00
|
|
|
if (sr.length < 18) {
|
2000-04-06 22:03:35 +00:00
|
|
|
return (ISC_R_UNEXPECTEDEND);
|
2020-02-13 21:48:23 +01:00
|
|
|
}
|
1999-01-27 13:38:21 +00:00
|
|
|
|
|
|
|
isc_buffer_forward(source, 18);
|
1999-01-29 08:04:13 +00:00
|
|
|
RETERR(mem_tobuffer(target, sr.base, 18));
|
1999-01-27 13:38:21 +00:00
|
|
|
|
2000-05-15 21:14:38 +00:00
|
|
|
/*
|
|
|
|
* Signer.
|
|
|
|
*/
|
1999-01-27 13:38:21 +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-01-27 13:38:21 +00:00
|
|
|
|
2000-05-15 21:14:38 +00:00
|
|
|
/*
|
|
|
|
* Sig.
|
|
|
|
*/
|
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-08-13 10:51:40 +10:00
|
|
|
if (sr.length == 0) {
|
|
|
|
return (ISC_R_UNEXPECTEDEND);
|
|
|
|
}
|
1999-01-29 08:04:13 +00:00
|
|
|
isc_buffer_forward(source, sr.length);
|
2000-03-17 17:08:36 +00:00
|
|
|
return (mem_tobuffer(target, sr.base, sr.length));
|
1999-01-27 13:38:21 +00:00
|
|
|
}
|
|
|
|
|
2020-02-13 14:44:37 -08:00
|
|
|
static inline isc_result_t
|
|
|
|
towire_sig(ARGS_TOWIRE) {
|
|
|
|
isc_region_t sr;
|
|
|
|
dns_name_t name;
|
2001-02-12 03:05:05 +00:00
|
|
|
dns_offsets_t offsets;
|
1999-01-27 13:38:21 +00:00
|
|
|
|
2015-08-17 12:23:35 +05:30
|
|
|
REQUIRE(rdata->type == dns_rdatatype_sig);
|
2000-10-25 05:44:10 +00:00
|
|
|
REQUIRE(rdata->length != 0);
|
1999-01-27 13:38:21 +00:00
|
|
|
|
2000-05-04 22:19:34 +00:00
|
|
|
dns_compress_setmethods(cctx, DNS_COMPRESS_NONE);
|
1999-01-27 13:38:21 +00:00
|
|
|
dns_rdata_toregion(rdata, &sr);
|
|
|
|
/*
|
|
|
|
* type covered: 2
|
|
|
|
* algorithm: 1
|
|
|
|
* labels: 1
|
|
|
|
* original ttl: 4
|
|
|
|
* signature expiration: 4
|
|
|
|
* time signed: 4
|
|
|
|
* key footprint: 2
|
|
|
|
*/
|
|
|
|
RETERR(mem_tobuffer(target, sr.base, 18));
|
|
|
|
isc_region_consume(&sr, 18);
|
|
|
|
|
2000-05-15 21:14:38 +00:00
|
|
|
/*
|
|
|
|
* Signer.
|
|
|
|
*/
|
2001-02-12 03:05:05 +00:00
|
|
|
dns_name_init(&name, offsets);
|
1999-01-27 13:38:21 +00:00
|
|
|
dns_name_fromregion(&name, &sr);
|
2000-08-01 01:33:37 +00:00
|
|
|
isc_region_consume(&sr, name_length(&name));
|
1999-01-27 13:38:21 +00:00
|
|
|
RETERR(dns_name_towire(&name, cctx, target));
|
|
|
|
|
2000-05-15 21:14:38 +00:00
|
|
|
/*
|
|
|
|
* Signature.
|
|
|
|
*/
|
1999-01-27 13:38:21 +00:00
|
|
|
return (mem_tobuffer(target, sr.base, sr.length));
|
|
|
|
}
|
|
|
|
|
2020-02-13 14:44:37 -08:00
|
|
|
static inline int
|
|
|
|
compare_sig(ARGS_COMPARE) {
|
1999-01-27 13:38:21 +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-01-27 13:38:21 +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_sig);
|
2000-10-25 05:44:10 +00:00
|
|
|
REQUIRE(rdata1->length != 0);
|
|
|
|
REQUIRE(rdata2->length != 0);
|
1999-01-27 13:38:21 +00:00
|
|
|
|
|
|
|
dns_rdata_toregion(rdata1, &r1);
|
|
|
|
dns_rdata_toregion(rdata2, &r2);
|
|
|
|
|
|
|
|
INSIST(r1.length > 18);
|
|
|
|
INSIST(r2.length > 18);
|
|
|
|
r1.length = 18;
|
|
|
|
r2.length = 18;
|
2002-01-05 07:05:28 +00:00
|
|
|
order = isc_region_compare(&r1, &r2);
|
2020-02-13 21:48:23 +01:00
|
|
|
if (order != 0) {
|
2000-03-17 21:43:46 +00:00
|
|
|
return (order);
|
2020-02-13 21:48:23 +01:00
|
|
|
}
|
1999-01-27 13:38:21 +00:00
|
|
|
|
|
|
|
dns_name_init(&name1, NULL);
|
|
|
|
dns_name_init(&name2, NULL);
|
|
|
|
dns_rdata_toregion(rdata1, &r1);
|
|
|
|
dns_rdata_toregion(rdata2, &r2);
|
|
|
|
isc_region_consume(&r1, 18);
|
|
|
|
isc_region_consume(&r2, 18);
|
|
|
|
dns_name_fromregion(&name1, &r1);
|
|
|
|
dns_name_fromregion(&name2, &r2);
|
2000-03-17 21:43:46 +00:00
|
|
|
order = dns_name_rdatacompare(&name1, &name2);
|
2020-02-13 21:48:23 +01:00
|
|
|
if (order != 0) {
|
2000-03-17 21:43:46 +00:00
|
|
|
return (order);
|
2020-02-13 21:48:23 +01:00
|
|
|
}
|
2000-03-17 17:08:36 +00:00
|
|
|
|
1999-01-27 13:38:21 +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-01-27 13:38:21 +00:00
|
|
|
}
|
|
|
|
|
2020-02-13 14:44:37 -08:00
|
|
|
static inline isc_result_t
|
|
|
|
fromstruct_sig(ARGS_FROMSTRUCT) {
|
2000-05-22 12:38:12 +00:00
|
|
|
dns_rdata_sig_t *sig = source;
|
1999-01-27 13:38:21 +00:00
|
|
|
|
2015-08-17 12:23:35 +05:30
|
|
|
REQUIRE(type == dns_rdatatype_sig);
|
2019-09-27 10:40:51 +02:00
|
|
|
REQUIRE(sig != NULL);
|
2000-05-22 12:38:12 +00:00
|
|
|
REQUIRE(sig->common.rdtype == type);
|
|
|
|
REQUIRE(sig->common.rdclass == rdclass);
|
2001-06-21 04:00:47 +00:00
|
|
|
REQUIRE(sig->signature != NULL || sig->siglen == 0);
|
2000-08-01 01:33:37 +00:00
|
|
|
|
2001-03-16 22:53:20 +00:00
|
|
|
UNUSED(type);
|
2000-12-01 01:40:59 +00:00
|
|
|
UNUSED(rdclass);
|
|
|
|
|
2000-05-15 21:14:38 +00:00
|
|
|
/*
|
|
|
|
* Type covered.
|
|
|
|
*/
|
1999-08-25 14:18:35 +00:00
|
|
|
RETERR(uint16_tobuffer(sig->covered, target));
|
|
|
|
|
2000-05-15 21:14:38 +00:00
|
|
|
/*
|
|
|
|
* Algorithm.
|
|
|
|
*/
|
1999-08-25 14:18:35 +00:00
|
|
|
RETERR(uint8_tobuffer(sig->algorithm, target));
|
|
|
|
|
2000-05-15 21:14:38 +00:00
|
|
|
/*
|
|
|
|
* Labels.
|
|
|
|
*/
|
1999-08-25 14:18:35 +00:00
|
|
|
RETERR(uint8_tobuffer(sig->labels, target));
|
|
|
|
|
2000-05-15 21:14:38 +00:00
|
|
|
/*
|
|
|
|
* Original TTL.
|
|
|
|
*/
|
1999-08-25 14:18:35 +00:00
|
|
|
RETERR(uint32_tobuffer(sig->originalttl, target));
|
|
|
|
|
2000-05-15 21:14:38 +00:00
|
|
|
/*
|
|
|
|
* Expire time.
|
|
|
|
*/
|
1999-08-25 14:18:35 +00:00
|
|
|
RETERR(uint32_tobuffer(sig->timeexpire, target));
|
|
|
|
|
2000-05-15 21:14:38 +00:00
|
|
|
/*
|
|
|
|
* Time signed.
|
|
|
|
*/
|
1999-08-25 14:18:35 +00:00
|
|
|
RETERR(uint32_tobuffer(sig->timesigned, target));
|
|
|
|
|
2000-05-15 21:14:38 +00:00
|
|
|
/*
|
|
|
|
* Key ID.
|
|
|
|
*/
|
1999-08-25 14:18:35 +00:00
|
|
|
RETERR(uint16_tobuffer(sig->keyid, target));
|
|
|
|
|
2000-05-15 21:14:38 +00:00
|
|
|
/*
|
|
|
|
* Signer name.
|
|
|
|
*/
|
2000-05-05 18:15:02 +00:00
|
|
|
RETERR(name_tobuffer(&sig->signer, target));
|
1999-08-25 14:18:35 +00:00
|
|
|
|
2000-05-15 21:14:38 +00:00
|
|
|
/*
|
|
|
|
* Signature.
|
|
|
|
*/
|
2000-05-22 12:38:12 +00:00
|
|
|
return (mem_tobuffer(target, sig->signature, sig->siglen));
|
1999-01-27 13:38:21 +00:00
|
|
|
}
|
|
|
|
|
2020-02-13 14:44:37 -08:00
|
|
|
static inline isc_result_t
|
|
|
|
tostruct_sig(ARGS_TOSTRUCT) {
|
|
|
|
isc_region_t sr;
|
2000-05-05 05:50:14 +00:00
|
|
|
dns_rdata_sig_t *sig = target;
|
2020-02-13 14:44:37 -08:00
|
|
|
dns_name_t signer;
|
1999-01-27 13:38:21 +00:00
|
|
|
|
2015-08-17 12:23:35 +05:30
|
|
|
REQUIRE(rdata->type == dns_rdatatype_sig);
|
2019-09-27 10:40:51 +02:00
|
|
|
REQUIRE(sig != NULL);
|
2000-10-25 05:44:10 +00:00
|
|
|
REQUIRE(rdata->length != 0);
|
2000-08-01 01:33:37 +00:00
|
|
|
|
1999-08-25 14:18:35 +00:00
|
|
|
sig->common.rdclass = rdata->rdclass;
|
|
|
|
sig->common.rdtype = rdata->type;
|
|
|
|
ISC_LINK_INIT(&sig->common, link);
|
2000-05-05 05:50:14 +00:00
|
|
|
|
1999-08-25 14:18:35 +00:00
|
|
|
dns_rdata_toregion(rdata, &sr);
|
|
|
|
|
2000-05-15 21:14:38 +00:00
|
|
|
/*
|
|
|
|
* Type covered.
|
|
|
|
*/
|
1999-08-25 14:18:35 +00:00
|
|
|
sig->covered = uint16_fromregion(&sr);
|
|
|
|
isc_region_consume(&sr, 2);
|
|
|
|
|
2000-05-15 21:14:38 +00:00
|
|
|
/*
|
|
|
|
* Algorithm.
|
|
|
|
*/
|
1999-08-25 14:18:35 +00:00
|
|
|
sig->algorithm = uint8_fromregion(&sr);
|
|
|
|
isc_region_consume(&sr, 1);
|
|
|
|
|
2000-05-15 21:14:38 +00:00
|
|
|
/*
|
|
|
|
* Labels.
|
|
|
|
*/
|
1999-08-25 14:18:35 +00:00
|
|
|
sig->labels = uint8_fromregion(&sr);
|
|
|
|
isc_region_consume(&sr, 1);
|
|
|
|
|
2000-05-15 21:14:38 +00:00
|
|
|
/*
|
|
|
|
* Original TTL.
|
|
|
|
*/
|
1999-08-25 14:18:35 +00:00
|
|
|
sig->originalttl = uint32_fromregion(&sr);
|
|
|
|
isc_region_consume(&sr, 4);
|
|
|
|
|
2000-05-15 21:14:38 +00:00
|
|
|
/*
|
|
|
|
* Expire time.
|
|
|
|
*/
|
1999-08-25 14:18:35 +00:00
|
|
|
sig->timeexpire = uint32_fromregion(&sr);
|
|
|
|
isc_region_consume(&sr, 4);
|
|
|
|
|
2000-05-15 21:14:38 +00:00
|
|
|
/*
|
|
|
|
* Time signed.
|
|
|
|
*/
|
1999-08-25 14:18:35 +00:00
|
|
|
sig->timesigned = uint32_fromregion(&sr);
|
|
|
|
isc_region_consume(&sr, 4);
|
|
|
|
|
2000-05-15 21:14:38 +00:00
|
|
|
/*
|
|
|
|
* Key ID.
|
|
|
|
*/
|
1999-08-25 14:18:35 +00:00
|
|
|
sig->keyid = uint16_fromregion(&sr);
|
|
|
|
isc_region_consume(&sr, 2);
|
|
|
|
|
|
|
|
dns_name_init(&signer, NULL);
|
|
|
|
dns_name_fromregion(&signer, &sr);
|
1999-10-07 21:49:39 +00:00
|
|
|
dns_name_init(&sig->signer, NULL);
|
2000-05-19 02:03:56 +00:00
|
|
|
RETERR(name_duporclone(&signer, mctx, &sig->signer));
|
1999-10-07 21:49:39 +00:00
|
|
|
isc_region_consume(&sr, name_length(&sig->signer));
|
1999-08-25 14:18:35 +00:00
|
|
|
|
2000-05-15 21:14:38 +00:00
|
|
|
/*
|
|
|
|
* Signature.
|
|
|
|
*/
|
1999-08-31 14:55:47 +00:00
|
|
|
sig->siglen = sr.length;
|
2001-06-21 04:00:47 +00:00
|
|
|
sig->signature = mem_maybedup(mctx, sr.base, sig->siglen);
|
2020-02-13 21:48:23 +01:00
|
|
|
if (sig->signature == NULL) {
|
2001-06-21 04:00:47 +00:00
|
|
|
goto cleanup;
|
2020-02-13 21:48:23 +01:00
|
|
|
}
|
2000-05-05 05:50:14 +00:00
|
|
|
|
|
|
|
sig->mctx = mctx;
|
2000-04-06 22:03:35 +00:00
|
|
|
return (ISC_R_SUCCESS);
|
2000-05-05 05:50:14 +00:00
|
|
|
|
2020-02-12 13:59:18 +01:00
|
|
|
cleanup:
|
2020-02-13 21:48:23 +01:00
|
|
|
if (mctx != NULL) {
|
2000-05-05 05:50:14 +00:00
|
|
|
dns_name_free(&sig->signer, mctx);
|
2020-02-13 21:48:23 +01:00
|
|
|
}
|
2000-05-05 05:50:14 +00:00
|
|
|
return (ISC_R_NOMEMORY);
|
1999-01-27 13:38:21 +00:00
|
|
|
}
|
1999-05-07 03:24:15 +00:00
|
|
|
|
2020-02-13 14:44:37 -08:00
|
|
|
static inline void
|
|
|
|
freestruct_sig(ARGS_FREESTRUCT) {
|
2020-02-12 13:59:18 +01:00
|
|
|
dns_rdata_sig_t *sig = (dns_rdata_sig_t *)source;
|
1999-08-25 14:18:35 +00:00
|
|
|
|
2019-09-27 10:40:51 +02:00
|
|
|
REQUIRE(sig != NULL);
|
2015-08-17 12:23:35 +05:30
|
|
|
REQUIRE(sig->common.rdtype == dns_rdatatype_sig);
|
1999-08-25 14:18:35 +00:00
|
|
|
|
2020-02-13 21:48:23 +01:00
|
|
|
if (sig->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(&sig->signer, sig->mctx);
|
2020-02-13 21:48:23 +01:00
|
|
|
if (sig->signature != NULL) {
|
2000-05-05 05:50:14 +00:00
|
|
|
isc_mem_free(sig->mctx, sig->signature);
|
2020-02-13 21:48:23 +01:00
|
|
|
}
|
2000-05-05 05:50:14 +00:00
|
|
|
sig->mctx = NULL;
|
1999-05-07 03:24:15 +00:00
|
|
|
}
|
1999-08-02 22:18:31 +00:00
|
|
|
|
2020-02-13 14:44:37 -08:00
|
|
|
static inline isc_result_t
|
|
|
|
additionaldata_sig(ARGS_ADDLDATA) {
|
2015-08-17 12:23:35 +05:30
|
|
|
REQUIRE(rdata->type == dns_rdatatype_sig);
|
1999-08-02 22:18:31 +00:00
|
|
|
|
2000-04-28 01:24:18 +00:00
|
|
|
UNUSED(rdata);
|
2019-07-05 16:20:20 +10:00
|
|
|
UNUSED(owner);
|
2000-03-17 17:08:36 +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
|
|
|
}
|
|
|
|
|
2020-02-13 14:44:37 -08:00
|
|
|
static inline isc_result_t
|
|
|
|
digest_sig(ARGS_DIGEST) {
|
2015-08-17 12:23:35 +05:30
|
|
|
REQUIRE(rdata->type == dns_rdatatype_sig);
|
1999-08-31 22:05:55 +00:00
|
|
|
|
2000-04-28 01:24:18 +00:00
|
|
|
UNUSED(rdata);
|
2000-03-17 17:08:36 +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
|
|
|
}
|
|
|
|
|
|
|
|
static inline dns_rdatatype_t
|
2020-02-13 14:44:37 -08:00
|
|
|
covers_sig(dns_rdata_t *rdata) {
|
1999-08-31 22:05:55 +00:00
|
|
|
dns_rdatatype_t type;
|
2020-02-13 14:44:37 -08:00
|
|
|
isc_region_t r;
|
1999-08-31 22:05:55 +00:00
|
|
|
|
2015-08-17 12:23:35 +05:30
|
|
|
REQUIRE(rdata->type == dns_rdatatype_sig);
|
1999-08-31 22:05:55 +00:00
|
|
|
|
|
|
|
dns_rdata_toregion(rdata, &r);
|
|
|
|
type = uint16_fromregion(&r);
|
|
|
|
|
|
|
|
return (type);
|
|
|
|
}
|
|
|
|
|
2020-02-13 14:44:37 -08:00
|
|
|
static inline bool
|
|
|
|
checkowner_sig(ARGS_CHECKOWNER) {
|
2015-08-17 12:23:35 +05:30
|
|
|
REQUIRE(type == dns_rdatatype_sig);
|
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
|
|
|
}
|
|
|
|
|
2020-02-13 14:44:37 -08:00
|
|
|
static inline bool
|
|
|
|
checknames_sig(ARGS_CHECKNAMES) {
|
2015-08-17 12:23:35 +05:30
|
|
|
REQUIRE(rdata->type == dns_rdatatype_sig);
|
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
|
|
|
}
|
|
|
|
|
2020-02-13 14:44:37 -08:00
|
|
|
static inline int
|
|
|
|
casecompare_sig(ARGS_COMPARE) {
|
2009-12-04 21:09:34 +00:00
|
|
|
return (compare_sig(rdata1, rdata2));
|
|
|
|
}
|
2020-02-12 13:59:18 +01:00
|
|
|
#endif /* RDATA_GENERIC_SIG_24_C */
|