1999-01-27 13:38:21 +00:00
|
|
|
/*
|
1999-09-15 23:03:43 +00:00
|
|
|
* Copyright (C) 1999 Internet Software Consortium.
|
|
|
|
*
|
1999-01-27 13:38:21 +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-01-27 13:38:21 +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.
|
|
|
|
*/
|
|
|
|
|
1999-10-07 21:49:39 +00:00
|
|
|
/* $Id: sig_24.c,v 1.23 1999/10/07 21:49:38 bwelling Exp $ */
|
1999-01-27 13:38:21 +00:00
|
|
|
|
|
|
|
/* RFC 2065 */
|
|
|
|
|
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
|
|
|
|
1999-08-12 01:32:42 +00:00
|
|
|
static inline dns_result_t
|
1999-08-02 22:18:31 +00:00
|
|
|
fromtext_sig(dns_rdataclass_t rdclass, dns_rdatatype_t type,
|
1999-02-16 22:42:33 +00:00
|
|
|
isc_lex_t *lexer, dns_name_t *origin,
|
|
|
|
isc_boolean_t downcase, isc_buffer_t *target)
|
|
|
|
{
|
1999-01-27 13:38:21 +00:00
|
|
|
isc_token_t token;
|
|
|
|
unsigned char c;
|
|
|
|
dns_rdatatype_t covered;
|
|
|
|
isc_textregion_t *tsr;
|
|
|
|
char *e;
|
|
|
|
dns_result_t result;
|
|
|
|
dns_name_t name;
|
|
|
|
isc_buffer_t buffer;
|
1999-06-08 10:35:23 +00:00
|
|
|
isc_uint32_t time_signed, time_expire;
|
1999-01-27 13:38:21 +00:00
|
|
|
|
|
|
|
REQUIRE(type == 24);
|
|
|
|
|
1999-08-02 22:18:31 +00:00
|
|
|
rdclass = rdclass; /*unused*/
|
1999-01-27 13:38:21 +00:00
|
|
|
origin = origin; /*unused*/
|
|
|
|
downcase = downcase; /*unused*/
|
|
|
|
|
|
|
|
/* type covered */
|
|
|
|
RETERR(gettoken(lexer, &token, isc_tokentype_string, ISC_FALSE));
|
|
|
|
tsr = &token.value.as_textregion;
|
|
|
|
result = dns_rdatatype_fromtext(&covered, tsr);
|
|
|
|
if (result != DNS_R_SUCCESS && result != DNS_R_NOTIMPLEMENTED) {
|
|
|
|
covered = strtol(token.value.as_pointer, &e, 10);
|
1999-02-02 13:31:46 +00:00
|
|
|
if (*e != 0)
|
1999-01-27 13:38:21 +00:00
|
|
|
return (result);
|
|
|
|
}
|
|
|
|
RETERR(uint16_tobuffer(covered, target));
|
|
|
|
|
|
|
|
/* algorithm */
|
1999-09-17 09:25:21 +00:00
|
|
|
RETERR(gettoken(lexer, &token, isc_tokentype_string, ISC_FALSE));
|
|
|
|
RETERR(dns_secalg_fromtext(&c, &token.value.as_textregion));
|
1999-01-27 13:38:21 +00:00
|
|
|
RETERR(mem_tobuffer(target, &c, 1));
|
|
|
|
|
|
|
|
/* labels */
|
|
|
|
RETERR(gettoken(lexer, &token, isc_tokentype_number, ISC_FALSE));
|
|
|
|
if (token.value.as_ulong > 0xff)
|
|
|
|
return (DNS_R_RANGE);
|
|
|
|
c = token.value.as_ulong;
|
|
|
|
RETERR(mem_tobuffer(target, &c, 1));
|
|
|
|
|
|
|
|
/* original ttl */
|
|
|
|
RETERR(gettoken(lexer, &token, isc_tokentype_number, ISC_FALSE));
|
|
|
|
RETERR(uint32_tobuffer(token.value.as_ulong, target));
|
|
|
|
|
|
|
|
/* signature expiration */
|
|
|
|
RETERR(gettoken(lexer, &token, isc_tokentype_string, ISC_FALSE));
|
1999-06-08 10:35:23 +00:00
|
|
|
RETERR(dns_time32_fromtext(token.value.as_pointer, &time_expire));
|
|
|
|
RETERR(uint32_tobuffer(time_expire, target));
|
1999-01-27 13:38:21 +00:00
|
|
|
|
|
|
|
/* time signed */
|
|
|
|
RETERR(gettoken(lexer, &token, isc_tokentype_string, ISC_FALSE));
|
1999-06-08 10:35:23 +00:00
|
|
|
RETERR(dns_time32_fromtext(token.value.as_pointer, &time_signed));
|
|
|
|
RETERR(uint32_tobuffer(time_signed, target));
|
1999-01-27 13:38:21 +00:00
|
|
|
|
|
|
|
/* key footprint */
|
|
|
|
RETERR(gettoken(lexer, &token, isc_tokentype_number, ISC_FALSE));
|
|
|
|
RETERR(uint16_tobuffer(token.value.as_ulong, target));
|
|
|
|
|
|
|
|
/* signer */
|
|
|
|
RETERR(gettoken(lexer, &token, isc_tokentype_string, ISC_FALSE));
|
|
|
|
dns_name_init(&name, NULL);
|
|
|
|
buffer_fromregion(&buffer, &token.value.as_region,
|
|
|
|
ISC_BUFFERTYPE_TEXT);
|
|
|
|
origin = (origin != NULL) ? origin : dns_rootname;
|
|
|
|
RETERR(dns_name_fromtext(&name, &buffer, origin, downcase, target));
|
|
|
|
|
|
|
|
/* sig */
|
1999-05-18 17:46:59 +00:00
|
|
|
return (isc_base64_tobuffer(lexer, target, -1));
|
1999-01-27 13:38:21 +00:00
|
|
|
}
|
|
|
|
|
1999-08-12 01:32:42 +00:00
|
|
|
static inline dns_result_t
|
1999-06-08 10:35:23 +00:00
|
|
|
totext_sig(dns_rdata_t *rdata, dns_rdata_textctx_t *tctx,
|
|
|
|
isc_buffer_t *target)
|
|
|
|
{
|
1999-01-27 13:38:21 +00:00
|
|
|
isc_region_t sr;
|
|
|
|
char buf[sizeof "4294967295"];
|
|
|
|
dns_rdatatype_t covered;
|
|
|
|
unsigned long ttl;
|
|
|
|
unsigned long when;
|
|
|
|
unsigned long exp;
|
|
|
|
unsigned long foot;
|
|
|
|
dns_name_t name;
|
|
|
|
dns_name_t prefix;
|
|
|
|
isc_boolean_t sub;
|
|
|
|
|
|
|
|
REQUIRE(rdata->type == 24);
|
|
|
|
|
1999-06-08 10:35:23 +00:00
|
|
|
tctx = tctx; /*unused*/
|
1999-01-27 13:38:21 +00:00
|
|
|
|
|
|
|
dns_rdata_toregion(rdata, &sr);
|
|
|
|
|
|
|
|
/* type covered */
|
|
|
|
covered = uint16_fromregion(&sr);
|
|
|
|
isc_region_consume(&sr, 2);
|
|
|
|
RETERR(dns_rdatatype_totext(covered, target));
|
|
|
|
RETERR(str_totext(" ", target));
|
|
|
|
|
|
|
|
/* algorithm */
|
|
|
|
sprintf(buf, "%u", sr.base[0]);
|
|
|
|
isc_region_consume(&sr, 1);
|
|
|
|
RETERR(str_totext(buf, target));
|
|
|
|
RETERR(str_totext(" ", target));
|
|
|
|
|
|
|
|
/* labels */
|
|
|
|
sprintf(buf, "%u", sr.base[0]);
|
|
|
|
isc_region_consume(&sr, 1);
|
|
|
|
RETERR(str_totext(buf, target));
|
|
|
|
RETERR(str_totext(" ", target));
|
|
|
|
|
|
|
|
/* ttl */
|
|
|
|
ttl = uint32_fromregion(&sr);
|
|
|
|
isc_region_consume(&sr, 4);
|
|
|
|
sprintf(buf, "%lu", ttl);
|
|
|
|
RETERR(str_totext(buf, target));
|
|
|
|
RETERR(str_totext(" ", target));
|
|
|
|
|
|
|
|
/* sig exp */
|
|
|
|
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
|
|
|
|
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));
|
|
|
|
|
1999-01-27 13:38:21 +00:00
|
|
|
/* time signed */
|
|
|
|
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));
|
|
|
|
|
|
|
|
/* footprint */
|
|
|
|
foot = uint16_fromregion(&sr);
|
|
|
|
isc_region_consume(&sr, 2);
|
1999-08-31 14:55:47 +00:00
|
|
|
sprintf(buf, "%lu", foot);
|
1999-01-27 13:38:21 +00:00
|
|
|
RETERR(str_totext(buf, target));
|
|
|
|
RETERR(str_totext(" ", target));
|
|
|
|
|
|
|
|
/* signer */
|
|
|
|
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));
|
|
|
|
|
|
|
|
/* sig */
|
1999-06-08 10:35:23 +00:00
|
|
|
RETERR(str_totext(tctx->linebreak, target));
|
|
|
|
RETERR(isc_base64_totext(&sr, 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));
|
1999-06-08 10:35:23 +00:00
|
|
|
|
|
|
|
return DNS_R_SUCCESS;
|
1999-01-27 13:38:21 +00:00
|
|
|
}
|
|
|
|
|
1999-08-12 01:32:42 +00:00
|
|
|
static inline dns_result_t
|
1999-08-02 22:18:31 +00:00
|
|
|
fromwire_sig(dns_rdataclass_t rdclass, dns_rdatatype_t type,
|
1999-02-16 22:42:33 +00:00
|
|
|
isc_buffer_t *source, dns_decompress_t *dctx,
|
|
|
|
isc_boolean_t downcase, isc_buffer_t *target)
|
|
|
|
{
|
1999-01-27 13:38:21 +00:00
|
|
|
isc_region_t sr;
|
|
|
|
dns_name_t name;
|
|
|
|
|
|
|
|
REQUIRE(type == 24);
|
1999-02-24 06:31:35 +00:00
|
|
|
|
|
|
|
if (dns_decompress_edns(dctx) >= 1 || !dns_decompress_strict(dctx))
|
|
|
|
dns_decompress_setmethods(dctx, DNS_COMPRESS_ALL);
|
|
|
|
else
|
|
|
|
dns_decompress_setmethods(dctx, DNS_COMPRESS_NONE);
|
1999-01-27 13:38:21 +00:00
|
|
|
|
1999-08-02 22:18:31 +00:00
|
|
|
rdclass = rdclass; /*unused*/
|
1999-01-27 13:38:21 +00:00
|
|
|
|
|
|
|
isc_buffer_active(source, &sr);
|
|
|
|
/*
|
|
|
|
* type covered: 2
|
|
|
|
* algorithm: 1
|
|
|
|
* labels: 1
|
|
|
|
* original ttl: 4
|
|
|
|
* signature expiration: 4
|
|
|
|
* time signed: 4
|
|
|
|
* key footprint: 2
|
|
|
|
*/
|
|
|
|
if (sr.length < 18)
|
|
|
|
return (DNS_R_UNEXPECTEDEND);
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
/* signer */
|
|
|
|
dns_name_init(&name, NULL);
|
|
|
|
RETERR(dns_name_fromwire(&name, source, dctx, downcase, target));
|
|
|
|
|
|
|
|
/* sig */
|
|
|
|
isc_buffer_active(source, &sr);
|
1999-01-29 08:04:13 +00:00
|
|
|
isc_buffer_forward(source, sr.length);
|
1999-01-27 13:38:21 +00:00
|
|
|
return(mem_tobuffer(target, sr.base, sr.length));
|
|
|
|
}
|
|
|
|
|
1999-08-12 01:32:42 +00:00
|
|
|
static inline dns_result_t
|
1999-01-27 13:38:21 +00:00
|
|
|
towire_sig(dns_rdata_t *rdata, dns_compress_t *cctx, isc_buffer_t *target) {
|
|
|
|
isc_region_t sr;
|
|
|
|
dns_name_t name;
|
|
|
|
|
|
|
|
REQUIRE(rdata->type == 24);
|
|
|
|
|
1999-02-22 07:24:05 +00:00
|
|
|
if (dns_compress_getedns(cctx) >= 1)
|
|
|
|
dns_compress_setmethods(cctx, DNS_COMPRESS_ALL);
|
|
|
|
else
|
|
|
|
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);
|
|
|
|
|
|
|
|
/* signer */
|
|
|
|
dns_name_init(&name, NULL);
|
|
|
|
dns_name_fromregion(&name, &sr);
|
|
|
|
isc_region_consume(&sr, name_length(&name));
|
|
|
|
RETERR(dns_name_towire(&name, cctx, target));
|
|
|
|
|
|
|
|
/* signature */
|
|
|
|
return (mem_tobuffer(target, sr.base, sr.length));
|
|
|
|
}
|
|
|
|
|
1999-08-12 01:32:42 +00:00
|
|
|
static inline int
|
1999-01-27 13:38:21 +00:00
|
|
|
compare_sig(dns_rdata_t *rdata1, dns_rdata_t *rdata2) {
|
|
|
|
isc_region_t r1;
|
|
|
|
isc_region_t r2;
|
|
|
|
dns_name_t name1;
|
|
|
|
dns_name_t name2;
|
|
|
|
int result;
|
|
|
|
|
|
|
|
REQUIRE(rdata1->type == rdata2->type);
|
1999-08-02 22:18:31 +00:00
|
|
|
REQUIRE(rdata1->rdclass == rdata2->rdclass);
|
1999-01-27 13:38:21 +00:00
|
|
|
REQUIRE(rdata1->type == 24);
|
|
|
|
|
|
|
|
dns_rdata_toregion(rdata1, &r1);
|
|
|
|
dns_rdata_toregion(rdata2, &r2);
|
|
|
|
|
|
|
|
INSIST(r1.length > 18);
|
|
|
|
INSIST(r2.length > 18);
|
|
|
|
r1.length = 18;
|
|
|
|
r2.length = 18;
|
|
|
|
result = compare_region(&r1, &r2);
|
|
|
|
if (result != 0)
|
|
|
|
return (result);
|
|
|
|
|
|
|
|
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);
|
1999-02-15 05:44:22 +00:00
|
|
|
result = dns_name_rdatacompare(&name1, &name2);
|
1999-01-27 13:38:21 +00:00
|
|
|
if (result != 0)
|
|
|
|
return (result);
|
|
|
|
isc_region_consume(&r1, name_length(&name1));
|
|
|
|
isc_region_consume(&r2, name_length(&name2));
|
|
|
|
|
|
|
|
return (compare_region(&r1, &r2));
|
|
|
|
}
|
|
|
|
|
1999-08-12 01:32:42 +00:00
|
|
|
static inline dns_result_t
|
1999-08-02 22:18:31 +00:00
|
|
|
fromstruct_sig(dns_rdataclass_t rdclass, dns_rdatatype_t type, void *source,
|
1999-02-16 22:42:33 +00:00
|
|
|
isc_buffer_t *target)
|
|
|
|
{
|
1999-08-25 14:18:35 +00:00
|
|
|
isc_region_t tr;
|
|
|
|
dns_rdata_generic_sig_t *sig;
|
|
|
|
dns_compress_t cctx;
|
1999-01-27 13:38:21 +00:00
|
|
|
|
|
|
|
REQUIRE(type == 24);
|
|
|
|
|
1999-08-02 22:18:31 +00:00
|
|
|
rdclass = rdclass; /*unused*/
|
1999-01-27 13:38:21 +00:00
|
|
|
|
|
|
|
source = source;
|
|
|
|
target = target;
|
|
|
|
|
1999-08-25 14:18:35 +00:00
|
|
|
sig = (dns_rdata_generic_sig_t *) source;
|
|
|
|
REQUIRE(sig->mctx != NULL);
|
|
|
|
|
|
|
|
/* Type covered */
|
|
|
|
RETERR(uint16_tobuffer(sig->covered, target));
|
|
|
|
|
|
|
|
/* Algorithm */
|
|
|
|
RETERR(uint8_tobuffer(sig->algorithm, target));
|
|
|
|
|
|
|
|
/* Labels */
|
|
|
|
RETERR(uint8_tobuffer(sig->labels, target));
|
|
|
|
|
|
|
|
/* Original TTL */
|
|
|
|
RETERR(uint32_tobuffer(sig->originalttl, target));
|
|
|
|
|
|
|
|
/* Expire time */
|
|
|
|
RETERR(uint32_tobuffer(sig->timeexpire, target));
|
|
|
|
|
|
|
|
/* Time signed */
|
|
|
|
RETERR(uint32_tobuffer(sig->timesigned, target));
|
|
|
|
|
|
|
|
/* Key ID */
|
|
|
|
RETERR(uint16_tobuffer(sig->keyid, target));
|
|
|
|
|
|
|
|
/* Signer name */
|
|
|
|
RETERR(dns_compress_init(&cctx, -1, sig->mctx));
|
|
|
|
dns_compress_setmethods(&cctx, DNS_COMPRESS_NONE);
|
1999-10-07 21:49:39 +00:00
|
|
|
RETERR(dns_name_towire(&sig->signer, &cctx, target));
|
1999-08-25 14:18:35 +00:00
|
|
|
dns_compress_invalidate(&cctx);
|
|
|
|
|
|
|
|
/* Signature */
|
|
|
|
if (sig->siglen > 0) {
|
|
|
|
isc_buffer_available(target, &tr);
|
|
|
|
if (tr.length < sig->siglen)
|
|
|
|
return (DNS_R_NOSPACE);
|
|
|
|
memcpy(tr.base, sig->signature, sig->siglen);
|
|
|
|
isc_buffer_add(target, sig->siglen);
|
|
|
|
}
|
|
|
|
|
|
|
|
return (DNS_R_SUCCESS);
|
1999-01-27 13:38:21 +00:00
|
|
|
}
|
|
|
|
|
1999-08-12 01:32:42 +00:00
|
|
|
static inline dns_result_t
|
1999-05-07 03:24:15 +00:00
|
|
|
tostruct_sig(dns_rdata_t *rdata, void *target, isc_mem_t *mctx) {
|
1999-08-25 14:18:35 +00:00
|
|
|
isc_region_t sr;
|
|
|
|
dns_rdata_generic_sig_t *sig;
|
|
|
|
dns_name_t signer;
|
1999-01-27 13:38:21 +00:00
|
|
|
|
|
|
|
REQUIRE(rdata->type == 24);
|
|
|
|
|
|
|
|
target = target;
|
1999-05-07 03:24:15 +00:00
|
|
|
mctx = mctx;
|
1999-01-27 13:38:21 +00:00
|
|
|
|
1999-08-25 14:18:35 +00:00
|
|
|
sig = (dns_rdata_generic_sig_t *) target;
|
|
|
|
sig->common.rdclass = rdata->rdclass;
|
|
|
|
sig->common.rdtype = rdata->type;
|
|
|
|
ISC_LINK_INIT(&sig->common, link);
|
|
|
|
sig->mctx = mctx;
|
|
|
|
dns_rdata_toregion(rdata, &sr);
|
|
|
|
|
|
|
|
/* Type covered */
|
|
|
|
if (sr.length < 2)
|
|
|
|
return (ISC_R_UNEXPECTEDEND);
|
|
|
|
sig->covered = uint16_fromregion(&sr);
|
|
|
|
isc_region_consume(&sr, 2);
|
|
|
|
|
|
|
|
/* Algorithm */
|
|
|
|
if (sr.length < 1)
|
|
|
|
return (ISC_R_UNEXPECTEDEND);
|
|
|
|
sig->algorithm = uint8_fromregion(&sr);
|
|
|
|
isc_region_consume(&sr, 1);
|
|
|
|
|
|
|
|
/* Labels */
|
|
|
|
if (sr.length < 1)
|
|
|
|
return (ISC_R_UNEXPECTEDEND);
|
|
|
|
sig->labels = uint8_fromregion(&sr);
|
|
|
|
isc_region_consume(&sr, 1);
|
|
|
|
|
|
|
|
/* Original TTL */
|
|
|
|
if (sr.length < 4)
|
|
|
|
return (ISC_R_UNEXPECTEDEND);
|
|
|
|
sig->originalttl = uint32_fromregion(&sr);
|
|
|
|
isc_region_consume(&sr, 4);
|
|
|
|
|
|
|
|
/* Expire time */
|
|
|
|
if (sr.length < 4)
|
|
|
|
return (ISC_R_UNEXPECTEDEND);
|
|
|
|
sig->timeexpire = uint32_fromregion(&sr);
|
|
|
|
isc_region_consume(&sr, 4);
|
|
|
|
|
|
|
|
/* Time signed */
|
|
|
|
if (sr.length < 4)
|
|
|
|
return (ISC_R_UNEXPECTEDEND);
|
|
|
|
sig->timesigned = uint32_fromregion(&sr);
|
|
|
|
isc_region_consume(&sr, 4);
|
|
|
|
|
|
|
|
/* Key ID */
|
|
|
|
if (sr.length < 2)
|
|
|
|
return (ISC_R_UNEXPECTEDEND);
|
|
|
|
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);
|
|
|
|
RETERR(dns_name_dup(&signer, mctx, &sig->signer));
|
|
|
|
isc_region_consume(&sr, name_length(&sig->signer));
|
1999-08-25 14:18:35 +00:00
|
|
|
|
|
|
|
/* Signature */
|
1999-08-31 14:55:47 +00:00
|
|
|
sig->siglen = sr.length;
|
1999-08-25 14:18:35 +00:00
|
|
|
if (sig->siglen > 0) {
|
|
|
|
sig->signature = isc_mem_get(mctx, sig->siglen);
|
|
|
|
if (sig->signature == NULL)
|
|
|
|
return (DNS_R_NOMEMORY);
|
|
|
|
memcpy(sig->signature, sr.base, sig->siglen);
|
|
|
|
isc_region_consume(&sr, sig->siglen);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
sig->signature = NULL;
|
|
|
|
|
|
|
|
return (DNS_R_SUCCESS);
|
1999-01-27 13:38:21 +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_sig(void *source) {
|
1999-08-25 14:18:35 +00:00
|
|
|
dns_rdata_generic_sig_t *sig = (dns_rdata_generic_sig_t *) source;
|
|
|
|
|
1999-05-07 03:24:15 +00:00
|
|
|
REQUIRE(source != NULL);
|
1999-08-25 14:18:35 +00:00
|
|
|
REQUIRE(sig->common.rdtype == 24);
|
|
|
|
|
1999-10-07 21:49:39 +00:00
|
|
|
dns_name_free(&sig->signer, sig->mctx);
|
1999-08-25 14:18:35 +00:00
|
|
|
if (sig->siglen > 0)
|
|
|
|
isc_mem_put(sig->mctx, sig->signature, sig->siglen);
|
1999-05-07 03:24:15 +00:00
|
|
|
}
|
1999-08-02 22:18:31 +00:00
|
|
|
|
1999-08-12 01:32:42 +00:00
|
|
|
static inline dns_result_t
|
1999-08-02 22:18:31 +00:00
|
|
|
additionaldata_sig(dns_rdata_t *rdata, dns_additionaldatafunc_t add,
|
|
|
|
void *arg)
|
|
|
|
{
|
|
|
|
REQUIRE(rdata->type == 24);
|
|
|
|
|
|
|
|
(void)add;
|
|
|
|
(void)arg;
|
|
|
|
|
|
|
|
return (DNS_R_SUCCESS);
|
|
|
|
}
|
|
|
|
|
1999-08-31 22:05:55 +00:00
|
|
|
static inline dns_result_t
|
|
|
|
digest_sig(dns_rdata_t *rdata, dns_digestfunc_t digest, void *arg) {
|
|
|
|
|
|
|
|
REQUIRE(rdata->type == 24);
|
|
|
|
|
|
|
|
(void)digest;
|
|
|
|
(void)arg;
|
|
|
|
|
|
|
|
return (DNS_R_NOTIMPLEMENTED);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline dns_rdatatype_t
|
|
|
|
covers_sig(dns_rdata_t *rdata) {
|
|
|
|
dns_rdatatype_t type;
|
|
|
|
isc_region_t r;
|
|
|
|
|
|
|
|
REQUIRE(rdata->type == 24);
|
|
|
|
|
|
|
|
dns_rdata_toregion(rdata, &r);
|
|
|
|
type = uint16_fromregion(&r);
|
|
|
|
|
|
|
|
return (type);
|
|
|
|
}
|
|
|
|
|
1999-05-05 00:19:04 +00:00
|
|
|
#endif /* RDATA_GENERIC_SIG_24_C */
|